| Index: src/ia32/full-codegen-ia32.cc
|
| diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
|
| index e43e5259e89cb5fae5f2669089781e8524c0af1d..eac3f5a5069bc88dacbc8600a6286a67886198bf 100644
|
| --- a/src/ia32/full-codegen-ia32.cc
|
| +++ b/src/ia32/full-codegen-ia32.cc
|
| @@ -133,22 +133,26 @@ void FullCodeGenerator::Generate() {
|
| }
|
| #endif
|
|
|
| - // Strict mode functions and builtins need to replace the receiver
|
| - // with undefined when called as functions (without an explicit
|
| - // receiver object). ecx is zero for method calls and non-zero for
|
| - // function calls.
|
| - if (!info->is_classic_mode() || info->is_native()) {
|
| + // Classic mode functions and builtins need to replace the receiver with the
|
| + // global proxy when called as functions (without an explicit receiver
|
| + // object).
|
| + if (info->is_classic_mode() && !info->is_native()) {
|
| Label ok;
|
| __ test(ecx, ecx);
|
| __ j(zero, &ok, Label::kNear);
|
| +
|
| // +1 for return address.
|
| int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize;
|
| __ mov(ecx, Operand(esp, receiver_offset));
|
| - __ JumpIfSmi(ecx, &ok);
|
| - __ CmpObjectType(ecx, JS_GLOBAL_PROXY_TYPE, ecx);
|
| +
|
| + __ cmp(ecx, isolate()->factory()->undefined_value());
|
| __ j(not_equal, &ok, Label::kNear);
|
| - __ mov(Operand(esp, receiver_offset),
|
| - Immediate(isolate()->factory()->undefined_value()));
|
| +
|
| + __ mov(ecx, GlobalObjectOperand());
|
| + __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset));
|
| +
|
| + __ mov(Operand(esp, receiver_offset), ecx);
|
| +
|
| __ bind(&ok);
|
| }
|
|
|
| @@ -624,7 +628,7 @@ void FullCodeGenerator::DoTest(Expression* condition,
|
| Label* if_false,
|
| Label* fall_through) {
|
| Handle<Code> ic = ToBooleanStub::GetUninitialized(isolate());
|
| - CallIC(ic, RelocInfo::CODE_TARGET, condition->test_id());
|
| + CallIC(ic, NOT_CONTEXTUAL, condition->test_id());
|
| __ test(result_register(), result_register());
|
| // The stub returns nonzero for true.
|
| Split(not_zero, if_true, if_false, fall_through);
|
| @@ -975,7 +979,7 @@ void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
|
| // Record position before stub call for type feedback.
|
| SetSourcePosition(clause->position());
|
| Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT);
|
| - CallIC(ic, RelocInfo::CODE_TARGET, clause->CompareId());
|
| + CallIC(ic, NOT_CONTEXTUAL, clause->CompareId());
|
| patch_site.EmitPatchInfo();
|
|
|
| Label skip;
|
| @@ -1331,11 +1335,11 @@ void FullCodeGenerator::EmitLoadGlobalCheckExtensions(Variable* var,
|
| // load IC call.
|
| __ mov(edx, GlobalObjectOperand());
|
| __ mov(ecx, var->name());
|
| - Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
|
| - RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF)
|
| - ? RelocInfo::CODE_TARGET
|
| - : RelocInfo::CODE_TARGET_CONTEXT;
|
| - CallIC(ic, mode);
|
| + ContextualMode mode = (typeof_state == INSIDE_TYPEOF)
|
| + ? NOT_CONTEXTUAL
|
| + : CONTEXTUAL;
|
| +
|
| + CallLoadIC(mode);
|
| }
|
|
|
|
|
| @@ -1415,8 +1419,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) {
|
| // object in eax.
|
| __ mov(edx, GlobalObjectOperand());
|
| __ mov(ecx, var->name());
|
| - Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
|
| - CallIC(ic, RelocInfo::CODE_TARGET_CONTEXT);
|
| + CallLoadIC(CONTEXTUAL);
|
| context()->Plug(eax);
|
| break;
|
| }
|
| @@ -1632,10 +1635,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
|
| VisitForAccumulatorValue(value);
|
| __ mov(ecx, Immediate(key->value()));
|
| __ mov(edx, Operand(esp, 0));
|
| - Handle<Code> ic = is_classic_mode()
|
| - ? isolate()->builtins()->StoreIC_Initialize()
|
| - : isolate()->builtins()->StoreIC_Initialize_Strict();
|
| - CallIC(ic, RelocInfo::CODE_TARGET, key->LiteralFeedbackId());
|
| + CallStoreIC(NOT_CONTEXTUAL, key->LiteralFeedbackId());
|
| PrepareForBailoutForId(key->id(), NO_REGISTERS);
|
| } else {
|
| VisitForEffect(value);
|
| @@ -1716,8 +1716,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
|
| Handle<FixedArrayBase> constant_elements_values(
|
| FixedArrayBase::cast(constant_elements->get(1)));
|
|
|
| - AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites
|
| - ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE;
|
| + AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE;
|
| if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) {
|
| // If the only customer of allocation sites is transitioning, then
|
| // we can turn it off if we don't have anywhere else to transition to.
|
| @@ -2058,19 +2057,17 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
|
| __ push(eax); // save result
|
| __ mov(edx, eax); // result
|
| __ mov(ecx, isolate()->factory()->done_string()); // "done"
|
| - Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize();
|
| - CallIC(done_ic); // result.done in eax
|
| + CallLoadIC(NOT_CONTEXTUAL); // result.done in eax
|
| Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate());
|
| CallIC(bool_ic);
|
| __ test(eax, eax);
|
| __ j(zero, &l_try);
|
|
|
| // result.value
|
| - __ pop(edx); // result
|
| + __ pop(edx); // result
|
| __ mov(ecx, isolate()->factory()->value_string()); // "value"
|
| - Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize();
|
| - CallIC(value_ic); // result.value in eax
|
| - context()->DropAndPlug(2, eax); // drop iter and g
|
| + CallLoadIC(NOT_CONTEXTUAL); // result.value in eax
|
| + context()->DropAndPlug(2, eax); // drop iter and g
|
| break;
|
| }
|
| }
|
| @@ -2213,15 +2210,14 @@ void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
|
| Literal* key = prop->key()->AsLiteral();
|
| ASSERT(!key->value()->IsSmi());
|
| __ mov(ecx, Immediate(key->value()));
|
| - Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
|
| - CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId());
|
| + CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId());
|
| }
|
|
|
|
|
| void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
|
| SetSourcePosition(prop->position());
|
| Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
|
| - CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId());
|
| + CallIC(ic, NOT_CONTEXTUAL, prop->PropertyFeedbackId());
|
| }
|
|
|
|
|
| @@ -2242,7 +2238,7 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
|
| __ bind(&stub_call);
|
| __ mov(eax, ecx);
|
| BinaryOpICStub stub(op, mode);
|
| - CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET,
|
| + CallIC(stub.GetCode(isolate()), NOT_CONTEXTUAL,
|
| expr->BinaryOperationFeedbackId());
|
| patch_site.EmitPatchInfo();
|
| __ jmp(&done, Label::kNear);
|
| @@ -2328,7 +2324,7 @@ void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr,
|
| __ pop(edx);
|
| BinaryOpICStub stub(op, mode);
|
| JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
|
| - CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET,
|
| + CallIC(stub.GetCode(isolate()), NOT_CONTEXTUAL,
|
| expr->BinaryOperationFeedbackId());
|
| patch_site.EmitPatchInfo();
|
| context()->Plug(eax);
|
| @@ -2367,10 +2363,7 @@ void FullCodeGenerator::EmitAssignment(Expression* expr) {
|
| __ mov(edx, eax);
|
| __ pop(eax); // Restore value.
|
| __ mov(ecx, prop->key()->AsLiteral()->value());
|
| - Handle<Code> ic = is_classic_mode()
|
| - ? isolate()->builtins()->StoreIC_Initialize()
|
| - : isolate()->builtins()->StoreIC_Initialize_Strict();
|
| - CallIC(ic);
|
| + CallStoreIC(NOT_CONTEXTUAL);
|
| break;
|
| }
|
| case KEYED_PROPERTY: {
|
| @@ -2397,11 +2390,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var,
|
| // Global var, const, or let.
|
| __ mov(ecx, var->name());
|
| __ mov(edx, GlobalObjectOperand());
|
| - Handle<Code> ic = is_classic_mode()
|
| - ? isolate()->builtins()->StoreIC_Initialize()
|
| - : isolate()->builtins()->StoreIC_Initialize_Strict();
|
| - CallIC(ic, RelocInfo::CODE_TARGET_CONTEXT);
|
| -
|
| + CallStoreIC(CONTEXTUAL);
|
| } else if (op == Token::INIT_CONST) {
|
| // Const initializers need a write barrier.
|
| ASSERT(!var->IsParameter()); // No const parameters.
|
| @@ -2495,11 +2484,7 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
|
| SetSourcePosition(expr->position());
|
| __ mov(ecx, prop->key()->AsLiteral()->value());
|
| __ pop(edx);
|
| - Handle<Code> ic = is_classic_mode()
|
| - ? isolate()->builtins()->StoreIC_Initialize()
|
| - : isolate()->builtins()->StoreIC_Initialize_Strict();
|
| - CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId());
|
| -
|
| + CallStoreIC(NOT_CONTEXTUAL, expr->AssignmentFeedbackId());
|
| PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
|
| context()->Plug(eax);
|
| }
|
| @@ -2518,7 +2503,7 @@ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
|
| Handle<Code> ic = is_classic_mode()
|
| ? isolate()->builtins()->KeyedStoreIC_Initialize()
|
| : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
|
| - CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId());
|
| + CallIC(ic, NOT_CONTEXTUAL, expr->AssignmentFeedbackId());
|
|
|
| PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
|
| context()->Plug(eax);
|
| @@ -2547,10 +2532,11 @@ void FullCodeGenerator::VisitProperty(Property* expr) {
|
|
|
|
|
| void FullCodeGenerator::CallIC(Handle<Code> code,
|
| - RelocInfo::Mode rmode,
|
| + ContextualMode mode,
|
| TypeFeedbackId ast_id) {
|
| ic_total_count_++;
|
| - __ call(code, rmode, ast_id);
|
| + ASSERT(mode != CONTEXTUAL || ast_id.IsNone());
|
| + __ call(code, RelocInfo::CODE_TARGET, ast_id);
|
| }
|
|
|
|
|
| @@ -2558,7 +2544,7 @@ void FullCodeGenerator::CallIC(Handle<Code> code,
|
|
|
| void FullCodeGenerator::EmitCallWithIC(Call* expr,
|
| Handle<Object> name,
|
| - RelocInfo::Mode mode) {
|
| + ContextualMode mode) {
|
| // Code common for calls using the IC.
|
| ZoneList<Expression*>* args = expr->arguments();
|
| int arg_count = args->length();
|
| @@ -2572,7 +2558,10 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr,
|
| SetSourcePosition(expr->position());
|
| Handle<Code> ic =
|
| isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
|
| - CallIC(ic, mode, expr->CallFeedbackId());
|
| + TypeFeedbackId ast_id = mode == CONTEXTUAL
|
| + ? TypeFeedbackId::None()
|
| + : expr->CallFeedbackId();
|
| + CallIC(ic, mode, ast_id);
|
| RecordJSReturnSite(expr);
|
| // Restore context register.
|
| __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
|
| @@ -2604,7 +2593,7 @@ void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr,
|
| Handle<Code> ic =
|
| isolate()->stub_cache()->ComputeKeyedCallInitialize(arg_count);
|
| __ mov(ecx, Operand(esp, (arg_count + 1) * kPointerSize)); // Key.
|
| - CallIC(ic, RelocInfo::CODE_TARGET, expr->CallFeedbackId());
|
| + CallIC(ic, NOT_CONTEXTUAL, expr->CallFeedbackId());
|
| RecordJSReturnSite(expr);
|
| // Restore context register.
|
| __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
|
| @@ -2703,7 +2692,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| }
|
| // Record source position for debugger.
|
| SetSourcePosition(expr->position());
|
| - CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT);
|
| + CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS);
|
| __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize));
|
| __ CallStub(&stub);
|
| RecordJSReturnSite(expr);
|
| @@ -2714,8 +2703,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| } else if (proxy != NULL && proxy->var()->IsUnallocated()) {
|
| // Push global object as receiver for the call IC.
|
| __ push(GlobalObjectOperand());
|
| - EmitCallWithIC(expr, proxy->name(), RelocInfo::CODE_TARGET_CONTEXT);
|
| -
|
| + EmitCallWithIC(expr, proxy->name(), CONTEXTUAL);
|
| } else if (proxy != NULL && proxy->var()->IsLookupSlot()) {
|
| // Call to a lookup slot (dynamically introduced variable).
|
| Label slow, done;
|
| @@ -2743,14 +2731,13 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| __ push(eax);
|
| // The receiver is implicitly the global receiver. Indicate this by
|
| // passing the hole to the call function stub.
|
| - __ push(Immediate(isolate()->factory()->the_hole_value()));
|
| + __ push(Immediate(isolate()->factory()->undefined_value()));
|
| __ bind(&call);
|
| }
|
|
|
| // The receiver is either the global receiver or an object found by
|
| - // LoadContextSlot. That object could be the hole if the receiver is
|
| - // implicitly the global object.
|
| - EmitCallWithStub(expr, RECEIVER_MIGHT_BE_IMPLICIT);
|
| + // LoadContextSlot.
|
| + EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
|
|
|
| } else if (property != NULL) {
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| @@ -2759,7 +2746,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| if (property->key()->IsPropertyName()) {
|
| EmitCallWithIC(expr,
|
| property->key()->AsLiteral()->value(),
|
| - RelocInfo::CODE_TARGET);
|
| + NOT_CONTEXTUAL);
|
| } else {
|
| EmitKeyedCallWithIC(expr, property->key());
|
| }
|
| @@ -2769,9 +2756,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| VisitForStackValue(callee);
|
| }
|
| - // Load global receiver object.
|
| - __ mov(ebx, GlobalObjectOperand());
|
| - __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset));
|
| + __ push(Immediate(isolate()->factory()->undefined_value()));
|
| // Emit function call.
|
| EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
|
| }
|
| @@ -3709,7 +3694,7 @@ void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) {
|
| __ mov(edi, result_register());
|
| ParameterCount count(arg_count);
|
| __ InvokeFunction(edi, count, CALL_FUNCTION,
|
| - NullCallWrapper(), CALL_AS_METHOD);
|
| + NullCallWrapper(), CALL_AS_FUNCTION);
|
| __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
|
| __ jmp(&done);
|
|
|
| @@ -4150,7 +4135,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
|
| if (expr->is_jsruntime()) {
|
| // Call the JS runtime function via a call IC.
|
| __ Set(ecx, Immediate(expr->name()));
|
| - RelocInfo::Mode mode = RelocInfo::CODE_TARGET;
|
| + ContextualMode mode = NOT_CONTEXTUAL;
|
| Handle<Code> ic =
|
| isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
|
| CallIC(ic, mode, expr->CallRuntimeFeedbackId());
|
| @@ -4410,7 +4395,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
|
| __ mov(eax, Immediate(Smi::FromInt(1)));
|
| BinaryOpICStub stub(expr->binary_op(), NO_OVERWRITE);
|
| CallIC(stub.GetCode(isolate()),
|
| - RelocInfo::CODE_TARGET,
|
| + NOT_CONTEXTUAL,
|
| expr->CountBinOpFeedbackId());
|
| patch_site.EmitPatchInfo();
|
| __ bind(&done);
|
| @@ -4442,10 +4427,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
|
| case NAMED_PROPERTY: {
|
| __ mov(ecx, prop->key()->AsLiteral()->value());
|
| __ pop(edx);
|
| - Handle<Code> ic = is_classic_mode()
|
| - ? isolate()->builtins()->StoreIC_Initialize()
|
| - : isolate()->builtins()->StoreIC_Initialize_Strict();
|
| - CallIC(ic, RelocInfo::CODE_TARGET, expr->CountStoreFeedbackId());
|
| + CallStoreIC(NOT_CONTEXTUAL, expr->CountStoreFeedbackId());
|
| PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
|
| if (expr->is_postfix()) {
|
| if (!context()->IsEffect()) {
|
| @@ -4462,7 +4444,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
|
| Handle<Code> ic = is_classic_mode()
|
| ? isolate()->builtins()->KeyedStoreIC_Initialize()
|
| : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
|
| - CallIC(ic, RelocInfo::CODE_TARGET, expr->CountStoreFeedbackId());
|
| + CallIC(ic, NOT_CONTEXTUAL, expr->CountStoreFeedbackId());
|
| PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
|
| if (expr->is_postfix()) {
|
| // Result is on the stack
|
| @@ -4487,10 +4469,9 @@ void FullCodeGenerator::VisitForTypeofValue(Expression* expr) {
|
| Comment cmnt(masm_, "Global variable");
|
| __ mov(edx, GlobalObjectOperand());
|
| __ mov(ecx, Immediate(proxy->name()));
|
| - Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
|
| // Use a regular load, not a contextual load, to avoid a reference
|
| // error.
|
| - CallIC(ic);
|
| + CallLoadIC(NOT_CONTEXTUAL);
|
| PrepareForBailout(expr, TOS_REG);
|
| context()->Plug(eax);
|
| } else if (proxy != NULL && proxy->var()->IsLookupSlot()) {
|
| @@ -4652,7 +4633,7 @@ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
|
| // Record position and call the compare IC.
|
| SetSourcePosition(expr->position());
|
| Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op);
|
| - CallIC(ic, RelocInfo::CODE_TARGET, expr->CompareOperationFeedbackId());
|
| + CallIC(ic, NOT_CONTEXTUAL, expr->CompareOperationFeedbackId());
|
| patch_site.EmitPatchInfo();
|
|
|
| PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| @@ -4688,7 +4669,7 @@ void FullCodeGenerator::EmitLiteralCompareNil(CompareOperation* expr,
|
| Split(equal, if_true, if_false, fall_through);
|
| } else {
|
| Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil);
|
| - CallIC(ic, RelocInfo::CODE_TARGET, expr->CompareOperationFeedbackId());
|
| + CallIC(ic, NOT_CONTEXTUAL, expr->CompareOperationFeedbackId());
|
| __ test(eax, eax);
|
| Split(not_zero, if_true, if_false, fall_through);
|
| }
|
|
|