OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 19 matching lines...) Expand all Loading... |
30 #include "codegen-inl.h" | 30 #include "codegen-inl.h" |
31 #include "fast-codegen.h" | 31 #include "fast-codegen.h" |
32 | 32 |
33 namespace v8 { | 33 namespace v8 { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 #define __ ACCESS_MASM(masm()) | 36 #define __ ACCESS_MASM(masm()) |
37 | 37 |
38 void FastCodeGenerator::EmitLoadReceiver(Register reg) { | 38 void FastCodeGenerator::EmitLoadReceiver(Register reg) { |
39 // Offset 2 is due to return address and saved frame pointer. | 39 // Offset 2 is due to return address and saved frame pointer. |
40 int index = 2 + function()->scope()->num_parameters(); | 40 int index = 2 + scope()->num_parameters(); |
41 __ movq(reg, Operand(rbp, index * kPointerSize)); | 41 __ movq(reg, Operand(rbp, index * kPointerSize)); |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 void FastCodeGenerator::EmitReceiverMapCheck() { | 45 void FastCodeGenerator::EmitReceiverMapCheck() { |
46 Comment cmnt(masm(), ";; MapCheck(this)"); | 46 Comment cmnt(masm(), ";; MapCheck(this)"); |
47 if (FLAG_print_ir) { | 47 if (FLAG_print_ir) { |
48 PrintF("MapCheck(this)\n"); | 48 PrintF("MapCheck(this)\n"); |
49 } | 49 } |
50 | 50 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 __ movq(rcx, FieldOperand(rdx, JSObject::kPropertiesOffset)); | 95 __ movq(rcx, FieldOperand(rdx, JSObject::kPropertiesOffset)); |
96 } | 96 } |
97 // Perform the store. | 97 // Perform the store. |
98 __ movq(FieldOperand(rcx, offset), rax); | 98 __ movq(FieldOperand(rcx, offset), rax); |
99 // Preserve value from write barrier in case it's needed. | 99 // Preserve value from write barrier in case it's needed. |
100 __ movq(rbx, rax); | 100 __ movq(rbx, rax); |
101 __ RecordWrite(rcx, offset, rbx, rdi); | 101 __ RecordWrite(rcx, offset, rbx, rdi); |
102 } | 102 } |
103 | 103 |
104 | 104 |
105 void FastCodeGenerator::Generate(FunctionLiteral* fun, CompilationInfo* info) { | 105 void FastCodeGenerator::Generate(CompilationInfo* info) { |
106 ASSERT(function_ == NULL); | |
107 ASSERT(info_ == NULL); | 106 ASSERT(info_ == NULL); |
108 function_ = fun; | |
109 info_ = info; | 107 info_ = info; |
110 | 108 |
111 // Save the caller's frame pointer and set up our own. | 109 // Save the caller's frame pointer and set up our own. |
112 Comment prologue_cmnt(masm(), ";; Prologue"); | 110 Comment prologue_cmnt(masm(), ";; Prologue"); |
113 __ push(rbp); | 111 __ push(rbp); |
114 __ movq(rbp, rsp); | 112 __ movq(rbp, rsp); |
115 __ push(rsi); // Context. | 113 __ push(rsi); // Context. |
116 __ push(rdi); // Closure. | 114 __ push(rdi); // Closure. |
117 // Note that we keep a live register reference to esi (context) at this | 115 // Note that we keep a live register reference to esi (context) at this |
118 // point. | 116 // point. |
119 | 117 |
120 // Receiver (this) is allocated to rdx if there are this properties. | 118 // Receiver (this) is allocated to rdx if there are this properties. |
121 if (has_this_properties()) EmitReceiverMapCheck(); | 119 if (has_this_properties()) EmitReceiverMapCheck(); |
122 | 120 |
123 VisitStatements(fun->body()); | 121 VisitStatements(info->function()->body()); |
124 | 122 |
125 Comment return_cmnt(masm(), ";; Return(<undefined>)"); | 123 Comment return_cmnt(masm(), ";; Return(<undefined>)"); |
126 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | 124 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
127 | 125 |
128 Comment epilogue_cmnt(masm(), ";; Epilogue"); | 126 Comment epilogue_cmnt(masm(), ";; Epilogue"); |
129 __ movq(rsp, rbp); | 127 __ movq(rsp, rbp); |
130 __ pop(rbp); | 128 __ pop(rbp); |
131 __ ret((fun->scope()->num_parameters() + 1) * kPointerSize); | 129 __ ret((scope()->num_parameters() + 1) * kPointerSize); |
132 | 130 |
133 __ bind(&bailout_); | 131 __ bind(&bailout_); |
134 } | 132 } |
135 | 133 |
136 | 134 |
137 #undef __ | 135 #undef __ |
138 | 136 |
139 | 137 |
140 } } // namespace v8::internal | 138 } } // namespace v8::internal |
OLD | NEW |