OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2711 __ mov(r1, Operand(Smi::FromInt(node->literal_index()))); | 2711 __ mov(r1, Operand(Smi::FromInt(node->literal_index()))); |
2712 // Constant properties. | 2712 // Constant properties. |
2713 __ mov(r0, Operand(node->constant_properties())); | 2713 __ mov(r0, Operand(node->constant_properties())); |
2714 frame_->EmitPushMultiple(3, r2.bit() | r1.bit() | r0.bit()); | 2714 frame_->EmitPushMultiple(3, r2.bit() | r1.bit() | r0.bit()); |
2715 if (node->depth() > 1) { | 2715 if (node->depth() > 1) { |
2716 frame_->CallRuntime(Runtime::kCreateObjectLiteral, 3); | 2716 frame_->CallRuntime(Runtime::kCreateObjectLiteral, 3); |
2717 } else { | 2717 } else { |
2718 frame_->CallRuntime(Runtime::kCreateObjectLiteralShallow, 3); | 2718 frame_->CallRuntime(Runtime::kCreateObjectLiteralShallow, 3); |
2719 } | 2719 } |
2720 frame_->EmitPush(r0); // save the result | 2720 frame_->EmitPush(r0); // save the result |
2721 // r0: created object literal | |
2722 | |
2723 for (int i = 0; i < node->properties()->length(); i++) { | 2721 for (int i = 0; i < node->properties()->length(); i++) { |
| 2722 // At the start of each iteration, the top of stack contains |
| 2723 // the newly created object literal. |
2724 ObjectLiteral::Property* property = node->properties()->at(i); | 2724 ObjectLiteral::Property* property = node->properties()->at(i); |
2725 Literal* key = property->key(); | 2725 Literal* key = property->key(); |
2726 Expression* value = property->value(); | 2726 Expression* value = property->value(); |
2727 switch (property->kind()) { | 2727 switch (property->kind()) { |
2728 case ObjectLiteral::Property::CONSTANT: | 2728 case ObjectLiteral::Property::CONSTANT: |
2729 break; | 2729 break; |
2730 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 2730 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
2731 if (CompileTimeValue::IsCompileTimeValue(property->value())) break; | 2731 if (CompileTimeValue::IsCompileTimeValue(property->value())) break; |
2732 // else fall through | 2732 // else fall through |
2733 case ObjectLiteral::Property::COMPUTED: // fall through | 2733 case ObjectLiteral::Property::COMPUTED: |
| 2734 if (key->handle()->IsSymbol()) { |
| 2735 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); |
| 2736 LoadAndSpill(value); |
| 2737 frame_->EmitPop(r0); |
| 2738 __ mov(r2, Operand(key->handle())); |
| 2739 __ ldr(r1, frame_->Top()); // Load the receiver. |
| 2740 frame_->CallCodeObject(ic, RelocInfo::CODE_TARGET, 0); |
| 2741 break; |
| 2742 } |
| 2743 // else fall through |
2734 case ObjectLiteral::Property::PROTOTYPE: { | 2744 case ObjectLiteral::Property::PROTOTYPE: { |
| 2745 __ ldr(r0, frame_->Top()); |
2735 frame_->EmitPush(r0); // dup the result | 2746 frame_->EmitPush(r0); // dup the result |
2736 LoadAndSpill(key); | 2747 LoadAndSpill(key); |
2737 LoadAndSpill(value); | 2748 LoadAndSpill(value); |
2738 frame_->CallRuntime(Runtime::kSetProperty, 3); | 2749 frame_->CallRuntime(Runtime::kSetProperty, 3); |
2739 // restore r0 | |
2740 __ ldr(r0, frame_->Top()); | |
2741 break; | 2750 break; |
2742 } | 2751 } |
2743 case ObjectLiteral::Property::SETTER: { | 2752 case ObjectLiteral::Property::SETTER: { |
| 2753 __ ldr(r0, frame_->Top()); |
2744 frame_->EmitPush(r0); | 2754 frame_->EmitPush(r0); |
2745 LoadAndSpill(key); | 2755 LoadAndSpill(key); |
2746 __ mov(r0, Operand(Smi::FromInt(1))); | 2756 __ mov(r0, Operand(Smi::FromInt(1))); |
2747 frame_->EmitPush(r0); | 2757 frame_->EmitPush(r0); |
2748 LoadAndSpill(value); | 2758 LoadAndSpill(value); |
2749 frame_->CallRuntime(Runtime::kDefineAccessor, 4); | 2759 frame_->CallRuntime(Runtime::kDefineAccessor, 4); |
2750 __ ldr(r0, frame_->Top()); | |
2751 break; | 2760 break; |
2752 } | 2761 } |
2753 case ObjectLiteral::Property::GETTER: { | 2762 case ObjectLiteral::Property::GETTER: { |
| 2763 __ ldr(r0, frame_->Top()); |
2754 frame_->EmitPush(r0); | 2764 frame_->EmitPush(r0); |
2755 LoadAndSpill(key); | 2765 LoadAndSpill(key); |
2756 __ mov(r0, Operand(Smi::FromInt(0))); | 2766 __ mov(r0, Operand(Smi::FromInt(0))); |
2757 frame_->EmitPush(r0); | 2767 frame_->EmitPush(r0); |
2758 LoadAndSpill(value); | 2768 LoadAndSpill(value); |
2759 frame_->CallRuntime(Runtime::kDefineAccessor, 4); | 2769 frame_->CallRuntime(Runtime::kDefineAccessor, 4); |
2760 __ ldr(r0, frame_->Top()); | |
2761 break; | 2770 break; |
2762 } | 2771 } |
2763 } | 2772 } |
2764 } | 2773 } |
2765 ASSERT(frame_->height() == original_height + 1); | 2774 ASSERT(frame_->height() == original_height + 1); |
2766 } | 2775 } |
2767 | 2776 |
2768 | 2777 |
2769 void CodeGenerator::VisitArrayLiteral(ArrayLiteral* node) { | 2778 void CodeGenerator::VisitArrayLiteral(ArrayLiteral* node) { |
2770 #ifdef DEBUG | 2779 #ifdef DEBUG |
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4381 break; | 4390 break; |
4382 } | 4391 } |
4383 | 4392 |
4384 case NAMED: { | 4393 case NAMED: { |
4385 Comment cmnt(masm, "[ Store to named Property"); | 4394 Comment cmnt(masm, "[ Store to named Property"); |
4386 // Call the appropriate IC code. | 4395 // Call the appropriate IC code. |
4387 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 4396 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); |
4388 Handle<String> name(GetName()); | 4397 Handle<String> name(GetName()); |
4389 | 4398 |
4390 frame->EmitPop(r0); | 4399 frame->EmitPop(r0); |
4391 // Setup the name register. | 4400 frame->EmitPop(r1); |
4392 __ mov(r2, Operand(name)); | 4401 __ mov(r2, Operand(name)); |
4393 frame->CallCodeObject(ic, RelocInfo::CODE_TARGET, 0); | 4402 frame->CallCodeObject(ic, RelocInfo::CODE_TARGET, 0); |
4394 frame->EmitPush(r0); | 4403 frame->EmitPush(r0); |
4395 cgen_->UnloadReference(this); | 4404 set_unloaded(); |
4396 break; | 4405 break; |
4397 } | 4406 } |
4398 | 4407 |
4399 case KEYED: { | 4408 case KEYED: { |
4400 Comment cmnt(masm, "[ Store to keyed Property"); | 4409 Comment cmnt(masm, "[ Store to keyed Property"); |
4401 Property* property = expression_->AsProperty(); | 4410 Property* property = expression_->AsProperty(); |
4402 ASSERT(property != NULL); | 4411 ASSERT(property != NULL); |
4403 cgen_->CodeForSourcePosition(property->position()); | 4412 cgen_->CodeForSourcePosition(property->position()); |
4404 | 4413 |
4405 // Call IC code. | 4414 // Call IC code. |
(...skipping 3054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7460 | 7469 |
7461 // Just jump to runtime to add the two strings. | 7470 // Just jump to runtime to add the two strings. |
7462 __ bind(&string_add_runtime); | 7471 __ bind(&string_add_runtime); |
7463 __ TailCallRuntime(ExternalReference(Runtime::kStringAdd), 2, 1); | 7472 __ TailCallRuntime(ExternalReference(Runtime::kStringAdd), 2, 1); |
7464 } | 7473 } |
7465 | 7474 |
7466 | 7475 |
7467 #undef __ | 7476 #undef __ |
7468 | 7477 |
7469 } } // namespace v8::internal | 7478 } } // namespace v8::internal |
OLD | NEW |