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 2691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2702 | 2702 |
2703 | 2703 |
2704 void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) { | 2704 void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) { |
2705 #ifdef DEBUG | 2705 #ifdef DEBUG |
2706 int original_height = frame_->height(); | 2706 int original_height = frame_->height(); |
2707 #endif | 2707 #endif |
2708 VirtualFrame::SpilledScope spilled_scope; | 2708 VirtualFrame::SpilledScope spilled_scope; |
2709 Comment cmnt(masm_, "[ ObjectLiteral"); | 2709 Comment cmnt(masm_, "[ ObjectLiteral"); |
2710 | 2710 |
2711 // Load the function of this activation. | 2711 // Load the function of this activation. |
2712 __ ldr(r2, frame_->Function()); | 2712 __ ldr(r3, frame_->Function()); |
2713 // Literal array. | 2713 // Literal array. |
2714 __ ldr(r2, FieldMemOperand(r2, JSFunction::kLiteralsOffset)); | 2714 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); |
2715 // Literal index. | 2715 // Literal index. |
2716 __ mov(r1, Operand(Smi::FromInt(node->literal_index()))); | 2716 __ mov(r2, Operand(Smi::FromInt(node->literal_index()))); |
2717 // Constant properties. | 2717 // Constant properties. |
2718 __ mov(r0, Operand(node->constant_properties())); | 2718 __ mov(r1, Operand(node->constant_properties())); |
2719 frame_->EmitPushMultiple(3, r2.bit() | r1.bit() | r0.bit()); | 2719 // Should the object literal have fast elements? |
| 2720 __ mov(r0, Operand(Smi::FromInt(node->fast_elements() ? 1 : 0))); |
| 2721 frame_->EmitPushMultiple(4, r3.bit() | r2.bit() | r1.bit() | r0.bit()); |
2720 if (node->depth() > 1) { | 2722 if (node->depth() > 1) { |
2721 frame_->CallRuntime(Runtime::kCreateObjectLiteral, 3); | 2723 frame_->CallRuntime(Runtime::kCreateObjectLiteral, 4); |
2722 } else { | 2724 } else { |
2723 frame_->CallRuntime(Runtime::kCreateObjectLiteralShallow, 3); | 2725 frame_->CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); |
2724 } | 2726 } |
2725 frame_->EmitPush(r0); // save the result | 2727 frame_->EmitPush(r0); // save the result |
2726 for (int i = 0; i < node->properties()->length(); i++) { | 2728 for (int i = 0; i < node->properties()->length(); i++) { |
2727 // At the start of each iteration, the top of stack contains | 2729 // At the start of each iteration, the top of stack contains |
2728 // the newly created object literal. | 2730 // the newly created object literal. |
2729 ObjectLiteral::Property* property = node->properties()->at(i); | 2731 ObjectLiteral::Property* property = node->properties()->at(i); |
2730 Literal* key = property->key(); | 2732 Literal* key = property->key(); |
2731 Expression* value = property->value(); | 2733 Expression* value = property->value(); |
2732 switch (property->kind()) { | 2734 switch (property->kind()) { |
2733 case ObjectLiteral::Property::CONSTANT: | 2735 case ObjectLiteral::Property::CONSTANT: |
(...skipping 5221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7955 | 7957 |
7956 // Just jump to runtime to add the two strings. | 7958 // Just jump to runtime to add the two strings. |
7957 __ bind(&string_add_runtime); | 7959 __ bind(&string_add_runtime); |
7958 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); | 7960 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); |
7959 } | 7961 } |
7960 | 7962 |
7961 | 7963 |
7962 #undef __ | 7964 #undef __ |
7963 | 7965 |
7964 } } // namespace v8::internal | 7966 } } // namespace v8::internal |
OLD | NEW |