| 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/code-stubs.h" | 5 #include "src/code-stubs.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 2065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2076 Node* one = assembler->Float64Constant(1.0); | 2076 Node* one = assembler->Float64Constant(1.0); |
| 2077 Node* fdec_result = assembler->Float64Sub(fdec_value, one); | 2077 Node* fdec_result = assembler->Float64Sub(fdec_value, one); |
| 2078 result_var.Bind(assembler->ChangeFloat64ToTagged(fdec_result)); | 2078 result_var.Bind(assembler->ChangeFloat64ToTagged(fdec_result)); |
| 2079 assembler->Goto(&end); | 2079 assembler->Goto(&end); |
| 2080 } | 2080 } |
| 2081 | 2081 |
| 2082 assembler->Bind(&end); | 2082 assembler->Bind(&end); |
| 2083 return result_var.value(); | 2083 return result_var.value(); |
| 2084 } | 2084 } |
| 2085 | 2085 |
| 2086 // ES6 section 7.1.13 ToObject (argument) |
| 2087 void ToObjectStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
| 2088 typedef compiler::Node Node; |
| 2089 typedef CodeStubAssembler::Label Label; |
| 2090 typedef CodeStubAssembler::Variable Variable; |
| 2091 |
| 2092 Label if_number(assembler, Label::kDeferred), if_notsmi(assembler), |
| 2093 if_jsreceiver(assembler), if_noconstructor(assembler, Label::kDeferred), |
| 2094 if_wrapjsvalue(assembler); |
| 2095 |
| 2096 Node* object = assembler->Parameter(Descriptor::kArgument); |
| 2097 Node* context = assembler->Parameter(Descriptor::kContext); |
| 2098 |
| 2099 Variable constructor_function_index_var(assembler, |
| 2100 MachineRepresentation::kWord32); |
| 2101 |
| 2102 assembler->Branch(assembler->WordIsSmi(object), &if_number, &if_notsmi); |
| 2103 |
| 2104 assembler->Bind(&if_notsmi); |
| 2105 Node* map = assembler->LoadMap(object); |
| 2106 |
| 2107 assembler->GotoIf( |
| 2108 assembler->WordEqual(map, assembler->HeapNumberMapConstant()), |
| 2109 &if_number); |
| 2110 |
| 2111 Node* instance_type = assembler->LoadMapInstanceType(map); |
| 2112 assembler->GotoIf( |
| 2113 assembler->Int32GreaterThanOrEqual( |
| 2114 instance_type, assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE)), |
| 2115 &if_jsreceiver); |
| 2116 |
| 2117 Node* constructor_function_index = assembler->LoadObjectField( |
| 2118 map, Map::kInObjectPropertiesOrConstructorFunctionIndexOffset, |
| 2119 MachineType::Uint8()); |
| 2120 assembler->GotoIf( |
| 2121 assembler->Word32Equal( |
| 2122 constructor_function_index, |
| 2123 assembler->Int32Constant(Map::kNoConstructorFunctionIndex)), |
| 2124 &if_noconstructor); |
| 2125 constructor_function_index_var.Bind(constructor_function_index); |
| 2126 assembler->Goto(&if_wrapjsvalue); |
| 2127 |
| 2128 assembler->Bind(&if_number); |
| 2129 constructor_function_index_var.Bind( |
| 2130 assembler->Int32Constant(Context::NUMBER_FUNCTION_INDEX)); |
| 2131 assembler->Goto(&if_wrapjsvalue); |
| 2132 |
| 2133 assembler->Bind(&if_wrapjsvalue); |
| 2134 Node* native_context = assembler->LoadNativeContext(context); |
| 2135 Node* constructor = assembler->LoadFixedArrayElement( |
| 2136 native_context, constructor_function_index_var.value()); |
| 2137 Node* initial_map = assembler->LoadObjectField( |
| 2138 constructor, JSFunction::kPrototypeOrInitialMapOffset); |
| 2139 Node* js_value = assembler->Allocate(JSValue::kSize); |
| 2140 assembler->StoreMapNoWriteBarrier(js_value, initial_map); |
| 2141 assembler->StoreObjectFieldRoot(js_value, JSValue::kPropertiesOffset, |
| 2142 Heap::kEmptyFixedArrayRootIndex); |
| 2143 assembler->StoreObjectFieldRoot(js_value, JSObject::kElementsOffset, |
| 2144 Heap::kEmptyFixedArrayRootIndex); |
| 2145 assembler->StoreObjectField(js_value, JSValue::kValueOffset, object); |
| 2146 assembler->Return(js_value); |
| 2147 |
| 2148 assembler->Bind(&if_noconstructor); |
| 2149 assembler->TailCallRuntime( |
| 2150 Runtime::kThrowUndefinedOrNullToObject, context, |
| 2151 assembler->HeapConstant(assembler->factory()->NewStringFromAsciiChecked( |
| 2152 "ToObject", TENURED))); |
| 2153 |
| 2154 assembler->Bind(&if_jsreceiver); |
| 2155 assembler->Return(object); |
| 2156 } |
| 2157 |
| 2086 // static | 2158 // static |
| 2087 // ES6 section 12.5.5 typeof operator | 2159 // ES6 section 12.5.5 typeof operator |
| 2088 compiler::Node* TypeofStub::Generate(CodeStubAssembler* assembler, | 2160 compiler::Node* TypeofStub::Generate(CodeStubAssembler* assembler, |
| 2089 compiler::Node* value, | 2161 compiler::Node* value, |
| 2090 compiler::Node* context) { | 2162 compiler::Node* context) { |
| 2091 typedef compiler::Node Node; | 2163 typedef compiler::Node Node; |
| 2092 typedef CodeStubAssembler::Label Label; | 2164 typedef CodeStubAssembler::Label Label; |
| 2093 typedef CodeStubAssembler::Variable Variable; | 2165 typedef CodeStubAssembler::Variable Variable; |
| 2094 | 2166 |
| 2095 Variable result_var(assembler, MachineRepresentation::kTagged); | 2167 Variable result_var(assembler, MachineRepresentation::kTagged); |
| 2096 | 2168 |
| 2097 Label return_number(assembler, Label::kDeferred), if_oddball(assembler), | 2169 Label return_number(assembler, Label::kDeferred), if_oddball(assembler), |
| 2098 return_function(assembler), return_undefined(assembler), | 2170 return_function(assembler), return_undefined(assembler), |
| 2099 return_object(assembler), return_string(assembler), | 2171 return_object(assembler), return_string(assembler), |
| 2100 return_result(assembler); | 2172 return_result(assembler); |
| 2101 | 2173 |
| 2102 assembler->GotoIf(assembler->WordIsSmi(value), &return_number); | 2174 assembler->GotoIf(assembler->WordIsSmi(value), &return_number); |
| 2103 | 2175 |
| 2104 Node* map = assembler->LoadMap(value); | 2176 Node* map = assembler->LoadMap(value); |
| 2105 | 2177 |
| 2106 assembler->GotoIf( | 2178 assembler->GotoIf( |
| 2107 assembler->WordEqual(map, assembler->HeapNumberMapConstant()), | 2179 assembler->WordEqual(map, assembler->HeapNumberMapConstant()), |
| 2108 &return_number); | 2180 &return_number); |
| 2109 | 2181 |
| 2110 Node* instance_type = assembler->LoadInstanceType(value); | 2182 Node* instance_type = assembler->LoadMapInstanceType(map); |
| 2111 | 2183 |
| 2112 assembler->GotoIf(assembler->Word32Equal( | 2184 assembler->GotoIf(assembler->Word32Equal( |
| 2113 instance_type, assembler->Int32Constant(ODDBALL_TYPE)), | 2185 instance_type, assembler->Int32Constant(ODDBALL_TYPE)), |
| 2114 &if_oddball); | 2186 &if_oddball); |
| 2115 | 2187 |
| 2116 Node* callable_or_undetectable_mask = | 2188 Node* callable_or_undetectable_mask = |
| 2117 assembler->Word32And(assembler->LoadMapBitField(map), | 2189 assembler->Word32And(assembler->LoadMapBitField(map), |
| 2118 assembler->Int32Constant(1 << Map::kIsCallable | | 2190 assembler->Int32Constant(1 << Map::kIsCallable | |
| 2119 1 << Map::kIsUndetectable)); | 2191 1 << Map::kIsUndetectable)); |
| 2120 | 2192 |
| (...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4338 FUNCTION_ADDR(Runtime_KeyedStoreIC_MissFromStubFailure)); | 4410 FUNCTION_ADDR(Runtime_KeyedStoreIC_MissFromStubFailure)); |
| 4339 } | 4411 } |
| 4340 | 4412 |
| 4341 | 4413 |
| 4342 void ElementsTransitionAndStoreStub::InitializeDescriptor( | 4414 void ElementsTransitionAndStoreStub::InitializeDescriptor( |
| 4343 CodeStubDescriptor* descriptor) { | 4415 CodeStubDescriptor* descriptor) { |
| 4344 descriptor->Initialize( | 4416 descriptor->Initialize( |
| 4345 FUNCTION_ADDR(Runtime_ElementsTransitionAndStoreIC_Miss)); | 4417 FUNCTION_ADDR(Runtime_ElementsTransitionAndStoreIC_Miss)); |
| 4346 } | 4418 } |
| 4347 | 4419 |
| 4348 | |
| 4349 void ToObjectStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | |
| 4350 descriptor->Initialize(Runtime::FunctionForId(Runtime::kToObject)->entry); | |
| 4351 descriptor->SetMissHandler(Runtime::kToObject); | |
| 4352 } | |
| 4353 | |
| 4354 void StoreTransitionStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4420 void StoreTransitionStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4355 descriptor->Initialize( | 4421 descriptor->Initialize( |
| 4356 FUNCTION_ADDR(Runtime_TransitionStoreIC_MissFromStubFailure)); | 4422 FUNCTION_ADDR(Runtime_TransitionStoreIC_MissFromStubFailure)); |
| 4357 } | 4423 } |
| 4358 | 4424 |
| 4359 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4425 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4360 descriptor->Initialize( | 4426 descriptor->Initialize( |
| 4361 Runtime::FunctionForId(Runtime::kNumberToString)->entry); | 4427 Runtime::FunctionForId(Runtime::kNumberToString)->entry); |
| 4362 descriptor->SetMissHandler(Runtime::kNumberToString); | 4428 descriptor->SetMissHandler(Runtime::kNumberToString); |
| 4363 } | 4429 } |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4774 function_context, assembler->Int32Constant(Context::CLOSURE_INDEX), | 4840 function_context, assembler->Int32Constant(Context::CLOSURE_INDEX), |
| 4775 function, SKIP_WRITE_BARRIER); | 4841 function, SKIP_WRITE_BARRIER); |
| 4776 assembler->StoreFixedArrayElement( | 4842 assembler->StoreFixedArrayElement( |
| 4777 function_context, assembler->Int32Constant(Context::PREVIOUS_INDEX), | 4843 function_context, assembler->Int32Constant(Context::PREVIOUS_INDEX), |
| 4778 context, SKIP_WRITE_BARRIER); | 4844 context, SKIP_WRITE_BARRIER); |
| 4779 assembler->StoreFixedArrayElement( | 4845 assembler->StoreFixedArrayElement( |
| 4780 function_context, assembler->Int32Constant(Context::EXTENSION_INDEX), | 4846 function_context, assembler->Int32Constant(Context::EXTENSION_INDEX), |
| 4781 assembler->TheHoleConstant(), SKIP_WRITE_BARRIER); | 4847 assembler->TheHoleConstant(), SKIP_WRITE_BARRIER); |
| 4782 | 4848 |
| 4783 // Copy the native context from the previous context. | 4849 // Copy the native context from the previous context. |
| 4784 Node* native_context = assembler->LoadFixedArrayElement( | 4850 Node* native_context = assembler->LoadNativeContext(context); |
| 4785 context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX)); | |
| 4786 assembler->StoreFixedArrayElement( | 4851 assembler->StoreFixedArrayElement( |
| 4787 function_context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX), | 4852 function_context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX), |
| 4788 native_context, SKIP_WRITE_BARRIER); | 4853 native_context, SKIP_WRITE_BARRIER); |
| 4789 | 4854 |
| 4790 // Initialize the rest of the slots to undefined. | 4855 // Initialize the rest of the slots to undefined. |
| 4791 Node* undefined = assembler->UndefinedConstant(); | 4856 Node* undefined = assembler->UndefinedConstant(); |
| 4792 Variable var_slot_index(assembler, MachineRepresentation::kWord32); | 4857 Variable var_slot_index(assembler, MachineRepresentation::kWord32); |
| 4793 var_slot_index.Bind(min_context_slots); | 4858 var_slot_index.Bind(min_context_slots); |
| 4794 Label loop(assembler, &var_slot_index), after_loop(assembler); | 4859 Label loop(assembler, &var_slot_index), after_loop(assembler); |
| 4795 assembler->Goto(&loop); | 4860 assembler->Goto(&loop); |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5280 if (type->Is(Type::UntaggedPointer())) { | 5345 if (type->Is(Type::UntaggedPointer())) { |
| 5281 return Representation::External(); | 5346 return Representation::External(); |
| 5282 } | 5347 } |
| 5283 | 5348 |
| 5284 DCHECK(!type->Is(Type::Untagged())); | 5349 DCHECK(!type->Is(Type::Untagged())); |
| 5285 return Representation::Tagged(); | 5350 return Representation::Tagged(); |
| 5286 } | 5351 } |
| 5287 | 5352 |
| 5288 } // namespace internal | 5353 } // namespace internal |
| 5289 } // namespace v8 | 5354 } // namespace v8 |
| OLD | NEW |