Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 function_ = fun; | 55 function_ = fun; |
| 56 SetFunctionPosition(fun); | 56 SetFunctionPosition(fun); |
| 57 | 57 |
| 58 __ push(rbp); // Caller's frame pointer. | 58 __ push(rbp); // Caller's frame pointer. |
| 59 __ movq(rbp, rsp); | 59 __ movq(rbp, rsp); |
| 60 __ push(rsi); // Callee's context. | 60 __ push(rsi); // Callee's context. |
| 61 __ push(rdi); // Callee's JS Function. | 61 __ push(rdi); // Callee's JS Function. |
| 62 | 62 |
| 63 { Comment cmnt(masm_, "[ Allocate locals"); | 63 { Comment cmnt(masm_, "[ Allocate locals"); |
| 64 int locals_count = fun->scope()->num_stack_slots(); | 64 int locals_count = fun->scope()->num_stack_slots(); |
| 65 for (int i = 0; i < locals_count; i++) { | 65 if (locals_count <= 1) { |
| 66 __ PushRoot(Heap::kUndefinedValueRootIndex); | 66 if (locals_count > 0) { |
| 67 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
| 68 } | |
| 69 } else { | |
| 70 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex); | |
| 71 for (int i = 0; i < locals_count; i++) { | |
| 72 __ push(rdx); | |
| 73 } | |
| 67 } | 74 } |
| 68 } | 75 } |
| 69 | 76 |
| 77 bool function_in_register = true; | |
| 78 | |
| 79 Variable* arguments = fun->scope()->arguments()->AsVariable(); | |
| 80 if (arguments != NULL) { | |
| 81 // Function uses arguments object. | |
| 82 Comment cmnt(masm_, "[ Allocate arguments object"); | |
| 83 __ push(rdi); | |
| 84 // Receiver is located above the frame pointer, return address and | |
|
William Hesse
2009/11/12 09:56:49
I think we would say "below" here. Instead, say t
Lasse Reichstein
2009/11/13 08:54:37
Using "above" and "below" wrt stacks is the stuff
| |
| 85 // parameters. | |
| 86 __ lea(rdx, Operand(rbp, (fun->num_parameters() + 2) * kPointerSize)); | |
| 87 __ push(rdx); | |
| 88 __ Push(Smi::FromInt(fun->num_parameters())); | |
| 89 // Arguments to ArgumentsAccessStub: | |
| 90 // function, receiver address, parameter count. | |
| 91 // The stub will rewrite receiever and parameter count if the previous | |
|
William Hesse
2009/11/12 09:56:49
receiver
Lasse Reichstein
2009/11/13 08:54:37
fixed
| |
| 92 // stack frame was an arguments adapter frame. | |
| 93 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT); | |
| 94 __ CallStub(&stub); | |
| 95 Slot* arguments_slot = arguments->slot(); | |
|
William Hesse
2009/11/12 09:56:49
This variable name isn't much shorter than the exp
Lasse Reichstein
2009/11/13 08:54:37
I'll inline it.
We probably don't have the SlotOpe
| |
| 96 __ movq(Operand(rbp, SlotOffset(arguments_slot)), rax); | |
| 97 Slot* dot_arguments_slot = | |
| 98 fun->scope()->arguments_shadow()->AsVariable()->slot(); | |
| 99 __ movq(Operand(rbp, SlotOffset(dot_arguments_slot)), rax); | |
| 100 function_in_register = false; | |
| 101 } | |
| 102 | |
| 70 // Possibly allocate a local context. | 103 // Possibly allocate a local context. |
| 71 if (fun->scope()->num_heap_slots() > 0) { | 104 if (fun->scope()->num_heap_slots() > 0) { |
| 72 Comment cmnt(masm_, "[ Allocate local context"); | 105 Comment cmnt(masm_, "[ Allocate local context"); |
| 73 // Argument to NewContext is the function, still in rdi. | 106 if (function_in_register) { |
| 74 __ push(rdi); | 107 // Argument to NewContext is the function, still in rdi. |
| 108 __ push(rdi); | |
| 109 } else { | |
| 110 // Argument to NewContext is the function, no longer in rdi. | |
| 111 __ push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | |
| 112 } | |
| 75 __ CallRuntime(Runtime::kNewContext, 1); | 113 __ CallRuntime(Runtime::kNewContext, 1); |
| 76 // Context is returned in both rax and rsi. It replaces the context | 114 // Context is returned in both rax and rsi. It replaces the context |
| 77 // passed to us. It's saved in the stack and kept live in rsi. | 115 // passed to us. It's saved in the stack and kept live in rsi. |
| 78 __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi); | 116 __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi); |
| 79 #ifdef DEBUG | 117 #ifdef DEBUG |
| 80 // Assert we do not have to copy any parameters into the context. | 118 // Assert we do not have to copy any parameters into the context. |
| 81 for (int i = 0, len = fun->scope()->num_parameters(); i < len; i++) { | 119 for (int i = 0, len = fun->scope()->num_parameters(); i < len; i++) { |
| 82 Slot* slot = fun->scope()->parameter(i)->slot(); | 120 Slot* slot = fun->scope()->parameter(i)->slot(); |
| 83 ASSERT(slot != NULL && slot->type() != Slot::CONTEXT); | 121 ASSERT(slot != NULL && slot->type() != Slot::CONTEXT); |
| 84 } | 122 } |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 __ push(CodeGenerator::GlobalObject()); | 463 __ push(CodeGenerator::GlobalObject()); |
| 426 __ Move(rcx, expr->name()); | 464 __ Move(rcx, expr->name()); |
| 427 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 465 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
| 428 __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT); | 466 __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT); |
| 429 // A test rax instruction following the call is used by the IC to | 467 // A test rax instruction following the call is used by the IC to |
| 430 // indicate that the inobject property case was inlined. Ensure there | 468 // indicate that the inobject property case was inlined. Ensure there |
| 431 // is no test rax instruction here. | 469 // is no test rax instruction here. |
| 432 __ nop(); | 470 __ nop(); |
| 433 | 471 |
| 434 DropAndMove(expr->context(), rax); | 472 DropAndMove(expr->context(), rax); |
| 435 } else { | 473 } else if (rewrite->AsSlot() != NULL) { |
| 436 Slot* slot = rewrite->AsSlot(); | 474 Slot* slot = rewrite->AsSlot(); |
| 437 ASSERT_NE(NULL, slot); | |
| 438 switch (slot->type()) { | 475 switch (slot->type()) { |
| 439 case Slot::LOCAL: | 476 case Slot::LOCAL: |
| 440 case Slot::PARAMETER: { | 477 case Slot::PARAMETER: { |
| 441 Comment cmnt(masm_, "Stack slot"); | 478 Comment cmnt(masm_, "Stack slot"); |
| 442 Move(expr->context(), slot); | 479 Move(expr->context(), slot); |
| 443 break; | 480 break; |
| 444 } | 481 } |
| 445 | 482 |
| 446 case Slot::CONTEXT: { | 483 case Slot::CONTEXT: { |
| 447 Comment cmnt(masm_, "Context slot"); | 484 Comment cmnt(masm_, "Context slot"); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 468 } | 505 } |
| 469 __ movq(rax, Operand(rax, Context::SlotOffset(slot->index()))); | 506 __ movq(rax, Operand(rax, Context::SlotOffset(slot->index()))); |
| 470 Move(expr->context(), rax); | 507 Move(expr->context(), rax); |
| 471 break; | 508 break; |
| 472 } | 509 } |
| 473 | 510 |
| 474 case Slot::LOOKUP: | 511 case Slot::LOOKUP: |
| 475 UNREACHABLE(); | 512 UNREACHABLE(); |
| 476 break; | 513 break; |
| 477 } | 514 } |
| 515 } else { | |
| 516 // The parameter variable has been rewritten into an explict access to | |
| 517 // the arguments object. | |
| 518 Property* property = rewrite->AsProperty(); | |
| 519 ASSERT_NOT_NULL(property); | |
| 520 ASSERT_EQ(expr->context(), property->context()); | |
| 521 Visit(property); | |
| 478 } | 522 } |
| 479 } | 523 } |
| 480 | 524 |
| 481 | 525 |
| 482 void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 526 void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 483 Comment cmnt(masm_, "[ RegExpLiteral"); | 527 Comment cmnt(masm_, "[ RegExpLiteral"); |
| 484 Label done; | 528 Label done; |
| 485 // Registers will be used as follows: | 529 // Registers will be used as follows: |
| 486 // rdi = JS function. | 530 // rdi = JS function. |
| 487 // rbx = literals array. | 531 // rbx = literals array. |
| (...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1503 true_label_ = saved_true; | 1547 true_label_ = saved_true; |
| 1504 false_label_ = saved_false; | 1548 false_label_ = saved_false; |
| 1505 // Convert current context to test context: End post-test code. | 1549 // Convert current context to test context: End post-test code. |
| 1506 } | 1550 } |
| 1507 | 1551 |
| 1508 | 1552 |
| 1509 #undef __ | 1553 #undef __ |
| 1510 | 1554 |
| 1511 | 1555 |
| 1512 } } // namespace v8::internal | 1556 } } // namespace v8::internal |
| OLD | NEW |