mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
Supports FrameLookup vm test on MIPS
As with the similar CL for ARM, also: - Supports inline allocation of objects. - Supports checking of inline cache and instance calls. - Supports subtype test cache. - Supports (some) equality checks. - Supports for (some) conditional branches. - Supports for pool pointer setup in stubs. Review URL: https://codereview.chromium.org//14076005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21233 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
02f305a0f1
commit
2c5cea8d4e
11 changed files with 1228 additions and 100 deletions
|
@ -69,7 +69,6 @@ dart/*: Skip
|
|||
[ $arch == simmips ]
|
||||
# Tests needing an assembler.
|
||||
cc/Dart2JSCompileAll: Skip
|
||||
cc/FrameLookup: Skip
|
||||
cc/UseDartApi: Skip
|
||||
# Tests needing Dart execution.
|
||||
dart/*: Skip
|
||||
|
|
|
@ -204,20 +204,47 @@ void Assembler::LoadClass(Register result, Register object) {
|
|||
}
|
||||
|
||||
|
||||
void Assembler::EnterStubFrame() {
|
||||
addiu(SP, SP, Immediate(-3 * kWordSize));
|
||||
sw(ZR, Address(SP, 2 * kWordSize)); // PC marker is 0 in stubs.
|
||||
sw(RA, Address(SP, 1 * kWordSize));
|
||||
sw(FP, Address(SP, 0 * kWordSize));
|
||||
mov(FP, SP);
|
||||
void Assembler::EnterStubFrame(bool uses_pp) {
|
||||
if (uses_pp) {
|
||||
addiu(SP, SP, Immediate(-4 * kWordSize));
|
||||
sw(ZR, Address(SP, 3 * kWordSize)); // PC marker is 0 in stubs.
|
||||
sw(RA, Address(SP, 2 * kWordSize));
|
||||
sw(PP, Address(SP, 1 * kWordSize));
|
||||
sw(FP, Address(SP, 0 * kWordSize));
|
||||
mov(FP, SP);
|
||||
// Setup pool pointer for this stub.
|
||||
Label next;
|
||||
bal(&next);
|
||||
delay_slot()->mov(T0, RA);
|
||||
|
||||
const intptr_t object_pool_pc_dist =
|
||||
Instructions::HeaderSize() - Instructions::object_pool_offset() +
|
||||
CodeSize();
|
||||
|
||||
Bind(&next);
|
||||
lw(PP, Address(T0, -object_pool_pc_dist));
|
||||
} else {
|
||||
addiu(SP, SP, Immediate(-3 * kWordSize));
|
||||
sw(ZR, Address(SP, 2 * kWordSize)); // PC marker is 0 in stubs.
|
||||
sw(RA, Address(SP, 1 * kWordSize));
|
||||
sw(FP, Address(SP, 0 * kWordSize));
|
||||
mov(FP, SP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Assembler::LeaveStubFrame() {
|
||||
void Assembler::LeaveStubFrame(bool uses_pp) {
|
||||
mov(SP, FP);
|
||||
lw(RA, Address(SP, 1 * kWordSize));
|
||||
lw(FP, Address(SP, 0 * kWordSize));
|
||||
addiu(SP, SP, Immediate(3 * kWordSize));
|
||||
if (uses_pp) {
|
||||
lw(RA, Address(SP, 2 * kWordSize));
|
||||
lw(PP, Address(SP, 1 * kWordSize));
|
||||
lw(FP, Address(SP, 0 * kWordSize));
|
||||
addiu(SP, SP, Immediate(4 * kWordSize));
|
||||
} else {
|
||||
lw(RA, Address(SP, 1 * kWordSize));
|
||||
lw(FP, Address(SP, 0 * kWordSize));
|
||||
addiu(SP, SP, Immediate(3 * kWordSize));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -250,14 +277,15 @@ void Assembler::EnterDartFrame(intptr_t frame_size) {
|
|||
// the PC at this sw instruction.
|
||||
Bind(&next);
|
||||
|
||||
if (offset != 0) {
|
||||
// Adjust PC for any intrinsic code that could have been generated
|
||||
// before a frame is created.
|
||||
addiu(T0, T0, Immediate(-offset));
|
||||
}
|
||||
|
||||
// Save PC in frame for fast identification of corresponding code.
|
||||
sw(T0, Address(SP, 3 * kWordSize));
|
||||
if (offset == 0) {
|
||||
sw(T0, Address(SP, 3 * kWordSize));
|
||||
} else {
|
||||
// Adjust saved PC for any intrinsic code that could have been generated
|
||||
// before a frame is created.
|
||||
AddImmediate(T1, T0, -offset);
|
||||
sw(T1, Address(SP, 3 * kWordSize));
|
||||
}
|
||||
|
||||
// Set FP to the saved previous FP.
|
||||
addiu(FP, SP, Immediate(kWordSize));
|
||||
|
@ -266,7 +294,7 @@ void Assembler::EnterDartFrame(intptr_t frame_size) {
|
|||
lw(PP, Address(T0, -object_pool_pc_dist));
|
||||
|
||||
// Reserve space for locals.
|
||||
addiu(SP, SP, Immediate(-frame_size));
|
||||
AddImmediate(SP, -frame_size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -285,7 +313,7 @@ void Assembler::LeaveDartFrame() {
|
|||
void Assembler::ReserveAlignedFrameSpace(intptr_t frame_space) {
|
||||
// Reserve space for arguments and align frame before entering
|
||||
// the C++ world.
|
||||
addiu(SP, SP, Immediate(-frame_space));
|
||||
AddImmediate(SP, -frame_space);
|
||||
if (OS::ActivationFrameAlignment() > 0) {
|
||||
LoadImmediate(TMP1, ~(OS::ActivationFrameAlignment() - 1));
|
||||
and_(SP, SP, TMP1);
|
||||
|
|
|
@ -169,8 +169,8 @@ class Assembler : public ValueObject {
|
|||
|
||||
// Set up a stub frame so that the stack traversal code can easily identify
|
||||
// a stub frame.
|
||||
void EnterStubFrame();
|
||||
void LeaveStubFrame();
|
||||
void EnterStubFrame(bool uses_pp = false);
|
||||
void LeaveStubFrame(bool uses_pp = false);
|
||||
|
||||
// Instruction pattern from entrypoint is used in dart frame prologs
|
||||
// to set up the frame and save a PC which can be used to figure out the
|
||||
|
@ -565,6 +565,19 @@ class Assembler : public ValueObject {
|
|||
}
|
||||
}
|
||||
|
||||
void AddImmediate(Register rd, Register rs, int32_t value) {
|
||||
if (Utils::IsInt(kImmBits, value)) {
|
||||
addiu(rd, rs, Immediate(value));
|
||||
} else {
|
||||
LoadImmediate(TMP1, value);
|
||||
addu(rd, rs, TMP1);
|
||||
}
|
||||
}
|
||||
|
||||
void AddImmediate(Register rd, int32_t value) {
|
||||
AddImmediate(rd, rd, value);
|
||||
}
|
||||
|
||||
void BranchEqual(Register rd, int32_t value, Label* l) {
|
||||
LoadImmediate(TMP1, value);
|
||||
beq(rd, TMP1, l);
|
||||
|
@ -678,7 +691,7 @@ class Assembler : public ValueObject {
|
|||
void PushObject(const Object& object);
|
||||
|
||||
// Sets register rd to zero if the object is equal to register rn,
|
||||
// set to non-zero otherwise.
|
||||
// sets it to non-zero otherwise.
|
||||
void CompareObject(Register rd, Register rn, const Object& object);
|
||||
|
||||
void LoadClassId(Register result, Register object);
|
||||
|
|
|
@ -31,11 +31,11 @@ enum Register {
|
|||
R19 = 19,
|
||||
R20 = 20,
|
||||
R21 = 21,
|
||||
kLastFreeCpuRegister = 21,
|
||||
R22 = 22,
|
||||
R23 = 23,
|
||||
R24 = 24,
|
||||
R25 = 25,
|
||||
kLastFreeCpuRegister = 25,
|
||||
R26 = 26,
|
||||
R27 = 27,
|
||||
R28 = 28,
|
||||
|
@ -144,6 +144,10 @@ const Register PP = S7; // Caches object pool pointer in generated code.
|
|||
const Register SPREG = SP; // Stack pointer register.
|
||||
const Register FPREG = FP; // Frame pointer register.
|
||||
|
||||
// The code that generates a comparison can be far away from the code that
|
||||
// generates the branch that uses the result of that comparison. In this case,
|
||||
// CMPRES is used for the result of the comparison.
|
||||
const Register CMPRES = T8;
|
||||
|
||||
typedef uint32_t RegList;
|
||||
const RegList kAllCpuRegistersList = 0xFFFFFFFF;
|
||||
|
@ -162,10 +166,12 @@ static const int kLastParamSlotIndex = 3;
|
|||
static const int kFirstLocalSlotIndex = -2;
|
||||
|
||||
|
||||
// Values for the condition field. // UNIMPLEMENTED.
|
||||
// Values for the condition field.
|
||||
// There is no condition field on MIPS, but Conditions are used and passed
|
||||
// around by the intermediate language, so we need them here, too.
|
||||
enum Condition {
|
||||
kNoCondition = -1,
|
||||
kMaxCondition = 16,
|
||||
EQ, // equal
|
||||
NE, // not equal
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -49,13 +49,21 @@ void CompilerDeoptInfoWithStub::GenerateCode(FlowGraphCompiler* compiler,
|
|||
#define __ assembler()->
|
||||
|
||||
|
||||
// Fall through if bool_register contains null.
|
||||
void FlowGraphCompiler::GenerateBoolToJump(Register bool_register,
|
||||
Label* is_true,
|
||||
Label* is_false) {
|
||||
UNIMPLEMENTED();
|
||||
Label fall_through;
|
||||
__ BranchEqual(bool_register, reinterpret_cast<intptr_t>(Object::null()),
|
||||
&fall_through);
|
||||
__ BranchEqual(bool_register, Bool::True(), is_true);
|
||||
__ b(is_false);
|
||||
__ Bind(&fall_through);
|
||||
}
|
||||
|
||||
|
||||
// A0: instance (must be preserved).
|
||||
// A1: instantiator type arguments (if used).
|
||||
RawSubtypeTestCache* FlowGraphCompiler::GenerateCallSubtypeTestStub(
|
||||
TypeTestStubKind test_kind,
|
||||
Register instance_reg,
|
||||
|
@ -63,8 +71,28 @@ RawSubtypeTestCache* FlowGraphCompiler::GenerateCallSubtypeTestStub(
|
|||
Register temp_reg,
|
||||
Label* is_instance_lbl,
|
||||
Label* is_not_instance_lbl) {
|
||||
UNIMPLEMENTED();
|
||||
return NULL;
|
||||
ASSERT(instance_reg == A0);
|
||||
ASSERT(temp_reg == kNoRegister); // Unused on MIPS.
|
||||
const SubtypeTestCache& type_test_cache =
|
||||
SubtypeTestCache::ZoneHandle(SubtypeTestCache::New());
|
||||
__ LoadObject(A2, type_test_cache);
|
||||
if (test_kind == kTestTypeOneArg) {
|
||||
ASSERT(type_arguments_reg == kNoRegister);
|
||||
__ LoadImmediate(A1, reinterpret_cast<intptr_t>(Object::null()));
|
||||
__ BranchLink(&StubCode::Subtype1TestCacheLabel());
|
||||
} else if (test_kind == kTestTypeTwoArgs) {
|
||||
ASSERT(type_arguments_reg == kNoRegister);
|
||||
__ LoadImmediate(A1, reinterpret_cast<intptr_t>(Object::null()));
|
||||
__ BranchLink(&StubCode::Subtype2TestCacheLabel());
|
||||
} else if (test_kind == kTestTypeThreeArgs) {
|
||||
ASSERT(type_arguments_reg == A1);
|
||||
__ BranchLink(&StubCode::Subtype3TestCacheLabel());
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
}
|
||||
// Result is in V0: null -> not found, otherwise Bool::True or Bool::False.
|
||||
GenerateBoolToJump(V0, is_instance_lbl, is_not_instance_lbl);
|
||||
return type_test_cache.raw();
|
||||
}
|
||||
|
||||
|
||||
|
@ -153,13 +181,35 @@ bool FlowGraphCompiler::GenerateInstantiatedTypeNoArgumentsTest(
|
|||
}
|
||||
|
||||
|
||||
// Uses SubtypeTestCache to store instance class and result.
|
||||
// A0: instance to test.
|
||||
// Clobbers A1, A2, T0-T3.
|
||||
// Immediate class test already done.
|
||||
// TODO(srdjan): Implement a quicker subtype check, as type test
|
||||
// arrays can grow too high, but they may be useful when optimizing
|
||||
// code (type-feedback).
|
||||
RawSubtypeTestCache* FlowGraphCompiler::GenerateSubtype1TestCacheLookup(
|
||||
intptr_t token_pos,
|
||||
const Class& type_class,
|
||||
Label* is_instance_lbl,
|
||||
Label* is_not_instance_lbl) {
|
||||
UNIMPLEMENTED();
|
||||
return NULL;
|
||||
__ Comment("Subtype1TestCacheLookup");
|
||||
const Register kInstanceReg = A0;
|
||||
__ LoadClass(T0, kInstanceReg);
|
||||
// T0: instance class.
|
||||
// Check immediate superclass equality.
|
||||
__ lw(T0, FieldAddress(T0, Class::super_type_offset()));
|
||||
__ lw(T0, FieldAddress(T0, Type::type_class_offset()));
|
||||
__ BranchEqual(T0, type_class, is_instance_lbl);
|
||||
|
||||
const Register kTypeArgumentsReg = kNoRegister;
|
||||
const Register kTempReg = kNoRegister;
|
||||
return GenerateCallSubtypeTestStub(kTestTypeOneArg,
|
||||
kInstanceReg,
|
||||
kTypeArgumentsReg,
|
||||
kTempReg,
|
||||
is_instance_lbl,
|
||||
is_not_instance_lbl);
|
||||
}
|
||||
|
||||
|
||||
|
@ -329,8 +379,8 @@ void FlowGraphCompiler::GenerateAssertAssignable(intptr_t token_pos,
|
|||
__ sw(A2, Address(SP, 1 * kWordSize));
|
||||
__ sw(A1, Address(SP, 0 * kWordSize));
|
||||
__ PushObject(dst_name); // Push the name of the destination.
|
||||
__ LoadObject(A0, test_cache);
|
||||
__ Push(A0);
|
||||
__ LoadObject(T0, test_cache);
|
||||
__ Push(T0);
|
||||
GenerateCallRuntime(token_pos, deopt_id, kTypeCheckRuntimeEntry, locs);
|
||||
// Pop the parameters supplied to the runtime entry. The result of the
|
||||
// type check runtime call is the checked value.
|
||||
|
@ -405,11 +455,11 @@ void FlowGraphCompiler::CopyParameters() {
|
|||
__ subu(T1, T1, T2);
|
||||
__ sll(T1, T1, 1);
|
||||
__ addu(T1, FP, T1);
|
||||
__ addiu(T1, T1, Immediate(kLastParamSlotIndex * kWordSize));
|
||||
__ AddImmediate(T1, kLastParamSlotIndex * kWordSize);
|
||||
|
||||
// Let T0 point to the last copied positional argument, i.e. to
|
||||
// fp[kFirstLocalSlotIndex - (num_pos_args - 1)].
|
||||
__ addiu(T0, FP, Immediate((kFirstLocalSlotIndex + 1) * kWordSize));
|
||||
__ AddImmediate(T0, FP, (kFirstLocalSlotIndex + 1) * kWordSize);
|
||||
__ sll(T3, T2, 1); // T2 is a Smi.
|
||||
__ subu(T0, T0, T3);
|
||||
|
||||
|
@ -457,10 +507,10 @@ void FlowGraphCompiler::CopyParameters() {
|
|||
// fp[kLastParamSlotIndex + num_args - 1 - 0]; num_args (T1) is Smi.
|
||||
__ sll(T3, T1, 1);
|
||||
__ addu(T1, FP, T3);
|
||||
__ addiu(T1, T1, Immediate((kLastParamSlotIndex - 1) * kWordSize));
|
||||
__ AddImmediate(T1, (kLastParamSlotIndex - 1) * kWordSize);
|
||||
// Let T0 point to the entry of the first named argument.
|
||||
__ addiu(T0, S4, Immediate(
|
||||
ArgumentsDescriptor::first_named_entry_offset() - kHeapObjectTag));
|
||||
__ AddImmediate(T0, S4,
|
||||
ArgumentsDescriptor::first_named_entry_offset() - kHeapObjectTag);
|
||||
for (int i = 0; i < num_opt_named_params; i++) {
|
||||
Label load_default_value, assign_optional_parameter;
|
||||
const int param_pos = opt_param_position[i];
|
||||
|
@ -475,7 +525,7 @@ void FlowGraphCompiler::CopyParameters() {
|
|||
__ lw(T3, Address(T0, ArgumentsDescriptor::position_offset()));
|
||||
// T3 is arg_pos as Smi.
|
||||
// Point to next named entry.
|
||||
__ addiu(T0, T0, Immediate(ArgumentsDescriptor::named_entry_size()));
|
||||
__ AddImmediate(T0, ArgumentsDescriptor::named_entry_size());
|
||||
__ subu(T3, ZR, T3);
|
||||
__ sll(T3, T3, 1);
|
||||
__ addu(T3, T1, T3);
|
||||
|
@ -537,7 +587,7 @@ void FlowGraphCompiler::CopyParameters() {
|
|||
// We need to unwind the space we reserved for locals and copied parameters.
|
||||
// The NoSuchMethodFunction stub does not expect to see that area on the
|
||||
// stack.
|
||||
__ addiu(SP, SP, Immediate(StackSize() * kWordSize));
|
||||
__ AddImmediate(SP, StackSize() * kWordSize);
|
||||
}
|
||||
// The call below has an empty stackmap because we have just
|
||||
// dropped the spill slots.
|
||||
|
@ -730,7 +780,7 @@ void FlowGraphCompiler::CompileGraph() {
|
|||
// We need to unwind the space we reserved for locals and copied
|
||||
// parameters. The NoSuchMethodFunction stub does not expect to see
|
||||
// that area on the stack.
|
||||
__ addiu(SP, SP, Immediate(StackSize() * kWordSize));
|
||||
__ AddImmediate(SP, StackSize() * kWordSize);
|
||||
}
|
||||
// The call below has an empty stackmap because we have just
|
||||
// dropped the spill slots.
|
||||
|
@ -858,7 +908,22 @@ void FlowGraphCompiler::GenerateCallRuntime(intptr_t token_pos,
|
|||
intptr_t deopt_id,
|
||||
const RuntimeEntry& entry,
|
||||
LocationSummary* locs) {
|
||||
__ Unimplemented("call runtime");
|
||||
__ CallRuntime(entry);
|
||||
AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos);
|
||||
RecordSafepoint(locs);
|
||||
if (deopt_id != Isolate::kNoDeoptId) {
|
||||
// Marks either the continuation point in unoptimized code or the
|
||||
// deoptimization point in optimized code, after call.
|
||||
if (is_optimizing()) {
|
||||
AddDeoptIndexAtCall(deopt_id, token_pos);
|
||||
} else {
|
||||
// Add deoptimization continuation point after the call and before the
|
||||
// arguments are removed.
|
||||
AddCurrentDescriptor(PcDescriptors::kDeoptAfter,
|
||||
deopt_id,
|
||||
token_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -932,7 +997,16 @@ void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg,
|
|||
void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left,
|
||||
Register right,
|
||||
bool needs_number_check) {
|
||||
UNIMPLEMENTED();
|
||||
if (needs_number_check) {
|
||||
__ Push(left);
|
||||
__ Push(right);
|
||||
__ BranchLink(&StubCode::IdenticalWithNumberCheckLabel());
|
||||
// Stub returns result in CMPRES. If it is 0, then left and right are equal.
|
||||
__ Pop(right);
|
||||
__ Pop(left);
|
||||
} else {
|
||||
__ subu(CMPRES, left, right);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "vm/locations.h"
|
||||
#include "vm/object_store.h"
|
||||
#include "vm/parser.h"
|
||||
#include "vm/simulator.h"
|
||||
#include "vm/stub_code.h"
|
||||
#include "vm/symbols.h"
|
||||
|
||||
|
@ -194,13 +195,45 @@ LocationSummary* AssertAssignableInstr::MakeLocationSummary() const {
|
|||
|
||||
|
||||
LocationSummary* AssertBooleanInstr::MakeLocationSummary() const {
|
||||
UNIMPLEMENTED();
|
||||
return NULL;
|
||||
const intptr_t kNumInputs = 1;
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* locs =
|
||||
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
|
||||
locs->set_in(0, Location::RegisterLocation(A0));
|
||||
locs->set_out(Location::RegisterLocation(A0));
|
||||
return locs;
|
||||
}
|
||||
|
||||
|
||||
static void EmitAssertBoolean(Register reg,
|
||||
intptr_t token_pos,
|
||||
intptr_t deopt_id,
|
||||
LocationSummary* locs,
|
||||
FlowGraphCompiler* compiler) {
|
||||
// Check that the type of the value is allowed in conditional context.
|
||||
// Call the runtime if the object is not bool::true or bool::false.
|
||||
ASSERT(locs->always_calls());
|
||||
Label done;
|
||||
__ BranchEqual(reg, Bool::True(), &done);
|
||||
__ BranchEqual(reg, Bool::False(), &done);
|
||||
|
||||
__ Push(reg); // Push the source object.
|
||||
compiler->GenerateCallRuntime(token_pos,
|
||||
deopt_id,
|
||||
kConditionTypeErrorRuntimeEntry,
|
||||
locs);
|
||||
// We should never return here.
|
||||
__ break_(0);
|
||||
__ Bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void AssertBooleanInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
UNIMPLEMENTED();
|
||||
Register obj = locs()->in(0).reg();
|
||||
Register result = locs()->out().reg();
|
||||
|
||||
EmitAssertBoolean(obj, token_pos(), deopt_id(), locs(), compiler);
|
||||
ASSERT(obj == result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -216,19 +249,296 @@ void ArgumentDefinitionTestInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
|||
|
||||
|
||||
LocationSummary* EqualityCompareInstr::MakeLocationSummary() const {
|
||||
const intptr_t kNumInputs = 2;
|
||||
const bool is_checked_strict_equal =
|
||||
HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid);
|
||||
if (receiver_class_id() == kMintCid) {
|
||||
const intptr_t kNumTemps = 1;
|
||||
LocationSummary* locs =
|
||||
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
|
||||
locs->set_in(0, Location::RequiresFpuRegister());
|
||||
locs->set_in(1, Location::RequiresFpuRegister());
|
||||
locs->set_temp(0, Location::RequiresRegister());
|
||||
locs->set_out(Location::RequiresRegister());
|
||||
return locs;
|
||||
}
|
||||
if (receiver_class_id() == kDoubleCid) {
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* locs =
|
||||
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
|
||||
locs->set_in(0, Location::RequiresFpuRegister());
|
||||
locs->set_in(1, Location::RequiresFpuRegister());
|
||||
locs->set_out(Location::RequiresRegister());
|
||||
return locs;
|
||||
}
|
||||
if (receiver_class_id() == kSmiCid) {
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* locs =
|
||||
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
|
||||
locs->set_in(0, Location::RegisterOrConstant(left()));
|
||||
// Only one input can be a constant operand. The case of two constant
|
||||
// operands should be handled by constant propagation.
|
||||
locs->set_in(1, locs->in(0).IsConstant()
|
||||
? Location::RequiresRegister()
|
||||
: Location::RegisterOrConstant(right()));
|
||||
locs->set_out(Location::RequiresRegister());
|
||||
return locs;
|
||||
}
|
||||
if (is_checked_strict_equal) {
|
||||
const intptr_t kNumTemps = 1;
|
||||
LocationSummary* locs =
|
||||
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
|
||||
locs->set_in(0, Location::RequiresRegister());
|
||||
locs->set_in(1, Location::RequiresRegister());
|
||||
locs->set_temp(0, Location::RequiresRegister());
|
||||
locs->set_out(Location::RequiresRegister());
|
||||
return locs;
|
||||
}
|
||||
if (IsPolymorphic()) {
|
||||
const intptr_t kNumTemps = 1;
|
||||
LocationSummary* locs =
|
||||
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
|
||||
UNIMPLEMENTED(); // TODO(regis): Verify register allocation.
|
||||
return locs;
|
||||
}
|
||||
const intptr_t kNumTemps = 1;
|
||||
LocationSummary* locs =
|
||||
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
|
||||
locs->set_in(0, Location::RegisterLocation(A1));
|
||||
locs->set_in(1, Location::RegisterLocation(A0));
|
||||
locs->set_temp(0, Location::RegisterLocation(T0));
|
||||
locs->set_out(Location::RegisterLocation(V0));
|
||||
return locs;
|
||||
}
|
||||
|
||||
|
||||
// A1: left.
|
||||
// A0: right.
|
||||
// Uses T0 to load ic_call_data.
|
||||
// Result in V0.
|
||||
static void EmitEqualityAsInstanceCall(FlowGraphCompiler* compiler,
|
||||
intptr_t deopt_id,
|
||||
intptr_t token_pos,
|
||||
Token::Kind kind,
|
||||
LocationSummary* locs,
|
||||
const ICData& original_ic_data) {
|
||||
if (!compiler->is_optimizing()) {
|
||||
compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
|
||||
deopt_id,
|
||||
token_pos);
|
||||
}
|
||||
const int kNumberOfArguments = 2;
|
||||
const Array& kNoArgumentNames = Array::Handle();
|
||||
const int kNumArgumentsChecked = 2;
|
||||
|
||||
Label check_identity;
|
||||
__ LoadImmediate(TMP1, reinterpret_cast<intptr_t>(Object::null()));
|
||||
__ beq(A1, TMP1, &check_identity);
|
||||
__ beq(A0, TMP1, &check_identity);
|
||||
|
||||
ICData& equality_ic_data = ICData::ZoneHandle();
|
||||
if (compiler->is_optimizing() && FLAG_propagate_ic_data) {
|
||||
ASSERT(!original_ic_data.IsNull());
|
||||
if (original_ic_data.NumberOfChecks() == 0) {
|
||||
// IC call for reoptimization populates original ICData.
|
||||
equality_ic_data = original_ic_data.raw();
|
||||
} else {
|
||||
// Megamorphic call.
|
||||
equality_ic_data = original_ic_data.AsUnaryClassChecks();
|
||||
}
|
||||
} else {
|
||||
equality_ic_data = ICData::New(compiler->parsed_function().function(),
|
||||
Symbols::EqualOperator(),
|
||||
deopt_id,
|
||||
kNumArgumentsChecked);
|
||||
}
|
||||
__ addiu(SP, SP, Immediate(-2 * kWordSize));
|
||||
__ sw(A1, Address(SP, 1 * kWordSize));
|
||||
__ sw(A0, Address(SP, 0 * kWordSize));
|
||||
compiler->GenerateInstanceCall(deopt_id,
|
||||
token_pos,
|
||||
kNumberOfArguments,
|
||||
kNoArgumentNames,
|
||||
locs,
|
||||
equality_ic_data);
|
||||
Label check_ne;
|
||||
__ b(&check_ne);
|
||||
|
||||
__ Bind(&check_identity);
|
||||
Label equality_done;
|
||||
if (compiler->is_optimizing()) {
|
||||
// No need to update IC data.
|
||||
Label is_true;
|
||||
__ beq(A1, A0, &is_true);
|
||||
__ LoadObject(V0, (kind == Token::kEQ) ? Bool::False() : Bool::True());
|
||||
__ b(&equality_done);
|
||||
__ Bind(&is_true);
|
||||
__ LoadObject(V0, (kind == Token::kEQ) ? Bool::True() : Bool::False());
|
||||
if (kind == Token::kNE) {
|
||||
// Skip not-equal result conversion.
|
||||
__ b(&equality_done);
|
||||
}
|
||||
} else {
|
||||
// Call stub, load IC data in register. The stub will update ICData if
|
||||
// necessary.
|
||||
Register ic_data_reg = locs->temp(0).reg();
|
||||
ASSERT(ic_data_reg == T0); // Stub depends on it.
|
||||
__ LoadObject(ic_data_reg, equality_ic_data);
|
||||
// Pass left in A1 and right in A0.
|
||||
compiler->GenerateCall(token_pos,
|
||||
&StubCode::EqualityWithNullArgLabel(),
|
||||
PcDescriptors::kOther,
|
||||
locs);
|
||||
}
|
||||
__ Bind(&check_ne);
|
||||
if (kind == Token::kNE) {
|
||||
Label true_label, done;
|
||||
// Negate the condition: true label returns false and vice versa.
|
||||
__ BranchEqual(V0, Bool::True(), &true_label);
|
||||
__ LoadObject(V0, Bool::True());
|
||||
__ b(&done);
|
||||
__ Bind(&true_label);
|
||||
__ LoadObject(V0, Bool::False());
|
||||
__ Bind(&done);
|
||||
}
|
||||
__ Bind(&equality_done);
|
||||
}
|
||||
|
||||
|
||||
// Emit code when ICData's targets are all Object == (which is ===).
|
||||
static void EmitCheckedStrictEqual(FlowGraphCompiler* compiler,
|
||||
const ICData& ic_data,
|
||||
const LocationSummary& locs,
|
||||
Token::Kind kind,
|
||||
BranchInstr* branch,
|
||||
intptr_t deopt_id) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
|
||||
// First test if receiver is NULL, in which case === is applied.
|
||||
// If type feedback was provided (lists of <class-id, target>), do a
|
||||
// type by type check (either === or static call to the operator.
|
||||
static void EmitGenericEqualityCompare(FlowGraphCompiler* compiler,
|
||||
LocationSummary* locs,
|
||||
Token::Kind kind,
|
||||
BranchInstr* branch,
|
||||
const ICData& ic_data,
|
||||
intptr_t deopt_id,
|
||||
intptr_t token_pos) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
|
||||
static void EmitSmiComparisonOp(FlowGraphCompiler* compiler,
|
||||
const LocationSummary& locs,
|
||||
Token::Kind kind,
|
||||
BranchInstr* branch) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
|
||||
static void EmitUnboxedMintEqualityOp(FlowGraphCompiler* compiler,
|
||||
const LocationSummary& locs,
|
||||
Token::Kind kind,
|
||||
BranchInstr* branch) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
|
||||
static void EmitDoubleComparisonOp(FlowGraphCompiler* compiler,
|
||||
const LocationSummary& locs,
|
||||
Token::Kind kind,
|
||||
BranchInstr* branch) {
|
||||
UNIMPLEMENTED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
UNIMPLEMENTED();
|
||||
ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ));
|
||||
BranchInstr* kNoBranch = NULL;
|
||||
if (receiver_class_id() == kSmiCid) {
|
||||
EmitSmiComparisonOp(compiler, *locs(), kind(), kNoBranch);
|
||||
return;
|
||||
}
|
||||
if (receiver_class_id() == kMintCid) {
|
||||
EmitUnboxedMintEqualityOp(compiler, *locs(), kind(), kNoBranch);
|
||||
return;
|
||||
}
|
||||
if (receiver_class_id() == kDoubleCid) {
|
||||
EmitDoubleComparisonOp(compiler, *locs(), kind(), kNoBranch);
|
||||
return;
|
||||
}
|
||||
const bool is_checked_strict_equal =
|
||||
HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid);
|
||||
if (is_checked_strict_equal) {
|
||||
EmitCheckedStrictEqual(compiler, *ic_data(), *locs(), kind(), kNoBranch,
|
||||
deopt_id());
|
||||
return;
|
||||
}
|
||||
if (IsPolymorphic()) {
|
||||
EmitGenericEqualityCompare(compiler, locs(), kind(), kNoBranch, *ic_data(),
|
||||
deopt_id(), token_pos());
|
||||
return;
|
||||
}
|
||||
Register left = locs()->in(0).reg();
|
||||
Register right = locs()->in(1).reg();
|
||||
ASSERT(left == A1);
|
||||
ASSERT(right == A0);
|
||||
EmitEqualityAsInstanceCall(compiler,
|
||||
deopt_id(),
|
||||
token_pos(),
|
||||
kind(),
|
||||
locs(),
|
||||
*ic_data());
|
||||
ASSERT(locs()->out().reg() == V0);
|
||||
}
|
||||
|
||||
|
||||
void EqualityCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler,
|
||||
BranchInstr* branch) {
|
||||
UNIMPLEMENTED();
|
||||
ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ));
|
||||
if (receiver_class_id() == kSmiCid) {
|
||||
// Deoptimizes if both arguments not Smi.
|
||||
EmitSmiComparisonOp(compiler, *locs(), kind(), branch);
|
||||
return;
|
||||
}
|
||||
if (receiver_class_id() == kMintCid) {
|
||||
EmitUnboxedMintEqualityOp(compiler, *locs(), kind(), branch);
|
||||
return;
|
||||
}
|
||||
if (receiver_class_id() == kDoubleCid) {
|
||||
EmitDoubleComparisonOp(compiler, *locs(), kind(), branch);
|
||||
return;
|
||||
}
|
||||
const bool is_checked_strict_equal =
|
||||
HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid);
|
||||
if (is_checked_strict_equal) {
|
||||
EmitCheckedStrictEqual(compiler, *ic_data(), *locs(), kind(), branch,
|
||||
deopt_id());
|
||||
return;
|
||||
}
|
||||
if (IsPolymorphic()) {
|
||||
EmitGenericEqualityCompare(compiler, locs(), kind(), branch, *ic_data(),
|
||||
deopt_id(), token_pos());
|
||||
return;
|
||||
}
|
||||
Register left = locs()->in(0).reg();
|
||||
Register right = locs()->in(1).reg();
|
||||
ASSERT(left == A1);
|
||||
ASSERT(right == A0);
|
||||
EmitEqualityAsInstanceCall(compiler,
|
||||
deopt_id(),
|
||||
token_pos(),
|
||||
Token::kEQ, // kNE reverse occurs at branch.
|
||||
locs(),
|
||||
*ic_data());
|
||||
if (branch->is_checked()) {
|
||||
EmitAssertBoolean(V0, token_pos(), deopt_id(), locs(), compiler);
|
||||
}
|
||||
Condition branch_condition = (kind() == Token::kNE) ? NE : EQ;
|
||||
__ CompareObject(CMPRES, V0, Bool::True());
|
||||
branch->EmitBranchOnCondition(compiler, branch_condition);
|
||||
}
|
||||
|
||||
|
||||
|
@ -272,10 +582,10 @@ void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
|||
__ PushObject(Object::ZoneHandle());
|
||||
// Pass a pointer to the first argument in A2.
|
||||
if (!function().HasOptionalParameters()) {
|
||||
__ addiu(A2, FP, Immediate((kLastParamSlotIndex +
|
||||
function().NumParameters() - 1) * kWordSize));
|
||||
__ AddImmediate(A2, FP, (kLastParamSlotIndex +
|
||||
function().NumParameters() - 1) * kWordSize);
|
||||
} else {
|
||||
__ addiu(A2, FP, Immediate(kFirstLocalSlotIndex * kWordSize));
|
||||
__ AddImmediate(A2, FP, kFirstLocalSlotIndex * kWordSize);
|
||||
}
|
||||
// Compute the effective address. When running under the simulator,
|
||||
// this is a redirection address that forces the simulator to call
|
||||
|
@ -719,7 +1029,7 @@ LocationSummary* BranchInstr::MakeLocationSummary() const {
|
|||
|
||||
|
||||
void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
UNIMPLEMENTED();
|
||||
comparison()->EmitBranchCode(compiler, this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -835,25 +1145,79 @@ void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
|||
|
||||
|
||||
LocationSummary* GotoInstr::MakeLocationSummary() const {
|
||||
UNIMPLEMENTED();
|
||||
return NULL;
|
||||
return new LocationSummary(0, 0, LocationSummary::kNoCall);
|
||||
}
|
||||
|
||||
|
||||
void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
UNIMPLEMENTED();
|
||||
// Add deoptimization descriptor for deoptimizing instructions
|
||||
// that may be inserted before this instruction.
|
||||
if (!compiler->is_optimizing()) {
|
||||
compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
|
||||
GetDeoptId(),
|
||||
0); // No token position.
|
||||
}
|
||||
|
||||
if (HasParallelMove()) {
|
||||
compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
|
||||
}
|
||||
|
||||
// We can fall through if the successor is the next block in the list.
|
||||
// Otherwise, we need a jump.
|
||||
if (!compiler->CanFallThroughTo(successor())) {
|
||||
__ b(compiler->GetJumpLabel(successor()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Condition NegateCondition(Condition condition) {
|
||||
switch (condition) {
|
||||
case EQ: return NE;
|
||||
case NE: return EQ;
|
||||
default:
|
||||
OS::Print("Error: Condition not recognized: %d\n", condition);
|
||||
UNIMPLEMENTED();
|
||||
return EQ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ControlInstruction::EmitBranchOnValue(FlowGraphCompiler* compiler,
|
||||
bool value) {
|
||||
UNIMPLEMENTED();
|
||||
if (value && !compiler->CanFallThroughTo(true_successor())) {
|
||||
__ b(compiler->GetJumpLabel(true_successor()));
|
||||
} else if (!value && !compiler->CanFallThroughTo(false_successor())) {
|
||||
__ b(compiler->GetJumpLabel(false_successor()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The comparison result is in CMPRES.
|
||||
void ControlInstruction::EmitBranchOnCondition(FlowGraphCompiler* compiler,
|
||||
Condition true_condition) {
|
||||
UNIMPLEMENTED();
|
||||
if (compiler->CanFallThroughTo(false_successor())) {
|
||||
// If the next block is the false successor we will fall through to it.
|
||||
if (true_condition == EQ) {
|
||||
__ beq(CMPRES, ZR, compiler->GetJumpLabel(true_successor()));
|
||||
} else {
|
||||
ASSERT(true_condition == NE);
|
||||
__ bne(CMPRES, ZR, compiler->GetJumpLabel(true_successor()));
|
||||
}
|
||||
} else {
|
||||
// If the next block is the true successor we negate comparison and fall
|
||||
// through to it.
|
||||
Condition false_condition = NegateCondition(true_condition);
|
||||
if (false_condition == EQ) {
|
||||
__ beq(CMPRES, ZR, compiler->GetJumpLabel(false_successor()));
|
||||
} else {
|
||||
ASSERT(false_condition == NE);
|
||||
__ bne(CMPRES, ZR, compiler->GetJumpLabel(false_successor()));
|
||||
}
|
||||
// Fall through or jump to the true successor.
|
||||
if (!compiler->CanFallThroughTo(true_successor())) {
|
||||
__ b(compiler->GetJumpLabel(true_successor()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -869,19 +1233,89 @@ void CurrentContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
|||
|
||||
|
||||
LocationSummary* StrictCompareInstr::MakeLocationSummary() const {
|
||||
UNIMPLEMENTED();
|
||||
return NULL;
|
||||
const intptr_t kNumInputs = 2;
|
||||
const intptr_t kNumTemps = 0;
|
||||
LocationSummary* locs =
|
||||
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
|
||||
locs->set_in(0, Location::RegisterOrConstant(left()));
|
||||
locs->set_in(1, Location::RegisterOrConstant(right()));
|
||||
locs->set_out(Location::RequiresRegister());
|
||||
return locs;
|
||||
}
|
||||
|
||||
|
||||
// Special code for numbers (compare values instead of references.)
|
||||
void StrictCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
UNIMPLEMENTED();
|
||||
ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT);
|
||||
Location left = locs()->in(0);
|
||||
Location right = locs()->in(1);
|
||||
if (left.IsConstant() && right.IsConstant()) {
|
||||
// TODO(vegorov): should be eliminated earlier by constant propagation.
|
||||
const bool result = (kind() == Token::kEQ_STRICT) ?
|
||||
left.constant().raw() == right.constant().raw() :
|
||||
left.constant().raw() != right.constant().raw();
|
||||
__ LoadObject(locs()->out().reg(), result ? Bool::True() : Bool::False());
|
||||
return;
|
||||
}
|
||||
if (left.IsConstant()) {
|
||||
compiler->EmitEqualityRegConstCompare(right.reg(),
|
||||
left.constant(),
|
||||
needs_number_check());
|
||||
} else if (right.IsConstant()) {
|
||||
compiler->EmitEqualityRegConstCompare(left.reg(),
|
||||
right.constant(),
|
||||
needs_number_check());
|
||||
} else {
|
||||
compiler->EmitEqualityRegRegCompare(left.reg(),
|
||||
right.reg(),
|
||||
needs_number_check());
|
||||
}
|
||||
|
||||
Register result = locs()->out().reg();
|
||||
Label load_true, done;
|
||||
if (kind() == Token::kEQ_STRICT) {
|
||||
__ beq(CMPRES, ZR, &load_true);
|
||||
} else {
|
||||
ASSERT(kind() == Token::kNE_STRICT);
|
||||
__ bne(CMPRES, ZR, &load_true);
|
||||
}
|
||||
__ LoadObject(result, Bool::False());
|
||||
__ b(&done);
|
||||
__ Bind(&load_true);
|
||||
__ LoadObject(result, Bool::True());
|
||||
__ Bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void StrictCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler,
|
||||
BranchInstr* branch) {
|
||||
UNIMPLEMENTED();
|
||||
ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT);
|
||||
Location left = locs()->in(0);
|
||||
Location right = locs()->in(1);
|
||||
if (left.IsConstant() && right.IsConstant()) {
|
||||
// TODO(vegorov): should be eliminated earlier by constant propagation.
|
||||
const bool result = (kind() == Token::kEQ_STRICT) ?
|
||||
left.constant().raw() == right.constant().raw() :
|
||||
left.constant().raw() != right.constant().raw();
|
||||
branch->EmitBranchOnValue(compiler, result);
|
||||
return;
|
||||
}
|
||||
if (left.IsConstant()) {
|
||||
compiler->EmitEqualityRegConstCompare(right.reg(),
|
||||
left.constant(),
|
||||
needs_number_check());
|
||||
} else if (right.IsConstant()) {
|
||||
compiler->EmitEqualityRegConstCompare(left.reg(),
|
||||
right.constant(),
|
||||
needs_number_check());
|
||||
} else {
|
||||
compiler->EmitEqualityRegRegCompare(left.reg(),
|
||||
right.reg(),
|
||||
needs_number_check());
|
||||
}
|
||||
|
||||
Condition true_condition = (kind() == Token::kEQ_STRICT) ? EQ : NE;
|
||||
branch->EmitBranchOnCondition(compiler, true_condition);
|
||||
}
|
||||
|
||||
|
||||
|
@ -924,13 +1358,19 @@ void StoreVMFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
|||
|
||||
|
||||
LocationSummary* AllocateObjectInstr::MakeLocationSummary() const {
|
||||
UNIMPLEMENTED();
|
||||
return NULL;
|
||||
return MakeCallSummary();
|
||||
}
|
||||
|
||||
|
||||
void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
UNIMPLEMENTED();
|
||||
const Class& cls = Class::ZoneHandle(constructor().Owner());
|
||||
const Code& stub = Code::Handle(StubCode::GetAllocationStubForClass(cls));
|
||||
const ExternalLabel label(cls.ToCString(), stub.EntryPoint());
|
||||
compiler->GenerateCall(token_pos(),
|
||||
&label,
|
||||
PcDescriptors::kOther,
|
||||
locs());
|
||||
__ Drop(ArgumentCount()); // Discard arguments.
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,11 +14,6 @@
|
|||
|
||||
namespace dart {
|
||||
|
||||
// Compiler only implemented on IA32, X64, and ARM.
|
||||
#if defined(TARGET_ARCH_IA32) || \
|
||||
defined(TARGET_ARCH_X64) || \
|
||||
defined(TARGET_ARCH_ARM)
|
||||
|
||||
// Setup function for invocation.
|
||||
static void SetupFunction(const char* test_library_name,
|
||||
const char* test_class_name,
|
||||
|
@ -221,6 +216,4 @@ TEST_CASE(DartDynamicResolve) {
|
|||
}
|
||||
}
|
||||
|
||||
#endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 || TARGET_ARCH_ARM
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -832,6 +832,8 @@ void Simulator::DoBreak(Instr *instr) {
|
|||
reinterpret_cast<intptr_t>(instr) - Instr::kInstrSize);
|
||||
set_pc(get_pc() + Instr::kInstrSize);
|
||||
dbg.Stop(instr, message);
|
||||
// Adjust for extra pc increment.
|
||||
set_pc(get_pc() - Instr::kInstrSize);
|
||||
} else if (instr->BreakCodeField() == Instr::kRedirectCode) {
|
||||
SimulatorSetjmpBuffer buffer(this);
|
||||
|
||||
|
@ -914,6 +916,8 @@ void Simulator::DoBreak(Instr *instr) {
|
|||
} else {
|
||||
SimulatorDebugger dbg(this);
|
||||
dbg.Stop(instr, "breakpoint");
|
||||
// Adjust for extra pc increment.
|
||||
set_pc(get_pc() - Instr::kInstrSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
namespace dart {
|
||||
|
||||
// The constant kExitLinkOffsetInEntryFrame must be kept in sync with the
|
||||
// code in the InvokeDartCode stub.
|
||||
static const int kExitLinkOffsetInEntryFrame = -10 * kWordSize;
|
||||
static const int kPcAddressOffsetFromSp = -2 * kWordSize;
|
||||
static const int kEntrypointMarkerOffsetFromFp = 2 * kWordSize;
|
||||
static const int kSpOffsetFromPreviousFp = 3 * kWordSize;
|
||||
|
@ -54,7 +57,10 @@ void StackFrameIterator::SetupLastExitFrameData() {
|
|||
|
||||
|
||||
void StackFrameIterator::SetupNextExitFrameData() {
|
||||
UNIMPLEMENTED();
|
||||
uword exit_address = entry_.fp() + kExitLinkOffsetInEntryFrame;
|
||||
uword exit_marker = *reinterpret_cast<uword*>(exit_address);
|
||||
frames_.fp_ = exit_marker;
|
||||
frames_.sp_ = 0;
|
||||
}
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -764,7 +764,7 @@ void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler,
|
|||
|
||||
// Instance in R0, return its class-id in R0 as Smi.
|
||||
__ Bind(&get_class_id_as_smi);
|
||||
Label not_smi;
|
||||
|
||||
// Test if Smi -> load Smi class for comparison.
|
||||
__ tst(R0, ShifterOperand(kSmiTagMask));
|
||||
__ mov(R0, ShifterOperand(Smi::RawValue(kSmiCid)), EQ);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "vm/assembler.h"
|
||||
#include "vm/code_generator.h"
|
||||
#include "vm/dart_entry.h"
|
||||
#include "vm/flow_graph_compiler.h"
|
||||
#include "vm/instructions.h"
|
||||
#include "vm/stack_frame.h"
|
||||
#include "vm/stub_code.h"
|
||||
|
@ -16,6 +17,13 @@
|
|||
|
||||
namespace dart {
|
||||
|
||||
DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects.");
|
||||
DEFINE_FLAG(bool, use_slow_path, false,
|
||||
"Set to true for debugging & verifying the slow paths.");
|
||||
DECLARE_FLAG(int, optimization_counter_threshold);
|
||||
DECLARE_FLAG(bool, trace_optimized_ic_calls);
|
||||
|
||||
|
||||
// Input parameters:
|
||||
// RA : return address.
|
||||
// SP : address of last argument in argument array.
|
||||
|
@ -90,8 +98,8 @@ void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) {
|
|||
__ mov(SP, FP);
|
||||
__ lw(RA, Address(SP, 1 * kWordSize));
|
||||
__ lw(FP, Address(SP, 0 * kWordSize));
|
||||
__ addiu(SP, SP, Immediate(2 * kWordSize));
|
||||
__ Ret();
|
||||
__ delay_slot()->addiu(SP, SP, Immediate(2 * kWordSize));
|
||||
}
|
||||
|
||||
|
||||
|
@ -182,8 +190,8 @@ void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) {
|
|||
__ mov(SP, FP);
|
||||
__ lw(RA, Address(SP, 1 * kWordSize));
|
||||
__ lw(FP, Address(SP, 0 * kWordSize));
|
||||
__ addiu(SP, SP, Immediate(2 * kWordSize));
|
||||
__ Ret();
|
||||
__ delay_slot()->addiu(SP, SP, Immediate(2 * kWordSize));
|
||||
}
|
||||
|
||||
|
||||
|
@ -209,7 +217,7 @@ void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) {
|
|||
__ LeaveStubFrame();
|
||||
|
||||
__ lw(T0, FieldAddress(T0, Code::instructions_offset()));
|
||||
__ addiu(T0, T0, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
|
||||
__ AddImmediate(T0, Instructions::HeaderSize() - kHeapObjectTag);
|
||||
__ jr(T0);
|
||||
}
|
||||
|
||||
|
@ -311,25 +319,21 @@ void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) {
|
|||
__ lw(T1, FieldAddress(S4, ArgumentsDescriptor::count_offset()));
|
||||
__ SmiUntag(T1);
|
||||
|
||||
// Compute address of 'arguments array' data area into A2.
|
||||
__ lw(A2, Address(A2, VMHandles::kOffsetOfRawPtrInHandle));
|
||||
__ AddImmediate(A2, Array::data_offset() - kHeapObjectTag);
|
||||
|
||||
// Set up arguments for the Dart call.
|
||||
Label push_arguments;
|
||||
Label done_push_arguments;
|
||||
|
||||
// Compute address of 'arguments array' data area into A2.
|
||||
// See also the addiu in the delay slot of the upcoming beq.
|
||||
__ lw(A2, Address(A2, VMHandles::kOffsetOfRawPtrInHandle));
|
||||
|
||||
__ beq(T1, ZR, &done_push_arguments); // check if there are arguments.
|
||||
__ delay_slot()->addiu(A2, A2,
|
||||
Immediate(Array::data_offset() - kHeapObjectTag));
|
||||
|
||||
__ mov(A1, ZR);
|
||||
__ Bind(&push_arguments);
|
||||
__ lw(A3, Address(A2));
|
||||
__ Push(A3);
|
||||
__ addiu(A2, A2, Immediate(kWordSize));
|
||||
__ addiu(A1, A1, Immediate(1));
|
||||
__ BranchLess(A1, T1, &push_arguments);
|
||||
__ delay_slot()->addiu(A2, A2, Immediate(kWordSize));
|
||||
|
||||
__ Bind(&done_push_arguments);
|
||||
|
||||
|
@ -341,7 +345,7 @@ void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) {
|
|||
__ lw(CTX, Address(CTX, VMHandles::kOffsetOfRawPtrInHandle));
|
||||
|
||||
// Get rid of arguments pushed on the stack.
|
||||
__ addiu(SP, FP, Immediate(kSavedContextOffsetInEntryFrame));
|
||||
__ AddImmediate(SP, FP, kSavedContextOffsetInEntryFrame);
|
||||
|
||||
// Load Isolate pointer from Context structure into CTX. Drop Context.
|
||||
__ lw(CTX, FieldAddress(CTX, Context::isolate_offset()));
|
||||
|
@ -379,9 +383,174 @@ void StubCode::GenerateUpdateStoreBufferStub(Assembler* assembler) {
|
|||
}
|
||||
|
||||
|
||||
// Called for inline allocation of objects.
|
||||
// Input parameters:
|
||||
// RA : return address.
|
||||
// SP + 4 : type arguments object (only if class is parameterized).
|
||||
// SP + 0 : type arguments of instantiator (only if class is parameterized).
|
||||
void StubCode::GenerateAllocationStubForClass(Assembler* assembler,
|
||||
const Class& cls) {
|
||||
__ Unimplemented("AllocateObject stub");
|
||||
// The generated code is different if the class is parameterized.
|
||||
const bool is_cls_parameterized =
|
||||
cls.type_arguments_field_offset() != Class::kNoTypeArguments;
|
||||
// kInlineInstanceSize is a constant used as a threshold for determining
|
||||
// when the object initialization should be done as a loop or as
|
||||
// straight line code.
|
||||
const int kInlineInstanceSize = 12;
|
||||
const intptr_t instance_size = cls.instance_size();
|
||||
ASSERT(instance_size > 0);
|
||||
const intptr_t type_args_size = InstantiatedTypeArguments::InstanceSize();
|
||||
if (FLAG_inline_alloc &&
|
||||
PageSpace::IsPageAllocatableSize(instance_size + type_args_size)) {
|
||||
Label slow_case;
|
||||
Heap* heap = Isolate::Current()->heap();
|
||||
__ LoadImmediate(T5, heap->TopAddress());
|
||||
__ lw(T2, Address(T5));
|
||||
__ LoadImmediate(T4, instance_size);
|
||||
__ addu(T3, T2, T4);
|
||||
if (is_cls_parameterized) {
|
||||
Label no_instantiator;
|
||||
__ lw(T1, Address(SP, 1 * kWordSize));
|
||||
__ lw(T0, Address(SP, 0 * kWordSize));
|
||||
// A new InstantiatedTypeArguments object only needs to be allocated if
|
||||
// the instantiator is provided (not kNoInstantiator, but may be null).
|
||||
__ BranchEqual(T0, Smi::RawValue(StubCode::kNoInstantiator),
|
||||
&no_instantiator);
|
||||
__ delay_slot()->mov(T4, T3);
|
||||
__ AddImmediate(T3, type_args_size);
|
||||
__ Bind(&no_instantiator);
|
||||
// T4: potential new object end and, if T4 != T3, potential new
|
||||
// InstantiatedTypeArguments object start.
|
||||
}
|
||||
// Check if the allocation fits into the remaining space.
|
||||
// T2: potential new object start.
|
||||
// T3: potential next object start.
|
||||
if (FLAG_use_slow_path) {
|
||||
__ b(&slow_case);
|
||||
} else {
|
||||
__ BranchGreaterEqual(T3, heap->EndAddress(), &slow_case);
|
||||
}
|
||||
|
||||
// Successfully allocated the object(s), now update top to point to
|
||||
// next object start and initialize the object.
|
||||
__ sw(T3, Address(T5));
|
||||
|
||||
if (is_cls_parameterized) {
|
||||
// Initialize the type arguments field in the object.
|
||||
// T2: new object start.
|
||||
// T4: potential new object end and, if T4 != T3, potential new
|
||||
// InstantiatedTypeArguments object start.
|
||||
// T3: next object start.
|
||||
Label type_arguments_ready;
|
||||
__ beq(T4, T3, &type_arguments_ready);
|
||||
// Initialize InstantiatedTypeArguments object at T4.
|
||||
__ sw(T1, Address(T4,
|
||||
InstantiatedTypeArguments::uninstantiated_type_arguments_offset()));
|
||||
__ sw(T0, Address(T4,
|
||||
InstantiatedTypeArguments::instantiator_type_arguments_offset()));
|
||||
const Class& ita_cls =
|
||||
Class::ZoneHandle(Object::instantiated_type_arguments_class());
|
||||
// Set the tags.
|
||||
uword tags = 0;
|
||||
tags = RawObject::SizeTag::update(type_args_size, tags);
|
||||
tags = RawObject::ClassIdTag::update(ita_cls.id(), tags);
|
||||
__ LoadImmediate(T0, tags);
|
||||
__ sw(T0, Address(T4, Instance::tags_offset()));
|
||||
// Set the new InstantiatedTypeArguments object (T4) as the type
|
||||
// arguments (T1) of the new object (T2).
|
||||
__ addiu(T1, T4, Immediate(kHeapObjectTag));
|
||||
// Set T3 to new object end.
|
||||
__ mov(T3, T4);
|
||||
__ Bind(&type_arguments_ready);
|
||||
// T2: new object.
|
||||
// T1: new object type arguments.
|
||||
}
|
||||
|
||||
// T2: new object start.
|
||||
// T3: next object start.
|
||||
// T1: new object type arguments (if is_cls_parameterized).
|
||||
// Set the tags.
|
||||
uword tags = 0;
|
||||
tags = RawObject::SizeTag::update(instance_size, tags);
|
||||
ASSERT(cls.id() != kIllegalCid);
|
||||
tags = RawObject::ClassIdTag::update(cls.id(), tags);
|
||||
__ LoadImmediate(T0, tags);
|
||||
__ sw(T0, Address(T2, Instance::tags_offset()));
|
||||
|
||||
// Initialize the remaining words of the object.
|
||||
__ LoadImmediate(T0, reinterpret_cast<intptr_t>(Object::null()));
|
||||
|
||||
// T0: raw null.
|
||||
// T2: new object start.
|
||||
// T3: next object start.
|
||||
// T1: new object type arguments (if is_cls_parameterized).
|
||||
// First try inlining the initialization without a loop.
|
||||
if (instance_size < (kInlineInstanceSize * kWordSize)) {
|
||||
// Check if the object contains any non-header fields.
|
||||
// Small objects are initialized using a consecutive set of writes.
|
||||
for (intptr_t current_offset = sizeof(RawObject);
|
||||
current_offset < instance_size;
|
||||
current_offset += kWordSize) {
|
||||
__ sw(T0, Address(T2, current_offset));
|
||||
}
|
||||
} else {
|
||||
__ addiu(T4, T2, Immediate(sizeof(RawObject)));
|
||||
// Loop until the whole object is initialized.
|
||||
// T0: raw null.
|
||||
// T2: new object.
|
||||
// T3: next object start.
|
||||
// T4: next word to be initialized.
|
||||
// T1: new object type arguments (if is_cls_parameterized).
|
||||
Label init_loop;
|
||||
Label done;
|
||||
__ Bind(&init_loop);
|
||||
__ BranchGreaterEqual(T4, T3, &done); // Done if T4 >= T3.
|
||||
__ sw(T0, Address(T4));
|
||||
__ AddImmediate(T4, kWordSize);
|
||||
__ b(&init_loop);
|
||||
__ Bind(&done);
|
||||
}
|
||||
if (is_cls_parameterized) {
|
||||
// R1: new object type arguments.
|
||||
// Set the type arguments in the new object.
|
||||
__ sw(T1, Address(T2, cls.type_arguments_field_offset()));
|
||||
}
|
||||
// Done allocating and initializing the instance.
|
||||
// R2: new object still missing its heap tag.
|
||||
__ Ret();
|
||||
__ delay_slot()->addiu(V0, T2, Immediate(kHeapObjectTag));
|
||||
|
||||
__ Bind(&slow_case);
|
||||
}
|
||||
if (is_cls_parameterized) {
|
||||
__ lw(T1, Address(SP, 1 * kWordSize));
|
||||
__ lw(T0, Address(SP, 0 * kWordSize));
|
||||
}
|
||||
// Create a stub frame as we are pushing some objects on the stack before
|
||||
// calling into the runtime.
|
||||
__ EnterStubFrame(true); // Uses pool pointer to pass cls to runtime.
|
||||
__ LoadImmediate(T2, reinterpret_cast<intptr_t>(Object::null()));
|
||||
__ Push(T2); // Setup space on stack for return value.
|
||||
__ PushObject(cls); // Push class of object to be allocated.
|
||||
if (is_cls_parameterized) {
|
||||
// Push type arguments of object to be allocated and of instantiator.
|
||||
__ addiu(SP, SP, Immediate(-2 * kWordSize));
|
||||
__ sw(T1, Address(SP, 1 * kWordSize));
|
||||
__ sw(T0, Address(SP, 0 * kWordSize));
|
||||
} else {
|
||||
// Push null type arguments and kNoInstantiator.
|
||||
__ LoadImmediate(T1, Smi::RawValue(StubCode::kNoInstantiator));
|
||||
__ addiu(SP, SP, Immediate(-2 * kWordSize));
|
||||
__ sw(T2, Address(SP, 1 * kWordSize));
|
||||
__ sw(T1, Address(SP, 0 * kWordSize));
|
||||
}
|
||||
__ CallRuntime(kAllocateObjectRuntimeEntry); // Allocate object.
|
||||
__ Drop(3); // Pop arguments.
|
||||
__ Pop(V0); // Pop result (newly allocated object).
|
||||
// V0: new object
|
||||
// Restore the frame pointer.
|
||||
__ LeaveStubFrame(true);
|
||||
__ Ret();
|
||||
}
|
||||
|
||||
|
||||
|
@ -401,30 +570,242 @@ void StubCode::GenerateOptimizedUsageCounterIncrement(Assembler* assembler) {
|
|||
}
|
||||
|
||||
|
||||
// Loads function into 'temp_reg'.
|
||||
void StubCode::GenerateUsageCounterIncrement(Assembler* assembler,
|
||||
Register temp_reg) {
|
||||
__ Unimplemented("UsageCounterIncrement stub");
|
||||
Register ic_reg = S5;
|
||||
Register func_reg = temp_reg;
|
||||
ASSERT(temp_reg == T0);
|
||||
__ lw(func_reg, FieldAddress(ic_reg, ICData::function_offset()));
|
||||
__ lw(T1, FieldAddress(func_reg, Function::usage_counter_offset()));
|
||||
Label is_hot;
|
||||
if (FlowGraphCompiler::CanOptimize()) {
|
||||
ASSERT(FLAG_optimization_counter_threshold > 1);
|
||||
// The usage_counter is always less than FLAG_optimization_counter_threshold
|
||||
// except when the function gets optimized.
|
||||
__ BranchEqual(T1, FLAG_optimization_counter_threshold, &is_hot);
|
||||
// As long as VM has no OSR do not optimize in the middle of the function
|
||||
// but only at exit so that we have collected all type feedback before
|
||||
// optimizing.
|
||||
}
|
||||
__ addiu(T1, T1, Immediate(1));
|
||||
__ sw(T1, FieldAddress(func_reg, Function::usage_counter_offset()));
|
||||
__ Bind(&is_hot);
|
||||
}
|
||||
|
||||
|
||||
// Generate inline cache check for 'num_args'.
|
||||
// AR: return address
|
||||
// S5: Inline cache data object.
|
||||
// S4: Arguments descriptor array.
|
||||
// Control flow:
|
||||
// - If receiver is null -> jump to IC miss.
|
||||
// - If receiver is Smi -> load Smi class.
|
||||
// - If receiver is not-Smi -> load receiver's class.
|
||||
// - Check if 'num_args' (including receiver) match any IC data group.
|
||||
// - Match found -> jump to target.
|
||||
// - Match not found -> jump to IC miss.
|
||||
void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler,
|
||||
intptr_t num_args) {
|
||||
__ Unimplemented("NArgsCheckInlineCache stub");
|
||||
ASSERT(num_args > 0);
|
||||
#if defined(DEBUG)
|
||||
{ Label ok;
|
||||
// Check that the IC data array has NumberOfArgumentsChecked() == num_args.
|
||||
// 'num_args_tested' is stored as an untagged int.
|
||||
__ lw(T0, FieldAddress(S5, ICData::num_args_tested_offset()));
|
||||
__ BranchEqual(T0, num_args, &ok);
|
||||
__ Stop("Incorrect stub for IC data");
|
||||
__ Bind(&ok);
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
// Preserve return address, since LR is needed for subroutine call.
|
||||
__ mov(T2, RA);
|
||||
// Loop that checks if there is an IC data match.
|
||||
Label loop, update, test, found, get_class_id_as_smi;
|
||||
// S5: IC data object (preserved).
|
||||
__ lw(T0, FieldAddress(S5, ICData::ic_data_offset()));
|
||||
// T0: ic_data_array with check entries: classes and target functions.
|
||||
__ AddImmediate(T0, Array::data_offset() - kHeapObjectTag);
|
||||
// T0: points directly to the first ic data array element.
|
||||
|
||||
// Get the receiver's class ID (first read number of arguments from
|
||||
// arguments descriptor array and then access the receiver from the stack).
|
||||
__ lw(T1, FieldAddress(S4, ArgumentsDescriptor::count_offset()));
|
||||
__ AddImmediate(T1, -Smi::RawValue(1));
|
||||
__ sll(T3, T1, 1); // T1 (argument_count - 1) is smi.
|
||||
__ addu(T3, T3, SP);
|
||||
__ bal(&get_class_id_as_smi);
|
||||
__ delay_slot()->lw(T3, Address(T3));
|
||||
// T1: argument_count - 1 (smi).
|
||||
// T3: receiver's class ID (smi).
|
||||
__ b(&test);
|
||||
__ delay_slot()->lw(T4, Address(T0)); // First class id (smi) to check.
|
||||
|
||||
__ Bind(&loop);
|
||||
for (int i = 0; i < num_args; i++) {
|
||||
if (i > 0) {
|
||||
// If not the first, load the next argument's class ID.
|
||||
__ LoadImmediate(T3, Smi::RawValue(-i));
|
||||
__ addu(T3, T1, T3);
|
||||
__ sll(T3, T3, 1);
|
||||
__ addu(T3, SP, T3);
|
||||
__ bal(&get_class_id_as_smi);
|
||||
__ delay_slot()->lw(T3, Address(T3));
|
||||
// T3: next argument class ID (smi).
|
||||
__ lw(T4, Address(T0, i * kWordSize));
|
||||
// T4: next class ID to check (smi).
|
||||
}
|
||||
if (i < (num_args - 1)) {
|
||||
__ bne(T3, T4, &update); // Continue.
|
||||
} else {
|
||||
// Last check, all checks before matched.
|
||||
Label skip;
|
||||
__ bne(T3, T4, &skip);
|
||||
__ b(&found); // Break.
|
||||
__ delay_slot()->mov(RA, T2); // Restore return address if found.
|
||||
__ Bind(&skip);
|
||||
}
|
||||
}
|
||||
__ Bind(&update);
|
||||
// Reload receiver class ID. It has not been destroyed when num_args == 1.
|
||||
if (num_args > 1) {
|
||||
__ sll(T3, T1, 1);
|
||||
__ addu(T3, SP, T3);
|
||||
__ bal(&get_class_id_as_smi);
|
||||
__ delay_slot()->lw(T3, Address(T3));
|
||||
}
|
||||
|
||||
const intptr_t entry_size = ICData::TestEntryLengthFor(num_args) * kWordSize;
|
||||
__ AddImmediate(T0, entry_size); // Next entry.
|
||||
__ lw(T4, Address(T0)); // Next class ID.
|
||||
|
||||
__ Bind(&test);
|
||||
__ BranchNotEqual(T4, Smi::RawValue(kIllegalCid), &loop); // Done?
|
||||
|
||||
// IC miss.
|
||||
// Restore return address.
|
||||
__ mov(RA, T2);
|
||||
|
||||
// Compute address of arguments (first read number of arguments from
|
||||
// arguments descriptor array and then compute address on the stack).
|
||||
// T1: argument_count - 1 (smi).
|
||||
__ sll(T1, T1, 1);
|
||||
__ addu(T1, SP, T1); // T1 is Smi.
|
||||
// T1: address of receiver.
|
||||
// Create a stub frame as we are pushing some objects on the stack before
|
||||
// calling into the runtime.
|
||||
__ EnterStubFrame();
|
||||
__ LoadImmediate(T3, reinterpret_cast<intptr_t>(Object::null()));
|
||||
// Preserve IC data object and arguments descriptor array and
|
||||
// setup space on stack for result (target code object).
|
||||
__ addiu(SP, SP, Immediate(-3 * kWordSize));
|
||||
__ sw(S5, Address(SP, 2 * kWordSize));
|
||||
__ sw(S4, Address(SP, 1 * kWordSize));
|
||||
__ sw(T3, Address(SP, 0 * kWordSize));
|
||||
// Push call arguments.
|
||||
for (intptr_t i = 0; i < num_args; i++) {
|
||||
__ lw(TMP, Address(T1, -i * kWordSize));
|
||||
__ Push(TMP);
|
||||
}
|
||||
// Pass IC data object and arguments descriptor array.
|
||||
__ addiu(SP, SP, Immediate(-2 * kWordSize));
|
||||
__ sw(S5, Address(SP, 1 * kWordSize));
|
||||
__ sw(S4, Address(SP, 0 * kWordSize));
|
||||
|
||||
if (num_args == 1) {
|
||||
__ CallRuntime(kInlineCacheMissHandlerOneArgRuntimeEntry);
|
||||
} else if (num_args == 2) {
|
||||
__ CallRuntime(kInlineCacheMissHandlerTwoArgsRuntimeEntry);
|
||||
} else if (num_args == 3) {
|
||||
__ CallRuntime(kInlineCacheMissHandlerThreeArgsRuntimeEntry);
|
||||
} else {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
// Remove the call arguments pushed earlier, including the IC data object
|
||||
// and the arguments descriptor array.
|
||||
__ Drop(num_args + 2);
|
||||
// Pop returned code object into T3 (null if not found).
|
||||
// Restore arguments descriptor array and IC data array.
|
||||
__ lw(T3, Address(SP, 0 * kWordSize));
|
||||
__ lw(S4, Address(SP, 1 * kWordSize));
|
||||
__ lw(S5, Address(SP, 2 * kWordSize));
|
||||
__ addiu(SP, SP, Immediate(3 * kWordSize));
|
||||
__ LeaveStubFrame();
|
||||
Label call_target_function;
|
||||
__ BranchNotEqual(T3, reinterpret_cast<intptr_t>(Object::null()),
|
||||
&call_target_function);
|
||||
// NoSuchMethod or closure.
|
||||
// Mark IC call that it may be a closure call that does not collect
|
||||
// type feedback.
|
||||
__ LoadImmediate(TMP2, 1);
|
||||
__ Branch(&StubCode::InstanceFunctionLookupLabel());
|
||||
__ delay_slot()->sb(TMP2, FieldAddress(S5, ICData::is_closure_call_offset()));
|
||||
|
||||
__ Bind(&found);
|
||||
// T0: Pointer to an IC data check group.
|
||||
const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize;
|
||||
const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize;
|
||||
__ lw(T3, Address(T0, target_offset));
|
||||
__ lw(T4, Address(T0, count_offset));
|
||||
|
||||
__ AddImmediateDetectOverflow(T4, T4, Smi::RawValue(1), T5);
|
||||
|
||||
__ bgez(T5, &call_target_function); // No overflow.
|
||||
__ delay_slot()->sw(T4, Address(T0, count_offset));
|
||||
|
||||
__ LoadImmediate(T1, Smi::RawValue(Smi::kMaxValue));
|
||||
__ sw(T1, Address(T0, count_offset));
|
||||
|
||||
__ Bind(&call_target_function);
|
||||
// T0: Target function.
|
||||
__ lw(T3, FieldAddress(T3, Function::code_offset()));
|
||||
__ lw(T3, FieldAddress(T3, Code::instructions_offset()));
|
||||
__ AddImmediate(T3, Instructions::HeaderSize() - kHeapObjectTag);
|
||||
__ jr(T3);
|
||||
|
||||
// Instance in T3, return its class-id in T3 as Smi.
|
||||
__ Bind(&get_class_id_as_smi);
|
||||
Label not_smi;
|
||||
// Test if Smi -> load Smi class for comparison.
|
||||
__ andi(TMP1, T3, Immediate(kSmiTagMask));
|
||||
__ bne(TMP1, ZR, ¬_smi);
|
||||
__ LoadImmediate(T3, Smi::RawValue(kSmiCid));
|
||||
__ jr(RA);
|
||||
|
||||
__ Bind(¬_smi);
|
||||
__ LoadClassId(T3, T3);
|
||||
__ SmiTag(T3);
|
||||
__ jr(RA);
|
||||
}
|
||||
|
||||
|
||||
// Use inline cache data array to invoke the target or continue in inline
|
||||
// cache miss handler. Stub for 1-argument check (receiver class).
|
||||
// RA: Return address.
|
||||
// S5: Inline cache data object.
|
||||
// S4: Arguments descriptor array.
|
||||
// Inline cache data object structure:
|
||||
// 0: function-name
|
||||
// 1: N, number of arguments checked.
|
||||
// 2 .. (length - 1): group of checks, each check containing:
|
||||
// - N classes.
|
||||
// - 1 target function.
|
||||
void StubCode::GenerateOneArgCheckInlineCacheStub(Assembler* assembler) {
|
||||
__ Unimplemented("GenerateOneArgCheckInlineCacheStub stub");
|
||||
GenerateUsageCounterIncrement(assembler, T0);
|
||||
GenerateNArgsCheckInlineCacheStub(assembler, 1);
|
||||
}
|
||||
|
||||
|
||||
void StubCode::GenerateTwoArgsCheckInlineCacheStub(Assembler* assembler) {
|
||||
__ Unimplemented("GenerateTwoArgsCheckInlineCacheStub stub");
|
||||
GenerateUsageCounterIncrement(assembler, T0);
|
||||
GenerateNArgsCheckInlineCacheStub(assembler, 2);
|
||||
}
|
||||
|
||||
|
||||
void StubCode::GenerateThreeArgsCheckInlineCacheStub(Assembler* assembler) {
|
||||
__ Unimplemented("GenerateThreeArgsCheckInlineCacheStub stub");
|
||||
GenerateUsageCounterIncrement(assembler, T0);
|
||||
GenerateNArgsCheckInlineCacheStub(assembler, 3);
|
||||
}
|
||||
|
||||
|
||||
|
@ -474,18 +855,106 @@ void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) {
|
|||
}
|
||||
|
||||
|
||||
// Used to check class and type arguments. Arguments passed in registers:
|
||||
// RA: return address.
|
||||
// A0: instance (must be preserved).
|
||||
// A1: instantiator type arguments or NULL.
|
||||
// A2: cache array.
|
||||
// Result in V0: null -> not found, otherwise result (true or false).
|
||||
static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) {
|
||||
ASSERT((1 <= n) && (n <= 3));
|
||||
if (n > 1) {
|
||||
// Get instance type arguments.
|
||||
__ LoadClass(T0, A0);
|
||||
// Compute instance type arguments into R4.
|
||||
Label has_no_type_arguments;
|
||||
__ LoadImmediate(T1, reinterpret_cast<intptr_t>(Object::null()));
|
||||
__ lw(T2, FieldAddress(T0,
|
||||
Class::type_arguments_field_offset_in_words_offset()));
|
||||
__ BranchEqual(T2, Class::kNoTypeArguments, &has_no_type_arguments);
|
||||
__ sll(T2, T2, 2);
|
||||
__ addu(T2, A0, T2); // T2 <- A0 + T2 * 4
|
||||
__ lw(T1, FieldAddress(T2, 0));
|
||||
__ Bind(&has_no_type_arguments);
|
||||
}
|
||||
__ LoadClassId(T0, A0);
|
||||
// A0: instance.
|
||||
// A1: instantiator type arguments or NULL.
|
||||
// A2: SubtypeTestCache.
|
||||
// T0: instance class id.
|
||||
// T1: instance type arguments (null if none), used only if n > 1.
|
||||
__ lw(T2, FieldAddress(A2, SubtypeTestCache::cache_offset()));
|
||||
__ AddImmediate(T2, Array::data_offset() - kHeapObjectTag);
|
||||
|
||||
Label loop, found, not_found, next_iteration;
|
||||
// T0: instance class id.
|
||||
// T1: instance type arguments.
|
||||
// T2: Entry start.
|
||||
__ SmiTag(T0);
|
||||
__ Bind(&loop);
|
||||
__ lw(T3, Address(T2, kWordSize * SubtypeTestCache::kInstanceClassId));
|
||||
__ BranchEqual(T3, reinterpret_cast<intptr_t>(Object::null()), ¬_found);
|
||||
|
||||
if (n == 1) {
|
||||
__ BranchEqual(T3, T0, &found);
|
||||
} else {
|
||||
__ BranchNotEqual(T3, T0, &next_iteration);
|
||||
__ lw(T3,
|
||||
Address(T2, kWordSize * SubtypeTestCache::kInstanceTypeArguments));
|
||||
if (n == 2) {
|
||||
__ BranchEqual(T3, T1, &found);
|
||||
} else {
|
||||
__ BranchNotEqual(T3, T1, &next_iteration);
|
||||
__ lw(T3, Address(T2, kWordSize *
|
||||
SubtypeTestCache::kInstantiatorTypeArguments));
|
||||
__ BranchEqual(T3, A1, &found);
|
||||
}
|
||||
}
|
||||
__ Bind(&next_iteration);
|
||||
__ AddImmediate(T2, kWordSize * SubtypeTestCache::kTestEntryLength);
|
||||
__ b(&loop);
|
||||
// Fall through to not found.
|
||||
__ Bind(¬_found);
|
||||
__ LoadImmediate(V0, reinterpret_cast<intptr_t>(Object::null()));
|
||||
__ Ret();
|
||||
|
||||
__ Bind(&found);
|
||||
__ Ret();
|
||||
__ delay_slot()->lw(V0,
|
||||
Address(T2, kWordSize * SubtypeTestCache::kTestResult));
|
||||
}
|
||||
|
||||
|
||||
// Used to check class and type arguments. Arguments passed in registers:
|
||||
// RA: return address.
|
||||
// A0: instance (must be preserved).
|
||||
// A1: instantiator type arguments or NULL.
|
||||
// A2: cache array.
|
||||
// Result in V0: null -> not found, otherwise result (true or false).
|
||||
void StubCode::GenerateSubtype1TestCacheStub(Assembler* assembler) {
|
||||
__ Unimplemented("Subtype1TestCache Stub");
|
||||
GenerateSubtypeNTestCacheStub(assembler, 1);
|
||||
}
|
||||
|
||||
|
||||
// Used to check class and type arguments. Arguments passed in registers:
|
||||
// LR: return address.
|
||||
// A0: instance (must be preserved).
|
||||
// A1: instantiator type arguments or NULL.
|
||||
// A2: cache array.
|
||||
// Result in V0: null -> not found, otherwise result (true or false).
|
||||
void StubCode::GenerateSubtype2TestCacheStub(Assembler* assembler) {
|
||||
__ Unimplemented("Subtype2TestCache Stub");
|
||||
GenerateSubtypeNTestCacheStub(assembler, 2);
|
||||
}
|
||||
|
||||
|
||||
// Used to check class and type arguments. Arguments passed in registers:
|
||||
// RA: return address.
|
||||
// A0: instance (must be preserved).
|
||||
// A1: instantiator type arguments or NULL.
|
||||
// A2: cache array.
|
||||
// Result in V0: null -> not found, otherwise result (true or false).
|
||||
void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) {
|
||||
__ Unimplemented("Subtype3TestCache Stub");
|
||||
GenerateSubtypeNTestCacheStub(assembler, 3);
|
||||
}
|
||||
|
||||
|
||||
|
@ -511,17 +980,113 @@ void StubCode::GenerateJumpToErrorHandlerStub(Assembler* assembler) {
|
|||
|
||||
|
||||
void StubCode::GenerateEqualityWithNullArgStub(Assembler* assembler) {
|
||||
__ Unimplemented("EqualityWithNullArg stub");
|
||||
__ Unimplemented("EqualityWithNullArg Stub");
|
||||
}
|
||||
|
||||
|
||||
void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) {
|
||||
__ Unimplemented("OptimizeFunction stub");
|
||||
__ Unimplemented("OptimizeFunction Stub");
|
||||
}
|
||||
|
||||
|
||||
DECLARE_LEAF_RUNTIME_ENTRY(intptr_t,
|
||||
BigintCompare,
|
||||
RawBigint* left,
|
||||
RawBigint* right);
|
||||
|
||||
|
||||
// Does identical check (object references are equal or not equal) with special
|
||||
// checks for boxed numbers.
|
||||
// LR: return address.
|
||||
// SP + 4: left operand.
|
||||
// SP + 0: right operand.
|
||||
// Return: CMPRES is zero if equal, non-zero otherwise.
|
||||
// Note: A Mint cannot contain a value that would fit in Smi, a Bigint
|
||||
// cannot contain a value that fits in Mint or Smi.
|
||||
void StubCode::GenerateIdenticalWithNumberCheckStub(Assembler* assembler) {
|
||||
__ Unimplemented("IdenticalWithNumberCheck stub");
|
||||
const Register ret = CMPRES;
|
||||
const Register temp1 = TMP1;
|
||||
const Register temp2 = TMP2;
|
||||
const Register left = T1;
|
||||
const Register right = T0;
|
||||
// Preserve left, right and temp.
|
||||
__ addiu(SP, SP, Immediate(-2 * kWordSize));
|
||||
__ sw(T1, Address(SP, 1 * kWordSize));
|
||||
__ sw(T0, Address(SP, 0 * kWordSize));
|
||||
// TOS + 4: left argument.
|
||||
// TOS + 3: right argument.
|
||||
// TOS + 1: saved left
|
||||
// TOS + 0: saved right
|
||||
__ lw(left, Address(SP, 3 * kWordSize));
|
||||
__ lw(right, Address(SP, 2 * kWordSize));
|
||||
Label reference_compare, done, check_mint, check_bigint;
|
||||
// If any of the arguments is Smi do reference compare.
|
||||
__ andi(temp1, left, Immediate(kSmiTagMask));
|
||||
__ beq(temp1, ZR, &reference_compare);
|
||||
__ andi(temp1, right, Immediate(kSmiTagMask));
|
||||
__ beq(temp1, ZR, &reference_compare);
|
||||
|
||||
// Value compare for two doubles.
|
||||
__ LoadImmediate(temp1, kDoubleCid);
|
||||
__ LoadClassId(temp2, left);
|
||||
__ bne(temp1, temp2, &check_mint);
|
||||
__ LoadClassId(temp2, right);
|
||||
__ subu(ret, temp1, temp2);
|
||||
__ bne(ret, ZR, &done);
|
||||
|
||||
// Double values bitwise compare.
|
||||
__ lw(temp1, FieldAddress(left, Double::value_offset() + 0 * kWordSize));
|
||||
__ lw(temp1, FieldAddress(right, Double::value_offset() + 0 * kWordSize));
|
||||
__ subu(ret, temp1, temp2);
|
||||
__ bne(ret, ZR, &done);
|
||||
__ lw(temp1, FieldAddress(left, Double::value_offset() + 1 * kWordSize));
|
||||
__ lw(temp2, FieldAddress(right, Double::value_offset() + 1 * kWordSize));
|
||||
__ b(&done);
|
||||
__ delay_slot()->subu(ret, temp1, temp2);
|
||||
|
||||
__ Bind(&check_mint);
|
||||
__ LoadImmediate(temp1, kMintCid);
|
||||
__ LoadClassId(temp2, left);
|
||||
__ bne(temp1, temp2, &check_bigint);
|
||||
__ LoadClassId(temp2, right);
|
||||
__ subu(ret, temp1, temp2);
|
||||
__ bne(ret, ZR, &done);
|
||||
|
||||
__ lw(temp1, FieldAddress(left, Mint::value_offset() + 0 * kWordSize));
|
||||
__ lw(temp2, FieldAddress(right, Mint::value_offset() + 0 * kWordSize));
|
||||
__ subu(ret, temp1, temp2);
|
||||
__ bne(ret, ZR, &done);
|
||||
__ lw(temp1, FieldAddress(left, Mint::value_offset() + 1 * kWordSize));
|
||||
__ lw(temp2, FieldAddress(right, Mint::value_offset() + 1 * kWordSize));
|
||||
__ b(&done);
|
||||
__ delay_slot()->subu(ret, temp1, temp2);
|
||||
|
||||
__ Bind(&check_bigint);
|
||||
__ LoadImmediate(temp1, kBigintCid);
|
||||
__ LoadClassId(temp2, left);
|
||||
__ bne(temp1, temp2, &reference_compare);
|
||||
__ LoadClassId(temp2, right);
|
||||
__ subu(ret, temp1, temp2);
|
||||
__ bne(ret, ZR, &done);
|
||||
|
||||
__ EnterStubFrame(0);
|
||||
__ ReserveAlignedFrameSpace(2 * kWordSize);
|
||||
__ addiu(SP, SP, Immediate(-2 * kWordSize));
|
||||
__ sw(T1, Address(SP, 1 * kWordSize));
|
||||
__ sw(T0, Address(SP, 0 * kWordSize));
|
||||
__ CallRuntime(kBigintCompareRuntimeEntry);
|
||||
// Result in V0, 0 means equal.
|
||||
__ LeaveStubFrame();
|
||||
__ b(&done);
|
||||
__ delay_slot()->mov(CMPRES, V0);
|
||||
|
||||
__ Bind(&reference_compare);
|
||||
__ subu(ret, left, right);
|
||||
__ Bind(&done);
|
||||
__ lw(T0, Address(SP, 0 * kWordSize));
|
||||
__ lw(T1, Address(SP, 1 * kWordSize));
|
||||
__ Ret();
|
||||
__ delay_slot()->addiu(SP, SP, Immediate(2 * kWordSize));
|
||||
}
|
||||
|
||||
} // namespace dart
|
||||
|
|
Loading…
Reference in a new issue