OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 return Operand(eax); | 448 return Operand(eax); |
449 } | 449 } |
450 } | 450 } |
451 | 451 |
452 | 452 |
453 Operand CodeGenerator::ContextSlotOperandCheckExtensions(Slot* slot, | 453 Operand CodeGenerator::ContextSlotOperandCheckExtensions(Slot* slot, |
454 Register tmp, | 454 Register tmp, |
455 Label* slow) { | 455 Label* slow) { |
456 ASSERT(slot->type() == Slot::CONTEXT); | 456 ASSERT(slot->type() == Slot::CONTEXT); |
457 int index = slot->index(); | 457 int index = slot->index(); |
458 __ mov(tmp, Operand(esi)); | 458 Register context = esi; |
459 for (Scope* s = scope(); s != slot->var()->scope(); s = s->outer_scope()) { | 459 for (Scope* s = scope(); s != slot->var()->scope(); s = s->outer_scope()) { |
460 if (s->num_heap_slots() > 0) { | 460 if (s->num_heap_slots() > 0) { |
461 if (s->calls_eval()) { | 461 if (s->calls_eval()) { |
462 // Check that extension is NULL. | 462 // Check that extension is NULL. |
463 __ cmp(ContextOperand(tmp, Context::EXTENSION_INDEX), Immediate(0)); | 463 __ cmp(ContextOperand(context, Context::EXTENSION_INDEX), Immediate(0)); |
464 __ j(not_equal, slow, not_taken); | 464 __ j(not_equal, slow, not_taken); |
465 } | 465 } |
466 __ mov(tmp, ContextOperand(tmp, Context::CLOSURE_INDEX)); | 466 __ mov(tmp, ContextOperand(context, Context::CLOSURE_INDEX)); |
467 __ mov(tmp, FieldOperand(tmp, JSFunction::kContextOffset)); | 467 __ mov(tmp, FieldOperand(tmp, JSFunction::kContextOffset)); |
| 468 context = tmp; |
468 } | 469 } |
469 } | 470 } |
470 // Check that last extension is NULL. | 471 // Check that last extension is NULL. |
471 __ cmp(ContextOperand(tmp, Context::EXTENSION_INDEX), Immediate(0)); | 472 __ cmp(ContextOperand(tmp, Context::EXTENSION_INDEX), Immediate(0)); |
472 __ j(not_equal, slow, not_taken); | 473 __ j(not_equal, slow, not_taken); |
473 __ mov(tmp, ContextOperand(tmp, Context::FCONTEXT_INDEX)); | 474 __ mov(tmp, ContextOperand(tmp, Context::FCONTEXT_INDEX)); |
474 return ContextOperand(tmp, index); | 475 return ContextOperand(tmp, index); |
475 } | 476 } |
476 | 477 |
477 | 478 |
(...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2405 } | 2406 } |
2406 } | 2407 } |
2407 | 2408 |
2408 | 2409 |
2409 void CodeGenerator::LoadFromGlobalSlotCheckExtensions(Slot* slot, | 2410 void CodeGenerator::LoadFromGlobalSlotCheckExtensions(Slot* slot, |
2410 TypeofState typeof_state, | 2411 TypeofState typeof_state, |
2411 Register tmp, | 2412 Register tmp, |
2412 Label* slow) { | 2413 Label* slow) { |
2413 // Check that no extension objects have been created by calls to | 2414 // Check that no extension objects have been created by calls to |
2414 // eval from the current scope to the global scope. | 2415 // eval from the current scope to the global scope. |
2415 __ mov(tmp, Operand(esi)); | 2416 Register context = esi; |
2416 for (Scope* s = scope(); s != NULL; s = s->outer_scope()) { | 2417 for (Scope* s = scope(); s != NULL; s = s->outer_scope()) { |
2417 if (s->num_heap_slots() > 0) { | 2418 if (s->num_heap_slots() > 0) { |
2418 if (s->calls_eval()) { | 2419 if (s->calls_eval()) { |
2419 // Check that extension is NULL. | 2420 // Check that extension is NULL. |
2420 __ cmp(ContextOperand(tmp, Context::EXTENSION_INDEX), Immediate(0)); | 2421 __ cmp(ContextOperand(context, Context::EXTENSION_INDEX), Immediate(0)); |
2421 __ j(not_equal, slow, not_taken); | 2422 __ j(not_equal, slow, not_taken); |
2422 } | 2423 } |
2423 // Load next context in chain. | 2424 // Load next context in chain. |
2424 __ mov(tmp, ContextOperand(tmp, Context::CLOSURE_INDEX)); | 2425 __ mov(tmp, ContextOperand(context, Context::CLOSURE_INDEX)); |
2425 __ mov(tmp, FieldOperand(tmp, JSFunction::kContextOffset)); | 2426 __ mov(tmp, FieldOperand(tmp, JSFunction::kContextOffset)); |
| 2427 context = tmp; |
2426 } | 2428 } |
2427 // If no outer scope calls eval, we do not need to check more | 2429 // If no outer scope calls eval, we do not need to check more |
2428 // context extensions. | 2430 // context extensions. |
2429 if (!s->outer_scope_calls_eval()) break; | 2431 if (!s->outer_scope_calls_eval()) break; |
2430 } | 2432 } |
2431 | 2433 |
2432 // All extension objects were empty and it is safe to use a global | 2434 // All extension objects were empty and it is safe to use a global |
2433 // load IC call. | 2435 // load IC call. |
2434 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 2436 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
2435 // Load the global object. | 2437 // Load the global object. |
(...skipping 2984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5420 | 5422 |
5421 // Slow-case: Go through the JavaScript implementation. | 5423 // Slow-case: Go through the JavaScript implementation. |
5422 __ bind(&slow); | 5424 __ bind(&slow); |
5423 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 5425 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
5424 } | 5426 } |
5425 | 5427 |
5426 | 5428 |
5427 #undef __ | 5429 #undef __ |
5428 | 5430 |
5429 } } // namespace v8::internal | 5431 } } // namespace v8::internal |
OLD | NEW |