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 <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #if V8_TARGET_ARCH_MIPS64 | 9 #if V8_TARGET_ARCH_MIPS64 |
10 | 10 |
(...skipping 3915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3926 | 3926 |
3927 // --------------------------------------------------------------------------- | 3927 // --------------------------------------------------------------------------- |
3928 // Support functions. | 3928 // Support functions. |
3929 | 3929 |
3930 | 3930 |
3931 void MacroAssembler::TryGetFunctionPrototype(Register function, | 3931 void MacroAssembler::TryGetFunctionPrototype(Register function, |
3932 Register result, | 3932 Register result, |
3933 Register scratch, | 3933 Register scratch, |
3934 Label* miss, | 3934 Label* miss, |
3935 bool miss_on_bound_function) { | 3935 bool miss_on_bound_function) { |
3936 // Check that the receiver isn't a smi. | 3936 Label non_instance; |
3937 JumpIfSmi(function, miss); | 3937 if (miss_on_bound_function) { |
| 3938 // Check that the receiver isn't a smi. |
| 3939 JumpIfSmi(function, miss); |
3938 | 3940 |
3939 // Check that the function really is a function. Load map into result reg. | 3941 // Check that the function really is a function. Load map into result reg. |
3940 GetObjectType(function, result, scratch); | 3942 GetObjectType(function, result, scratch); |
3941 Branch(miss, ne, scratch, Operand(JS_FUNCTION_TYPE)); | 3943 Branch(miss, ne, scratch, Operand(JS_FUNCTION_TYPE)); |
3942 | 3944 |
3943 if (miss_on_bound_function) { | |
3944 ld(scratch, | 3945 ld(scratch, |
3945 FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset)); | 3946 FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
3946 // ld(scratch, | |
3947 // FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset)); | |
3948 // And(scratch, scratch, | |
3949 // Operand(Smi::FromInt(1 << SharedFunctionInfo::kBoundFunction))); | |
3950 lwu(scratch, | 3947 lwu(scratch, |
3951 FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset)); | 3948 FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset)); |
3952 And(scratch, scratch, | 3949 And(scratch, scratch, |
3953 Operand(1 << SharedFunctionInfo::kBoundFunction)); | 3950 Operand(1 << SharedFunctionInfo::kBoundFunction)); |
3954 Branch(miss, ne, scratch, Operand(zero_reg)); | 3951 Branch(miss, ne, scratch, Operand(zero_reg)); |
| 3952 |
| 3953 // Make sure that the function has an instance prototype. |
| 3954 lbu(scratch, FieldMemOperand(result, Map::kBitFieldOffset)); |
| 3955 And(scratch, scratch, Operand(1 << Map::kHasNonInstancePrototype)); |
| 3956 Branch(&non_instance, ne, scratch, Operand(zero_reg)); |
3955 } | 3957 } |
3956 | 3958 |
3957 // Make sure that the function has an instance prototype. | |
3958 Label non_instance; | |
3959 lbu(scratch, FieldMemOperand(result, Map::kBitFieldOffset)); | |
3960 And(scratch, scratch, Operand(1 << Map::kHasNonInstancePrototype)); | |
3961 Branch(&non_instance, ne, scratch, Operand(zero_reg)); | |
3962 | |
3963 // Get the prototype or initial map from the function. | 3959 // Get the prototype or initial map from the function. |
3964 ld(result, | 3960 ld(result, |
3965 FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 3961 FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
3966 | 3962 |
3967 // If the prototype or initial map is the hole, don't return it and | 3963 // If the prototype or initial map is the hole, don't return it and |
3968 // simply miss the cache instead. This will allow us to allocate a | 3964 // simply miss the cache instead. This will allow us to allocate a |
3969 // prototype object on-demand in the runtime system. | 3965 // prototype object on-demand in the runtime system. |
3970 LoadRoot(t8, Heap::kTheHoleValueRootIndex); | 3966 LoadRoot(t8, Heap::kTheHoleValueRootIndex); |
3971 Branch(miss, eq, result, Operand(t8)); | 3967 Branch(miss, eq, result, Operand(t8)); |
3972 | 3968 |
3973 // If the function does not have an initial map, we're done. | 3969 // If the function does not have an initial map, we're done. |
3974 Label done; | 3970 Label done; |
3975 GetObjectType(result, scratch, scratch); | 3971 GetObjectType(result, scratch, scratch); |
3976 Branch(&done, ne, scratch, Operand(MAP_TYPE)); | 3972 Branch(&done, ne, scratch, Operand(MAP_TYPE)); |
3977 | 3973 |
3978 // Get the prototype from the initial map. | 3974 // Get the prototype from the initial map. |
3979 ld(result, FieldMemOperand(result, Map::kPrototypeOffset)); | 3975 ld(result, FieldMemOperand(result, Map::kPrototypeOffset)); |
3980 jmp(&done); | |
3981 | 3976 |
3982 // Non-instance prototype: Fetch prototype from constructor field | 3977 if (miss_on_bound_function) { |
3983 // in initial map. | 3978 jmp(&done); |
3984 bind(&non_instance); | 3979 |
3985 ld(result, FieldMemOperand(result, Map::kConstructorOffset)); | 3980 // Non-instance prototype: Fetch prototype from constructor field |
| 3981 // in initial map. |
| 3982 bind(&non_instance); |
| 3983 ld(result, FieldMemOperand(result, Map::kConstructorOffset)); |
| 3984 } |
3986 | 3985 |
3987 // All done. | 3986 // All done. |
3988 bind(&done); | 3987 bind(&done); |
3989 } | 3988 } |
3990 | 3989 |
3991 | 3990 |
3992 void MacroAssembler::GetObjectType(Register object, | 3991 void MacroAssembler::GetObjectType(Register object, |
3993 Register map, | 3992 Register map, |
3994 Register type_reg) { | 3993 Register type_reg) { |
3995 ld(map, FieldMemOperand(object, HeapObject::kMapOffset)); | 3994 ld(map, FieldMemOperand(object, HeapObject::kMapOffset)); |
(...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5943 } | 5942 } |
5944 if (ms.shift() > 0) sra(result, result, ms.shift()); | 5943 if (ms.shift() > 0) sra(result, result, ms.shift()); |
5945 srl(at, dividend, 31); | 5944 srl(at, dividend, 31); |
5946 Addu(result, result, Operand(at)); | 5945 Addu(result, result, Operand(at)); |
5947 } | 5946 } |
5948 | 5947 |
5949 | 5948 |
5950 } } // namespace v8::internal | 5949 } } // namespace v8::internal |
5951 | 5950 |
5952 #endif // V8_TARGET_ARCH_MIPS64 | 5951 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |