2011-12-17 00:56:02 +00:00
|
|
|
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "vm/globals.h"
|
|
|
|
#if defined(TARGET_ARCH_X64)
|
|
|
|
|
|
|
|
#include "vm/code_patcher.h"
|
2017-09-04 14:18:37 +00:00
|
|
|
#include "vm/compiler/assembler/assembler.h"
|
2011-12-17 00:56:02 +00:00
|
|
|
#include "vm/dart_entry.h"
|
|
|
|
#include "vm/instructions.h"
|
|
|
|
#include "vm/native_entry.h"
|
|
|
|
#include "vm/native_entry_test.h"
|
2017-04-19 17:21:53 +00:00
|
|
|
#include "vm/runtime_entry.h"
|
2011-12-17 00:56:02 +00:00
|
|
|
#include "vm/stub_code.h"
|
2012-07-24 00:01:50 +00:00
|
|
|
#include "vm/symbols.h"
|
2011-12-17 00:56:02 +00:00
|
|
|
#include "vm/unit_test.h"
|
|
|
|
|
|
|
|
namespace dart {
|
|
|
|
|
|
|
|
#define __ assembler->
|
|
|
|
|
|
|
|
ASSEMBLER_TEST_GENERATE(IcDataAccess, assembler) {
|
2016-04-11 23:28:29 +00:00
|
|
|
Thread* thread = Thread::Current();
|
|
|
|
const String& class_name = String::Handle(Symbols::New(thread, "ownerClass"));
|
2012-08-02 23:00:55 +00:00
|
|
|
const Script& script = Script::Handle();
|
2016-05-17 19:19:06 +00:00
|
|
|
const Class& owner_class = Class::Handle(Class::New(
|
|
|
|
Library::Handle(), class_name, script, TokenPosition::kNoSource));
|
2016-11-08 21:54:47 +00:00
|
|
|
const String& function_name =
|
|
|
|
String::Handle(Symbols::New(thread, "callerFunction"));
|
2021-01-07 23:45:37 +00:00
|
|
|
const FunctionType& signature = FunctionType::ZoneHandle(FunctionType::New());
|
2016-11-08 21:54:47 +00:00
|
|
|
const Function& function = Function::Handle(Function::New(
|
2021-01-15 23:32:02 +00:00
|
|
|
signature, function_name, UntaggedFunction::kRegularFunction, true, false,
|
2021-01-07 23:45:37 +00:00
|
|
|
false, false, false, owner_class, TokenPosition::kNoSource));
|
2012-02-22 00:40:03 +00:00
|
|
|
|
2021-09-10 22:21:36 +00:00
|
|
|
const String& target_name =
|
|
|
|
String::Handle(Symbols::New(thread, "targetFunction"));
|
2017-05-18 21:03:43 +00:00
|
|
|
const intptr_t kTypeArgsLen = 0;
|
|
|
|
const intptr_t kNumArgs = 1;
|
2020-03-05 15:17:04 +00:00
|
|
|
const Array& args_descriptor = Array::Handle(ArgumentsDescriptor::NewBoxed(
|
|
|
|
kTypeArgsLen, kNumArgs, Object::null_array()));
|
2017-09-28 19:43:32 +00:00
|
|
|
const ICData& ic_data = ICData::ZoneHandle(ICData::New(
|
|
|
|
function, target_name, args_descriptor, 15, 1, ICData::kInstance));
|
2012-02-22 00:40:03 +00:00
|
|
|
|
2015-07-31 19:38:33 +00:00
|
|
|
// Code accessing pp is generated, but not executed. Uninitialized pp is OK.
|
|
|
|
__ set_constant_pool_allowed(true);
|
|
|
|
|
|
|
|
__ LoadObject(RBX, ic_data);
|
2018-11-21 17:45:11 +00:00
|
|
|
__ CallPatchable(StubCode::OneArgCheckInlineCache());
|
2011-12-17 00:56:02 +00:00
|
|
|
__ ret();
|
|
|
|
}
|
|
|
|
|
2013-02-15 23:55:31 +00:00
|
|
|
ASSEMBLER_TEST_RUN(IcDataAccess, test) {
|
2018-10-09 17:30:25 +00:00
|
|
|
uword end = test->payload_start() + test->code().Size();
|
|
|
|
uword return_address = end - 1; // sizeof(ret)
|
2012-12-05 15:35:18 +00:00
|
|
|
ICData& ic_data = ICData::Handle();
|
2013-06-20 16:29:39 +00:00
|
|
|
CodePatcher::GetInstanceCallAt(return_address, test->code(), &ic_data);
|
2012-02-22 00:40:03 +00:00
|
|
|
EXPECT_STREQ("targetFunction",
|
2016-11-08 21:54:47 +00:00
|
|
|
String::Handle(ic_data.target_name()).ToCString());
|
2014-04-25 23:45:14 +00:00
|
|
|
EXPECT_EQ(1, ic_data.NumArgsTested());
|
2011-12-17 00:56:02 +00:00
|
|
|
EXPECT_EQ(0, ic_data.NumberOfChecks());
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dart
|
|
|
|
|
|
|
|
#endif // TARGET_ARCH_X64
|