| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 6062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6073 CallRuntimeFromDeferred( | 6073 CallRuntimeFromDeferred( |
| 6074 Runtime::kAllocateInOldPointerSpace, 1, instr, instr->context()); | 6074 Runtime::kAllocateInOldPointerSpace, 1, instr, instr->context()); |
| 6075 } else { | 6075 } else { |
| 6076 CallRuntimeFromDeferred( | 6076 CallRuntimeFromDeferred( |
| 6077 Runtime::kAllocateInNewSpace, 1, instr, instr->context()); | 6077 Runtime::kAllocateInNewSpace, 1, instr, instr->context()); |
| 6078 } | 6078 } |
| 6079 __ StoreToSafepointRegisterSlot(result, eax); | 6079 __ StoreToSafepointRegisterSlot(result, eax); |
| 6080 } | 6080 } |
| 6081 | 6081 |
| 6082 | 6082 |
| 6083 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | |
| 6084 ASSERT(ToRegister(instr->context()).is(esi)); | |
| 6085 Handle<FixedArray> literals = instr->hydrogen()->literals(); | |
| 6086 ElementsKind boilerplate_elements_kind = | |
| 6087 instr->hydrogen()->boilerplate_elements_kind(); | |
| 6088 AllocationSiteMode allocation_site_mode = | |
| 6089 instr->hydrogen()->allocation_site_mode(); | |
| 6090 | |
| 6091 // Deopt if the array literal boilerplate ElementsKind is of a type different | |
| 6092 // than the expected one. The check isn't necessary if the boilerplate has | |
| 6093 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. | |
| 6094 if (CanTransitionToMoreGeneralFastElementsKind( | |
| 6095 boilerplate_elements_kind, true)) { | |
| 6096 __ LoadHeapObject(eax, instr->hydrogen()->boilerplate_object()); | |
| 6097 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | |
| 6098 // Load the map's "bit field 2". We only need the first byte, | |
| 6099 // but the following masking takes care of that anyway. | |
| 6100 __ mov(ebx, FieldOperand(ebx, Map::kBitField2Offset)); | |
| 6101 // Retrieve elements_kind from bit field 2. | |
| 6102 __ and_(ebx, Map::kElementsKindMask); | |
| 6103 __ cmp(ebx, boilerplate_elements_kind << Map::kElementsKindShift); | |
| 6104 DeoptimizeIf(not_equal, instr->environment()); | |
| 6105 } | |
| 6106 | |
| 6107 // Set up the parameters to the stub/runtime call and pick the right | |
| 6108 // runtime function or stub to call. Boilerplate already exists, | |
| 6109 // constant elements are never accessed, pass an empty fixed array. | |
| 6110 int length = instr->hydrogen()->length(); | |
| 6111 if (instr->hydrogen()->IsCopyOnWrite()) { | |
| 6112 ASSERT(instr->hydrogen()->depth() == 1); | |
| 6113 __ LoadHeapObject(eax, literals); | |
| 6114 __ mov(ebx, Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); | |
| 6115 __ mov(ecx, Immediate(isolate()->factory()->empty_fixed_array())); | |
| 6116 FastCloneShallowArrayStub::Mode mode = | |
| 6117 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; | |
| 6118 FastCloneShallowArrayStub stub(mode, DONT_TRACK_ALLOCATION_SITE, length); | |
| 6119 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | |
| 6120 } else if (instr->hydrogen()->depth() > 1) { | |
| 6121 __ PushHeapObject(literals); | |
| 6122 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); | |
| 6123 __ push(Immediate(isolate()->factory()->empty_fixed_array())); | |
| 6124 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); | |
| 6125 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | |
| 6126 __ PushHeapObject(literals); | |
| 6127 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); | |
| 6128 __ push(Immediate(isolate()->factory()->empty_fixed_array())); | |
| 6129 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); | |
| 6130 } else { | |
| 6131 __ LoadHeapObject(eax, literals); | |
| 6132 __ mov(ebx, Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); | |
| 6133 __ mov(ecx, Immediate(isolate()->factory()->empty_fixed_array())); | |
| 6134 FastCloneShallowArrayStub::Mode mode = | |
| 6135 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS | |
| 6136 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | |
| 6137 : FastCloneShallowArrayStub::CLONE_ELEMENTS; | |
| 6138 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); | |
| 6139 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | |
| 6140 } | |
| 6141 } | |
| 6142 | |
| 6143 | |
| 6144 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { | 6083 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { |
| 6145 ASSERT(ToRegister(instr->value()).is(eax)); | 6084 ASSERT(ToRegister(instr->value()).is(eax)); |
| 6146 __ push(eax); | 6085 __ push(eax); |
| 6147 CallRuntime(Runtime::kToFastProperties, 1, instr); | 6086 CallRuntime(Runtime::kToFastProperties, 1, instr); |
| 6148 } | 6087 } |
| 6149 | 6088 |
| 6150 | 6089 |
| 6151 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { | 6090 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { |
| 6152 ASSERT(ToRegister(instr->context()).is(esi)); | 6091 ASSERT(ToRegister(instr->context()).is(esi)); |
| 6153 Label materialized; | 6092 Label materialized; |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6575 FixedArray::kHeaderSize - kPointerSize)); | 6514 FixedArray::kHeaderSize - kPointerSize)); |
| 6576 __ bind(&done); | 6515 __ bind(&done); |
| 6577 } | 6516 } |
| 6578 | 6517 |
| 6579 | 6518 |
| 6580 #undef __ | 6519 #undef __ |
| 6581 | 6520 |
| 6582 } } // namespace v8::internal | 6521 } } // namespace v8::internal |
| 6583 | 6522 |
| 6584 #endif // V8_TARGET_ARCH_IA32 | 6523 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |