| Index: src/x64/lithium-codegen-x64.cc
|
| diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
|
| index beaa1f1df96853c515d0c47c7a88ad3380edaacd..0a2c3ce554e7aab62102fa91b96617d69281b8b9 100644
|
| --- a/src/x64/lithium-codegen-x64.cc
|
| +++ b/src/x64/lithium-codegen-x64.cc
|
| @@ -67,7 +67,7 @@ class SafepointGenerator : public CallWrapper {
|
| #define __ masm()->
|
|
|
| bool LCodeGen::GenerateCode() {
|
| - HPhase phase("Z_Code generation", chunk());
|
| + LPhase phase("Z_Code generation", chunk());
|
| ASSERT(is_unused());
|
| status_ = GENERATING;
|
|
|
| @@ -92,7 +92,7 @@ void LCodeGen::FinishCode(Handle<Code> code) {
|
| RegisterDependentCodeForEmbeddedMaps(code);
|
| }
|
| PopulateDeoptimizationData(code);
|
| - info()->CommitDependentMaps(code);
|
| + info()->CommitDependencies(code);
|
| }
|
|
|
|
|
| @@ -511,27 +511,6 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
|
|
|
| for (int i = 0; i < translation_size; ++i) {
|
| LOperand* value = environment->values()->at(i);
|
| - // spilled_registers_ and spilled_double_registers_ are either
|
| - // both NULL or both set.
|
| - if (environment->spilled_registers() != NULL && value != NULL) {
|
| - if (value->IsRegister() &&
|
| - environment->spilled_registers()[value->index()] != NULL) {
|
| - translation->MarkDuplicate();
|
| - AddToTranslation(translation,
|
| - environment->spilled_registers()[value->index()],
|
| - environment->HasTaggedValueAt(i),
|
| - environment->HasUint32ValueAt(i));
|
| - } else if (
|
| - value->IsDoubleRegister() &&
|
| - environment->spilled_double_registers()[value->index()] != NULL) {
|
| - translation->MarkDuplicate();
|
| - AddToTranslation(
|
| - translation,
|
| - environment->spilled_double_registers()[value->index()],
|
| - false,
|
| - false);
|
| - }
|
| - }
|
|
|
| // TODO(mstarzinger): Introduce marker operands to indicate that this value
|
| // is not present and must be reconstructed from the deoptimizer. Currently
|
| @@ -541,12 +520,6 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
|
| translation->BeginArgumentsObject(arguments_count);
|
| for (int i = 0; i < arguments_count; ++i) {
|
| LOperand* value = environment->values()->at(translation_size + i);
|
| - ASSERT(environment->spilled_registers() == NULL ||
|
| - !value->IsRegister() ||
|
| - environment->spilled_registers()[value->index()] == NULL);
|
| - ASSERT(environment->spilled_registers() == NULL ||
|
| - !value->IsDoubleRegister() ||
|
| - environment->spilled_double_registers()[value->index()] == NULL);
|
| AddToTranslation(translation,
|
| value,
|
| environment->HasTaggedValueAt(translation_size + i),
|
| @@ -1000,7 +973,8 @@ void LCodeGen::DoCallStub(LCallStub* instr) {
|
|
|
|
|
| void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) {
|
| - // Nothing to do.
|
| + // Record the address of the first unknown OSR value as the place to enter.
|
| + if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset();
|
| }
|
|
|
|
|
| @@ -1034,12 +1008,12 @@ void LCodeGen::DoModI(LModI* instr) {
|
| __ andl(left_reg, Immediate(divisor - 1));
|
| __ bind(&done);
|
|
|
| - } else if (hmod->has_fixed_right_arg()) {
|
| + } else if (hmod->fixed_right_arg().has_value) {
|
| Register left_reg = ToRegister(instr->left());
|
| ASSERT(left_reg.is(ToRegister(instr->result())));
|
| Register right_reg = ToRegister(instr->right());
|
|
|
| - int32_t divisor = hmod->fixed_right_arg_value();
|
| + int32_t divisor = hmod->fixed_right_arg().value;
|
| ASSERT(IsPowerOf2(divisor));
|
|
|
| // Check if our assumption of a fixed right operand still holds.
|
| @@ -1612,8 +1586,11 @@ void LCodeGen::DoValueOf(LValueOf* instr) {
|
| Register result = ToRegister(instr->result());
|
| ASSERT(input.is(result));
|
| Label done;
|
| - // If the object is a smi return the object.
|
| - __ JumpIfSmi(input, &done, Label::kNear);
|
| +
|
| + if (!instr->hydrogen()->value()->IsHeapObject()) {
|
| + // If the object is a smi return the object.
|
| + __ JumpIfSmi(input, &done, Label::kNear);
|
| + }
|
|
|
| // If the object is not a value type, return the object.
|
| __ CmpObjectType(input, JS_VALUE_TYPE, kScratchRegister);
|
| @@ -1862,10 +1839,12 @@ int LCodeGen::GetNextEmittedBlock() const {
|
| }
|
|
|
|
|
| -void LCodeGen::EmitBranch(int left_block, int right_block, Condition cc) {
|
| +template<class InstrType>
|
| +void LCodeGen::EmitBranch(InstrType instr, Condition cc) {
|
| + int right_block = instr->FalseDestination(chunk_);
|
| + int left_block = instr->TrueDestination(chunk_);
|
| +
|
| int next_block = GetNextEmittedBlock();
|
| - right_block = chunk_->LookupDestination(right_block);
|
| - left_block = chunk_->LookupDestination(left_block);
|
|
|
| if (right_block == left_block) {
|
| EmitGoto(left_block);
|
| @@ -1888,26 +1867,23 @@ void LCodeGen::DoDebugBreak(LDebugBreak* instr) {
|
|
|
|
|
| void LCodeGen::DoBranch(LBranch* instr) {
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| Representation r = instr->hydrogen()->value()->representation();
|
| if (r.IsInteger32()) {
|
| ASSERT(!info()->IsStub());
|
| Register reg = ToRegister(instr->value());
|
| __ testl(reg, reg);
|
| - EmitBranch(true_block, false_block, not_zero);
|
| + EmitBranch(instr, not_zero);
|
| } else if (r.IsSmi()) {
|
| ASSERT(!info()->IsStub());
|
| Register reg = ToRegister(instr->value());
|
| __ testq(reg, reg);
|
| - EmitBranch(true_block, false_block, not_zero);
|
| + EmitBranch(instr, not_zero);
|
| } else if (r.IsDouble()) {
|
| ASSERT(!info()->IsStub());
|
| XMMRegister reg = ToDoubleRegister(instr->value());
|
| __ xorps(xmm0, xmm0);
|
| __ ucomisd(reg, xmm0);
|
| - EmitBranch(true_block, false_block, not_equal);
|
| + EmitBranch(instr, not_equal);
|
| } else {
|
| ASSERT(r.IsTagged());
|
| Register reg = ToRegister(instr->value());
|
| @@ -1915,43 +1891,52 @@ void LCodeGen::DoBranch(LBranch* instr) {
|
| if (type.IsBoolean()) {
|
| ASSERT(!info()->IsStub());
|
| __ CompareRoot(reg, Heap::kTrueValueRootIndex);
|
| - EmitBranch(true_block, false_block, equal);
|
| + EmitBranch(instr, equal);
|
| } else if (type.IsSmi()) {
|
| ASSERT(!info()->IsStub());
|
| __ SmiCompare(reg, Smi::FromInt(0));
|
| - EmitBranch(true_block, false_block, not_equal);
|
| + EmitBranch(instr, not_equal);
|
| + } else if (type.IsJSArray()) {
|
| + ASSERT(!info()->IsStub());
|
| + EmitBranch(instr, no_condition);
|
| + } else if (type.IsHeapNumber()) {
|
| + ASSERT(!info()->IsStub());
|
| + __ xorps(xmm0, xmm0);
|
| + __ ucomisd(xmm0, FieldOperand(reg, HeapNumber::kValueOffset));
|
| + EmitBranch(instr, not_equal);
|
| + } else if (type.IsString()) {
|
| + ASSERT(!info()->IsStub());
|
| + __ cmpq(FieldOperand(reg, String::kLengthOffset), Immediate(0));
|
| + EmitBranch(instr, not_equal);
|
| } else {
|
| - Label* true_label = chunk_->GetAssemblyLabel(true_block);
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
| -
|
| ToBooleanStub::Types expected = instr->hydrogen()->expected_input_types();
|
| // Avoid deopts in the case where we've never executed this path before.
|
| - if (expected.IsEmpty()) expected = ToBooleanStub::all_types();
|
| + if (expected.IsEmpty()) expected = ToBooleanStub::Types::Generic();
|
|
|
| if (expected.Contains(ToBooleanStub::UNDEFINED)) {
|
| // undefined -> false.
|
| __ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
|
| - __ j(equal, false_label);
|
| + __ j(equal, instr->FalseLabel(chunk_));
|
| }
|
| if (expected.Contains(ToBooleanStub::BOOLEAN)) {
|
| // true -> true.
|
| __ CompareRoot(reg, Heap::kTrueValueRootIndex);
|
| - __ j(equal, true_label);
|
| + __ j(equal, instr->TrueLabel(chunk_));
|
| // false -> false.
|
| __ CompareRoot(reg, Heap::kFalseValueRootIndex);
|
| - __ j(equal, false_label);
|
| + __ j(equal, instr->FalseLabel(chunk_));
|
| }
|
| if (expected.Contains(ToBooleanStub::NULL_TYPE)) {
|
| // 'null' -> false.
|
| __ CompareRoot(reg, Heap::kNullValueRootIndex);
|
| - __ j(equal, false_label);
|
| + __ j(equal, instr->FalseLabel(chunk_));
|
| }
|
|
|
| if (expected.Contains(ToBooleanStub::SMI)) {
|
| // Smis: 0 -> false, all other -> true.
|
| __ Cmp(reg, Smi::FromInt(0));
|
| - __ j(equal, false_label);
|
| - __ JumpIfSmi(reg, true_label);
|
| + __ j(equal, instr->FalseLabel(chunk_));
|
| + __ JumpIfSmi(reg, instr->TrueLabel(chunk_));
|
| } else if (expected.NeedsMap()) {
|
| // If we need a map later and have a Smi -> deopt.
|
| __ testb(reg, Immediate(kSmiTagMask));
|
| @@ -1966,14 +1951,14 @@ void LCodeGen::DoBranch(LBranch* instr) {
|
| // Undetectable -> false.
|
| __ testb(FieldOperand(map, Map::kBitFieldOffset),
|
| Immediate(1 << Map::kIsUndetectable));
|
| - __ j(not_zero, false_label);
|
| + __ j(not_zero, instr->FalseLabel(chunk_));
|
| }
|
| }
|
|
|
| if (expected.Contains(ToBooleanStub::SPEC_OBJECT)) {
|
| // spec object -> true.
|
| __ CmpInstanceType(map, FIRST_SPEC_OBJECT_TYPE);
|
| - __ j(above_equal, true_label);
|
| + __ j(above_equal, instr->TrueLabel(chunk_));
|
| }
|
|
|
| if (expected.Contains(ToBooleanStub::STRING)) {
|
| @@ -1982,8 +1967,8 @@ void LCodeGen::DoBranch(LBranch* instr) {
|
| __ CmpInstanceType(map, FIRST_NONSTRING_TYPE);
|
| __ j(above_equal, ¬_string, Label::kNear);
|
| __ cmpq(FieldOperand(reg, String::kLengthOffset), Immediate(0));
|
| - __ j(not_zero, true_label);
|
| - __ jmp(false_label);
|
| + __ j(not_zero, instr->TrueLabel(chunk_));
|
| + __ jmp(instr->FalseLabel(chunk_));
|
| __ bind(¬_string);
|
| }
|
|
|
| @@ -1994,13 +1979,16 @@ void LCodeGen::DoBranch(LBranch* instr) {
|
| __ j(not_equal, ¬_heap_number, Label::kNear);
|
| __ xorps(xmm0, xmm0);
|
| __ ucomisd(xmm0, FieldOperand(reg, HeapNumber::kValueOffset));
|
| - __ j(zero, false_label);
|
| - __ jmp(true_label);
|
| + __ j(zero, instr->FalseLabel(chunk_));
|
| + __ jmp(instr->TrueLabel(chunk_));
|
| __ bind(¬_heap_number);
|
| }
|
|
|
| - // We've seen something for the first time -> deopt.
|
| - DeoptimizeIf(no_condition, instr->environment());
|
| + if (!expected.IsGeneric()) {
|
| + // We've seen something for the first time -> deopt.
|
| + // This can only happen if we are not generic already.
|
| + DeoptimizeIf(no_condition, instr->environment());
|
| + }
|
| }
|
| }
|
| }
|
| @@ -2049,24 +2037,21 @@ inline Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) {
|
| void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
|
| LOperand* left = instr->left();
|
| LOperand* right = instr->right();
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| Condition cc = TokenToCondition(instr->op(), instr->is_double());
|
|
|
| if (left->IsConstantOperand() && right->IsConstantOperand()) {
|
| // We can statically evaluate the comparison.
|
| double left_val = ToDouble(LConstantOperand::cast(left));
|
| double right_val = ToDouble(LConstantOperand::cast(right));
|
| - int next_block =
|
| - EvalComparison(instr->op(), left_val, right_val) ? true_block
|
| - : false_block;
|
| + int next_block = EvalComparison(instr->op(), left_val, right_val) ?
|
| + instr->TrueDestination(chunk_) : instr->FalseDestination(chunk_);
|
| EmitGoto(next_block);
|
| } else {
|
| if (instr->is_double()) {
|
| // Don't base result on EFLAGS when a NaN is involved. Instead
|
| // jump to the false block.
|
| __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right));
|
| - __ j(parity_even, chunk_->GetAssemblyLabel(false_block));
|
| + __ j(parity_even, instr->FalseLabel(chunk_));
|
| } else {
|
| int32_t value;
|
| if (right->IsConstantOperand()) {
|
| @@ -2105,15 +2090,13 @@ void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
|
| }
|
| }
|
| }
|
| - EmitBranch(true_block, false_block, cc);
|
| + EmitBranch(instr, cc);
|
| }
|
| }
|
|
|
|
|
| void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) {
|
| Register left = ToRegister(instr->left());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
|
|
| if (instr->right()->IsConstantOperand()) {
|
| Handle<Object> right = ToHandle(LConstantOperand::cast(instr->right()));
|
| @@ -2122,17 +2105,15 @@ void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) {
|
| Register right = ToRegister(instr->right());
|
| __ cmpq(left, right);
|
| }
|
| - EmitBranch(true_block, false_block, equal);
|
| + EmitBranch(instr, equal);
|
| }
|
|
|
|
|
| void LCodeGen::DoCmpConstantEqAndBranch(LCmpConstantEqAndBranch* instr) {
|
| Register left = ToRegister(instr->left());
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
|
|
| __ cmpq(left, Immediate(instr->hydrogen()->right()));
|
| - EmitBranch(true_block, false_block, equal);
|
| + EmitBranch(instr, equal);
|
| }
|
|
|
|
|
| @@ -2164,21 +2145,21 @@ Condition LCodeGen::EmitIsObject(Register input,
|
| void LCodeGen::DoIsObjectAndBranch(LIsObjectAndBranch* instr) {
|
| Register reg = ToRegister(instr->value());
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| - Label* true_label = chunk_->GetAssemblyLabel(true_block);
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
| -
|
| - Condition true_cond = EmitIsObject(reg, false_label, true_label);
|
| + Condition true_cond = EmitIsObject(
|
| + reg, instr->FalseLabel(chunk_), instr->TrueLabel(chunk_));
|
|
|
| - EmitBranch(true_block, false_block, true_cond);
|
| + EmitBranch(instr, true_cond);
|
| }
|
|
|
|
|
| Condition LCodeGen::EmitIsString(Register input,
|
| Register temp1,
|
| - Label* is_not_string) {
|
| - __ JumpIfSmi(input, is_not_string);
|
| + Label* is_not_string,
|
| + SmiCheck check_needed = INLINE_SMI_CHECK) {
|
| + if (check_needed == INLINE_SMI_CHECK) {
|
| + __ JumpIfSmi(input, is_not_string);
|
| + }
|
| +
|
| Condition cond = masm_->IsObjectStringType(input, temp1, temp1);
|
|
|
| return cond;
|
| @@ -2189,20 +2170,18 @@ void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) {
|
| Register reg = ToRegister(instr->value());
|
| Register temp = ToRegister(instr->temp());
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
| + SmiCheck check_needed =
|
| + instr->hydrogen()->value()->IsHeapObject()
|
| + ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
|
|
|
| - Condition true_cond = EmitIsString(reg, temp, false_label);
|
| + Condition true_cond = EmitIsString(
|
| + reg, temp, instr->FalseLabel(chunk_), check_needed);
|
|
|
| - EmitBranch(true_block, false_block, true_cond);
|
| + EmitBranch(instr, true_cond);
|
| }
|
|
|
|
|
| void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) {
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| Condition is_smi;
|
| if (instr->value()->IsRegister()) {
|
| Register input = ToRegister(instr->value());
|
| @@ -2211,7 +2190,7 @@ void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) {
|
| Operand input = ToOperand(instr->value());
|
| is_smi = masm()->CheckSmi(input);
|
| }
|
| - EmitBranch(true_block, false_block, is_smi);
|
| + EmitBranch(instr, is_smi);
|
| }
|
|
|
|
|
| @@ -2219,21 +2198,18 @@ void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) {
|
| Register input = ToRegister(instr->value());
|
| Register temp = ToRegister(instr->temp());
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| - __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block));
|
| + if (!instr->hydrogen()->value()->IsHeapObject()) {
|
| + __ JumpIfSmi(input, instr->FalseLabel(chunk_));
|
| + }
|
| __ movq(temp, FieldOperand(input, HeapObject::kMapOffset));
|
| __ testb(FieldOperand(temp, Map::kBitFieldOffset),
|
| Immediate(1 << Map::kIsUndetectable));
|
| - EmitBranch(true_block, false_block, not_zero);
|
| + EmitBranch(instr, not_zero);
|
| }
|
|
|
|
|
| void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) {
|
| Token::Value op = instr->op();
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
|
|
| Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op);
|
| CallCode(ic, RelocInfo::CODE_TARGET, instr);
|
| @@ -2241,7 +2217,7 @@ void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) {
|
| Condition condition = TokenToCondition(op, false);
|
| __ testq(rax, rax);
|
|
|
| - EmitBranch(true_block, false_block, condition);
|
| + EmitBranch(instr, condition);
|
| }
|
|
|
|
|
| @@ -2268,15 +2244,12 @@ static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) {
|
| void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) {
|
| Register input = ToRegister(instr->value());
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
| -
|
| - __ JumpIfSmi(input, false_label);
|
| + if (!instr->hydrogen()->value()->IsHeapObject()) {
|
| + __ JumpIfSmi(input, instr->FalseLabel(chunk_));
|
| + }
|
|
|
| __ CmpObjectType(input, TestType(instr->hydrogen()), kScratchRegister);
|
| - EmitBranch(true_block, false_block, BranchCondition(instr->hydrogen()));
|
| + EmitBranch(instr, BranchCondition(instr->hydrogen()));
|
| }
|
|
|
|
|
| @@ -2296,12 +2269,9 @@ void LCodeGen::DoHasCachedArrayIndexAndBranch(
|
| LHasCachedArrayIndexAndBranch* instr) {
|
| Register input = ToRegister(instr->value());
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| __ testl(FieldOperand(input, String::kHashFieldOffset),
|
| Immediate(String::kContainsCachedArrayIndexMask));
|
| - EmitBranch(true_block, false_block, equal);
|
| + EmitBranch(instr, equal);
|
| }
|
|
|
|
|
| @@ -2379,25 +2349,18 @@ void LCodeGen::DoClassOfTestAndBranch(LClassOfTestAndBranch* instr) {
|
| Register temp2 = ToRegister(instr->temp2());
|
| Handle<String> class_name = instr->hydrogen()->class_name();
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| - Label* true_label = chunk_->GetAssemblyLabel(true_block);
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
| + EmitClassOfTest(instr->TrueLabel(chunk_), instr->FalseLabel(chunk_),
|
| + class_name, input, temp, temp2);
|
|
|
| - EmitClassOfTest(true_label, false_label, class_name, input, temp, temp2);
|
| -
|
| - EmitBranch(true_block, false_block, equal);
|
| + EmitBranch(instr, equal);
|
| }
|
|
|
|
|
| void LCodeGen::DoCmpMapAndBranch(LCmpMapAndBranch* instr) {
|
| Register reg = ToRegister(instr->value());
|
| - int true_block = instr->true_block_id();
|
| - int false_block = instr->false_block_id();
|
|
|
| __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), instr->map());
|
| - EmitBranch(true_block, false_block, equal);
|
| + EmitBranch(instr, equal);
|
| }
|
|
|
|
|
| @@ -2693,9 +2656,9 @@ void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) {
|
| __ movq(target, value);
|
|
|
| if (instr->hydrogen()->NeedsWriteBarrier()) {
|
| - HType type = instr->hydrogen()->value()->type();
|
| SmiCheck check_needed =
|
| - type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
|
| + instr->hydrogen()->value()->IsHeapObject()
|
| + ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
|
| int offset = Context::SlotOffset(instr->slot_index());
|
| Register scratch = ToRegister(instr->temp());
|
| __ RecordWriteContextSlot(context,
|
| @@ -3899,11 +3862,9 @@ void LCodeGen::DoCallNew(LCallNew* instr) {
|
| ASSERT(ToRegister(instr->result()).is(rax));
|
|
|
| __ Set(rax, instr->arity());
|
| - if (FLAG_optimize_constructed_arrays) {
|
| - // No cell in ebx for construct type feedback in optimized code
|
| - Handle<Object> undefined_value(isolate()->factory()->undefined_value());
|
| - __ Move(rbx, undefined_value);
|
| - }
|
| + // No cell in ebx for construct type feedback in optimized code
|
| + Handle<Object> undefined_value(isolate()->factory()->undefined_value());
|
| + __ Move(rbx, undefined_value);
|
| CallConstructStub stub(NO_CALL_FUNCTION_FLAGS);
|
| CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
|
| }
|
| @@ -3912,7 +3873,6 @@ void LCodeGen::DoCallNew(LCallNew* instr) {
|
| void LCodeGen::DoCallNewArray(LCallNewArray* instr) {
|
| ASSERT(ToRegister(instr->constructor()).is(rdi));
|
| ASSERT(ToRegister(instr->result()).is(rax));
|
| - ASSERT(FLAG_optimize_constructed_arrays);
|
|
|
| __ Set(rax, instr->arity());
|
| __ Move(rbx, instr->hydrogen()->property_cell());
|
| @@ -4021,9 +3981,9 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
|
| }
|
|
|
| // Do the store.
|
| - HType type = instr->hydrogen()->value()->type();
|
| SmiCheck check_needed =
|
| - type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
|
| + instr->hydrogen()->value()->IsHeapObject()
|
| + ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
|
|
|
| Register write_register = object;
|
| if (!access.IsInobject()) {
|
| @@ -4262,9 +4222,9 @@ void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) {
|
| ASSERT(instr->value()->IsRegister());
|
| Register value = ToRegister(instr->value());
|
| ASSERT(!instr->key()->IsConstantOperand());
|
| - HType type = instr->hydrogen()->value()->type();
|
| SmiCheck check_needed =
|
| - type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
|
| + instr->hydrogen()->value()->IsHeapObject()
|
| + ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
|
| // Compute address of modified element and store it into key register.
|
| Register key_reg(ToRegister(key));
|
| __ lea(key_reg, operand);
|
| @@ -4930,9 +4890,11 @@ void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
|
|
|
|
|
| void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
|
| - LOperand* input = instr->value();
|
| - Condition cc = masm()->CheckSmi(ToRegister(input));
|
| - DeoptimizeIf(cc, instr->environment());
|
| + if (!instr->hydrogen()->value()->IsHeapObject()) {
|
| + LOperand* input = instr->value();
|
| + Condition cc = masm()->CheckSmi(ToRegister(input));
|
| + DeoptimizeIf(cc, instr->environment());
|
| + }
|
| }
|
|
|
|
|
| @@ -5084,6 +5046,94 @@ void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) {
|
| }
|
|
|
|
|
| +void LCodeGen::DoAllocateObject(LAllocateObject* instr) {
|
| + class DeferredAllocateObject: public LDeferredCode {
|
| + public:
|
| + DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr)
|
| + : LDeferredCode(codegen), instr_(instr) { }
|
| + virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); }
|
| + virtual LInstruction* instr() { return instr_; }
|
| + private:
|
| + LAllocateObject* instr_;
|
| + };
|
| +
|
| + DeferredAllocateObject* deferred =
|
| + new(zone()) DeferredAllocateObject(this, instr);
|
| +
|
| + Register result = ToRegister(instr->result());
|
| + Register scratch = ToRegister(instr->temp());
|
| + Handle<JSFunction> constructor = instr->hydrogen()->constructor();
|
| + Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map();
|
| + int instance_size = initial_map->instance_size();
|
| + ASSERT(initial_map->pre_allocated_property_fields() +
|
| + initial_map->unused_property_fields() -
|
| + initial_map->inobject_properties() == 0);
|
| +
|
| + __ Allocate(instance_size, result, no_reg, scratch, deferred->entry(),
|
| + TAG_OBJECT);
|
| +
|
| + __ bind(deferred->exit());
|
| + if (FLAG_debug_code) {
|
| + Label is_in_new_space;
|
| + __ JumpIfInNewSpace(result, scratch, &is_in_new_space);
|
| + __ Abort("Allocated object is not in new-space");
|
| + __ bind(&is_in_new_space);
|
| + }
|
| +
|
| + // Load the initial map.
|
| + Register map = scratch;
|
| + __ LoadHeapObject(scratch, constructor);
|
| + __ movq(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset));
|
| +
|
| + if (FLAG_debug_code) {
|
| + __ AssertNotSmi(map);
|
| + __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset),
|
| + Immediate(instance_size >> kPointerSizeLog2));
|
| + __ Assert(equal, "Unexpected instance size");
|
| + __ cmpb(FieldOperand(map, Map::kPreAllocatedPropertyFieldsOffset),
|
| + Immediate(initial_map->pre_allocated_property_fields()));
|
| + __ Assert(equal, "Unexpected pre-allocated property fields count");
|
| + __ cmpb(FieldOperand(map, Map::kUnusedPropertyFieldsOffset),
|
| + Immediate(initial_map->unused_property_fields()));
|
| + __ Assert(equal, "Unexpected unused property fields count");
|
| + __ cmpb(FieldOperand(map, Map::kInObjectPropertiesOffset),
|
| + Immediate(initial_map->inobject_properties()));
|
| + __ Assert(equal, "Unexpected in-object property fields count");
|
| + }
|
| +
|
| + // Initialize map and fields of the newly allocated object.
|
| + ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
|
| + __ movq(FieldOperand(result, JSObject::kMapOffset), map);
|
| + __ LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex);
|
| + __ movq(FieldOperand(result, JSObject::kElementsOffset), scratch);
|
| + __ movq(FieldOperand(result, JSObject::kPropertiesOffset), scratch);
|
| + if (initial_map->inobject_properties() != 0) {
|
| + __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
|
| + for (int i = 0; i < initial_map->inobject_properties(); i++) {
|
| + int property_offset = JSObject::kHeaderSize + i * kPointerSize;
|
| + __ movq(FieldOperand(result, property_offset), scratch);
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| +void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) {
|
| + Register result = ToRegister(instr->result());
|
| + Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map();
|
| + int instance_size = initial_map->instance_size();
|
| +
|
| + // TODO(3095996): Get rid of this. For now, we need to make the
|
| + // result register contain a valid pointer because it is already
|
| + // contained in the register pointer map.
|
| + __ Set(result, 0);
|
| +
|
| + PushSafepointRegistersScope scope(this);
|
| + __ Push(Smi::FromInt(instance_size));
|
| + CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr);
|
| + __ StoreToSafepointRegisterSlot(result, rax);
|
| +}
|
| +
|
| +
|
| void LCodeGen::DoAllocate(LAllocate* instr) {
|
| class DeferredAllocate: public LDeferredCode {
|
| public:
|
| @@ -5259,15 +5309,12 @@ void LCodeGen::EmitPushTaggedOperand(LOperand* operand) {
|
|
|
| void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) {
|
| Register input = ToRegister(instr->value());
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| - Label* true_label = chunk_->GetAssemblyLabel(true_block);
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
|
|
| Condition final_branch_condition =
|
| - EmitTypeofIs(true_label, false_label, input, instr->type_literal());
|
| + EmitTypeofIs(instr->TrueLabel(chunk_),
|
| + instr->FalseLabel(chunk_), input, instr->type_literal());
|
| if (final_branch_condition != no_condition) {
|
| - EmitBranch(true_block, false_block, final_branch_condition);
|
| + EmitBranch(instr, final_branch_condition);
|
| }
|
| }
|
|
|
| @@ -5350,11 +5397,9 @@ Condition LCodeGen::EmitTypeofIs(Label* true_label,
|
|
|
| void LCodeGen::DoIsConstructCallAndBranch(LIsConstructCallAndBranch* instr) {
|
| Register temp = ToRegister(instr->temp());
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
|
|
| EmitIsConstructCall(temp);
|
| - EmitBranch(true_block, false_block, equal);
|
| + EmitBranch(instr, equal);
|
| }
|
|
|
|
|
| @@ -5506,15 +5551,15 @@ void LCodeGen::DoOsrEntry(LOsrEntry* instr) {
|
| // properly registered for deoptimization and records the assembler's PC
|
| // offset.
|
| LEnvironment* environment = instr->environment();
|
| - environment->SetSpilledRegisters(instr->SpilledRegisterArray(),
|
| - instr->SpilledDoubleRegisterArray());
|
|
|
| // If the environment were already registered, we would have no way of
|
| // backpatching it with the spill slot operands.
|
| ASSERT(!environment->HasBeenRegistered());
|
| RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
|
| - ASSERT(osr_pc_offset_ == -1);
|
| - osr_pc_offset_ = masm()->pc_offset();
|
| +
|
| + // Normally we record the first unknown OSR value as the entrypoint to the OSR
|
| + // code, but if there were none, record the entrypoint here.
|
| + if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset();
|
| }
|
|
|
|
|
|
|