| Index: src/arm/full-codegen-arm.cc
|
| diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
|
| index 224e0c79961c975beb4a0ce071387e06a0c972b6..2eb5ccf974be3810a51f89c244bd661ff3e83ada 100644
|
| --- a/src/arm/full-codegen-arm.cc
|
| +++ b/src/arm/full-codegen-arm.cc
|
| @@ -130,6 +130,9 @@ void FullCodeGenerator::Generate() {
|
| CompilationInfo* info = info_;
|
| handler_table_ =
|
| isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED);
|
| +
|
| + InitializeFeedbackVector();
|
| +
|
| profiling_counter_ = isolate()->factory()->NewCell(
|
| Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate()));
|
| SetFunctionPosition(function());
|
| @@ -202,20 +205,22 @@ void FullCodeGenerator::Generate() {
|
| if (heap_slots > 0) {
|
| // Argument to NewContext is the function, which is still in r1.
|
| Comment cmnt(masm_, "[ Allocate context");
|
| - __ push(r1);
|
| if (FLAG_harmony_scoping && info->scope()->is_global_scope()) {
|
| + __ push(r1);
|
| __ Push(info->scope()->GetScopeInfo());
|
| __ CallRuntime(Runtime::kNewGlobalContext, 2);
|
| } else if (heap_slots <= FastNewContextStub::kMaximumSlots) {
|
| FastNewContextStub stub(heap_slots);
|
| __ CallStub(&stub);
|
| } else {
|
| + __ push(r1);
|
| __ CallRuntime(Runtime::kNewFunctionContext, 1);
|
| }
|
| function_in_register = false;
|
| - // Context is returned in both r0 and cp. It replaces the context
|
| - // passed to us. It's saved in the stack and kept live in cp.
|
| - __ str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| + // Context is returned in r0. It replaces the context passed to us.
|
| + // It's saved in the stack and kept live in cp.
|
| + __ mov(cp, r0);
|
| + __ str(r0, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| // Copy any necessary parameters into the context.
|
| int num_parameters = info->scope()->num_parameters();
|
| for (int i = 0; i < num_parameters; i++) {
|
| @@ -666,7 +671,7 @@ void FullCodeGenerator::DoTest(Expression* condition,
|
| Label* if_false,
|
| Label* fall_through) {
|
| Handle<Code> ic = ToBooleanStub::GetUninitialized(isolate());
|
| - CallIC(ic, NOT_CONTEXTUAL, condition->test_id());
|
| + CallIC(ic, condition->test_id());
|
| __ tst(result_register(), result_register());
|
| Split(ne, if_true, if_false, fall_through);
|
| }
|
| @@ -1027,7 +1032,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, NOT_CONTEXTUAL, clause->CompareId());
|
| + CallIC(ic, clause->CompareId());
|
| patch_site.EmitPatchInfo();
|
|
|
| Label skip;
|
| @@ -1072,6 +1077,7 @@ void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
|
|
|
| void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
|
| Comment cmnt(masm_, "[ ForInStatement");
|
| + int slot = stmt->ForInFeedbackSlot();
|
| SetStatementPosition(stmt);
|
|
|
| Label loop, exit;
|
| @@ -1161,13 +1167,13 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
|
| Label non_proxy;
|
| __ bind(&fixed_array);
|
|
|
| - Handle<Cell> cell = isolate()->factory()->NewCell(
|
| - Handle<Object>(Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker),
|
| - isolate()));
|
| - RecordTypeFeedbackCell(stmt->ForInFeedbackId(), cell);
|
| - __ Move(r1, cell);
|
| - __ mov(r2, Operand(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker)));
|
| - __ str(r2, FieldMemOperand(r1, Cell::kValueOffset));
|
| + Handle<Object> feedback = Handle<Object>(
|
| + Smi::FromInt(TypeFeedbackInfo::kForInFastCaseMarker),
|
| + isolate());
|
| + StoreFeedbackVectorSlot(slot, feedback);
|
| + __ Move(r1, FeedbackVector());
|
| + __ mov(r2, Operand(Smi::FromInt(TypeFeedbackInfo::kForInSlowCaseMarker)));
|
| + __ str(r2, FieldMemOperand(r1, FixedArray::OffsetOfElementAt(slot)));
|
|
|
| __ mov(r1, Operand(Smi::FromInt(1))); // Smi indicates slow check
|
| __ ldr(r2, MemOperand(sp, 0 * kPointerSize)); // Get enumerated object
|
| @@ -1476,7 +1482,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) {
|
| // variables.
|
| switch (var->location()) {
|
| case Variable::UNALLOCATED: {
|
| - Comment cmnt(masm_, "Global variable");
|
| + Comment cmnt(masm_, "[ Global variable");
|
| // Use inline caching. Variable name is passed in r2 and the global
|
| // object (receiver) in r0.
|
| __ ldr(r0, GlobalObjectOperand());
|
| @@ -1489,9 +1495,8 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) {
|
| case Variable::PARAMETER:
|
| case Variable::LOCAL:
|
| case Variable::CONTEXT: {
|
| - Comment cmnt(masm_, var->IsContextSlot()
|
| - ? "Context variable"
|
| - : "Stack variable");
|
| + Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable"
|
| + : "[ Stack variable");
|
| if (var->binding_needs_init()) {
|
| // var->scope() may be NULL when the proxy is located in eval code and
|
| // refers to a potential outside binding. Currently those bindings are
|
| @@ -1554,12 +1559,12 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) {
|
| }
|
|
|
| case Variable::LOOKUP: {
|
| + Comment cmnt(masm_, "[ Lookup variable");
|
| Label done, slow;
|
| // Generate code for loading from variables potentially shadowed
|
| // by eval-introduced variables.
|
| EmitDynamicLookupFastCase(var, NOT_INSIDE_TYPEOF, &slow, &done);
|
| __ bind(&slow);
|
| - Comment cmnt(masm_, "Lookup variable");
|
| __ mov(r1, Operand(var->name()));
|
| __ Push(cp, r1); // Context and name.
|
| __ CallRuntime(Runtime::kLoadContextSlot, 2);
|
| @@ -1690,7 +1695,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
|
| VisitForAccumulatorValue(value);
|
| __ mov(r2, Operand(key->value()));
|
| __ ldr(r1, MemOperand(sp));
|
| - CallStoreIC(NOT_CONTEXTUAL, key->LiteralFeedbackId());
|
| + CallStoreIC(key->LiteralFeedbackId());
|
| PrepareForBailoutForId(key->id(), NO_REGISTERS);
|
| } else {
|
| VisitForEffect(value);
|
| @@ -2047,9 +2052,9 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
|
| // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; }
|
| __ bind(&l_catch);
|
| handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos()));
|
| - __ LoadRoot(r2, Heap::kthrow_stringRootIndex); // "throw"
|
| - __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter
|
| - __ Push(r3, r0); // iter, exception
|
| + __ LoadRoot(r2, Heap::kthrow_stringRootIndex); // "throw"
|
| + __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter
|
| + __ Push(r2, r3, r0); // "throw", iter, except
|
| __ jmp(&l_call);
|
|
|
| // try { received = %yield result }
|
| @@ -2076,22 +2081,30 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
|
| kLRHasBeenSaved, kDontSaveFPRegs);
|
| __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| - __ pop(r0); // result
|
| + __ pop(r0); // result
|
| EmitReturnSequence();
|
| - __ bind(&l_resume); // received in r0
|
| + __ bind(&l_resume); // received in r0
|
| __ PopTryHandler();
|
|
|
| // receiver = iter; f = 'next'; arg = received;
|
| __ bind(&l_next);
|
| - __ LoadRoot(r2, Heap::knext_stringRootIndex); // "next"
|
| - __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter
|
| - __ Push(r3, r0); // iter, received
|
| + __ LoadRoot(r2, Heap::knext_stringRootIndex); // "next"
|
| + __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter
|
| + __ Push(r2, r3, r0); // "next", iter, received
|
|
|
| // result = receiver[f](arg);
|
| __ bind(&l_call);
|
| - Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1);
|
| - CallIC(ic);
|
| + __ ldr(r1, MemOperand(sp, kPointerSize));
|
| + __ ldr(r0, MemOperand(sp, 2 * kPointerSize));
|
| + Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
|
| + CallIC(ic, TypeFeedbackId::None());
|
| + __ mov(r1, r0);
|
| + __ str(r1, MemOperand(sp, 2 * kPointerSize));
|
| + CallFunctionStub stub(1, CALL_AS_METHOD);
|
| + __ CallStub(&stub);
|
| +
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| + __ Drop(1); // The function is still on the stack; drop it.
|
|
|
| // if (!result.done) goto l_try;
|
| __ bind(&l_loop);
|
| @@ -2281,7 +2294,7 @@ void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
|
| SetSourcePosition(prop->position());
|
| // Call keyed load IC. It has arguments key and receiver in r0 and r1.
|
| Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
|
| - CallIC(ic, NOT_CONTEXTUAL, prop->PropertyFeedbackId());
|
| + CallIC(ic, prop->PropertyFeedbackId());
|
| }
|
|
|
|
|
| @@ -2308,8 +2321,7 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
|
|
|
| __ bind(&stub_call);
|
| BinaryOpICStub stub(op, mode);
|
| - CallIC(stub.GetCode(isolate()), NOT_CONTEXTUAL,
|
| - expr->BinaryOperationFeedbackId());
|
| + CallIC(stub.GetCode(isolate()), expr->BinaryOperationFeedbackId());
|
| patch_site.EmitPatchInfo();
|
| __ jmp(&done);
|
|
|
| @@ -2386,8 +2398,7 @@ void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr,
|
| __ pop(r1);
|
| BinaryOpICStub stub(op, mode);
|
| JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
|
| - CallIC(stub.GetCode(isolate()), NOT_CONTEXTUAL,
|
| - expr->BinaryOperationFeedbackId());
|
| + CallIC(stub.GetCode(isolate()), expr->BinaryOperationFeedbackId());
|
| patch_site.EmitPatchInfo();
|
| context()->Plug(r0);
|
| }
|
| @@ -2425,7 +2436,7 @@ void FullCodeGenerator::EmitAssignment(Expression* expr) {
|
| __ mov(r1, r0);
|
| __ pop(r0); // Restore value.
|
| __ mov(r2, Operand(prop->key()->AsLiteral()->value()));
|
| - CallStoreIC(NOT_CONTEXTUAL);
|
| + CallStoreIC();
|
| break;
|
| }
|
| case KEYED_PROPERTY: {
|
| @@ -2445,41 +2456,60 @@ void FullCodeGenerator::EmitAssignment(Expression* expr) {
|
| }
|
|
|
|
|
| +void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot(
|
| + Variable* var, MemOperand location) {
|
| + __ str(result_register(), location);
|
| + if (var->IsContextSlot()) {
|
| + // RecordWrite may destroy all its register arguments.
|
| + __ mov(r3, result_register());
|
| + int offset = Context::SlotOffset(var->index());
|
| + __ RecordWriteContextSlot(
|
| + r1, offset, r3, r2, kLRHasBeenSaved, kDontSaveFPRegs);
|
| + }
|
| +}
|
| +
|
| +
|
| +void FullCodeGenerator::EmitCallStoreContextSlot(
|
| + Handle<String> name, LanguageMode mode) {
|
| + __ push(r0); // Value.
|
| + __ mov(r1, Operand(name));
|
| + __ mov(r0, Operand(Smi::FromInt(mode)));
|
| + __ Push(cp, r1, r0); // Context, name, strict mode.
|
| + __ CallRuntime(Runtime::kStoreContextSlot, 4);
|
| +}
|
| +
|
| +
|
| void FullCodeGenerator::EmitVariableAssignment(Variable* var,
|
| Token::Value op) {
|
| if (var->IsUnallocated()) {
|
| // Global var, const, or let.
|
| __ mov(r2, Operand(var->name()));
|
| __ ldr(r1, GlobalObjectOperand());
|
| - CallStoreIC(CONTEXTUAL);
|
| + CallStoreIC();
|
| +
|
| } else if (op == Token::INIT_CONST) {
|
| // Const initializers need a write barrier.
|
| ASSERT(!var->IsParameter()); // No const parameters.
|
| - if (var->IsStackLocal()) {
|
| - __ ldr(r1, StackOperand(var));
|
| - __ CompareRoot(r1, Heap::kTheHoleValueRootIndex);
|
| - __ str(result_register(), StackOperand(var), eq);
|
| - } else {
|
| - ASSERT(var->IsContextSlot() || var->IsLookupSlot());
|
| - // Like var declarations, const declarations are hoisted to function
|
| - // scope. However, unlike var initializers, const initializers are
|
| - // able to drill a hole to that function context, even from inside a
|
| - // 'with' context. We thus bypass the normal static scope lookup for
|
| - // var->IsContextSlot().
|
| + if (var->IsLookupSlot()) {
|
| __ push(r0);
|
| __ mov(r0, Operand(var->name()));
|
| __ Push(cp, r0); // Context and name.
|
| __ CallRuntime(Runtime::kInitializeConstContextSlot, 3);
|
| + } else {
|
| + ASSERT(var->IsStackAllocated() || var->IsContextSlot());
|
| + Label skip;
|
| + MemOperand location = VarOperand(var, r1);
|
| + __ ldr(r2, location);
|
| + __ CompareRoot(r2, Heap::kTheHoleValueRootIndex);
|
| + __ b(ne, &skip);
|
| + EmitStoreToStackLocalOrContextSlot(var, location);
|
| + __ bind(&skip);
|
| }
|
|
|
| } else if (var->mode() == LET && op != Token::INIT_LET) {
|
| // Non-initializing assignment to let variable needs a write barrier.
|
| if (var->IsLookupSlot()) {
|
| - __ push(r0); // Value.
|
| - __ mov(r1, Operand(var->name()));
|
| - __ mov(r0, Operand(Smi::FromInt(language_mode())));
|
| - __ Push(cp, r1, r0); // Context, name, strict mode.
|
| - __ CallRuntime(Runtime::kStoreContextSlot, 4);
|
| + EmitCallStoreContextSlot(var->name(), language_mode());
|
| } else {
|
| ASSERT(var->IsStackAllocated() || var->IsContextSlot());
|
| Label assign;
|
| @@ -2492,20 +2522,16 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var,
|
| __ CallRuntime(Runtime::kThrowReferenceError, 1);
|
| // Perform the assignment.
|
| __ bind(&assign);
|
| - __ str(result_register(), location);
|
| - if (var->IsContextSlot()) {
|
| - // RecordWrite may destroy all its register arguments.
|
| - __ mov(r3, result_register());
|
| - int offset = Context::SlotOffset(var->index());
|
| - __ RecordWriteContextSlot(
|
| - r1, offset, r3, r2, kLRHasBeenSaved, kDontSaveFPRegs);
|
| - }
|
| + EmitStoreToStackLocalOrContextSlot(var, location);
|
| }
|
|
|
| } else if (!var->is_const_mode() || op == Token::INIT_CONST_HARMONY) {
|
| // Assignment to var or initializing assignment to let/const
|
| // in harmony mode.
|
| - if (var->IsStackAllocated() || var->IsContextSlot()) {
|
| + if (var->IsLookupSlot()) {
|
| + EmitCallStoreContextSlot(var->name(), language_mode());
|
| + } else {
|
| + ASSERT((var->IsStackAllocated() || var->IsContextSlot()));
|
| MemOperand location = VarOperand(var, r1);
|
| if (generate_debug_code_ && op == Token::INIT_LET) {
|
| // Check for an uninitialized let binding.
|
| @@ -2513,21 +2539,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var,
|
| __ CompareRoot(r2, Heap::kTheHoleValueRootIndex);
|
| __ Check(eq, kLetBindingReInitialization);
|
| }
|
| - // Perform the assignment.
|
| - __ str(r0, location);
|
| - if (var->IsContextSlot()) {
|
| - __ mov(r3, r0);
|
| - int offset = Context::SlotOffset(var->index());
|
| - __ RecordWriteContextSlot(
|
| - r1, offset, r3, r2, kLRHasBeenSaved, kDontSaveFPRegs);
|
| - }
|
| - } else {
|
| - ASSERT(var->IsLookupSlot());
|
| - __ push(r0); // Value.
|
| - __ mov(r1, Operand(var->name()));
|
| - __ mov(r0, Operand(Smi::FromInt(language_mode())));
|
| - __ Push(cp, r1, r0); // Context, name, strict mode.
|
| - __ CallRuntime(Runtime::kStoreContextSlot, 4);
|
| + EmitStoreToStackLocalOrContextSlot(var, location);
|
| }
|
| }
|
| // Non-initializing assignments to consts are ignored.
|
| @@ -2545,7 +2557,7 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
|
| __ mov(r2, Operand(prop->key()->AsLiteral()->value()));
|
| __ pop(r1);
|
|
|
| - CallStoreIC(NOT_CONTEXTUAL, expr->AssignmentFeedbackId());
|
| + CallStoreIC(expr->AssignmentFeedbackId());
|
|
|
| PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
|
| context()->Plug(r0);
|
| @@ -2562,7 +2574,7 @@ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
|
| Handle<Code> ic = is_classic_mode()
|
| ? isolate()->builtins()->KeyedStoreIC_Initialize()
|
| : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
|
| - CallIC(ic, NOT_CONTEXTUAL, expr->AssignmentFeedbackId());
|
| + CallIC(ic, expr->AssignmentFeedbackId());
|
|
|
| PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
|
| context()->Plug(r0);
|
| @@ -2589,73 +2601,105 @@ void FullCodeGenerator::VisitProperty(Property* expr) {
|
|
|
|
|
| void FullCodeGenerator::CallIC(Handle<Code> code,
|
| - ContextualMode mode,
|
| TypeFeedbackId ast_id) {
|
| ic_total_count_++;
|
| // All calls must have a predictable size in full-codegen code to ensure that
|
| // the debugger can patch them correctly.
|
| - ASSERT(mode != CONTEXTUAL || ast_id.IsNone());
|
| __ Call(code, RelocInfo::CODE_TARGET, ast_id, al,
|
| NEVER_INLINE_TARGET_ADDRESS);
|
| }
|
|
|
| -void FullCodeGenerator::EmitCallWithIC(Call* expr,
|
| - Handle<Object> name,
|
| - ContextualMode mode) {
|
| - // Code common for calls using the IC.
|
| +
|
| +// Code common for calls using the IC.
|
| +void FullCodeGenerator::EmitCallWithIC(Call* expr) {
|
| + Expression* callee = expr->expression();
|
| ZoneList<Expression*>* args = expr->arguments();
|
| int arg_count = args->length();
|
| +
|
| + CallFunctionFlags flags;
|
| + // Get the target function.
|
| + if (callee->IsVariableProxy()) {
|
| + { StackValueContext context(this);
|
| + EmitVariableLoad(callee->AsVariableProxy());
|
| + PrepareForBailout(callee, NO_REGISTERS);
|
| + }
|
| + // Push undefined as receiver. This is patched in the method prologue if it
|
| + // is a classic mode method.
|
| + __ Push(isolate()->factory()->undefined_value());
|
| + flags = NO_CALL_FUNCTION_FLAGS;
|
| + } else {
|
| + // Load the function from the receiver.
|
| + ASSERT(callee->IsProperty());
|
| + __ ldr(r0, MemOperand(sp, 0));
|
| + EmitNamedPropertyLoad(callee->AsProperty());
|
| + PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
|
| + // Push the target function under the receiver.
|
| + __ ldr(ip, MemOperand(sp, 0));
|
| + __ push(ip);
|
| + __ str(r0, MemOperand(sp, kPointerSize));
|
| + flags = CALL_AS_METHOD;
|
| + }
|
| +
|
| + // Load the arguments.
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| for (int i = 0; i < arg_count; i++) {
|
| VisitForStackValue(args->at(i));
|
| }
|
| - __ mov(r2, Operand(name));
|
| }
|
| +
|
| // Record source position for debugger.
|
| SetSourcePosition(expr->position());
|
| - // Call the IC initialization code.
|
| - Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
|
| - TypeFeedbackId ast_id = mode == CONTEXTUAL
|
| - ? TypeFeedbackId::None()
|
| - : expr->CallFeedbackId();
|
| - CallIC(ic, mode, ast_id);
|
| + CallFunctionStub stub(arg_count, flags);
|
| + __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
|
| + __ CallStub(&stub);
|
| +
|
| RecordJSReturnSite(expr);
|
| +
|
| // Restore context register.
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| - context()->Plug(r0);
|
| +
|
| + context()->DropAndPlug(1, r0);
|
| }
|
|
|
|
|
| +// Code common for calls using the IC.
|
| void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr,
|
| Expression* key) {
|
| // Load the key.
|
| VisitForAccumulatorValue(key);
|
|
|
| - // Swap the name of the function and the receiver on the stack to follow
|
| - // the calling convention for call ICs.
|
| - __ pop(r1);
|
| - __ push(r0);
|
| - __ push(r1);
|
| -
|
| - // Code common for calls using the IC.
|
| + Expression* callee = expr->expression();
|
| ZoneList<Expression*>* args = expr->arguments();
|
| int arg_count = args->length();
|
| +
|
| + // Load the function from the receiver.
|
| + ASSERT(callee->IsProperty());
|
| + __ ldr(r1, MemOperand(sp, 0));
|
| + EmitKeyedPropertyLoad(callee->AsProperty());
|
| + PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
|
| +
|
| + // Push the target function under the receiver.
|
| + __ ldr(ip, MemOperand(sp, 0));
|
| + __ push(ip);
|
| + __ str(r0, MemOperand(sp, kPointerSize));
|
| +
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| for (int i = 0; i < arg_count; i++) {
|
| VisitForStackValue(args->at(i));
|
| }
|
| }
|
| +
|
| // Record source position for debugger.
|
| SetSourcePosition(expr->position());
|
| - // Call the IC initialization code.
|
| - Handle<Code> ic =
|
| - isolate()->stub_cache()->ComputeKeyedCallInitialize(arg_count);
|
| - __ ldr(r2, MemOperand(sp, (arg_count + 1) * kPointerSize)); // Key.
|
| - CallIC(ic, NOT_CONTEXTUAL, expr->CallFeedbackId());
|
| + CallFunctionStub stub(arg_count, CALL_AS_METHOD);
|
| + __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
|
| + __ CallStub(&stub);
|
| +
|
| RecordJSReturnSite(expr);
|
| // Restore context register.
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| - context()->DropAndPlug(1, r0); // Drop the key still on the stack.
|
| +
|
| + context()->DropAndPlug(1, r0);
|
| }
|
|
|
|
|
| @@ -2672,15 +2716,15 @@ void FullCodeGenerator::EmitCallWithStub(Call* expr) {
|
| SetSourcePosition(expr->position());
|
|
|
| Handle<Object> uninitialized =
|
| - TypeFeedbackCells::UninitializedSentinel(isolate());
|
| - Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized);
|
| - RecordTypeFeedbackCell(expr->CallFeedbackId(), cell);
|
| - __ mov(r2, Operand(cell));
|
| + TypeFeedbackInfo::UninitializedSentinel(isolate());
|
| + StoreFeedbackVectorSlot(expr->CallFeedbackSlot(), uninitialized);
|
| + __ Move(r2, FeedbackVector());
|
| + __ mov(r3, Operand(Smi::FromInt(expr->CallFeedbackSlot())));
|
|
|
| // Record call targets in unoptimized code.
|
| CallFunctionStub stub(arg_count, RECORD_CALL_TARGET);
|
| __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
|
| - __ CallStub(&stub, expr->CallFeedbackId());
|
| + __ CallStub(&stub);
|
| RecordJSReturnSite(expr);
|
| // Restore context register.
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| @@ -2763,11 +2807,8 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| context()->DropAndPlug(1, r0);
|
| } else if (call_type == Call::GLOBAL_CALL) {
|
| - // Push global object as receiver for the call IC.
|
| - __ ldr(r0, GlobalObjectOperand());
|
| - __ push(r0);
|
| - VariableProxy* proxy = callee->AsVariableProxy();
|
| - EmitCallWithIC(expr, proxy->name(), CONTEXTUAL);
|
| + EmitCallWithIC(expr);
|
| +
|
| } else if (call_type == Call::LOOKUP_SLOT_CALL) {
|
| // Call to a lookup slot (dynamically introduced variable).
|
| VariableProxy* proxy = callee->AsVariableProxy();
|
| @@ -2813,9 +2854,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| VisitForStackValue(property->obj());
|
| }
|
| if (property->key()->IsPropertyName()) {
|
| - EmitCallWithIC(expr,
|
| - property->key()->AsLiteral()->value(),
|
| - NOT_CONTEXTUAL);
|
| + EmitCallWithIC(expr);
|
| } else {
|
| EmitKeyedCallWithIC(expr, property->key());
|
| }
|
| @@ -2866,10 +2905,10 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
|
|
|
| // Record call targets in unoptimized code.
|
| Handle<Object> uninitialized =
|
| - TypeFeedbackCells::UninitializedSentinel(isolate());
|
| - Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized);
|
| - RecordTypeFeedbackCell(expr->CallNewFeedbackId(), cell);
|
| - __ mov(r2, Operand(cell));
|
| + TypeFeedbackInfo::UninitializedSentinel(isolate());
|
| + StoreFeedbackVectorSlot(expr->CallNewFeedbackSlot(), uninitialized);
|
| + __ Move(r2, FeedbackVector());
|
| + __ mov(r3, Operand(Smi::FromInt(expr->CallNewFeedbackSlot())));
|
|
|
| CallConstructStub stub(RECORD_CALL_TARGET);
|
| __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL);
|
| @@ -3456,9 +3495,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
|
|
|
| if (FLAG_debug_code) {
|
| __ SmiTst(value);
|
| - __ ThrowIf(ne, kNonSmiValue);
|
| + __ Check(eq, kNonSmiValue);
|
| __ SmiTst(index);
|
| - __ ThrowIf(ne, kNonSmiIndex);
|
| + __ Check(eq, kNonSmiIndex);
|
| __ SmiUntag(index, index);
|
| static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
|
| __ EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type);
|
| @@ -3489,9 +3528,9 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
|
|
|
| if (FLAG_debug_code) {
|
| __ SmiTst(value);
|
| - __ ThrowIf(ne, kNonSmiValue);
|
| + __ Check(eq, kNonSmiValue);
|
| __ SmiTst(index);
|
| - __ ThrowIf(ne, kNonSmiIndex);
|
| + __ Check(eq, kNonSmiIndex);
|
| __ SmiUntag(index, index);
|
| static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
|
| __ EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type);
|
| @@ -3674,21 +3713,12 @@ void FullCodeGenerator::EmitStringCharAt(CallRuntime* expr) {
|
| void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) {
|
| ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT_EQ(2, args->length());
|
| + VisitForStackValue(args->at(0));
|
| + VisitForAccumulatorValue(args->at(1));
|
|
|
| - if (FLAG_new_string_add) {
|
| - VisitForStackValue(args->at(0));
|
| - VisitForAccumulatorValue(args->at(1));
|
| -
|
| - __ pop(r1);
|
| - NewStringAddStub stub(STRING_ADD_CHECK_BOTH, NOT_TENURED);
|
| - __ CallStub(&stub);
|
| - } else {
|
| - VisitForStackValue(args->at(0));
|
| - VisitForStackValue(args->at(1));
|
| -
|
| - StringAddStub stub(STRING_ADD_CHECK_BOTH);
|
| - __ CallStub(&stub);
|
| - }
|
| + __ pop(r1);
|
| + StringAddStub stub(STRING_ADD_CHECK_BOTH, NOT_TENURED);
|
| + __ CallStub(&stub);
|
| context()->Plug(r0);
|
| }
|
|
|
| @@ -3763,7 +3793,9 @@ void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) {
|
| ASSERT(args->length() == 3);
|
| VisitForStackValue(args->at(0));
|
| VisitForStackValue(args->at(1));
|
| - VisitForStackValue(args->at(2));
|
| + VisitForAccumulatorValue(args->at(2));
|
| + __ pop(r1);
|
| + __ pop(r2);
|
| __ CallStub(&stub);
|
| context()->Plug(r0);
|
| }
|
| @@ -3796,7 +3828,6 @@ void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
|
|
|
|
|
| Label done, not_found;
|
| - // tmp now holds finger offset as a smi.
|
| __ ldr(r2, FieldMemOperand(cache, JSFunctionResultCache::kFingerOffset));
|
| // r2 now holds finger offset as a smi.
|
| __ add(r3, cache, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
|
| @@ -3819,47 +3850,6 @@ void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitIsRegExpEquivalent(CallRuntime* expr) {
|
| - ZoneList<Expression*>* args = expr->arguments();
|
| - ASSERT_EQ(2, args->length());
|
| -
|
| - Register right = r0;
|
| - Register left = r1;
|
| - Register tmp = r2;
|
| - Register tmp2 = r3;
|
| -
|
| - VisitForStackValue(args->at(0));
|
| - VisitForAccumulatorValue(args->at(1));
|
| - __ pop(left);
|
| -
|
| - Label done, fail, ok;
|
| - __ cmp(left, Operand(right));
|
| - __ b(eq, &ok);
|
| - // Fail if either is a non-HeapObject.
|
| - __ and_(tmp, left, Operand(right));
|
| - __ JumpIfSmi(tmp, &fail);
|
| - __ ldr(tmp, FieldMemOperand(left, HeapObject::kMapOffset));
|
| - __ ldrb(tmp2, FieldMemOperand(tmp, Map::kInstanceTypeOffset));
|
| - __ cmp(tmp2, Operand(JS_REGEXP_TYPE));
|
| - __ b(ne, &fail);
|
| - __ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset));
|
| - __ cmp(tmp, Operand(tmp2));
|
| - __ b(ne, &fail);
|
| - __ ldr(tmp, FieldMemOperand(left, JSRegExp::kDataOffset));
|
| - __ ldr(tmp2, FieldMemOperand(right, JSRegExp::kDataOffset));
|
| - __ cmp(tmp, tmp2);
|
| - __ b(eq, &ok);
|
| - __ bind(&fail);
|
| - __ LoadRoot(r0, Heap::kFalseValueRootIndex);
|
| - __ jmp(&done);
|
| - __ bind(&ok);
|
| - __ LoadRoot(r0, Heap::kTrueValueRootIndex);
|
| - __ bind(&done);
|
| -
|
| - context()->Plug(r0);
|
| -}
|
| -
|
| -
|
| void FullCodeGenerator::EmitHasCachedArrayIndex(CallRuntime* expr) {
|
| ZoneList<Expression*>* args = expr->arguments();
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -4139,32 +4129,49 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
|
|
|
| Comment cmnt(masm_, "[ CallRuntime");
|
| ZoneList<Expression*>* args = expr->arguments();
|
| + int arg_count = args->length();
|
|
|
| if (expr->is_jsruntime()) {
|
| - // Prepare for calling JS runtime function.
|
| + // Push the builtins object as the receiver.
|
| __ ldr(r0, GlobalObjectOperand());
|
| __ ldr(r0, FieldMemOperand(r0, GlobalObject::kBuiltinsOffset));
|
| __ push(r0);
|
| - }
|
|
|
| - // Push the arguments ("left-to-right").
|
| - int arg_count = args->length();
|
| - for (int i = 0; i < arg_count; i++) {
|
| - VisitForStackValue(args->at(i));
|
| - }
|
| -
|
| - if (expr->is_jsruntime()) {
|
| - // Call the JS runtime function.
|
| + // Load the function from the receiver.
|
| __ mov(r2, Operand(expr->name()));
|
| - Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
|
| - CallIC(ic, NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
|
| + CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
|
| +
|
| + // Push the target function under the receiver.
|
| + __ ldr(ip, MemOperand(sp, 0));
|
| + __ push(ip);
|
| + __ str(r0, MemOperand(sp, kPointerSize));
|
| +
|
| + // Push the arguments ("left-to-right").
|
| + int arg_count = args->length();
|
| + for (int i = 0; i < arg_count; i++) {
|
| + VisitForStackValue(args->at(i));
|
| + }
|
| +
|
| + // Record source position of the IC call.
|
| + SetSourcePosition(expr->position());
|
| + CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS);
|
| + __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
|
| + __ CallStub(&stub);
|
| +
|
| // Restore context register.
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| +
|
| + context()->DropAndPlug(1, r0);
|
| } else {
|
| + // Push the arguments ("left-to-right").
|
| + for (int i = 0; i < arg_count; i++) {
|
| + VisitForStackValue(args->at(i));
|
| + }
|
| +
|
| // Call the C runtime function.
|
| __ CallRuntime(expr->function(), arg_count);
|
| + context()->Plug(r0);
|
| }
|
| - context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -4404,9 +4411,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
|
| SetSourcePosition(expr->position());
|
|
|
| BinaryOpICStub stub(Token::ADD, NO_OVERWRITE);
|
| - CallIC(stub.GetCode(isolate()),
|
| - NOT_CONTEXTUAL,
|
| - expr->CountBinOpFeedbackId());
|
| + CallIC(stub.GetCode(isolate()), expr->CountBinOpFeedbackId());
|
| patch_site.EmitPatchInfo();
|
| __ bind(&done);
|
|
|
| @@ -4435,7 +4440,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
|
| case NAMED_PROPERTY: {
|
| __ mov(r2, Operand(prop->key()->AsLiteral()->value()));
|
| __ pop(r1);
|
| - CallStoreIC(NOT_CONTEXTUAL, expr->CountStoreFeedbackId());
|
| + CallStoreIC(expr->CountStoreFeedbackId());
|
| PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
|
| if (expr->is_postfix()) {
|
| if (!context()->IsEffect()) {
|
| @@ -4451,7 +4456,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
|
| Handle<Code> ic = is_classic_mode()
|
| ? isolate()->builtins()->KeyedStoreIC_Initialize()
|
| : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
|
| - CallIC(ic, NOT_CONTEXTUAL, expr->CountStoreFeedbackId());
|
| + CallIC(ic, expr->CountStoreFeedbackId());
|
| PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
|
| if (expr->is_postfix()) {
|
| if (!context()->IsEffect()) {
|
| @@ -4471,7 +4476,7 @@ void FullCodeGenerator::VisitForTypeofValue(Expression* expr) {
|
| ASSERT(!context()->IsTest());
|
| VariableProxy* proxy = expr->AsVariableProxy();
|
| if (proxy != NULL && proxy->var()->IsUnallocated()) {
|
| - Comment cmnt(masm_, "Global variable");
|
| + Comment cmnt(masm_, "[ Global variable");
|
| __ ldr(r0, GlobalObjectOperand());
|
| __ mov(r2, Operand(proxy->name()));
|
| // Use a regular load, not a contextual load, to avoid a reference
|
| @@ -4480,6 +4485,7 @@ void FullCodeGenerator::VisitForTypeofValue(Expression* expr) {
|
| PrepareForBailout(expr, TOS_REG);
|
| context()->Plug(r0);
|
| } else if (proxy != NULL && proxy->var()->IsLookupSlot()) {
|
| + Comment cmnt(masm_, "[ Lookup slot");
|
| Label done, slow;
|
|
|
| // Generate code for loading from variables potentially shadowed
|
| @@ -4641,7 +4647,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, NOT_CONTEXTUAL, expr->CompareOperationFeedbackId());
|
| + CallIC(ic, expr->CompareOperationFeedbackId());
|
| patch_site.EmitPatchInfo();
|
| PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| __ cmp(r0, Operand::Zero());
|
| @@ -4676,7 +4682,7 @@ void FullCodeGenerator::EmitLiteralCompareNil(CompareOperation* expr,
|
| Split(eq, if_true, if_false, fall_through);
|
| } else {
|
| Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil);
|
| - CallIC(ic, NOT_CONTEXTUAL, expr->CompareOperationFeedbackId());
|
| + CallIC(ic, expr->CompareOperationFeedbackId());
|
| __ cmp(r0, Operand(0));
|
| Split(ne, if_true, if_false, fall_through);
|
| }
|
|
|