| Index: src/x64/lithium-codegen-x64.cc
|
| diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
|
| index dff6224be47568b17e774dbbb966e5c84baf4323..64366e2db46e7a3afeb96df0b2fc94930a4fe834 100644
|
| --- a/src/x64/lithium-codegen-x64.cc
|
| +++ b/src/x64/lithium-codegen-x64.cc
|
| @@ -87,7 +87,7 @@ void LCodeGen::FinishCode(Handle<Code> code) {
|
| ASSERT(is_done());
|
| code->set_stack_slots(GetStackSlotCount());
|
| code->set_safepoint_table_offset(safepoints_.GetCodeOffset());
|
| - RegisterDependentCodeForEmbeddedMaps(code);
|
| + if (code->is_optimized_code()) RegisterWeakObjectsInOptimizedCode(code);
|
| PopulateDeoptimizationData(code);
|
| info()->CommitDependencies(code);
|
| }
|
| @@ -218,17 +218,18 @@ bool LCodeGen::GeneratePrologue() {
|
| if (heap_slots > 0) {
|
| Comment(";;; Allocate local context");
|
| // Argument to NewContext is the function, which is still in rdi.
|
| - __ push(rdi);
|
| if (heap_slots <= FastNewContextStub::kMaximumSlots) {
|
| FastNewContextStub stub(heap_slots);
|
| __ CallStub(&stub);
|
| } else {
|
| + __ push(rdi);
|
| __ CallRuntime(Runtime::kNewFunctionContext, 1);
|
| }
|
| RecordSafepoint(Safepoint::kNoLazyDeopt);
|
| - // Context is returned in both rax and rsi. It replaces the context
|
| - // passed to us. It's saved in the stack and kept live in rsi.
|
| - __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rsi);
|
| + // Context is returned in rax. It replaces the context passed to us.
|
| + // It's saved in the stack and kept live in rsi.
|
| + __ movp(rsi, rax);
|
| + __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax);
|
|
|
| // Copy any necessary parameters into the context.
|
| int num_parameters = scope()->num_parameters();
|
| @@ -327,7 +328,8 @@ bool LCodeGen::GenerateDeferredCode() {
|
|
|
| HValue* value =
|
| instructions_->at(code->instruction_index())->hydrogen_value();
|
| - RecordAndWritePosition(value->position());
|
| + RecordAndWritePosition(
|
| + chunk()->graph()->SourcePositionToScriptPosition(value->position()));
|
|
|
| Comment(";;; <@%d,#%d> "
|
| "-------------------- Deferred %s --------------------",
|
| @@ -790,6 +792,14 @@ void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) {
|
| translations_.CreateByteArray(isolate()->factory());
|
| data->SetTranslationByteArray(*translations);
|
| data->SetInlinedFunctionCount(Smi::FromInt(inlined_function_count_));
|
| + data->SetOptimizationId(Smi::FromInt(info_->optimization_id()));
|
| + if (info_->IsOptimizing()) {
|
| + // Reference to shared function info does not change between phases.
|
| + AllowDeferredHandleDereference allow_handle_dereference;
|
| + data->SetSharedFunctionInfo(*info_->shared_info());
|
| + } else {
|
| + data->SetSharedFunctionInfo(Smi::FromInt(0));
|
| + }
|
|
|
| Handle<FixedArray> literals =
|
| factory()->NewFixedArray(deoptimization_literals_.length(), TENURED);
|
| @@ -951,11 +961,6 @@ void LCodeGen::DoCallStub(LCallStub* instr) {
|
| ASSERT(ToRegister(instr->context()).is(rsi));
|
| ASSERT(ToRegister(instr->result()).is(rax));
|
| switch (instr->hydrogen()->major_key()) {
|
| - case CodeStub::RegExpConstructResult: {
|
| - RegExpConstructResultStub stub;
|
| - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
|
| - break;
|
| - }
|
| case CodeStub::RegExpExec: {
|
| RegExpExecStub stub;
|
| CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
|
| @@ -986,7 +991,7 @@ void LCodeGen::DoModI(LModI* instr) {
|
| HMod* hmod = instr->hydrogen();
|
| HValue* left = hmod->left();
|
| HValue* right = hmod->right();
|
| - if (hmod->HasPowerOf2Divisor()) {
|
| + if (hmod->RightIsPowerOf2()) {
|
| // TODO(svenpanne) We should really do the strength reduction on the
|
| // Hydrogen level.
|
| Register left_reg = ToRegister(instr->left());
|
| @@ -1152,57 +1157,40 @@ void LCodeGen::DoMathFloorOfDiv(LMathFloorOfDiv* instr) {
|
|
|
|
|
| void LCodeGen::DoDivI(LDivI* instr) {
|
| - if (!instr->is_flooring() && instr->hydrogen()->HasPowerOf2Divisor()) {
|
| + if (!instr->is_flooring() && instr->hydrogen()->RightIsPowerOf2()) {
|
| Register dividend = ToRegister(instr->left());
|
| - int32_t divisor =
|
| - HConstant::cast(instr->hydrogen()->right())->Integer32Value();
|
| - int32_t test_value = 0;
|
| - int32_t power = 0;
|
| -
|
| - if (divisor > 0) {
|
| - test_value = divisor - 1;
|
| - power = WhichPowerOf2(divisor);
|
| - } else {
|
| - // Check for (0 / -x) that will produce negative zero.
|
| - if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
|
| - __ testl(dividend, dividend);
|
| - DeoptimizeIf(zero, instr->environment());
|
| - }
|
| - // Check for (kMinInt / -1).
|
| - if (divisor == -1 && instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
|
| - __ cmpl(dividend, Immediate(kMinInt));
|
| - DeoptimizeIf(zero, instr->environment());
|
| - }
|
| - test_value = - divisor - 1;
|
| - power = WhichPowerOf2(-divisor);
|
| - }
|
| -
|
| - if (test_value != 0) {
|
| - if (instr->hydrogen()->CheckFlag(
|
| - HInstruction::kAllUsesTruncatingToInt32)) {
|
| - Label done, negative;
|
| - __ cmpl(dividend, Immediate(0));
|
| - __ j(less, &negative, Label::kNear);
|
| - __ sarl(dividend, Immediate(power));
|
| - if (divisor < 0) __ negl(dividend);
|
| - __ jmp(&done, Label::kNear);
|
| + HDiv* hdiv = instr->hydrogen();
|
| + int32_t divisor = hdiv->right()->GetInteger32Constant();
|
| + Register result = ToRegister(instr->result());
|
| + ASSERT(!result.is(dividend));
|
|
|
| - __ bind(&negative);
|
| - __ negl(dividend);
|
| - __ sarl(dividend, Immediate(power));
|
| - if (divisor > 0) __ negl(dividend);
|
| - __ bind(&done);
|
| - return; // Don't fall through to "__ neg" below.
|
| - } else {
|
| - // Deoptimize if remainder is not 0.
|
| - __ testl(dividend, Immediate(test_value));
|
| - DeoptimizeIf(not_zero, instr->environment());
|
| - __ sarl(dividend, Immediate(power));
|
| - }
|
| + // Check for (0 / -x) that will produce negative zero.
|
| + if (hdiv->left()->RangeCanInclude(0) && divisor < 0 &&
|
| + hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) {
|
| + __ testl(dividend, dividend);
|
| + DeoptimizeIf(zero, instr->environment());
|
| }
|
| -
|
| - if (divisor < 0) __ negl(dividend);
|
| -
|
| + // Check for (kMinInt / -1).
|
| + if (hdiv->left()->RangeCanInclude(kMinInt) && divisor == -1 &&
|
| + hdiv->CheckFlag(HValue::kCanOverflow)) {
|
| + __ cmpl(dividend, Immediate(kMinInt));
|
| + DeoptimizeIf(zero, instr->environment());
|
| + }
|
| + // Deoptimize if remainder will not be 0.
|
| + if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
|
| + __ testl(dividend, Immediate(Abs(divisor) - 1));
|
| + DeoptimizeIf(not_zero, instr->environment());
|
| + }
|
| + __ Move(result, dividend);
|
| + int32_t shift = WhichPowerOf2(Abs(divisor));
|
| + if (shift > 0) {
|
| + // The arithmetic shift is always OK, the 'if' is an optimization only.
|
| + if (shift > 1) __ sarl(result, Immediate(31));
|
| + __ shrl(result, Immediate(32 - shift));
|
| + __ addl(result, dividend);
|
| + __ sarl(result, Immediate(shift));
|
| + }
|
| + if (divisor < 0) __ negl(result);
|
| return;
|
| }
|
|
|
| @@ -1578,40 +1566,6 @@ void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) {
|
| }
|
|
|
|
|
| -void LCodeGen::DoElementsKind(LElementsKind* instr) {
|
| - Register result = ToRegister(instr->result());
|
| - Register input = ToRegister(instr->value());
|
| -
|
| - // Load map into |result|.
|
| - __ movp(result, FieldOperand(input, HeapObject::kMapOffset));
|
| - // Load the map's "bit field 2" into |result|. We only need the first byte.
|
| - __ movzxbq(result, FieldOperand(result, Map::kBitField2Offset));
|
| - // Retrieve elements_kind from bit field 2.
|
| - __ and_(result, Immediate(Map::kElementsKindMask));
|
| - __ shr(result, Immediate(Map::kElementsKindShift));
|
| -}
|
| -
|
| -
|
| -void LCodeGen::DoValueOf(LValueOf* instr) {
|
| - Register input = ToRegister(instr->value());
|
| - Register result = ToRegister(instr->result());
|
| - ASSERT(input.is(result));
|
| - Label done;
|
| -
|
| - 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);
|
| - __ j(not_equal, &done, Label::kNear);
|
| - __ movp(result, FieldOperand(input, JSValue::kValueOffset));
|
| -
|
| - __ bind(&done);
|
| -}
|
| -
|
| -
|
| void LCodeGen::DoDateField(LDateField* instr) {
|
| Register object = ToRegister(instr->date());
|
| Register result = ToRegister(instr->result());
|
| @@ -1642,7 +1596,7 @@ void LCodeGen::DoDateField(LDateField* instr) {
|
| __ bind(&runtime);
|
| __ PrepareCallCFunction(2);
|
| __ movp(arg_reg_1, object);
|
| - __ Move(arg_reg_2, index, RelocInfo::NONE64);
|
| + __ Move(arg_reg_2, index, Assembler::RelocInfoNone());
|
| __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
|
| __ bind(&done);
|
| }
|
| @@ -1732,18 +1686,6 @@ void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) {
|
| }
|
|
|
|
|
| -void LCodeGen::DoThrow(LThrow* instr) {
|
| - __ push(ToRegister(instr->value()));
|
| - ASSERT(ToRegister(instr->context()).is(rsi));
|
| - CallRuntime(Runtime::kThrow, 1, instr);
|
| -
|
| - if (FLAG_debug_code) {
|
| - Comment("Unreachable code.");
|
| - __ int3();
|
| - }
|
| -}
|
| -
|
| -
|
| void LCodeGen::DoAddI(LAddI* instr) {
|
| LOperand* left = instr->left();
|
| LOperand* right = instr->right();
|
| @@ -2814,8 +2756,7 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) {
|
| }
|
|
|
| Register object = ToRegister(instr->object());
|
| - if (FLAG_track_double_fields &&
|
| - instr->hydrogen()->representation().IsDouble()) {
|
| + if (instr->hydrogen()->representation().IsDouble()) {
|
| XMMRegister result = ToDoubleRegister(instr->result());
|
| __ movsd(result, FieldOperand(object, offset));
|
| return;
|
| @@ -2830,6 +2771,12 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) {
|
| Representation representation = access.representation();
|
| if (representation.IsSmi() &&
|
| instr->hydrogen()->representation().IsInteger32()) {
|
| +#ifdef DEBUG
|
| + Register scratch = kScratchRegister;
|
| + __ Load(scratch, FieldOperand(object, offset), representation);
|
| + __ AssertSmi(scratch);
|
| +#endif
|
| +
|
| // Read int value directly from upper half of the smi.
|
| STATIC_ASSERT(kSmiTag == 0);
|
| STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 32);
|
| @@ -2898,15 +2845,6 @@ void LCodeGen::DoLoadRoot(LLoadRoot* instr) {
|
| }
|
|
|
|
|
| -void LCodeGen::DoLoadExternalArrayPointer(
|
| - LLoadExternalArrayPointer* instr) {
|
| - Register result = ToRegister(instr->result());
|
| - Register input = ToRegister(instr->object());
|
| - __ movp(result, FieldOperand(input,
|
| - ExternalPixelArray::kExternalPointerOffset));
|
| -}
|
| -
|
| -
|
| void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
|
| Register arguments = ToRegister(instr->arguments());
|
| Register result = ToRegister(instr->result());
|
| @@ -2960,40 +2898,40 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
|
| base_offset,
|
| instr->additional_index()));
|
|
|
| - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
|
| + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS ||
|
| elements_kind == FLOAT32_ELEMENTS) {
|
| XMMRegister result(ToDoubleRegister(instr->result()));
|
| __ movss(result, operand);
|
| __ cvtss2sd(result, result);
|
| - } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS ||
|
| + } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS ||
|
| elements_kind == FLOAT64_ELEMENTS) {
|
| __ movsd(ToDoubleRegister(instr->result()), operand);
|
| } else {
|
| Register result(ToRegister(instr->result()));
|
| switch (elements_kind) {
|
| - case EXTERNAL_BYTE_ELEMENTS:
|
| + case EXTERNAL_INT8_ELEMENTS:
|
| case INT8_ELEMENTS:
|
| __ movsxbq(result, operand);
|
| break;
|
| - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
|
| - case EXTERNAL_PIXEL_ELEMENTS:
|
| + case EXTERNAL_UINT8_ELEMENTS:
|
| + case EXTERNAL_UINT8_CLAMPED_ELEMENTS:
|
| case UINT8_ELEMENTS:
|
| case UINT8_CLAMPED_ELEMENTS:
|
| __ movzxbq(result, operand);
|
| break;
|
| - case EXTERNAL_SHORT_ELEMENTS:
|
| + case EXTERNAL_INT16_ELEMENTS:
|
| case INT16_ELEMENTS:
|
| __ movsxwq(result, operand);
|
| break;
|
| - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
|
| + case EXTERNAL_UINT16_ELEMENTS:
|
| case UINT16_ELEMENTS:
|
| __ movzxwq(result, operand);
|
| break;
|
| - case EXTERNAL_INT_ELEMENTS:
|
| + case EXTERNAL_INT32_ELEMENTS:
|
| case INT32_ELEMENTS:
|
| __ movsxlq(result, operand);
|
| break;
|
| - case EXTERNAL_UNSIGNED_INT_ELEMENTS:
|
| + case EXTERNAL_UINT32_ELEMENTS:
|
| case UINT32_ELEMENTS:
|
| __ movl(result, operand);
|
| if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) {
|
| @@ -3001,8 +2939,8 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
|
| DeoptimizeIf(negative, instr->environment());
|
| }
|
| break;
|
| - case EXTERNAL_FLOAT_ELEMENTS:
|
| - case EXTERNAL_DOUBLE_ELEMENTS:
|
| + case EXTERNAL_FLOAT32_ELEMENTS:
|
| + case EXTERNAL_FLOAT64_ELEMENTS:
|
| case FLOAT32_ELEMENTS:
|
| case FLOAT64_ELEMENTS:
|
| case FAST_ELEMENTS:
|
| @@ -3084,6 +3022,17 @@ void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) {
|
| if (representation.IsInteger32() &&
|
| hinstr->elements_kind() == FAST_SMI_ELEMENTS) {
|
| ASSERT(!requires_hole_check);
|
| +#ifdef DEBUG
|
| + Register scratch = kScratchRegister;
|
| + __ Load(scratch,
|
| + BuildFastArrayOperand(instr->elements(),
|
| + key,
|
| + FAST_ELEMENTS,
|
| + offset,
|
| + instr->additional_index()),
|
| + Representation::Smi());
|
| + __ AssertSmi(scratch);
|
| +#endif
|
| // Read int value directly from upper half of the smi.
|
| STATIC_ASSERT(kSmiTag == 0);
|
| STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 32);
|
| @@ -3221,20 +3170,22 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) {
|
| Label global_object, receiver_ok;
|
| Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear;
|
|
|
| - // Do not transform the receiver to object for strict mode
|
| - // functions.
|
| - __ movp(kScratchRegister,
|
| - FieldOperand(function, JSFunction::kSharedFunctionInfoOffset));
|
| - __ testb(FieldOperand(kScratchRegister,
|
| - SharedFunctionInfo::kStrictModeByteOffset),
|
| - Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte));
|
| - __ j(not_equal, &receiver_ok, dist);
|
| -
|
| - // Do not transform the receiver to object for builtins.
|
| - __ testb(FieldOperand(kScratchRegister,
|
| - SharedFunctionInfo::kNativeByteOffset),
|
| - Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte));
|
| - __ j(not_equal, &receiver_ok, dist);
|
| + if (!instr->hydrogen()->known_function()) {
|
| + // Do not transform the receiver to object for strict mode
|
| + // functions.
|
| + __ movp(kScratchRegister,
|
| + FieldOperand(function, JSFunction::kSharedFunctionInfoOffset));
|
| + __ testb(FieldOperand(kScratchRegister,
|
| + SharedFunctionInfo::kStrictModeByteOffset),
|
| + Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte));
|
| + __ j(not_equal, &receiver_ok, dist);
|
| +
|
| + // Do not transform the receiver to object for builtins.
|
| + __ testb(FieldOperand(kScratchRegister,
|
| + SharedFunctionInfo::kNativeByteOffset),
|
| + Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte));
|
| + __ j(not_equal, &receiver_ok, dist);
|
| + }
|
|
|
| // Normal function. Replace undefined or null with global receiver.
|
| __ CompareRoot(receiver, Heap::kNullValueRootIndex);
|
| @@ -3247,14 +3198,16 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) {
|
| DeoptimizeIf(is_smi, instr->environment());
|
| __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, kScratchRegister);
|
| DeoptimizeIf(below, instr->environment());
|
| - __ jmp(&receiver_ok, Label::kNear);
|
|
|
| + __ jmp(&receiver_ok, Label::kNear);
|
| __ bind(&global_object);
|
| __ movp(receiver, FieldOperand(function, JSFunction::kContextOffset));
|
| __ movp(receiver,
|
| - Operand(receiver, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
|
| + Operand(receiver,
|
| + Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
|
| __ movp(receiver,
|
| FieldOperand(receiver, GlobalObject::kGlobalReceiverOffset));
|
| +
|
| __ bind(&receiver_ok);
|
| }
|
|
|
| @@ -3329,14 +3282,6 @@ void LCodeGen::DoContext(LContext* instr) {
|
| }
|
|
|
|
|
| -void LCodeGen::DoOuterContext(LOuterContext* instr) {
|
| - Register context = ToRegister(instr->context());
|
| - Register result = ToRegister(instr->result());
|
| - __ movp(result,
|
| - Operand(context, Context::SlotOffset(Context::PREVIOUS_INDEX)));
|
| -}
|
| -
|
| -
|
| void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) {
|
| ASSERT(ToRegister(instr->context()).is(rsi));
|
| __ push(rsi); // The context is the first argument.
|
| @@ -3346,21 +3291,6 @@ void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) {
|
| }
|
|
|
|
|
| -void LCodeGen::DoGlobalObject(LGlobalObject* instr) {
|
| - Register context = ToRegister(instr->context());
|
| - Register result = ToRegister(instr->result());
|
| - __ movp(result,
|
| - Operand(context, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
|
| -}
|
| -
|
| -
|
| -void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) {
|
| - Register global = ToRegister(instr->global());
|
| - Register result = ToRegister(instr->result());
|
| - __ movp(result, FieldOperand(global, GlobalObject::kGlobalReceiverOffset));
|
| -}
|
| -
|
| -
|
| void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
|
| int formal_parameter_count,
|
| int arity,
|
| @@ -3391,7 +3321,7 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
|
| if (function.is_identical_to(info()->closure())) {
|
| __ CallSelf();
|
| } else {
|
| - __ call(FieldOperand(rdi, JSFunction::kCodeEntryOffset));
|
| + __ Call(FieldOperand(rdi, JSFunction::kCodeEntryOffset));
|
| }
|
|
|
| // Set up deoptimization.
|
| @@ -3456,7 +3386,7 @@ void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
|
| } else {
|
| Operand target = FieldOperand(rdi, JSFunction::kCodeEntryOffset);
|
| generator.BeforeCall(__ CallSize(target));
|
| - __ call(target);
|
| + __ Call(target);
|
| }
|
| generator.AfterCall();
|
| }
|
| @@ -3496,10 +3426,10 @@ void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) {
|
| __ LoadFromSafepointRegisterSlot(input_reg, input_reg);
|
|
|
| __ bind(&allocated);
|
| - __ MoveDouble(tmp2, FieldOperand(input_reg, HeapNumber::kValueOffset));
|
| + __ movq(tmp2, FieldOperand(input_reg, HeapNumber::kValueOffset));
|
| __ shl(tmp2, Immediate(1));
|
| __ shr(tmp2, Immediate(1));
|
| - __ MoveDouble(FieldOperand(tmp, HeapNumber::kValueOffset), tmp2);
|
| + __ movq(FieldOperand(tmp, HeapNumber::kValueOffset), tmp2);
|
| __ StoreToSafepointRegisterSlot(input_reg, tmp);
|
|
|
| __ bind(&done);
|
| @@ -3806,6 +3736,20 @@ void LCodeGen::DoMathLog(LMathLog* instr) {
|
| }
|
|
|
|
|
| +void LCodeGen::DoMathClz32(LMathClz32* instr) {
|
| + Register input = ToRegister(instr->value());
|
| + Register result = ToRegister(instr->result());
|
| + Label not_zero_input;
|
| + __ bsrl(result, input);
|
| +
|
| + __ j(not_zero, ¬_zero_input);
|
| + __ Set(result, 63); // 63^31 == 32
|
| +
|
| + __ bind(¬_zero_input);
|
| + __ xorl(result, Immediate(31)); // for x in [0..31], 31^x == 31-x.
|
| +}
|
| +
|
| +
|
| void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) {
|
| ASSERT(ToRegister(instr->context()).is(rsi));
|
| ASSERT(ToRegister(instr->function()).is(rdi));
|
| @@ -3833,13 +3777,8 @@ void LCodeGen::DoCallFunction(LCallFunction* instr) {
|
| ASSERT(ToRegister(instr->result()).is(rax));
|
|
|
| int arity = instr->arity();
|
| - CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS);
|
| - if (instr->hydrogen()->IsTailCall()) {
|
| - if (NeedsEagerFrame()) __ leave();
|
| - __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET);
|
| - } else {
|
| - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
|
| - }
|
| + CallFunctionStub stub(arity, instr->hydrogen()->function_flags());
|
| + CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
|
| }
|
|
|
|
|
| @@ -3863,7 +3802,7 @@ void LCodeGen::DoCallNewArray(LCallNewArray* instr) {
|
| ASSERT(ToRegister(instr->result()).is(rax));
|
|
|
| __ Set(rax, instr->arity());
|
| - __ Move(rbx, instr->hydrogen()->property_cell());
|
| + __ Move(rbx, factory()->undefined_value());
|
| ElementsKind kind = instr->hydrogen()->elements_kind();
|
| AllocationSiteOverrideMode override_mode =
|
| (AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE)
|
| @@ -3939,7 +3878,6 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
|
| Register value = ToRegister(instr->value());
|
| if (instr->object()->IsConstantOperand()) {
|
| ASSERT(value.is(rax));
|
| - ASSERT(!access.representation().IsSpecialization());
|
| LConstantOperand* object = LConstantOperand::cast(instr->object());
|
| __ store_rax(ToExternalReference(object));
|
| } else {
|
| @@ -3951,6 +3889,8 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
|
|
|
| Register object = ToRegister(instr->object());
|
| Handle<Map> transition = instr->transition();
|
| + SmiCheck check_needed = hinstr->value()->IsHeapObject()
|
| + ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
|
|
|
| if (FLAG_track_fields && representation.IsSmi()) {
|
| if (instr->value()->IsConstantOperand()) {
|
| @@ -3971,9 +3911,12 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
|
| Register value = ToRegister(instr->value());
|
| Condition cc = masm()->CheckSmi(value);
|
| DeoptimizeIf(cc, instr->environment());
|
| +
|
| + // We know that value is a smi now, so we can omit the check below.
|
| + check_needed = OMIT_SMI_CHECK;
|
| }
|
| }
|
| - } else if (FLAG_track_double_fields && representation.IsDouble()) {
|
| + } else if (representation.IsDouble()) {
|
| ASSERT(transition.is_null());
|
| ASSERT(access.IsInobject());
|
| ASSERT(!hinstr->NeedsWriteBarrier());
|
| @@ -4001,9 +3944,6 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
|
| }
|
|
|
| // Do the store.
|
| - SmiCheck check_needed = hinstr->value()->IsHeapObject()
|
| - ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
|
| -
|
| Register write_register = object;
|
| if (!access.IsInobject()) {
|
| write_register = ToRegister(instr->temp());
|
| @@ -4013,6 +3953,11 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
|
| if (representation.IsSmi() &&
|
| hinstr->value()->representation().IsInteger32()) {
|
| ASSERT(hinstr->store_mode() == STORE_TO_INITIALIZED_ENTRY);
|
| +#ifdef DEBUG
|
| + Register scratch = kScratchRegister;
|
| + __ Load(scratch, FieldOperand(write_register, offset), representation);
|
| + __ AssertSmi(scratch);
|
| +#endif
|
| // Store int value directly to upper half of the smi.
|
| STATIC_ASSERT(kSmiTag == 0);
|
| STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 32);
|
| @@ -4152,39 +4097,39 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
|
| base_offset,
|
| instr->additional_index()));
|
|
|
| - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
|
| + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS ||
|
| elements_kind == FLOAT32_ELEMENTS) {
|
| XMMRegister value(ToDoubleRegister(instr->value()));
|
| __ cvtsd2ss(value, value);
|
| __ movss(operand, value);
|
| - } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS ||
|
| + } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS ||
|
| elements_kind == FLOAT64_ELEMENTS) {
|
| __ movsd(operand, ToDoubleRegister(instr->value()));
|
| } else {
|
| Register value(ToRegister(instr->value()));
|
| switch (elements_kind) {
|
| - case EXTERNAL_PIXEL_ELEMENTS:
|
| - case EXTERNAL_BYTE_ELEMENTS:
|
| - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
|
| + case EXTERNAL_UINT8_CLAMPED_ELEMENTS:
|
| + case EXTERNAL_INT8_ELEMENTS:
|
| + case EXTERNAL_UINT8_ELEMENTS:
|
| case INT8_ELEMENTS:
|
| case UINT8_ELEMENTS:
|
| case UINT8_CLAMPED_ELEMENTS:
|
| __ movb(operand, value);
|
| break;
|
| - case EXTERNAL_SHORT_ELEMENTS:
|
| - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
|
| + case EXTERNAL_INT16_ELEMENTS:
|
| + case EXTERNAL_UINT16_ELEMENTS:
|
| case INT16_ELEMENTS:
|
| case UINT16_ELEMENTS:
|
| __ movw(operand, value);
|
| break;
|
| - case EXTERNAL_INT_ELEMENTS:
|
| - case EXTERNAL_UNSIGNED_INT_ELEMENTS:
|
| + case EXTERNAL_INT32_ELEMENTS:
|
| + case EXTERNAL_UINT32_ELEMENTS:
|
| case INT32_ELEMENTS:
|
| case UINT32_ELEMENTS:
|
| __ movl(operand, value);
|
| break;
|
| - case EXTERNAL_FLOAT_ELEMENTS:
|
| - case EXTERNAL_DOUBLE_ELEMENTS:
|
| + case EXTERNAL_FLOAT32_ELEMENTS:
|
| + case EXTERNAL_FLOAT64_ELEMENTS:
|
| case FLOAT32_ELEMENTS:
|
| case FLOAT64_ELEMENTS:
|
| case FAST_ELEMENTS:
|
| @@ -4266,6 +4211,17 @@ void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) {
|
| if (representation.IsInteger32()) {
|
| ASSERT(hinstr->store_mode() == STORE_TO_INITIALIZED_ENTRY);
|
| ASSERT(hinstr->elements_kind() == FAST_SMI_ELEMENTS);
|
| +#ifdef DEBUG
|
| + Register scratch = kScratchRegister;
|
| + __ Load(scratch,
|
| + BuildFastArrayOperand(instr->elements(),
|
| + key,
|
| + FAST_ELEMENTS,
|
| + offset,
|
| + instr->additional_index()),
|
| + Representation::Smi());
|
| + __ AssertSmi(scratch);
|
| +#endif
|
| // Store int value directly to upper half of the smi.
|
| STATIC_ASSERT(kSmiTag == 0);
|
| STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 32);
|
| @@ -4388,18 +4344,11 @@ void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) {
|
|
|
| void LCodeGen::DoStringAdd(LStringAdd* instr) {
|
| ASSERT(ToRegister(instr->context()).is(rsi));
|
| - if (FLAG_new_string_add) {
|
| - ASSERT(ToRegister(instr->left()).is(rdx));
|
| - ASSERT(ToRegister(instr->right()).is(rax));
|
| - NewStringAddStub stub(instr->hydrogen()->flags(),
|
| - isolate()->heap()->GetPretenureMode());
|
| - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
|
| - } else {
|
| - EmitPushTaggedOperand(instr->left());
|
| - EmitPushTaggedOperand(instr->right());
|
| - StringAddStub stub(instr->hydrogen()->flags());
|
| - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
|
| - }
|
| + ASSERT(ToRegister(instr->left()).is(rdx));
|
| + ASSERT(ToRegister(instr->right()).is(rax));
|
| + StringAddStub stub(instr->hydrogen()->flags(),
|
| + instr->hydrogen()->pretenure_flag());
|
| + CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
|
| }
|
|
|
|
|
| @@ -5142,7 +5091,11 @@ void LCodeGen::DoAllocate(LAllocate* instr) {
|
|
|
| if (instr->size()->IsConstantOperand()) {
|
| int32_t size = ToInteger32(LConstantOperand::cast(instr->size()));
|
| - __ Allocate(size, result, temp, no_reg, deferred->entry(), flags);
|
| + if (size <= Page::kMaxRegularHeapObjectSize) {
|
| + __ Allocate(size, result, temp, no_reg, deferred->entry(), flags);
|
| + } else {
|
| + __ jmp(deferred->entry());
|
| + }
|
| } else {
|
| Register size = ToRegister(instr->size());
|
| __ Allocate(size, result, temp, no_reg, deferred->entry(), flags);
|
|
|