OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, | 1215 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, |
1216 TypeofMode typeof_mode, | 1216 TypeofMode typeof_mode, |
1217 Label* slow) { | 1217 Label* slow) { |
1218 Register context = rsi; | 1218 Register context = rsi; |
1219 Register temp = rdx; | 1219 Register temp = rdx; |
1220 | 1220 |
1221 Scope* s = scope(); | 1221 Scope* s = scope(); |
1222 while (s != NULL) { | 1222 while (s != NULL) { |
1223 if (s->num_heap_slots() > 0) { | 1223 if (s->num_heap_slots() > 0) { |
1224 if (s->calls_sloppy_eval()) { | 1224 if (s->calls_sloppy_eval()) { |
1225 // Check that extension is NULL. | 1225 // Check that extension is "the hole". |
1226 __ cmpp(ContextOperand(context, Context::EXTENSION_INDEX), | 1226 __ JumpIfNotRoot(ContextOperand(context, Context::EXTENSION_INDEX), |
1227 Immediate(0)); | 1227 Heap::kTheHoleValueRootIndex, slow); |
1228 __ j(not_equal, slow); | |
1229 } | 1228 } |
1230 // Load next context in chain. | 1229 // Load next context in chain. |
1231 __ movp(temp, ContextOperand(context, Context::PREVIOUS_INDEX)); | 1230 __ movp(temp, ContextOperand(context, Context::PREVIOUS_INDEX)); |
1232 // Walk the rest of the chain without clobbering rsi. | 1231 // Walk the rest of the chain without clobbering rsi. |
1233 context = temp; | 1232 context = temp; |
1234 } | 1233 } |
1235 // If no outer scope calls eval, we do not need to check more | 1234 // If no outer scope calls eval, we do not need to check more |
1236 // context extensions. If we have reached an eval scope, we check | 1235 // context extensions. If we have reached an eval scope, we check |
1237 // all extensions from this point. | 1236 // all extensions from this point. |
1238 if (!s->outer_scope_calls_sloppy_eval() || s->is_eval_scope()) break; | 1237 if (!s->outer_scope_calls_sloppy_eval() || s->is_eval_scope()) break; |
1239 s = s->outer_scope(); | 1238 s = s->outer_scope(); |
1240 } | 1239 } |
1241 | 1240 |
1242 if (s != NULL && s->is_eval_scope()) { | 1241 if (s != NULL && s->is_eval_scope()) { |
1243 // Loop up the context chain. There is no frame effect so it is | 1242 // Loop up the context chain. There is no frame effect so it is |
1244 // safe to use raw labels here. | 1243 // safe to use raw labels here. |
1245 Label next, fast; | 1244 Label next, fast; |
1246 if (!context.is(temp)) { | 1245 if (!context.is(temp)) { |
1247 __ movp(temp, context); | 1246 __ movp(temp, context); |
1248 } | 1247 } |
1249 // Load map for comparison into register, outside loop. | 1248 // Load map for comparison into register, outside loop. |
1250 __ LoadRoot(kScratchRegister, Heap::kNativeContextMapRootIndex); | 1249 __ LoadRoot(kScratchRegister, Heap::kNativeContextMapRootIndex); |
1251 __ bind(&next); | 1250 __ bind(&next); |
1252 // Terminate at native context. | 1251 // Terminate at native context. |
1253 __ cmpp(kScratchRegister, FieldOperand(temp, HeapObject::kMapOffset)); | 1252 __ cmpp(kScratchRegister, FieldOperand(temp, HeapObject::kMapOffset)); |
1254 __ j(equal, &fast, Label::kNear); | 1253 __ j(equal, &fast, Label::kNear); |
1255 // Check that extension is NULL. | 1254 // Check that extension is "the hole". |
1256 __ cmpp(ContextOperand(temp, Context::EXTENSION_INDEX), Immediate(0)); | 1255 __ JumpIfNotRoot(ContextOperand(temp, Context::EXTENSION_INDEX), |
1257 __ j(not_equal, slow); | 1256 Heap::kTheHoleValueRootIndex, slow); |
1258 // Load next context in chain. | 1257 // Load next context in chain. |
1259 __ movp(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); | 1258 __ movp(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); |
1260 __ jmp(&next); | 1259 __ jmp(&next); |
1261 __ bind(&fast); | 1260 __ bind(&fast); |
1262 } | 1261 } |
1263 | 1262 |
1264 // All extension objects were empty and it is safe to use a normal global | 1263 // All extension objects were empty and it is safe to use a normal global |
1265 // load machinery. | 1264 // load machinery. |
1266 EmitGlobalVariableLoad(proxy, typeof_mode); | 1265 EmitGlobalVariableLoad(proxy, typeof_mode); |
1267 } | 1266 } |
1268 | 1267 |
1269 | 1268 |
1270 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, | 1269 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, |
1271 Label* slow) { | 1270 Label* slow) { |
1272 DCHECK(var->IsContextSlot()); | 1271 DCHECK(var->IsContextSlot()); |
1273 Register context = rsi; | 1272 Register context = rsi; |
1274 Register temp = rbx; | 1273 Register temp = rbx; |
1275 | 1274 |
1276 for (Scope* s = scope(); s != var->scope(); s = s->outer_scope()) { | 1275 for (Scope* s = scope(); s != var->scope(); s = s->outer_scope()) { |
1277 if (s->num_heap_slots() > 0) { | 1276 if (s->num_heap_slots() > 0) { |
1278 if (s->calls_sloppy_eval()) { | 1277 if (s->calls_sloppy_eval()) { |
1279 // Check that extension is NULL. | 1278 // Check that extension is "the hole". |
1280 __ cmpp(ContextOperand(context, Context::EXTENSION_INDEX), | 1279 __ JumpIfNotRoot(ContextOperand(context, Context::EXTENSION_INDEX), |
1281 Immediate(0)); | 1280 Heap::kTheHoleValueRootIndex, slow); |
1282 __ j(not_equal, slow); | |
1283 } | 1281 } |
1284 __ movp(temp, ContextOperand(context, Context::PREVIOUS_INDEX)); | 1282 __ movp(temp, ContextOperand(context, Context::PREVIOUS_INDEX)); |
1285 // Walk the rest of the chain without clobbering rsi. | 1283 // Walk the rest of the chain without clobbering rsi. |
1286 context = temp; | 1284 context = temp; |
1287 } | 1285 } |
1288 } | 1286 } |
1289 // Check that last extension is NULL. | 1287 // Check that last extension is "the hole". |
1290 __ cmpp(ContextOperand(context, Context::EXTENSION_INDEX), Immediate(0)); | 1288 __ JumpIfNotRoot(ContextOperand(context, Context::EXTENSION_INDEX), |
1291 __ j(not_equal, slow); | 1289 Heap::kTheHoleValueRootIndex, slow); |
1292 | 1290 |
1293 // This function is used only for loads, not stores, so it's safe to | 1291 // This function is used only for loads, not stores, so it's safe to |
1294 // return an rsi-based operand (the write barrier cannot be allowed to | 1292 // return an rsi-based operand (the write barrier cannot be allowed to |
1295 // destroy the rsi register). | 1293 // destroy the rsi register). |
1296 return ContextOperand(context, var->index()); | 1294 return ContextOperand(context, var->index()); |
1297 } | 1295 } |
1298 | 1296 |
1299 | 1297 |
1300 void FullCodeGenerator::EmitDynamicLookupFastCase(VariableProxy* proxy, | 1298 void FullCodeGenerator::EmitDynamicLookupFastCase(VariableProxy* proxy, |
1301 TypeofMode typeof_mode, | 1299 TypeofMode typeof_mode, |
(...skipping 3579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4881 Assembler::target_address_at(call_target_address, | 4879 Assembler::target_address_at(call_target_address, |
4882 unoptimized_code)); | 4880 unoptimized_code)); |
4883 return OSR_AFTER_STACK_CHECK; | 4881 return OSR_AFTER_STACK_CHECK; |
4884 } | 4882 } |
4885 | 4883 |
4886 | 4884 |
4887 } // namespace internal | 4885 } // namespace internal |
4888 } // namespace v8 | 4886 } // namespace v8 |
4889 | 4887 |
4890 #endif // V8_TARGET_ARCH_X64 | 4888 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |