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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 int locals_count = fun->scope()->num_stack_slots(); | 64 int locals_count = fun->scope()->num_stack_slots(); |
65 if (locals_count > 0) { | 65 if (locals_count > 0) { |
66 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 66 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
67 } | 67 } |
68 __ LoadRoot(r2, Heap::kStackLimitRootIndex); | 68 __ LoadRoot(r2, Heap::kStackLimitRootIndex); |
69 for (int i = 0; i < locals_count; i++) { | 69 for (int i = 0; i < locals_count; i++) { |
70 __ push(ip); | 70 __ push(ip); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 bool function_in_register = true; | |
75 | |
76 Variable* arguments = fun->scope()->arguments()->AsVariable(); | |
77 if (arguments != NULL) { | |
78 // Function uses arguments object. | |
79 Comment cmnt(masm_, "[ Allocate arguments object"); | |
80 __ mov(r3, r1); | |
81 // Receiver is located above the frame pointer, return address and | |
Kevin Millikin (Chromium)
2009/11/12 14:23:13
Like Bill, I think you should avoid "above" and "b
Lasse Reichstein
2009/11/13 08:54:37
I committed this comment: "Receiver is just before
| |
82 // parameters. | |
83 __ add(r2, fp, Operand((fun->num_parameters() + 2) * kPointerSize)); | |
84 __ mov(r1, Operand(Smi::FromInt(fun->num_parameters()))); | |
85 __ stm(db_w, sp, r1.bit() | r2.bit() | r3.bit()); | |
Kevin Millikin (Chromium)
2009/11/12 14:23:13
When using stm to push arguments, list the registe
Lasse Reichstein
2009/11/13 08:54:37
Will fix.
| |
86 | |
87 // Arguments to ArgumentsAccessStub: | |
88 // function, receiver address, parameter count. | |
89 // The stub will rewrite receiever and parameter count if the previous | |
90 // stack frame was an arguments adapter frame. | |
91 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT); | |
92 __ CallStub(&stub); | |
93 Slot* arguments_slot = arguments->slot(); | |
94 __ str(r0, MemOperand(fp, SlotOffset(arguments_slot))); | |
95 Slot* dot_arguments_slot = | |
96 fun->scope()->arguments_shadow()->AsVariable()->slot(); | |
97 __ str(r0, MemOperand(fp, SlotOffset(dot_arguments_slot))); | |
98 function_in_register = false; | |
Kevin Millikin (Chromium)
2009/11/12 14:23:13
Isn't function_in_register == (arguments != NULL)?
Lasse Reichstein
2009/11/13 08:54:37
It is. I preferred it this way because it avoided
| |
99 } | |
100 | |
74 // Possibly allocate a local context. | 101 // Possibly allocate a local context. |
75 if (fun->scope()->num_heap_slots() > 0) { | 102 if (fun->scope()->num_heap_slots() > 0) { |
76 Comment cmnt(masm_, "[ Allocate local context"); | 103 Comment cmnt(masm_, "[ Allocate local context"); |
77 // Argument to NewContext is the function, still in r1. | 104 // Argument to NewContext is the function, still in r1. |
Kevin Millikin (Chromium)
2009/11/12 14:23:13
Comment is wrong.
Lasse Reichstein
2009/11/13 08:54:37
Fixed.
| |
105 if (!function_in_register) { | |
106 __ ldr(r1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | |
107 } | |
78 __ push(r1); | 108 __ push(r1); |
79 __ CallRuntime(Runtime::kNewContext, 1); | 109 __ CallRuntime(Runtime::kNewContext, 1); |
80 // Context is returned in both r0 and cp. It replaces the context | 110 // Context is returned in both r0 and cp. It replaces the context |
81 // passed to us. It's saved in the stack and kept live in cp. | 111 // passed to us. It's saved in the stack and kept live in cp. |
82 __ str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 112 __ str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
83 #ifdef DEBUG | 113 #ifdef DEBUG |
84 // Assert we do not have to copy any parameters into the context. | 114 // Assert we do not have to copy any parameters into the context. |
85 for (int i = 0, len = fun->scope()->num_parameters(); i < len; i++) { | 115 for (int i = 0, len = fun->scope()->num_parameters(); i < len; i++) { |
86 Slot* slot = fun->scope()->parameter(i)->slot(); | 116 Slot* slot = fun->scope()->parameter(i)->slot(); |
87 ASSERT(slot != NULL && slot->type() != Slot::CONTEXT); | 117 ASSERT(slot != NULL && slot->type() != Slot::CONTEXT); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 ASSERT(expr->var()->is_global()); | 455 ASSERT(expr->var()->is_global()); |
426 Comment cmnt(masm_, "Global variable"); | 456 Comment cmnt(masm_, "Global variable"); |
427 // Use inline caching. Variable name is passed in r2 and the global | 457 // Use inline caching. Variable name is passed in r2 and the global |
428 // object on the stack. | 458 // object on the stack. |
429 __ ldr(ip, CodeGenerator::GlobalObject()); | 459 __ ldr(ip, CodeGenerator::GlobalObject()); |
430 __ push(ip); | 460 __ push(ip); |
431 __ mov(r2, Operand(expr->name())); | 461 __ mov(r2, Operand(expr->name())); |
432 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 462 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
433 __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT); | 463 __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT); |
434 DropAndMove(expr->context(), r0); | 464 DropAndMove(expr->context(), r0); |
435 } else { | 465 } else if (rewrite->AsSlot() != NULL) { |
436 Slot* slot = rewrite->AsSlot(); | 466 Slot* slot = rewrite->AsSlot(); |
437 ASSERT_NE(NULL, slot); | 467 ASSERT_NE(NULL, slot); |
438 switch (slot->type()) { | 468 switch (slot->type()) { |
439 case Slot::LOCAL: | 469 case Slot::LOCAL: |
440 case Slot::PARAMETER: { | 470 case Slot::PARAMETER: { |
441 Comment cmnt(masm_, "Stack slot"); | 471 Comment cmnt(masm_, "Stack slot"); |
442 Move(expr->context(), rewrite->AsSlot()); | 472 Move(expr->context(), rewrite->AsSlot()); |
443 break; | 473 break; |
444 } | 474 } |
445 | 475 |
(...skipping 21 matching lines...) Expand all Loading... | |
467 } | 497 } |
468 __ ldr(r0, CodeGenerator::ContextOperand(r0, slot->index())); | 498 __ ldr(r0, CodeGenerator::ContextOperand(r0, slot->index())); |
469 Move(expr->context(), r0); | 499 Move(expr->context(), r0); |
470 break; | 500 break; |
471 } | 501 } |
472 | 502 |
473 case Slot::LOOKUP: | 503 case Slot::LOOKUP: |
474 UNREACHABLE(); | 504 UNREACHABLE(); |
475 break; | 505 break; |
476 } | 506 } |
507 } else { | |
508 // The parameter variable has been rewritten into an explict access to | |
509 // the arguments object. | |
Kevin Millikin (Chromium)
2009/11/12 14:23:13
Here we don't know or care that it's the arguments
Lasse Reichstein
2009/11/13 08:54:37
True. It's currently the only reason, but we could
| |
510 Property* property = rewrite->AsProperty(); | |
511 ASSERT_NOT_NULL(property); | |
512 ASSERT_EQ(expr->context(), property->context()); | |
513 Visit(property); | |
477 } | 514 } |
478 } | 515 } |
479 | 516 |
480 | 517 |
481 void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 518 void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
482 Comment cmnt(masm_, "[ RegExpLiteral"); | 519 Comment cmnt(masm_, "[ RegExpLiteral"); |
483 Label done; | 520 Label done; |
484 // Registers will be used as follows: | 521 // Registers will be used as follows: |
485 // r4 = JS function, literals array | 522 // r4 = JS function, literals array |
486 // r3 = literal index | 523 // r3 = literal index |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1525 true_label_ = saved_true; | 1562 true_label_ = saved_true; |
1526 false_label_ = saved_false; | 1563 false_label_ = saved_false; |
1527 // Convert current context to test context: End post-test code. | 1564 // Convert current context to test context: End post-test code. |
1528 } | 1565 } |
1529 | 1566 |
1530 | 1567 |
1531 #undef __ | 1568 #undef __ |
1532 | 1569 |
1533 | 1570 |
1534 } } // namespace v8::internal | 1571 } } // namespace v8::internal |
OLD | NEW |