2014-04-02 17:39:32 +00:00
|
|
|
// Copyright (c) 2014, 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_ARM64)
|
|
|
|
|
2014-04-17 22:00:11 +00:00
|
|
|
#include "vm/code_patcher.h"
|
2017-09-04 14:18:37 +00:00
|
|
|
#include "vm/compiler/assembler/assembler.h"
|
2014-04-17 22:00:11 +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"
|
2014-04-17 22:00:11 +00:00
|
|
|
#include "vm/stub_code.h"
|
|
|
|
#include "vm/symbols.h"
|
|
|
|
#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"));
|
2014-04-17 22:00:11 +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"));
|
|
|
|
const Function& function = Function::Handle(Function::New(
|
|
|
|
function_name, RawFunction::kRegularFunction, true, false, false, false,
|
|
|
|
false, owner_class, TokenPosition::kNoSource));
|
2014-04-17 22:00:11 +00:00
|
|
|
|
|
|
|
const String& target_name = String::Handle(String::New("targetFunction"));
|
2017-05-18 21:03:43 +00:00
|
|
|
const intptr_t kTypeArgsLen = 0;
|
|
|
|
const intptr_t kNumArgs = 1;
|
|
|
|
const Array& args_descriptor = Array::Handle(
|
|
|
|
ArgumentsDescriptor::New(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));
|
2019-06-12 21:56:53 +00:00
|
|
|
const Code& stub = StubCode::OneArgCheckInlineCache();
|
2014-04-17 22:00:11 +00:00
|
|
|
|
2015-07-29 22:21:20 +00:00
|
|
|
// Code accessing pp is generated, but not executed. Uninitialized pp is OK.
|
|
|
|
__ set_constant_pool_allowed(true);
|
|
|
|
|
2019-07-10 22:20:10 +00:00
|
|
|
compiler::ObjectPoolBuilder& op = __ object_pool_builder();
|
2019-06-12 21:56:53 +00:00
|
|
|
const intptr_t ic_data_index =
|
|
|
|
op.AddObject(ic_data, ObjectPool::Patchability::kPatchable);
|
|
|
|
const intptr_t stub_index =
|
|
|
|
op.AddObject(stub, ObjectPool::Patchability::kPatchable);
|
|
|
|
ASSERT((ic_data_index + 1) == stub_index);
|
|
|
|
__ LoadDoubleWordFromPoolOffset(R5, CODE_REG,
|
|
|
|
ObjectPool::element_offset(ic_data_index));
|
2019-07-10 22:20:10 +00:00
|
|
|
__ ldr(LR, compiler::FieldAddress(
|
|
|
|
CODE_REG,
|
|
|
|
Code::entry_point_offset(Code::EntryKind::kMonomorphic)));
|
2019-06-12 21:56:53 +00:00
|
|
|
__ blr(LR);
|
2014-04-17 22:00:11 +00:00
|
|
|
__ ret();
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSEMBLER_TEST_RUN(IcDataAccess, test) {
|
2016-08-12 18:18:35 +00:00
|
|
|
uword end = test->payload_start() + test->code().Size();
|
|
|
|
uword return_address = end - Instr::kInstrSize;
|
2014-04-17 22:00:11 +00:00
|
|
|
ICData& ic_data = ICData::Handle();
|
|
|
|
CodePatcher::GetInstanceCallAt(return_address, test->code(), &ic_data);
|
|
|
|
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());
|
2014-04-17 22:00:11 +00:00
|
|
|
EXPECT_EQ(0, ic_data.NumberOfChecks());
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dart
|
2014-04-02 17:39:32 +00:00
|
|
|
|
|
|
|
#endif // defined TARGET_ARCH_ARM64
|