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 5473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5484 CallRuntimeFromDeferred( | 5484 CallRuntimeFromDeferred( |
5485 Runtime::kAllocateInOldPointerSpace, 1, instr); | 5485 Runtime::kAllocateInOldPointerSpace, 1, instr); |
5486 } else { | 5486 } else { |
5487 CallRuntimeFromDeferred( | 5487 CallRuntimeFromDeferred( |
5488 Runtime::kAllocateInNewSpace, 1, instr); | 5488 Runtime::kAllocateInNewSpace, 1, instr); |
5489 } | 5489 } |
5490 __ StoreToSafepointRegisterSlot(r0, result); | 5490 __ StoreToSafepointRegisterSlot(r0, result); |
5491 } | 5491 } |
5492 | 5492 |
5493 | 5493 |
5494 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | |
5495 Handle<FixedArray> literals = instr->hydrogen()->literals(); | |
5496 ElementsKind boilerplate_elements_kind = | |
5497 instr->hydrogen()->boilerplate_elements_kind(); | |
5498 AllocationSiteMode allocation_site_mode = | |
5499 instr->hydrogen()->allocation_site_mode(); | |
5500 | |
5501 // Deopt if the array literal boilerplate ElementsKind is of a type different | |
5502 // than the expected one. The check isn't necessary if the boilerplate has | |
5503 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. | |
5504 if (CanTransitionToMoreGeneralFastElementsKind( | |
5505 boilerplate_elements_kind, true)) { | |
5506 __ LoadHeapObject(r1, instr->hydrogen()->boilerplate_object()); | |
5507 // Load map into r2. | |
5508 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); | |
5509 // Load the map's "bit field 2". | |
5510 __ ldrb(r2, FieldMemOperand(r2, Map::kBitField2Offset)); | |
5511 // Retrieve elements_kind from bit field 2. | |
5512 __ ubfx(r2, r2, Map::kElementsKindShift, Map::kElementsKindBitCount); | |
5513 __ cmp(r2, Operand(boilerplate_elements_kind)); | |
5514 DeoptimizeIf(ne, instr->environment()); | |
5515 } | |
5516 | |
5517 // Set up the parameters to the stub/runtime call. | |
5518 __ LoadHeapObject(r3, literals); | |
5519 __ mov(r2, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); | |
5520 // Boilerplate already exists, constant elements are never accessed. | |
5521 // Pass an empty fixed array. | |
5522 __ mov(r1, Operand(isolate()->factory()->empty_fixed_array())); | |
5523 | |
5524 // Pick the right runtime function or stub to call. | |
5525 int length = instr->hydrogen()->length(); | |
5526 if (instr->hydrogen()->IsCopyOnWrite()) { | |
5527 ASSERT(instr->hydrogen()->depth() == 1); | |
5528 FastCloneShallowArrayStub::Mode mode = | |
5529 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; | |
5530 FastCloneShallowArrayStub stub(mode, DONT_TRACK_ALLOCATION_SITE, length); | |
5531 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | |
5532 } else if (instr->hydrogen()->depth() > 1) { | |
5533 __ Push(r3, r2, r1); | |
5534 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); | |
5535 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | |
5536 __ Push(r3, r2, r1); | |
5537 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); | |
5538 } else { | |
5539 FastCloneShallowArrayStub::Mode mode = | |
5540 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS | |
5541 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | |
5542 : FastCloneShallowArrayStub::CLONE_ELEMENTS; | |
5543 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); | |
5544 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | |
5545 } | |
5546 } | |
5547 | |
5548 | |
5549 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { | 5494 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { |
5550 ASSERT(ToRegister(instr->value()).is(r0)); | 5495 ASSERT(ToRegister(instr->value()).is(r0)); |
5551 __ push(r0); | 5496 __ push(r0); |
5552 CallRuntime(Runtime::kToFastProperties, 1, instr); | 5497 CallRuntime(Runtime::kToFastProperties, 1, instr); |
5553 } | 5498 } |
5554 | 5499 |
5555 | 5500 |
5556 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { | 5501 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { |
5557 Label materialized; | 5502 Label materialized; |
5558 // Registers will be used as follows: | 5503 // Registers will be used as follows: |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5979 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); | 5924 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); |
5980 __ ldr(result, FieldMemOperand(scratch, | 5925 __ ldr(result, FieldMemOperand(scratch, |
5981 FixedArray::kHeaderSize - kPointerSize)); | 5926 FixedArray::kHeaderSize - kPointerSize)); |
5982 __ bind(&done); | 5927 __ bind(&done); |
5983 } | 5928 } |
5984 | 5929 |
5985 | 5930 |
5986 #undef __ | 5931 #undef __ |
5987 | 5932 |
5988 } } // namespace v8::internal | 5933 } } // namespace v8::internal |
OLD | NEW |