OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins/builtins-utils-gen.h" | 5 #include "src/builtins/builtins-utils-gen.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 | 10 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 Node* context = Parameter(Descriptor::kContext); | 126 Node* context = Parameter(Descriptor::kContext); |
127 Node* input = Parameter(Descriptor::kArgument); | 127 Node* input = Parameter(Descriptor::kArgument); |
128 | 128 |
129 Return(ToNumber(context, input)); | 129 Return(ToNumber(context, input)); |
130 } | 130 } |
131 | 131 |
132 TF_BUILTIN(ToString, CodeStubAssembler) { | 132 TF_BUILTIN(ToString, CodeStubAssembler) { |
133 Node* context = Parameter(Descriptor::kContext); | 133 Node* context = Parameter(Descriptor::kContext); |
134 Node* input = Parameter(Descriptor::kArgument); | 134 Node* input = Parameter(Descriptor::kArgument); |
135 | 135 |
136 Label is_number(this); | 136 Return(ToString(context, input)); |
137 Label runtime(this); | |
138 | |
139 GotoIf(TaggedIsSmi(input), &is_number); | |
140 | |
141 Node* input_map = LoadMap(input); | |
142 Node* input_instance_type = LoadMapInstanceType(input_map); | |
143 | |
144 Label not_string(this); | |
145 GotoIfNot(IsStringInstanceType(input_instance_type), ¬_string); | |
146 Return(input); | |
147 | |
148 Label not_heap_number(this); | |
149 | |
150 BIND(¬_string); | |
151 { Branch(IsHeapNumberMap(input_map), &is_number, ¬_heap_number); } | |
152 | |
153 BIND(&is_number); | |
154 { Return(NumberToString(context, input)); } | |
155 | |
156 BIND(¬_heap_number); | |
157 { | |
158 GotoIf(Word32NotEqual(input_instance_type, Int32Constant(ODDBALL_TYPE)), | |
159 &runtime); | |
160 Return(LoadObjectField(input, Oddball::kToStringOffset)); | |
161 } | |
162 | |
163 BIND(&runtime); | |
164 { Return(CallRuntime(Runtime::kToString, context, input)); } | |
165 } | 137 } |
166 | 138 |
167 // 7.1.1.1 OrdinaryToPrimitive ( O, hint ) | 139 // 7.1.1.1 OrdinaryToPrimitive ( O, hint ) |
168 void ConversionBuiltinsAssembler::Generate_OrdinaryToPrimitive( | 140 void ConversionBuiltinsAssembler::Generate_OrdinaryToPrimitive( |
169 Node* context, Node* input, OrdinaryToPrimitiveHint hint) { | 141 Node* context, Node* input, OrdinaryToPrimitiveHint hint) { |
170 VARIABLE(var_result, MachineRepresentation::kTagged); | 142 VARIABLE(var_result, MachineRepresentation::kTagged); |
171 Label return_result(this, &var_result); | 143 Label return_result(this, &var_result); |
172 | 144 |
173 Handle<String> method_names[2]; | 145 Handle<String> method_names[2]; |
174 switch (hint) { | 146 switch (hint) { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 362 |
391 // ES6 section 12.5.5 typeof operator | 363 // ES6 section 12.5.5 typeof operator |
392 TF_BUILTIN(Typeof, CodeStubAssembler) { | 364 TF_BUILTIN(Typeof, CodeStubAssembler) { |
393 Node* object = Parameter(TypeofDescriptor::kObject); | 365 Node* object = Parameter(TypeofDescriptor::kObject); |
394 | 366 |
395 Return(Typeof(object)); | 367 Return(Typeof(object)); |
396 } | 368 } |
397 | 369 |
398 } // namespace internal | 370 } // namespace internal |
399 } // namespace v8 | 371 } // namespace v8 |
OLD | NEW |