| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 __ PushMultipleTimes(locals_count, x10); | 183 __ PushMultipleTimes(locals_count, x10); |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 bool function_in_register_x1 = true; | 187 bool function_in_register_x1 = true; |
| 188 | 188 |
| 189 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 189 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
| 190 if (heap_slots > 0) { | 190 if (heap_slots > 0) { |
| 191 // Argument to NewContext is the function, which is still in x1. | 191 // Argument to NewContext is the function, which is still in x1. |
| 192 Comment cmnt(masm_, "[ Allocate context"); | 192 Comment cmnt(masm_, "[ Allocate context"); |
| 193 __ Push(x1); | |
| 194 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { | 193 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { |
| 195 __ Push(info->scope()->GetScopeInfo()); | 194 __ Mov(x10, Operand(info->scope()->GetScopeInfo())); |
| 195 __ Push(x1, x10); |
| 196 __ CallRuntime(Runtime::kNewGlobalContext, 2); | 196 __ CallRuntime(Runtime::kNewGlobalContext, 2); |
| 197 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 197 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
| 198 FastNewContextStub stub(heap_slots); | 198 FastNewContextStub stub(heap_slots); |
| 199 __ CallStub(&stub); | 199 __ CallStub(&stub); |
| 200 } else { | 200 } else { |
| 201 __ Push(x1); |
| 201 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 202 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
| 202 } | 203 } |
| 203 function_in_register_x1 = false; | 204 function_in_register_x1 = false; |
| 204 // Context is returned in both x0 and cp. It replaces the context | 205 // Context is returned in x0. It replaces the context passed to us. |
| 205 // passed to us. It's saved in the stack and kept live in cp. | 206 // It's saved in the stack and kept live in cp. |
| 206 __ Str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 207 __ Mov(cp, x0); |
| 208 __ Str(x0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 207 // Copy any necessary parameters into the context. | 209 // Copy any necessary parameters into the context. |
| 208 int num_parameters = info->scope()->num_parameters(); | 210 int num_parameters = info->scope()->num_parameters(); |
| 209 for (int i = 0; i < num_parameters; i++) { | 211 for (int i = 0; i < num_parameters; i++) { |
| 210 Variable* var = scope()->parameter(i); | 212 Variable* var = scope()->parameter(i); |
| 211 if (var->IsContextSlot()) { | 213 if (var->IsContextSlot()) { |
| 212 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 214 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
| 213 (num_parameters - 1 - i) * kPointerSize; | 215 (num_parameters - 1 - i) * kPointerSize; |
| 214 // Load parameter from stack. | 216 // Load parameter from stack. |
| 215 __ Ldr(x10, MemOperand(fp, parameter_offset)); | 217 __ Ldr(x10, MemOperand(fp, parameter_offset)); |
| 216 // Store it in the context. | 218 // Store it in the context. |
| (...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2436 | 2438 |
| 2437 void FullCodeGenerator::VisitCall(Call* expr) { | 2439 void FullCodeGenerator::VisitCall(Call* expr) { |
| 2438 #ifdef DEBUG | 2440 #ifdef DEBUG |
| 2439 // We want to verify that RecordJSReturnSite gets called on all paths | 2441 // We want to verify that RecordJSReturnSite gets called on all paths |
| 2440 // through this function. Avoid early returns. | 2442 // through this function. Avoid early returns. |
| 2441 expr->return_is_recorded_ = false; | 2443 expr->return_is_recorded_ = false; |
| 2442 #endif | 2444 #endif |
| 2443 | 2445 |
| 2444 Comment cmnt(masm_, "[ Call"); | 2446 Comment cmnt(masm_, "[ Call"); |
| 2445 Expression* callee = expr->expression(); | 2447 Expression* callee = expr->expression(); |
| 2446 VariableProxy* proxy = callee->AsVariableProxy(); | 2448 Call::CallType call_type = expr->GetCallType(isolate()); |
| 2447 Property* property = callee->AsProperty(); | |
| 2448 | 2449 |
| 2449 if (proxy != NULL && proxy->var()->is_possibly_eval(isolate())) { | 2450 if (call_type == Call::POSSIBLY_EVAL_CALL) { |
| 2450 // In a call to eval, we first call %ResolvePossiblyDirectEval to | 2451 // In a call to eval, we first call %ResolvePossiblyDirectEval to |
| 2451 // resolve the function we need to call and the receiver of the | 2452 // resolve the function we need to call and the receiver of the |
| 2452 // call. Then we call the resolved function using the given | 2453 // call. Then we call the resolved function using the given |
| 2453 // arguments. | 2454 // arguments. |
| 2454 ZoneList<Expression*>* args = expr->arguments(); | 2455 ZoneList<Expression*>* args = expr->arguments(); |
| 2455 int arg_count = args->length(); | 2456 int arg_count = args->length(); |
| 2456 | 2457 |
| 2457 { | 2458 { |
| 2458 PreservePositionScope pos_scope(masm()->positions_recorder()); | 2459 PreservePositionScope pos_scope(masm()->positions_recorder()); |
| 2459 VisitForStackValue(callee); | 2460 VisitForStackValue(callee); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2481 | 2482 |
| 2482 // Call the evaluated function. | 2483 // Call the evaluated function. |
| 2483 CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS); | 2484 CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS); |
| 2484 __ Peek(x1, (arg_count + 1) * kXRegSizeInBytes); | 2485 __ Peek(x1, (arg_count + 1) * kXRegSizeInBytes); |
| 2485 __ CallStub(&stub); | 2486 __ CallStub(&stub); |
| 2486 RecordJSReturnSite(expr); | 2487 RecordJSReturnSite(expr); |
| 2487 // Restore context register. | 2488 // Restore context register. |
| 2488 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2489 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2489 context()->DropAndPlug(1, x0); | 2490 context()->DropAndPlug(1, x0); |
| 2490 | 2491 |
| 2491 } else if (proxy != NULL && proxy->var()->IsUnallocated()) { | 2492 } else if (call_type == Call::GLOBAL_CALL) { |
| 2492 // Push global object as receiver for the call IC. | 2493 // Push global object as receiver for the call IC. |
| 2493 __ Ldr(x10, GlobalObjectMemOperand()); | 2494 __ Ldr(x10, GlobalObjectMemOperand()); |
| 2494 __ Push(x10); | 2495 __ Push(x10); |
| 2496 VariableProxy* proxy = callee->AsVariableProxy(); |
| 2495 EmitCallWithIC(expr, proxy->name(), CONTEXTUAL); | 2497 EmitCallWithIC(expr, proxy->name(), CONTEXTUAL); |
| 2496 | 2498 |
| 2497 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 2499 } else if (call_type == Call::LOOKUP_SLOT_CALL) { |
| 2498 // Call to a lookup slot (dynamically introduced variable). | 2500 // Call to a lookup slot (dynamically introduced variable). |
| 2501 VariableProxy* proxy = callee->AsVariableProxy(); |
| 2499 Label slow, done; | 2502 Label slow, done; |
| 2500 | 2503 |
| 2501 { PreservePositionScope scope(masm()->positions_recorder()); | 2504 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2502 // Generate code for loading from variables potentially shadowed | 2505 // Generate code for loading from variables potentially shadowed |
| 2503 // by eval-introduced variables. | 2506 // by eval-introduced variables. |
| 2504 EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); | 2507 EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); |
| 2505 } | 2508 } |
| 2506 | 2509 |
| 2507 __ Bind(&slow); | 2510 __ Bind(&slow); |
| 2508 // Call the runtime to find the function to call (returned in x0) | 2511 // Call the runtime to find the function to call (returned in x0) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2525 // The receiver is implicitly the global receiver. Indicate this | 2528 // The receiver is implicitly the global receiver. Indicate this |
| 2526 // by passing the undefined to the call function stub. | 2529 // by passing the undefined to the call function stub. |
| 2527 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex); | 2530 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex); |
| 2528 __ Push(x1); | 2531 __ Push(x1); |
| 2529 __ Bind(&call); | 2532 __ Bind(&call); |
| 2530 } | 2533 } |
| 2531 | 2534 |
| 2532 // The receiver is either the global receiver or an object found | 2535 // The receiver is either the global receiver or an object found |
| 2533 // by LoadContextSlot. | 2536 // by LoadContextSlot. |
| 2534 EmitCallWithStub(expr); | 2537 EmitCallWithStub(expr); |
| 2535 } else if (property != NULL) { | 2538 } else if (call_type == Call::PROPERTY_CALL) { |
| 2539 Property* property = callee->AsProperty(); |
| 2536 { PreservePositionScope scope(masm()->positions_recorder()); | 2540 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2537 VisitForStackValue(property->obj()); | 2541 VisitForStackValue(property->obj()); |
| 2538 } | 2542 } |
| 2539 if (property->key()->IsPropertyName()) { | 2543 if (property->key()->IsPropertyName()) { |
| 2540 EmitCallWithIC(expr, | 2544 EmitCallWithIC(expr, |
| 2541 property->key()->AsLiteral()->value(), | 2545 property->key()->AsLiteral()->value(), |
| 2542 NOT_CONTEXTUAL); | 2546 NOT_CONTEXTUAL); |
| 2543 } else { | 2547 } else { |
| 2544 EmitKeyedCallWithIC(expr, property->key()); | 2548 EmitKeyedCallWithIC(expr, property->key()); |
| 2545 } | 2549 } |
| 2546 | 2550 |
| 2547 } else { | 2551 } else { |
| 2552 ASSERT(call_type == Call::OTHER_CALL); |
| 2548 // Call to an arbitrary expression not handled specially above. | 2553 // Call to an arbitrary expression not handled specially above. |
| 2549 { PreservePositionScope scope(masm()->positions_recorder()); | 2554 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2550 VisitForStackValue(callee); | 2555 VisitForStackValue(callee); |
| 2551 } | 2556 } |
| 2552 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex); | 2557 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex); |
| 2553 __ Push(x1); | 2558 __ Push(x1); |
| 2554 // Emit function call. | 2559 // Emit function call. |
| 2555 EmitCallWithStub(expr); | 2560 EmitCallWithStub(expr); |
| 2556 } | 2561 } |
| 2557 | 2562 |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3418 __ Bind(&done); | 3423 __ Bind(&done); |
| 3419 context()->Plug(result); | 3424 context()->Plug(result); |
| 3420 } | 3425 } |
| 3421 | 3426 |
| 3422 | 3427 |
| 3423 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { | 3428 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { |
| 3424 ASM_LOCATION("FullCodeGenerator::EmitStringAdd"); | 3429 ASM_LOCATION("FullCodeGenerator::EmitStringAdd"); |
| 3425 ZoneList<Expression*>* args = expr->arguments(); | 3430 ZoneList<Expression*>* args = expr->arguments(); |
| 3426 ASSERT_EQ(2, args->length()); | 3431 ASSERT_EQ(2, args->length()); |
| 3427 | 3432 |
| 3428 if (FLAG_new_string_add) { | 3433 VisitForStackValue(args->at(0)); |
| 3429 VisitForStackValue(args->at(0)); | 3434 VisitForAccumulatorValue(args->at(1)); |
| 3430 VisitForAccumulatorValue(args->at(1)); | |
| 3431 | 3435 |
| 3432 __ Pop(x1); | 3436 __ Pop(x1); |
| 3433 NewStringAddStub stub(STRING_ADD_CHECK_BOTH, NOT_TENURED); | 3437 StringAddStub stub(STRING_ADD_CHECK_BOTH, NOT_TENURED); |
| 3434 __ CallStub(&stub); | 3438 __ CallStub(&stub); |
| 3435 } else { | |
| 3436 VisitForStackValue(args->at(0)); | |
| 3437 VisitForStackValue(args->at(1)); | |
| 3438 | |
| 3439 StringAddStub stub(STRING_ADD_CHECK_BOTH); | |
| 3440 __ CallStub(&stub); | |
| 3441 } | |
| 3442 | 3439 |
| 3443 context()->Plug(x0); | 3440 context()->Plug(x0); |
| 3444 } | 3441 } |
| 3445 | 3442 |
| 3446 | 3443 |
| 3447 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { | 3444 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { |
| 3448 ZoneList<Expression*>* args = expr->arguments(); | 3445 ZoneList<Expression*>* args = expr->arguments(); |
| 3449 ASSERT_EQ(2, args->length()); | 3446 ASSERT_EQ(2, args->length()); |
| 3450 VisitForStackValue(args->at(0)); | 3447 VisitForStackValue(args->at(0)); |
| 3451 VisitForStackValue(args->at(1)); | 3448 VisitForStackValue(args->at(1)); |
| (...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5017 return previous_; | 5014 return previous_; |
| 5018 } | 5015 } |
| 5019 | 5016 |
| 5020 | 5017 |
| 5021 #undef __ | 5018 #undef __ |
| 5022 | 5019 |
| 5023 | 5020 |
| 5024 } } // namespace v8::internal | 5021 } } // namespace v8::internal |
| 5025 | 5022 |
| 5026 #endif // V8_TARGET_ARCH_A64 | 5023 #endif // V8_TARGET_ARCH_A64 |
| OLD | NEW |