| 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 5278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5289 } | 5289 } |
| 5290 } | 5290 } |
| 5291 } else { | 5291 } else { |
| 5292 UNREACHABLE(); | 5292 UNREACHABLE(); |
| 5293 } | 5293 } |
| 5294 } | 5294 } |
| 5295 } | 5295 } |
| 5296 | 5296 |
| 5297 | 5297 |
| 5298 void LCodeGen::DoFastLiteral(LFastLiteral* instr) { | 5298 void LCodeGen::DoFastLiteral(LFastLiteral* instr) { |
| 5299 int size = instr->hydrogen()->total_size(); | 5299 Handle<JSObject> result = instr->hydrogen()->boilerplate(); |
| 5300 ElementsKind boilerplate_elements_kind = | |
| 5301 instr->hydrogen()->boilerplate()->GetElementsKind(); | |
| 5302 | 5300 |
| 5303 // Deopt if the array literal boilerplate ElementsKind is of a type different | 5301 if (instr->hydrogen()->TransitionRequested()) { |
| 5304 // than the expected one. The check isn't necessary if the boilerplate has | 5302 ElementsKind to_kind = instr->hydrogen()->TransitionTo(); |
| 5305 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. | 5303 result = Runtime::DeepCopyBoilerplate(isolate(), |
| 5306 if (CanTransitionToMoreGeneralFastElementsKind( | 5304 instr->hydrogen()->boilerplate()); |
| 5307 boilerplate_elements_kind, true)) { | 5305 CHECK(!result.is_null()); |
| 5308 __ LoadHeapObject(r1, instr->hydrogen()->boilerplate()); | 5306 // Now transition the copy |
| 5309 // Load map into r2. | 5307 CHECK(!JSObject::TransitionElementsKind(result, to_kind).is_null()); |
| 5310 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); | 5308 } else { |
| 5311 // Load the map's "bit field 2". | 5309 ElementsKind boilerplate_elements_kind = result->GetElementsKind(); |
| 5312 __ ldrb(r2, FieldMemOperand(r2, Map::kBitField2Offset)); | 5310 |
| 5313 // Retrieve elements_kind from bit field 2. | 5311 // Deopt if the array literal boilerplate ElementsKind is of a type |
| 5314 __ ubfx(r2, r2, Map::kElementsKindShift, Map::kElementsKindBitCount); | 5312 // different than the expected one. The check isn't necessary if the |
| 5315 __ cmp(r2, Operand(boilerplate_elements_kind)); | 5313 // boilerplate has already been converted to TERMINAL_FAST_ELEMENTS_KIND. |
| 5316 DeoptimizeIf(ne, instr->environment()); | 5314 if (CanTransitionToMoreGeneralFastElementsKind( |
| 5315 boilerplate_elements_kind, true)) { |
| 5316 __ LoadHeapObject(r1, result); |
| 5317 // Load map into r2. |
| 5318 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); |
| 5319 // Load the map's "bit field 2". |
| 5320 __ ldrb(r2, FieldMemOperand(r2, Map::kBitField2Offset)); |
| 5321 // Retrieve elements_kind from bit field 2. |
| 5322 __ ubfx(r2, r2, Map::kElementsKindShift, Map::kElementsKindBitCount); |
| 5323 __ cmp(r2, Operand(boilerplate_elements_kind)); |
| 5324 DeoptimizeIf(ne, instr->environment()); |
| 5325 } |
| 5317 } | 5326 } |
| 5318 | 5327 |
| 5328 // We need to compute the size now. |
| 5329 int size = 0; |
| 5330 int max_properties = HFastLiteral::kMaxLiteralProperties; |
| 5331 HFastLiteral::IsFastLiteral(result, |
| 5332 HFastLiteral::kMaxLiteralDepth, |
| 5333 &max_properties, |
| 5334 &size); |
| 5335 |
| 5319 // Allocate all objects that are part of the literal in one big | 5336 // Allocate all objects that are part of the literal in one big |
| 5320 // allocation. This avoids multiple limit checks. | 5337 // allocation. This avoids multiple limit checks. |
| 5321 Label allocated, runtime_allocate; | 5338 Label allocated, runtime_allocate; |
| 5322 __ AllocateInNewSpace(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT); | 5339 __ AllocateInNewSpace(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT); |
| 5323 __ jmp(&allocated); | 5340 __ jmp(&allocated); |
| 5324 | 5341 |
| 5325 __ bind(&runtime_allocate); | 5342 __ bind(&runtime_allocate); |
| 5326 __ mov(r0, Operand(Smi::FromInt(size))); | 5343 __ mov(r0, Operand(Smi::FromInt(size))); |
| 5327 __ push(r0); | 5344 __ push(r0); |
| 5328 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); | 5345 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); |
| 5329 | 5346 |
| 5330 __ bind(&allocated); | 5347 __ bind(&allocated); |
| 5331 int offset = 0; | 5348 int offset = 0; |
| 5332 __ LoadHeapObject(r1, instr->hydrogen()->boilerplate()); | 5349 __ LoadHeapObject(r1, result); |
| 5333 EmitDeepCopy(instr->hydrogen()->boilerplate(), r0, r1, &offset); | 5350 EmitDeepCopy(result, r0, r1, &offset); |
| 5334 ASSERT_EQ(size, offset); | 5351 ASSERT_EQ(size, offset); |
| 5335 } | 5352 } |
| 5336 | 5353 |
| 5337 | 5354 |
| 5338 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { | 5355 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { |
| 5339 Handle<FixedArray> literals(instr->environment()->closure()->literals()); | 5356 Handle<FixedArray> literals(instr->environment()->closure()->literals()); |
| 5340 Handle<FixedArray> constant_properties = | 5357 Handle<FixedArray> constant_properties = |
| 5341 instr->hydrogen()->constant_properties(); | 5358 instr->hydrogen()->constant_properties(); |
| 5342 | 5359 |
| 5343 // Set up the parameters to the stub/runtime call. | 5360 // Set up the parameters to the stub/runtime call. |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5796 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); | 5813 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); |
| 5797 __ ldr(result, FieldMemOperand(scratch, | 5814 __ ldr(result, FieldMemOperand(scratch, |
| 5798 FixedArray::kHeaderSize - kPointerSize)); | 5815 FixedArray::kHeaderSize - kPointerSize)); |
| 5799 __ bind(&done); | 5816 __ bind(&done); |
| 5800 } | 5817 } |
| 5801 | 5818 |
| 5802 | 5819 |
| 5803 #undef __ | 5820 #undef __ |
| 5804 | 5821 |
| 5805 } } // namespace v8::internal | 5822 } } // namespace v8::internal |
| OLD | NEW |