OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 2980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2991 Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL); | 2991 Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL); |
2992 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2992 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2993 } | 2993 } |
2994 | 2994 |
2995 | 2995 |
2996 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) { | 2996 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) { |
2997 Register function = ToRegister(instr->function()); | 2997 Register function = ToRegister(instr->function()); |
2998 Register temp = ToRegister(instr->temp()); | 2998 Register temp = ToRegister(instr->temp()); |
2999 Register result = ToRegister(instr->result()); | 2999 Register result = ToRegister(instr->result()); |
3000 | 3000 |
3001 // Check that the function really is a function. | |
3002 __ CmpObjectType(function, JS_FUNCTION_TYPE, result); | |
3003 DeoptimizeIf(not_equal, instr->environment()); | |
3004 | |
3005 // Check whether the function has an instance prototype. | |
3006 Label non_instance; | |
3007 __ test_b(FieldOperand(result, Map::kBitFieldOffset), | |
3008 1 << Map::kHasNonInstancePrototype); | |
3009 __ j(not_zero, &non_instance, Label::kNear); | |
3010 | |
3011 // Get the prototype or initial map from the function. | 3001 // Get the prototype or initial map from the function. |
3012 __ mov(result, | 3002 __ mov(result, |
3013 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 3003 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
3014 | 3004 |
3015 // Check that the function has a prototype or an initial map. | 3005 // Check that the function has a prototype or an initial map. |
3016 __ cmp(Operand(result), Immediate(factory()->the_hole_value())); | 3006 __ cmp(Operand(result), Immediate(factory()->the_hole_value())); |
3017 DeoptimizeIf(equal, instr->environment()); | 3007 DeoptimizeIf(equal, instr->environment()); |
3018 | 3008 |
3019 // If the function does not have an initial map, we're done. | 3009 // If the function does not have an initial map, we're done. |
3020 Label done; | 3010 Label done; |
3021 __ CmpObjectType(result, MAP_TYPE, temp); | 3011 __ CmpObjectType(result, MAP_TYPE, temp); |
3022 __ j(not_equal, &done, Label::kNear); | 3012 __ j(not_equal, &done, Label::kNear); |
3023 | 3013 |
3024 // Get the prototype from the initial map. | 3014 // Get the prototype from the initial map. |
3025 __ mov(result, FieldOperand(result, Map::kPrototypeOffset)); | 3015 __ mov(result, FieldOperand(result, Map::kPrototypeOffset)); |
3026 __ jmp(&done, Label::kNear); | |
3027 | |
3028 // Non-instance prototype: Fetch prototype from constructor field | |
3029 // in the function's map. | |
3030 __ bind(&non_instance); | |
3031 __ mov(result, FieldOperand(result, Map::kConstructorOffset)); | |
3032 | 3016 |
3033 // All done. | 3017 // All done. |
3034 __ bind(&done); | 3018 __ bind(&done); |
3035 } | 3019 } |
3036 | 3020 |
3037 | 3021 |
3038 void LCodeGen::DoLoadRoot(LLoadRoot* instr) { | 3022 void LCodeGen::DoLoadRoot(LLoadRoot* instr) { |
3039 Register result = ToRegister(instr->result()); | 3023 Register result = ToRegister(instr->result()); |
3040 __ LoadRoot(result, instr->index()); | 3024 __ LoadRoot(result, instr->index()); |
3041 } | 3025 } |
(...skipping 2641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5683 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5667 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5684 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5668 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5685 } | 5669 } |
5686 | 5670 |
5687 | 5671 |
5688 #undef __ | 5672 #undef __ |
5689 | 5673 |
5690 } } // namespace v8::internal | 5674 } } // namespace v8::internal |
5691 | 5675 |
5692 #endif // V8_TARGET_ARCH_IA32 | 5676 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |