| Index: src/x64/lithium-codegen-x64.cc
|
| diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
|
| index 497dc768188634b31c96acf87d621843d4488001..beaa1f1df96853c515d0c47c7a88ad3380edaacd 100644
|
| --- a/src/x64/lithium-codegen-x64.cc
|
| +++ b/src/x64/lithium-codegen-x64.cc
|
| @@ -469,27 +469,15 @@ Operand LCodeGen::ToOperand(LOperand* op) const {
|
|
|
|
|
| void LCodeGen::WriteTranslation(LEnvironment* environment,
|
| - Translation* translation,
|
| - int* pushed_arguments_index,
|
| - int* pushed_arguments_count) {
|
| + Translation* translation) {
|
| if (environment == NULL) return;
|
|
|
| // The translation includes one command per value in the environment.
|
| - int translation_size = environment->values()->length();
|
| + int translation_size = environment->translation_size();
|
| // The output frame height does not include the parameters.
|
| int height = translation_size - environment->parameter_count();
|
|
|
| - // Function parameters are arguments to the outermost environment. The
|
| - // arguments index points to the first element of a sequence of tagged
|
| - // values on the stack that represent the arguments. This needs to be
|
| - // kept in sync with the LArgumentsElements implementation.
|
| - *pushed_arguments_index = -environment->parameter_count();
|
| - *pushed_arguments_count = environment->parameter_count();
|
| -
|
| - WriteTranslation(environment->outer(),
|
| - translation,
|
| - pushed_arguments_index,
|
| - pushed_arguments_count);
|
| + WriteTranslation(environment->outer(), translation);
|
| bool has_closure_id = !info()->closure().is_null() &&
|
| !info()->closure().is_identical_to(environment->closure());
|
| int closure_id = has_closure_id
|
| @@ -521,23 +509,6 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
|
| break;
|
| }
|
|
|
| - // Inlined frames which push their arguments cause the index to be
|
| - // bumped and another stack area to be used for materialization,
|
| - // otherwise actual argument values are unknown for inlined frames.
|
| - bool arguments_known = true;
|
| - int arguments_index = *pushed_arguments_index;
|
| - int arguments_count = *pushed_arguments_count;
|
| - if (environment->entry() != NULL) {
|
| - arguments_known = environment->entry()->arguments_pushed();
|
| - arguments_index = arguments_index < 0
|
| - ? GetStackSlotCount() : arguments_index + arguments_count;
|
| - arguments_count = environment->entry()->arguments_count() + 1;
|
| - if (environment->entry()->arguments_pushed()) {
|
| - *pushed_arguments_index = arguments_index;
|
| - *pushed_arguments_count = arguments_count;
|
| - }
|
| - }
|
| -
|
| for (int i = 0; i < translation_size; ++i) {
|
| LOperand* value = environment->values()->at(i);
|
| // spilled_registers_ and spilled_double_registers_ are either
|
| @@ -549,10 +520,7 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
|
| AddToTranslation(translation,
|
| environment->spilled_registers()[value->index()],
|
| environment->HasTaggedValueAt(i),
|
| - environment->HasUint32ValueAt(i),
|
| - arguments_known,
|
| - arguments_index,
|
| - arguments_count);
|
| + environment->HasUint32ValueAt(i));
|
| } else if (
|
| value->IsDoubleRegister() &&
|
| environment->spilled_double_registers()[value->index()] != NULL) {
|
| @@ -561,20 +529,36 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
|
| translation,
|
| environment->spilled_double_registers()[value->index()],
|
| false,
|
| - false,
|
| - arguments_known,
|
| - arguments_index,
|
| - arguments_count);
|
| + false);
|
| + }
|
| + }
|
| +
|
| + // TODO(mstarzinger): Introduce marker operands to indicate that this value
|
| + // is not present and must be reconstructed from the deoptimizer. Currently
|
| + // this is only used for the arguments object.
|
| + if (value == NULL) {
|
| + int arguments_count = environment->values()->length() - translation_size;
|
| + 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),
|
| + environment->HasUint32ValueAt(translation_size + i));
|
| }
|
| + continue;
|
| }
|
|
|
| AddToTranslation(translation,
|
| value,
|
| environment->HasTaggedValueAt(i),
|
| - environment->HasUint32ValueAt(i),
|
| - arguments_known,
|
| - arguments_index,
|
| - arguments_count);
|
| + environment->HasUint32ValueAt(i));
|
| }
|
| }
|
|
|
| @@ -582,17 +566,8 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
|
| void LCodeGen::AddToTranslation(Translation* translation,
|
| LOperand* op,
|
| bool is_tagged,
|
| - bool is_uint32,
|
| - bool arguments_known,
|
| - int arguments_index,
|
| - int arguments_count) {
|
| - if (op == NULL) {
|
| - // TODO(twuerthinger): Introduce marker operands to indicate that this value
|
| - // is not present and must be reconstructed from the deoptimizer. Currently
|
| - // this is only used for the arguments object.
|
| - translation->StoreArgumentsObject(
|
| - arguments_known, arguments_index, arguments_count);
|
| - } else if (op->IsStackSlot()) {
|
| + bool is_uint32) {
|
| + if (op->IsStackSlot()) {
|
| if (is_tagged) {
|
| translation->StoreStackSlot(op->index());
|
| } else if (is_uint32) {
|
| @@ -697,8 +672,6 @@ void LCodeGen::RegisterEnvironmentForDeoptimization(LEnvironment* environment,
|
|
|
| int frame_count = 0;
|
| int jsframe_count = 0;
|
| - int args_index = 0;
|
| - int args_count = 0;
|
| for (LEnvironment* e = environment; e != NULL; e = e->outer()) {
|
| ++frame_count;
|
| if (e->frame_type() == JS_FUNCTION) {
|
| @@ -706,7 +679,7 @@ void LCodeGen::RegisterEnvironmentForDeoptimization(LEnvironment* environment,
|
| }
|
| }
|
| Translation translation(&translations_, frame_count, jsframe_count, zone());
|
| - WriteTranslation(environment, &translation, &args_index, &args_count);
|
| + WriteTranslation(environment, &translation);
|
| int deoptimization_index = deoptimizations_.length();
|
| int pc_offset = masm()->pc_offset();
|
| environment->Register(deoptimization_index,
|
| @@ -733,7 +706,7 @@ void LCodeGen::DeoptimizeIf(Condition cc,
|
|
|
| ASSERT(FLAG_deopt_every_n_times == 0); // Not yet implemented on x64.
|
|
|
| - if (FLAG_trap_on_deopt) {
|
| + if (FLAG_trap_on_deopt && info()->IsOptimizing()) {
|
| Label done;
|
| if (cc != no_condition) {
|
| __ j(NegateCondition(cc), &done, Label::kNear);
|
| @@ -1744,10 +1717,11 @@ void LCodeGen::DoAddI(LAddI* instr) {
|
| if (LAddI::UseLea(instr->hydrogen()) && !left->Equals(instr->result())) {
|
| if (right->IsConstantOperand()) {
|
| int32_t offset = ToInteger32(LConstantOperand::cast(right));
|
| - __ lea(ToRegister(instr->result()), MemOperand(ToRegister(left), offset));
|
| + __ leal(ToRegister(instr->result()),
|
| + MemOperand(ToRegister(left), offset));
|
| } else {
|
| Operand address(ToRegister(left), ToRegister(right), times_1, 0);
|
| - __ lea(ToRegister(instr->result()), address);
|
| + __ leal(ToRegister(instr->result()), address);
|
| }
|
| } else {
|
| if (right->IsConstantOperand()) {
|
| @@ -2477,9 +2451,8 @@ void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) {
|
| Register map = ToRegister(instr->temp());
|
| __ movq(map, FieldOperand(object, HeapObject::kMapOffset));
|
| __ bind(deferred->map_check()); // Label for calculating code patching.
|
| - Handle<JSGlobalPropertyCell> cache_cell =
|
| - factory()->NewJSGlobalPropertyCell(factory()->the_hole_value());
|
| - __ movq(kScratchRegister, cache_cell, RelocInfo::GLOBAL_PROPERTY_CELL);
|
| + Handle<Cell> cache_cell = factory()->NewCell(factory()->the_hole_value());
|
| + __ movq(kScratchRegister, cache_cell, RelocInfo::CELL);
|
| __ cmpq(map, Operand(kScratchRegister, 0));
|
| __ j(not_equal, &cache_miss, Label::kNear);
|
| // Patched to load either true or false.
|
| @@ -2648,7 +2621,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
|
|
|
| void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) {
|
| Register value = ToRegister(instr->value());
|
| - Handle<JSGlobalPropertyCell> cell_handle = instr->hydrogen()->cell();
|
| + Handle<Cell> cell_handle = instr->hydrogen()->cell();
|
|
|
| // If the cell we are storing to contains the hole it could have
|
| // been deleted from the property dictionary. In that case, we need
|
| @@ -2658,14 +2631,14 @@ void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) {
|
| // We have a temp because CompareRoot might clobber kScratchRegister.
|
| Register cell = ToRegister(instr->temp());
|
| ASSERT(!value.is(cell));
|
| - __ movq(cell, cell_handle, RelocInfo::GLOBAL_PROPERTY_CELL);
|
| + __ movq(cell, cell_handle, RelocInfo::CELL);
|
| __ CompareRoot(Operand(cell, 0), Heap::kTheHoleValueRootIndex);
|
| DeoptimizeIf(equal, instr->environment());
|
| // Store the value.
|
| __ movq(Operand(cell, 0), value);
|
| } else {
|
| // Store the value.
|
| - __ movq(kScratchRegister, cell_handle, RelocInfo::GLOBAL_PROPERTY_CELL);
|
| + __ movq(kScratchRegister, cell_handle, RelocInfo::CELL);
|
| __ movq(Operand(kScratchRegister, 0), value);
|
| }
|
| // Cells are always rescanned, so no write barrier here.
|
| @@ -3951,8 +3924,26 @@ void LCodeGen::DoCallNewArray(LCallNewArray* instr) {
|
| ArrayNoArgumentConstructorStub stub(kind, disable_allocation_sites);
|
| CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
|
| } else if (instr->arity() == 1) {
|
| + Label done;
|
| + if (IsFastPackedElementsKind(kind)) {
|
| + Label packed_case;
|
| + // We might need a change here
|
| + // look at the first argument
|
| + __ movq(rcx, Operand(rsp, 0));
|
| + __ testq(rcx, rcx);
|
| + __ j(zero, &packed_case);
|
| +
|
| + ElementsKind holey_kind = GetHoleyElementsKind(kind);
|
| + ArraySingleArgumentConstructorStub stub(holey_kind,
|
| + disable_allocation_sites);
|
| + CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
|
| + __ jmp(&done);
|
| + __ bind(&packed_case);
|
| + }
|
| +
|
| ArraySingleArgumentConstructorStub stub(kind, disable_allocation_sites);
|
| CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
|
| + __ bind(&done);
|
| } else {
|
| ArrayNArgumentsConstructorStub stub(kind, disable_allocation_sites);
|
| CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
|
|
|