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_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
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 4522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4533 DCHECK(expr->arguments()->length() == 0); | 4533 DCHECK(expr->arguments()->length() == 0); |
4534 ExternalReference debug_is_active = | 4534 ExternalReference debug_is_active = |
4535 ExternalReference::debug_is_active_address(isolate()); | 4535 ExternalReference::debug_is_active_address(isolate()); |
4536 __ movzx_b(eax, Operand::StaticVariable(debug_is_active)); | 4536 __ movzx_b(eax, Operand::StaticVariable(debug_is_active)); |
4537 __ SmiTag(eax); | 4537 __ SmiTag(eax); |
4538 context()->Plug(eax); | 4538 context()->Plug(eax); |
4539 } | 4539 } |
4540 | 4540 |
4541 | 4541 |
4542 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 4542 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
4543 InlineFunctionGenerator generator = FindInlineFunctionGenerator(expr); | |
4544 if (generator != nullptr) { | |
4545 Comment cmnt(masm_, "[ InlineRuntimeCall"); | |
4546 EmitInlineRuntimeCall(expr, generator); | |
4547 return; | |
4548 } | |
4549 | |
4550 Comment cmnt(masm_, "[ CallRuntime"); | |
4551 ZoneList<Expression*>* args = expr->arguments(); | 4543 ZoneList<Expression*>* args = expr->arguments(); |
| 4544 int arg_count = args->length(); |
4552 | 4545 |
4553 if (expr->is_jsruntime()) { | 4546 if (expr->is_jsruntime()) { |
| 4547 Comment cmnt(masm_, "[ CallRuntime"); |
4554 // Push the builtins object as receiver. | 4548 // Push the builtins object as receiver. |
4555 __ mov(eax, GlobalObjectOperand()); | 4549 __ mov(eax, GlobalObjectOperand()); |
4556 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); | 4550 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); |
4557 | 4551 |
4558 // Load the function from the receiver. | 4552 // Load the function from the receiver. |
4559 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); | 4553 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); |
4560 __ mov(LoadDescriptor::NameRegister(), Immediate(expr->name())); | 4554 __ mov(LoadDescriptor::NameRegister(), Immediate(expr->name())); |
4561 if (FLAG_vector_ics) { | 4555 if (FLAG_vector_ics) { |
4562 __ mov(VectorLoadICDescriptor::SlotRegister(), | 4556 __ mov(VectorLoadICDescriptor::SlotRegister(), |
4563 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); | 4557 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); |
4564 CallLoadIC(NOT_CONTEXTUAL); | 4558 CallLoadIC(NOT_CONTEXTUAL); |
4565 } else { | 4559 } else { |
4566 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); | 4560 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); |
4567 } | 4561 } |
4568 | 4562 |
4569 // Push the target function under the receiver. | 4563 // Push the target function under the receiver. |
4570 __ push(Operand(esp, 0)); | 4564 __ push(Operand(esp, 0)); |
4571 __ mov(Operand(esp, kPointerSize), eax); | 4565 __ mov(Operand(esp, kPointerSize), eax); |
4572 | 4566 |
4573 // Code common for calls using the IC. | 4567 // Push the arguments ("left-to-right"). |
4574 ZoneList<Expression*>* args = expr->arguments(); | |
4575 int arg_count = args->length(); | |
4576 for (int i = 0; i < arg_count; i++) { | 4568 for (int i = 0; i < arg_count; i++) { |
4577 VisitForStackValue(args->at(i)); | 4569 VisitForStackValue(args->at(i)); |
4578 } | 4570 } |
4579 | 4571 |
4580 // Record source position of the IC call. | 4572 // Record source position of the IC call. |
4581 SetSourcePosition(expr->position()); | 4573 SetSourcePosition(expr->position()); |
4582 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 4574 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
4583 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 4575 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
4584 __ CallStub(&stub); | 4576 __ CallStub(&stub); |
| 4577 |
4585 // Restore context register. | 4578 // Restore context register. |
4586 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 4579 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
4587 context()->DropAndPlug(1, eax); | 4580 context()->DropAndPlug(1, eax); |
4588 | 4581 |
4589 } else { | 4582 } else { |
4590 // Push the arguments ("left-to-right"). | 4583 const Runtime::Function* function = expr->function(); |
4591 int arg_count = args->length(); | 4584 switch (function->function_id) { |
4592 for (int i = 0; i < arg_count; i++) { | 4585 #define CALL_INTRINSIC_GENERATOR(Name) \ |
4593 VisitForStackValue(args->at(i)); | 4586 case Runtime::kInline##Name: { \ |
| 4587 Comment cmnt(masm_, "[ Inline" #Name); \ |
| 4588 return Emit##Name(expr); \ |
| 4589 } |
| 4590 FOR_EACH_FULL_CODE_INTRINSIC(CALL_INTRINSIC_GENERATOR) |
| 4591 #undef CALL_INTRINSIC_GENERATOR |
| 4592 default: { |
| 4593 Comment cmnt(masm_, "[ CallRuntime for unhandled intrinsic"); |
| 4594 // Push the arguments ("left-to-right"). |
| 4595 for (int i = 0; i < arg_count; i++) { |
| 4596 VisitForStackValue(args->at(i)); |
| 4597 } |
| 4598 |
| 4599 // Call the C runtime function. |
| 4600 __ CallRuntime(expr->function(), arg_count); |
| 4601 context()->Plug(eax); |
| 4602 } |
4594 } | 4603 } |
4595 | |
4596 // Call the C runtime function. | |
4597 __ CallRuntime(expr->function(), arg_count); | |
4598 | |
4599 context()->Plug(eax); | |
4600 } | 4604 } |
4601 } | 4605 } |
4602 | 4606 |
4603 | 4607 |
4604 void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { | 4608 void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { |
4605 switch (expr->op()) { | 4609 switch (expr->op()) { |
4606 case Token::DELETE: { | 4610 case Token::DELETE: { |
4607 Comment cmnt(masm_, "[ UnaryOperation (DELETE)"); | 4611 Comment cmnt(masm_, "[ UnaryOperation (DELETE)"); |
4608 Property* property = expr->expression()->AsProperty(); | 4612 Property* property = expr->expression()->AsProperty(); |
4609 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 4613 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5385 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5389 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5386 Assembler::target_address_at(call_target_address, | 5390 Assembler::target_address_at(call_target_address, |
5387 unoptimized_code)); | 5391 unoptimized_code)); |
5388 return OSR_AFTER_STACK_CHECK; | 5392 return OSR_AFTER_STACK_CHECK; |
5389 } | 5393 } |
5390 | 5394 |
5391 | 5395 |
5392 } } // namespace v8::internal | 5396 } } // namespace v8::internal |
5393 | 5397 |
5394 #endif // V8_TARGET_ARCH_IA32 | 5398 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |