OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 VisitForStackValue(function); | 705 VisitForStackValue(function); |
706 } else { | 706 } else { |
707 __ push(Immediate(Smi::FromInt(0))); // No initial value! | 707 __ push(Immediate(Smi::FromInt(0))); // No initial value! |
708 } | 708 } |
709 __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 709 __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
710 break; | 710 break; |
711 } | 711 } |
712 } | 712 } |
713 | 713 |
714 } else if (prop != NULL) { | 714 } else if (prop != NULL) { |
715 if (function != NULL || mode == Variable::CONST) { | 715 // A const declaration aliasing a parameter is a illegal redeclaration. |
716 // We are declaring a function or constant that rewrites to a | 716 ASSERT(mode != Variable::CONST); |
717 // property. Use (keyed) IC to set the initial value. We cannot | 717 // Do nothing for a regular var declaration. |
718 // visit the rewrite because it's shared and we risk recording | 718 // Store the function for a function declaration. |
719 // duplicate AST IDs for bailouts from optimized code. | 719 if (function != NULL) { |
| 720 // We are declaring a function that rewrites to a property. |
| 721 // Use (keyed) IC to set the initial value. We cannot visit the |
| 722 // rewrite because it's shared and we risk recording duplicate AST |
| 723 // IDs for bailouts from optimized code. |
720 ASSERT(prop->obj()->AsVariableProxy() != NULL); | 724 ASSERT(prop->obj()->AsVariableProxy() != NULL); |
721 { AccumulatorValueContext for_object(this); | 725 { AccumulatorValueContext for_object(this); |
722 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); | 726 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); |
723 } | 727 } |
724 | 728 |
725 if (function != NULL) { | 729 __ push(eax); |
726 __ push(eax); | 730 VisitForAccumulatorValue(function); |
727 VisitForAccumulatorValue(function); | 731 __ pop(edx); |
728 __ pop(edx); | 732 |
729 } else { | |
730 __ mov(edx, eax); | |
731 __ mov(eax, isolate()->factory()->the_hole_value()); | |
732 } | |
733 ASSERT(prop->key()->AsLiteral() != NULL && | 733 ASSERT(prop->key()->AsLiteral() != NULL && |
734 prop->key()->AsLiteral()->handle()->IsSmi()); | 734 prop->key()->AsLiteral()->handle()->IsSmi()); |
735 __ SafeSet(ecx, Immediate(prop->key()->AsLiteral()->handle())); | 735 __ SafeSet(ecx, Immediate(prop->key()->AsLiteral()->handle())); |
736 | 736 |
737 Handle<Code> ic = is_strict_mode() | 737 Handle<Code> ic = is_strict_mode() |
738 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() | 738 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() |
739 : isolate()->builtins()->KeyedStoreIC_Initialize(); | 739 : isolate()->builtins()->KeyedStoreIC_Initialize(); |
740 EmitCallIC(ic, RelocInfo::CODE_TARGET, AstNode::kNoNumber); | 740 EmitCallIC(ic, RelocInfo::CODE_TARGET, AstNode::kNoNumber); |
741 } | 741 } |
742 } | 742 } |
(...skipping 3572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4315 // And return. | 4315 // And return. |
4316 __ ret(0); | 4316 __ ret(0); |
4317 } | 4317 } |
4318 | 4318 |
4319 | 4319 |
4320 #undef __ | 4320 #undef __ |
4321 | 4321 |
4322 } } // namespace v8::internal | 4322 } } // namespace v8::internal |
4323 | 4323 |
4324 #endif // V8_TARGET_ARCH_IA32 | 4324 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |