OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 __ push(rdx); | 167 __ push(rdx); |
168 } | 168 } |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 bool function_in_register = true; | 172 bool function_in_register = true; |
173 | 173 |
174 // Possibly allocate a local context. | 174 // Possibly allocate a local context. |
175 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 175 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
176 if (heap_slots > 0) { | 176 if (heap_slots > 0) { |
177 Comment cmnt(masm_, "[ Allocate local context"); | 177 if (info->scope()->is_global_scope()) { |
178 // Argument to NewContext is the function, which is still in rdi. | 178 Comment cmnt(masm_, "[ Allocate global context"); |
179 __ push(rdi); | 179 // Argument to NewContext is the function, which is still in edi. |
Sven Panne
2012/08/27 06:24:54
copy-n-paste typo: should be rdi. Consider moving
rossberg
2012/08/27 09:07:16
Done.
| |
180 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 180 __ push(rdi); |
181 FastNewContextStub stub(heap_slots); | 181 __ Push(info->scope()->GetScopeInfo()); |
182 __ CallStub(&stub); | 182 __ CallRuntime(Runtime::kNewGlobalContext, 2); |
183 } else { | 183 } else { |
184 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 184 Comment cmnt(masm_, "[ Allocate function context"); |
185 // Argument to NewContext is the function, which is still in edi. | |
186 __ push(rdi); | |
187 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | |
188 FastNewContextStub stub(heap_slots); | |
189 __ CallStub(&stub); | |
190 } else { | |
191 __ CallRuntime(Runtime::kNewFunctionContext, 1); | |
192 } | |
185 } | 193 } |
186 function_in_register = false; | 194 function_in_register = false; |
187 // Context is returned in both rax and rsi. It replaces the context | 195 // Context is returned in both rax and rsi. It replaces the context |
188 // passed to us. It's saved in the stack and kept live in rsi. | 196 // passed to us. It's saved in the stack and kept live in rsi. |
189 __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi); | 197 __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi); |
190 | 198 |
191 // Copy any necessary parameters into the context. | 199 // Copy any necessary parameters into the context. |
192 int num_parameters = info->scope()->num_parameters(); | 200 int num_parameters = info->scope()->num_parameters(); |
193 for (int i = 0; i < num_parameters; i++) { | 201 for (int i = 0; i < num_parameters; i++) { |
194 Variable* var = scope()->parameter(i); | 202 Variable* var = scope()->parameter(i); |
(...skipping 4345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4540 *context_length = 0; | 4548 *context_length = 0; |
4541 return previous_; | 4549 return previous_; |
4542 } | 4550 } |
4543 | 4551 |
4544 | 4552 |
4545 #undef __ | 4553 #undef __ |
4546 | 4554 |
4547 } } // namespace v8::internal | 4555 } } // namespace v8::internal |
4548 | 4556 |
4549 #endif // V8_TARGET_ARCH_X64 | 4557 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |