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 4383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4394 __ Set(result, 0); | 4394 __ Set(result, 0); |
4395 | 4395 |
4396 PushSafepointRegistersScope scope(this); | 4396 PushSafepointRegistersScope scope(this); |
4397 __ Push(Smi::FromInt(instance_size)); | 4397 __ Push(Smi::FromInt(instance_size)); |
4398 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr); | 4398 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr); |
4399 __ StoreToSafepointRegisterSlot(result, rax); | 4399 __ StoreToSafepointRegisterSlot(result, rax); |
4400 } | 4400 } |
4401 | 4401 |
4402 | 4402 |
4403 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | 4403 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
4404 Heap* heap = isolate()->heap(); | 4404 Handle<FixedArray> literals(instr->environment()->closure()->literals()); |
4405 ElementsKind boilerplate_elements_kind = | 4405 ElementsKind boilerplate_elements_kind = |
4406 instr->hydrogen()->boilerplate_elements_kind(); | 4406 instr->hydrogen()->boilerplate_elements_kind(); |
4407 | 4407 |
4408 // Deopt if the array literal boilerplate ElementsKind is of a type different | 4408 // Deopt if the array literal boilerplate ElementsKind is of a type different |
4409 // than the expected one. The check isn't necessary if the boilerplate has | 4409 // than the expected one. The check isn't necessary if the boilerplate has |
4410 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. | 4410 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. |
4411 if (CanTransitionToMoreGeneralFastElementsKind( | 4411 if (CanTransitionToMoreGeneralFastElementsKind( |
4412 boilerplate_elements_kind, true)) { | 4412 boilerplate_elements_kind, true)) { |
4413 __ LoadHeapObject(rax, instr->hydrogen()->boilerplate_object()); | 4413 __ LoadHeapObject(rax, instr->hydrogen()->boilerplate_object()); |
4414 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); | 4414 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); |
4415 // Load the map's "bit field 2". | 4415 // Load the map's "bit field 2". |
4416 __ movb(rbx, FieldOperand(rbx, Map::kBitField2Offset)); | 4416 __ movb(rbx, FieldOperand(rbx, Map::kBitField2Offset)); |
4417 // Retrieve elements_kind from bit field 2. | 4417 // Retrieve elements_kind from bit field 2. |
4418 __ and_(rbx, Immediate(Map::kElementsKindMask)); | 4418 __ and_(rbx, Immediate(Map::kElementsKindMask)); |
4419 __ cmpb(rbx, Immediate(boilerplate_elements_kind << | 4419 __ cmpb(rbx, Immediate(boilerplate_elements_kind << |
4420 Map::kElementsKindShift)); | 4420 Map::kElementsKindShift)); |
4421 DeoptimizeIf(not_equal, instr->environment()); | 4421 DeoptimizeIf(not_equal, instr->environment()); |
4422 } | 4422 } |
4423 | 4423 |
4424 // Set up the parameters to the stub/runtime call. | 4424 // Set up the parameters to the stub/runtime call. |
4425 __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 4425 __ PushHeapObject(literals); |
4426 __ push(FieldOperand(rax, JSFunction::kLiteralsOffset)); | |
4427 __ Push(Smi::FromInt(instr->hydrogen()->literal_index())); | 4426 __ Push(Smi::FromInt(instr->hydrogen()->literal_index())); |
4428 // Boilerplate already exists, constant elements are never accessed. | 4427 // Boilerplate already exists, constant elements are never accessed. |
4429 // Pass an empty fixed array. | 4428 // Pass an empty fixed array. |
4430 __ Push(Handle<FixedArray>(heap->empty_fixed_array())); | 4429 __ Push(isolate()->factory()->empty_fixed_array()); |
4431 | 4430 |
4432 // Pick the right runtime function or stub to call. | 4431 // Pick the right runtime function or stub to call. |
4433 int length = instr->hydrogen()->length(); | 4432 int length = instr->hydrogen()->length(); |
4434 if (instr->hydrogen()->IsCopyOnWrite()) { | 4433 if (instr->hydrogen()->IsCopyOnWrite()) { |
4435 ASSERT(instr->hydrogen()->depth() == 1); | 4434 ASSERT(instr->hydrogen()->depth() == 1); |
4436 FastCloneShallowArrayStub::Mode mode = | 4435 FastCloneShallowArrayStub::Mode mode = |
4437 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; | 4436 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; |
4438 FastCloneShallowArrayStub stub(mode, length); | 4437 FastCloneShallowArrayStub stub(mode, length); |
4439 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 4438 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
4440 } else if (instr->hydrogen()->depth() > 1) { | 4439 } else if (instr->hydrogen()->depth() > 1) { |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5046 FixedArray::kHeaderSize - kPointerSize)); | 5045 FixedArray::kHeaderSize - kPointerSize)); |
5047 __ bind(&done); | 5046 __ bind(&done); |
5048 } | 5047 } |
5049 | 5048 |
5050 | 5049 |
5051 #undef __ | 5050 #undef __ |
5052 | 5051 |
5053 } } // namespace v8::internal | 5052 } } // namespace v8::internal |
5054 | 5053 |
5055 #endif // V8_TARGET_ARCH_X64 | 5054 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |