 Chromium Code Reviews
 Chromium Code Reviews Issue 10876067:
  Introduce global contexts to represent lexical global scope(s).  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 10876067:
  Introduce global contexts to represent lexical global scope(s).  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 for (int i = 0; i < locals_count; i++) { | 185 for (int i = 0; i < locals_count; i++) { | 
| 186 __ push(at); | 186 __ push(at); | 
| 187 } | 187 } | 
| 188 } | 188 } | 
| 189 | 189 | 
| 190 bool function_in_register = true; | 190 bool function_in_register = true; | 
| 191 | 191 | 
| 192 // Possibly allocate a local context. | 192 // Possibly allocate a local context. | 
| 193 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 193 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 
| 194 if (heap_slots > 0) { | 194 if (heap_slots > 0) { | 
| 195 Comment cmnt(masm_, "[ Allocate local context"); | 195 if (info->scope()->is_global_scope()) { | 
| 196 // Argument to NewContext is the function, which is in a1. | 196 Comment cmnt(masm_, "[ Allocate global context"); | 
| 197 __ push(a1); | 197 // 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 a1. Consider moving t
 
rossberg
2012/08/27 09:07:16
Done.
 | |
| 198 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 198 __ push(a1); | 
| 199 FastNewContextStub stub(heap_slots); | 199 __ Push(info->scope()->GetScopeInfo()); | 
| 200 __ CallStub(&stub); | 200 __ CallRuntime(Runtime::kNewGlobalContext, 2); | 
| 201 } else { | 201 } else { | 
| 202 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 202 Comment cmnt(masm_, "[ Allocate function context"); | 
| 203 // Argument to NewContext is the function, which is still in edi. | |
| 204 __ push(a1); | |
| 205 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | |
| 206 FastNewContextStub stub(heap_slots); | |
| 207 __ CallStub(&stub); | |
| 208 } else { | |
| 209 __ CallRuntime(Runtime::kNewFunctionContext, 1); | |
| 210 } | |
| 203 } | 211 } | 
| 204 function_in_register = false; | 212 function_in_register = false; | 
| 205 // Context is returned in both v0 and cp. It replaces the context | 213 // Context is returned in both v0 and cp. It replaces the context | 
| 206 // passed to us. It's saved in the stack and kept live in cp. | 214 // passed to us. It's saved in the stack and kept live in cp. | 
| 207 __ sw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 215 __ sw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 
| 208 // Copy any necessary parameters into the context. | 216 // Copy any necessary parameters into the context. | 
| 209 int num_parameters = info->scope()->num_parameters(); | 217 int num_parameters = info->scope()->num_parameters(); | 
| 210 for (int i = 0; i < num_parameters; i++) { | 218 for (int i = 0; i < num_parameters; i++) { | 
| 211 Variable* var = scope()->parameter(i); | 219 Variable* var = scope()->parameter(i); | 
| 212 if (var->IsContextSlot()) { | 220 if (var->IsContextSlot()) { | 
| (...skipping 4397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4610 *context_length = 0; | 4618 *context_length = 0; | 
| 4611 return previous_; | 4619 return previous_; | 
| 4612 } | 4620 } | 
| 4613 | 4621 | 
| 4614 | 4622 | 
| 4615 #undef __ | 4623 #undef __ | 
| 4616 | 4624 | 
| 4617 } } // namespace v8::internal | 4625 } } // namespace v8::internal | 
| 4618 | 4626 | 
| 4619 #endif // V8_TARGET_ARCH_MIPS | 4627 #endif // V8_TARGET_ARCH_MIPS | 
| OLD | NEW |