| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 context()->Plug(eax); | 1268 context()->Plug(eax); |
| 1269 } | 1269 } |
| 1270 | 1270 |
| 1271 | 1271 |
| 1272 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | 1272 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
| 1273 Comment cmnt(masm_, "[ VariableProxy"); | 1273 Comment cmnt(masm_, "[ VariableProxy"); |
| 1274 EmitVariableLoad(expr); | 1274 EmitVariableLoad(expr); |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 | 1277 |
| 1278 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { |
| 1279 Comment cnmt(masm_, "[ SuperReference "); |
| 1280 |
| 1281 __ mov(LoadDescriptor::ReceiverRegister(), |
| 1282 Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1283 |
| 1284 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); |
| 1285 __ mov(LoadDescriptor::NameRegister(), home_object_symbol); |
| 1286 |
| 1287 CallLoadIC(NOT_CONTEXTUAL, expr->HomeObjectFeedbackId()); |
| 1288 |
| 1289 __ cmp(eax, isolate()->factory()->undefined_value()); |
| 1290 Label done; |
| 1291 __ j(not_equal, &done); |
| 1292 __ CallRuntime(Runtime::kThrowNonMethodError, 0); |
| 1293 __ bind(&done); |
| 1294 } |
| 1295 |
| 1296 |
| 1278 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, | 1297 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, |
| 1279 TypeofState typeof_state, | 1298 TypeofState typeof_state, |
| 1280 Label* slow) { | 1299 Label* slow) { |
| 1281 Register context = esi; | 1300 Register context = esi; |
| 1282 Register temp = edx; | 1301 Register temp = edx; |
| 1283 | 1302 |
| 1284 Scope* s = scope(); | 1303 Scope* s = scope(); |
| 1285 while (s != NULL) { | 1304 while (s != NULL) { |
| 1286 if (s->num_heap_slots() > 0) { | 1305 if (s->num_heap_slots() > 0) { |
| 1287 if (s->calls_sloppy_eval()) { | 1306 if (s->calls_sloppy_eval()) { |
| (...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 if (FLAG_vector_ics) { | 2237 if (FLAG_vector_ics) { |
| 2219 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2238 __ mov(VectorLoadICDescriptor::SlotRegister(), |
| 2220 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2239 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
| 2221 CallLoadIC(NOT_CONTEXTUAL); | 2240 CallLoadIC(NOT_CONTEXTUAL); |
| 2222 } else { | 2241 } else { |
| 2223 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | 2242 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); |
| 2224 } | 2243 } |
| 2225 } | 2244 } |
| 2226 | 2245 |
| 2227 | 2246 |
| 2247 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { |
| 2248 SetSourcePosition(prop->position()); |
| 2249 Literal* key = prop->key()->AsLiteral(); |
| 2250 DCHECK(!key->value()->IsSmi()); |
| 2251 DCHECK(prop->IsSuperAccess()); |
| 2252 |
| 2253 SuperReference* super_ref = prop->obj()->AsSuperReference(); |
| 2254 EmitLoadHomeObject(super_ref); |
| 2255 __ push(eax); |
| 2256 VisitForStackValue(super_ref->this_var()); |
| 2257 __ push(Immediate(key->value())); |
| 2258 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
| 2259 } |
| 2260 |
| 2261 |
| 2228 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2262 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
| 2229 SetSourcePosition(prop->position()); | 2263 SetSourcePosition(prop->position()); |
| 2230 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2264 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
| 2231 if (FLAG_vector_ics) { | 2265 if (FLAG_vector_ics) { |
| 2232 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2266 __ mov(VectorLoadICDescriptor::SlotRegister(), |
| 2233 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2267 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
| 2234 CallIC(ic); | 2268 CallIC(ic); |
| 2235 } else { | 2269 } else { |
| 2236 CallIC(ic, prop->PropertyFeedbackId()); | 2270 CallIC(ic, prop->PropertyFeedbackId()); |
| 2237 } | 2271 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2541 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
| 2508 context()->Plug(eax); | 2542 context()->Plug(eax); |
| 2509 } | 2543 } |
| 2510 | 2544 |
| 2511 | 2545 |
| 2512 void FullCodeGenerator::VisitProperty(Property* expr) { | 2546 void FullCodeGenerator::VisitProperty(Property* expr) { |
| 2513 Comment cmnt(masm_, "[ Property"); | 2547 Comment cmnt(masm_, "[ Property"); |
| 2514 Expression* key = expr->key(); | 2548 Expression* key = expr->key(); |
| 2515 | 2549 |
| 2516 if (key->IsPropertyName()) { | 2550 if (key->IsPropertyName()) { |
| 2517 VisitForAccumulatorValue(expr->obj()); | 2551 if (!expr->IsSuperAccess()) { |
| 2518 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); | 2552 VisitForAccumulatorValue(expr->obj()); |
| 2519 EmitNamedPropertyLoad(expr); | 2553 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); |
| 2554 EmitNamedPropertyLoad(expr); |
| 2555 } else { |
| 2556 EmitNamedSuperPropertyLoad(expr); |
| 2557 } |
| 2520 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2558 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
| 2521 context()->Plug(eax); | 2559 context()->Plug(eax); |
| 2522 } else { | 2560 } else { |
| 2523 VisitForStackValue(expr->obj()); | 2561 VisitForStackValue(expr->obj()); |
| 2524 VisitForAccumulatorValue(expr->key()); | 2562 VisitForAccumulatorValue(expr->key()); |
| 2525 __ pop(LoadDescriptor::ReceiverRegister()); // Object. | 2563 __ pop(LoadDescriptor::ReceiverRegister()); // Object. |
| 2526 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key. | 2564 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key. |
| 2527 EmitKeyedPropertyLoad(expr); | 2565 EmitKeyedPropertyLoad(expr); |
| 2528 context()->Plug(eax); | 2566 context()->Plug(eax); |
| 2529 } | 2567 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2548 { StackValueContext context(this); | 2586 { StackValueContext context(this); |
| 2549 EmitVariableLoad(callee->AsVariableProxy()); | 2587 EmitVariableLoad(callee->AsVariableProxy()); |
| 2550 PrepareForBailout(callee, NO_REGISTERS); | 2588 PrepareForBailout(callee, NO_REGISTERS); |
| 2551 } | 2589 } |
| 2552 // Push undefined as receiver. This is patched in the method prologue if it | 2590 // Push undefined as receiver. This is patched in the method prologue if it |
| 2553 // is a sloppy mode method. | 2591 // is a sloppy mode method. |
| 2554 __ push(Immediate(isolate()->factory()->undefined_value())); | 2592 __ push(Immediate(isolate()->factory()->undefined_value())); |
| 2555 } else { | 2593 } else { |
| 2556 // Load the function from the receiver. | 2594 // Load the function from the receiver. |
| 2557 DCHECK(callee->IsProperty()); | 2595 DCHECK(callee->IsProperty()); |
| 2596 DCHECK(!callee->AsProperty()->IsSuperAccess()); |
| 2558 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); | 2597 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); |
| 2559 EmitNamedPropertyLoad(callee->AsProperty()); | 2598 EmitNamedPropertyLoad(callee->AsProperty()); |
| 2560 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2599 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
| 2561 // Push the target function under the receiver. | 2600 // Push the target function under the receiver. |
| 2562 __ push(Operand(esp, 0)); | 2601 __ push(Operand(esp, 0)); |
| 2563 __ mov(Operand(esp, kPointerSize), eax); | 2602 __ mov(Operand(esp, kPointerSize), eax); |
| 2564 } | 2603 } |
| 2565 | 2604 |
| 2566 EmitCall(expr, call_type); | 2605 EmitCall(expr, call_type); |
| 2567 } | 2606 } |
| 2568 | 2607 |
| 2569 | 2608 |
| 2609 void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { |
| 2610 Expression* callee = expr->expression(); |
| 2611 DCHECK(callee->IsProperty()); |
| 2612 Property* prop = callee->AsProperty(); |
| 2613 DCHECK(prop->IsSuperAccess()); |
| 2614 |
| 2615 SetSourcePosition(prop->position()); |
| 2616 Literal* key = prop->key()->AsLiteral(); |
| 2617 DCHECK(!key->value()->IsSmi()); |
| 2618 // Load the function from the receiver. |
| 2619 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); |
| 2620 EmitLoadHomeObject(super_ref); |
| 2621 __ push(eax); |
| 2622 VisitForAccumulatorValue(super_ref->this_var()); |
| 2623 __ push(eax); |
| 2624 __ push(Operand(esp, kPointerSize)); |
| 2625 __ push(eax); |
| 2626 __ push(Immediate(key->value())); |
| 2627 // Stack here: |
| 2628 // - home_object |
| 2629 // - this (receiver) |
| 2630 // - home_object <-- LoadFromSuper will pop here and below. |
| 2631 // - this (receiver) |
| 2632 // - key |
| 2633 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
| 2634 |
| 2635 // Replace home_object with target function. |
| 2636 __ mov(Operand(esp, kPointerSize), eax); |
| 2637 |
| 2638 // Stack here: |
| 2639 // - target function |
| 2640 // - this (receiver) |
| 2641 EmitCall(expr, CallICState::METHOD); |
| 2642 } |
| 2643 |
| 2644 |
| 2570 // Code common for calls using the IC. | 2645 // Code common for calls using the IC. |
| 2571 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, | 2646 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, |
| 2572 Expression* key) { | 2647 Expression* key) { |
| 2573 // Load the key. | 2648 // Load the key. |
| 2574 VisitForAccumulatorValue(key); | 2649 VisitForAccumulatorValue(key); |
| 2575 | 2650 |
| 2576 Expression* callee = expr->expression(); | 2651 Expression* callee = expr->expression(); |
| 2577 | 2652 |
| 2578 // Load the function from the receiver. | 2653 // Load the function from the receiver. |
| 2579 DCHECK(callee->IsProperty()); | 2654 DCHECK(callee->IsProperty()); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2720 __ push(Immediate(isolate()->factory()->undefined_value())); | 2795 __ push(Immediate(isolate()->factory()->undefined_value())); |
| 2721 __ bind(&call); | 2796 __ bind(&call); |
| 2722 } | 2797 } |
| 2723 | 2798 |
| 2724 // The receiver is either the global receiver or an object found by | 2799 // The receiver is either the global receiver or an object found by |
| 2725 // LoadContextSlot. | 2800 // LoadContextSlot. |
| 2726 EmitCall(expr); | 2801 EmitCall(expr); |
| 2727 | 2802 |
| 2728 } else if (call_type == Call::PROPERTY_CALL) { | 2803 } else if (call_type == Call::PROPERTY_CALL) { |
| 2729 Property* property = callee->AsProperty(); | 2804 Property* property = callee->AsProperty(); |
| 2730 { PreservePositionScope scope(masm()->positions_recorder()); | 2805 bool is_named_call = property->key()->IsPropertyName(); |
| 2731 VisitForStackValue(property->obj()); | 2806 // super.x() is handled in EmitCallWithLoadIC. |
| 2807 if (property->IsSuperAccess() && is_named_call) { |
| 2808 EmitSuperCallWithLoadIC(expr); |
| 2809 } else { |
| 2810 { |
| 2811 PreservePositionScope scope(masm()->positions_recorder()); |
| 2812 VisitForStackValue(property->obj()); |
| 2813 } |
| 2814 if (is_named_call) { |
| 2815 EmitCallWithLoadIC(expr); |
| 2816 } else { |
| 2817 EmitKeyedCallWithLoadIC(expr, property->key()); |
| 2818 } |
| 2732 } | 2819 } |
| 2733 if (property->key()->IsPropertyName()) { | |
| 2734 EmitCallWithLoadIC(expr); | |
| 2735 } else { | |
| 2736 EmitKeyedCallWithLoadIC(expr, property->key()); | |
| 2737 } | |
| 2738 | |
| 2739 } else { | 2820 } else { |
| 2740 DCHECK(call_type == Call::OTHER_CALL); | 2821 DCHECK(call_type == Call::OTHER_CALL); |
| 2741 // Call to an arbitrary expression not handled specially above. | 2822 // Call to an arbitrary expression not handled specially above. |
| 2742 { PreservePositionScope scope(masm()->positions_recorder()); | 2823 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2743 VisitForStackValue(callee); | 2824 VisitForStackValue(callee); |
| 2744 } | 2825 } |
| 2745 __ push(Immediate(isolate()->factory()->undefined_value())); | 2826 __ push(Immediate(isolate()->factory()->undefined_value())); |
| 2746 // Emit function call. | 2827 // Emit function call. |
| 2747 EmitCall(expr); | 2828 EmitCall(expr); |
| 2748 } | 2829 } |
| (...skipping 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4816 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4897 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4817 Assembler::target_address_at(call_target_address, | 4898 Assembler::target_address_at(call_target_address, |
| 4818 unoptimized_code)); | 4899 unoptimized_code)); |
| 4819 return OSR_AFTER_STACK_CHECK; | 4900 return OSR_AFTER_STACK_CHECK; |
| 4820 } | 4901 } |
| 4821 | 4902 |
| 4822 | 4903 |
| 4823 } } // namespace v8::internal | 4904 } } // namespace v8::internal |
| 4824 | 4905 |
| 4825 #endif // V8_TARGET_ARCH_X87 | 4906 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |