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->LoadInstanceType(object); | |
Benedikt Meurer
2016/08/09 11:05:49
Load the instance type from the map here; saves lo
Franzi
2016/08/09 11:21:38
Done.
| |
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); |
(...skipping 2242 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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5280 if (type->Is(Type::UntaggedPointer())) { | 5346 if (type->Is(Type::UntaggedPointer())) { |
5281 return Representation::External(); | 5347 return Representation::External(); |
5282 } | 5348 } |
5283 | 5349 |
5284 DCHECK(!type->Is(Type::Untagged())); | 5350 DCHECK(!type->Is(Type::Untagged())); |
5285 return Representation::Tagged(); | 5351 return Representation::Tagged(); |
5286 } | 5352 } |
5287 | 5353 |
5288 } // namespace internal | 5354 } // namespace internal |
5289 } // namespace v8 | 5355 } // namespace v8 |
OLD | NEW |