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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 void LCodeGen::WriteTranslation(LEnvironment* environment, | 360 void LCodeGen::WriteTranslation(LEnvironment* environment, |
361 Translation* translation) { | 361 Translation* translation) { |
362 if (environment == NULL) return; | 362 if (environment == NULL) return; |
363 | 363 |
364 // The translation includes one command per value in the environment. | 364 // The translation includes one command per value in the environment. |
365 int translation_size = environment->values()->length(); | 365 int translation_size = environment->values()->length(); |
366 // The output frame height does not include the parameters. | 366 // The output frame height does not include the parameters. |
367 int height = translation_size - environment->parameter_count(); | 367 int height = translation_size - environment->parameter_count(); |
368 | 368 |
369 WriteTranslation(environment->outer(), translation); | 369 WriteTranslation(environment->outer(), translation); |
370 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | 370 int closure_id = *info()->closure() != *environment->closure() |
371 ? DefineDeoptimizationLiteral(environment->closure()) | |
372 : Translation::kSelfLiteralId; | |
371 switch (environment->frame_type()) { | 373 switch (environment->frame_type()) { |
372 case JS_FUNCTION: | 374 case JS_FUNCTION: |
373 translation->BeginJSFrame(environment->ast_id(), closure_id, height); | 375 translation->BeginJSFrame(environment->ast_id(), closure_id, height); |
374 break; | 376 break; |
375 case JS_CONSTRUCT: | 377 case JS_CONSTRUCT: |
376 translation->BeginConstructStubFrame(closure_id, translation_size); | 378 translation->BeginConstructStubFrame(closure_id, translation_size); |
377 break; | 379 break; |
378 case ARGUMENTS_ADAPTOR: | 380 case ARGUMENTS_ADAPTOR: |
379 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); | 381 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); |
380 break; | 382 break; |
(...skipping 2306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2687 } | 2689 } |
2688 | 2690 |
2689 | 2691 |
2690 void LCodeGen::DoDrop(LDrop* instr) { | 2692 void LCodeGen::DoDrop(LDrop* instr) { |
2691 __ Drop(instr->count()); | 2693 __ Drop(instr->count()); |
2692 } | 2694 } |
2693 | 2695 |
2694 | 2696 |
2695 void LCodeGen::DoThisFunction(LThisFunction* instr) { | 2697 void LCodeGen::DoThisFunction(LThisFunction* instr) { |
2696 Register result = ToRegister(instr->result()); | 2698 Register result = ToRegister(instr->result()); |
2697 __ LoadHeapObject(result, instr->hydrogen()->closure()); | 2699 __ mov(result, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
2698 } | 2700 } |
2699 | 2701 |
2700 | 2702 |
2701 void LCodeGen::DoContext(LContext* instr) { | 2703 void LCodeGen::DoContext(LContext* instr) { |
2702 Register result = ToRegister(instr->result()); | 2704 Register result = ToRegister(instr->result()); |
2703 __ mov(result, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2705 __ mov(result, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2704 } | 2706 } |
2705 | 2707 |
2706 | 2708 |
2707 void LCodeGen::DoOuterContext(LOuterContext* instr) { | 2709 void LCodeGen::DoOuterContext(LOuterContext* instr) { |
(...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4394 PushSafepointRegistersScope scope(this); | 4396 PushSafepointRegistersScope scope(this); |
4395 __ push(Immediate(Smi::FromInt(instance_size))); | 4397 __ push(Immediate(Smi::FromInt(instance_size))); |
4396 CallRuntimeFromDeferred( | 4398 CallRuntimeFromDeferred( |
4397 Runtime::kAllocateInNewSpace, 1, instr, instr->context()); | 4399 Runtime::kAllocateInNewSpace, 1, instr, instr->context()); |
4398 __ StoreToSafepointRegisterSlot(result, eax); | 4400 __ StoreToSafepointRegisterSlot(result, eax); |
4399 } | 4401 } |
4400 | 4402 |
4401 | 4403 |
4402 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | 4404 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
4403 ASSERT(ToRegister(instr->context()).is(esi)); | 4405 ASSERT(ToRegister(instr->context()).is(esi)); |
4404 Heap* heap = isolate()->heap(); | |
4405 ElementsKind boilerplate_elements_kind = | 4406 ElementsKind boilerplate_elements_kind = |
4406 instr->hydrogen()->boilerplate_elements_kind(); | 4407 instr->hydrogen()->boilerplate_elements_kind(); |
4407 | 4408 |
4408 // Deopt if the array literal boilerplate ElementsKind is of a type different | 4409 // 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 | 4410 // than the expected one. The check isn't necessary if the boilerplate has |
4410 // already been converted to FAST_ELEMENTS. | 4411 // already been converted to FAST_ELEMENTS. |
4411 if (boilerplate_elements_kind != FAST_ELEMENTS) { | 4412 if (boilerplate_elements_kind != FAST_ELEMENTS) { |
4412 __ LoadHeapObject(eax, instr->hydrogen()->boilerplate_object()); | 4413 __ LoadHeapObject(eax, instr->hydrogen()->boilerplate_object()); |
4413 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 4414 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
4414 // Load the map's "bit field 2". We only need the first byte, | 4415 // Load the map's "bit field 2". We only need the first byte, |
4415 // but the following masking takes care of that anyway. | 4416 // but the following masking takes care of that anyway. |
4416 __ mov(ebx, FieldOperand(ebx, Map::kBitField2Offset)); | 4417 __ mov(ebx, FieldOperand(ebx, Map::kBitField2Offset)); |
4417 // Retrieve elements_kind from bit field 2. | 4418 // Retrieve elements_kind from bit field 2. |
4418 __ and_(ebx, Map::kElementsKindMask); | 4419 __ and_(ebx, Map::kElementsKindMask); |
4419 __ cmp(ebx, boilerplate_elements_kind << Map::kElementsKindShift); | 4420 __ cmp(ebx, boilerplate_elements_kind << Map::kElementsKindShift); |
4420 DeoptimizeIf(not_equal, instr->environment()); | 4421 DeoptimizeIf(not_equal, instr->environment()); |
4421 } | 4422 } |
4422 | 4423 |
4423 // Set up the parameters to the stub/runtime call. | 4424 // Set up the parameters to the stub/runtime call. |
4424 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 4425 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
4425 __ push(FieldOperand(eax, JSFunction::kLiteralsOffset)); | 4426 __ push(FieldOperand(eax, JSFunction::kLiteralsOffset)); |
4426 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); | 4427 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); |
4427 // Boilerplate already exists, constant elements are never accessed. | 4428 __ push(Immediate(instr->hydrogen()->constant_elements())); |
fschneider
2012/04/20 14:05:43
This should not be necessary if we share the liter
| |
4428 // Pass an empty fixed array. | |
4429 __ push(Immediate(Handle<FixedArray>(heap->empty_fixed_array()))); | |
4430 | 4429 |
4431 // Pick the right runtime function or stub to call. | 4430 // Pick the right runtime function or stub to call. |
4432 int length = instr->hydrogen()->length(); | 4431 int length = instr->hydrogen()->length(); |
4433 if (instr->hydrogen()->IsCopyOnWrite()) { | 4432 if (instr->hydrogen()->IsCopyOnWrite()) { |
4434 ASSERT(instr->hydrogen()->depth() == 1); | 4433 ASSERT(instr->hydrogen()->depth() == 1); |
4435 FastCloneShallowArrayStub::Mode mode = | 4434 FastCloneShallowArrayStub::Mode mode = |
4436 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; | 4435 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; |
4437 FastCloneShallowArrayStub stub(mode, length); | 4436 FastCloneShallowArrayStub stub(mode, length); |
4438 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 4437 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
4439 } else if (instr->hydrogen()->depth() > 1) { | 4438 } else if (instr->hydrogen()->depth() > 1) { |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5025 FixedArray::kHeaderSize - kPointerSize)); | 5024 FixedArray::kHeaderSize - kPointerSize)); |
5026 __ bind(&done); | 5025 __ bind(&done); |
5027 } | 5026 } |
5028 | 5027 |
5029 | 5028 |
5030 #undef __ | 5029 #undef __ |
5031 | 5030 |
5032 } } // namespace v8::internal | 5031 } } // namespace v8::internal |
5033 | 5032 |
5034 #endif // V8_TARGET_ARCH_IA32 | 5033 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |