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.h" | 5 #include "src/builtins/builtins.h" |
6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 Callable callable = CodeFactory::OrdinaryToPrimitive( | 88 Callable callable = CodeFactory::OrdinaryToPrimitive( |
89 assembler->isolate(), (hint == ToPrimitiveHint::kString) | 89 assembler->isolate(), (hint == ToPrimitiveHint::kString) |
90 ? OrdinaryToPrimitiveHint::kString | 90 ? OrdinaryToPrimitiveHint::kString |
91 : OrdinaryToPrimitiveHint::kNumber); | 91 : OrdinaryToPrimitiveHint::kNumber); |
92 assembler->TailCallStub(callable, context, input); | 92 assembler->TailCallStub(callable, context, input); |
93 } | 93 } |
94 } | 94 } |
95 } // anonymous namespace | 95 } // anonymous namespace |
96 | 96 |
97 void Builtins::Generate_NonPrimitiveToPrimitive_Default( | 97 void Builtins::Generate_NonPrimitiveToPrimitive_Default( |
98 compiler::CodeAssemblerState* state) { | 98 CodeStubAssembler* assembler) { |
99 CodeStubAssembler assembler(state); | 99 Generate_NonPrimitiveToPrimitive(assembler, ToPrimitiveHint::kDefault); |
100 Generate_NonPrimitiveToPrimitive(&assembler, ToPrimitiveHint::kDefault); | |
101 } | 100 } |
102 | 101 |
103 void Builtins::Generate_NonPrimitiveToPrimitive_Number( | 102 void Builtins::Generate_NonPrimitiveToPrimitive_Number( |
104 compiler::CodeAssemblerState* state) { | 103 CodeStubAssembler* assembler) { |
105 CodeStubAssembler assembler(state); | 104 Generate_NonPrimitiveToPrimitive(assembler, ToPrimitiveHint::kNumber); |
106 Generate_NonPrimitiveToPrimitive(&assembler, ToPrimitiveHint::kNumber); | |
107 } | 105 } |
108 | 106 |
109 void Builtins::Generate_NonPrimitiveToPrimitive_String( | 107 void Builtins::Generate_NonPrimitiveToPrimitive_String( |
110 compiler::CodeAssemblerState* state) { | 108 CodeStubAssembler* assembler) { |
111 CodeStubAssembler assembler(state); | 109 Generate_NonPrimitiveToPrimitive(assembler, ToPrimitiveHint::kString); |
112 Generate_NonPrimitiveToPrimitive(&assembler, ToPrimitiveHint::kString); | |
113 } | 110 } |
114 | 111 |
115 void Builtins::Generate_StringToNumber(compiler::CodeAssemblerState* state) { | 112 void Builtins::Generate_StringToNumber(CodeStubAssembler* assembler) { |
116 typedef compiler::Node Node; | 113 typedef compiler::Node Node; |
117 typedef TypeConversionDescriptor Descriptor; | 114 typedef TypeConversionDescriptor Descriptor; |
118 CodeStubAssembler assembler(state); | |
119 | 115 |
120 Node* input = assembler.Parameter(Descriptor::kArgument); | 116 Node* input = assembler->Parameter(Descriptor::kArgument); |
121 Node* context = assembler.Parameter(Descriptor::kContext); | 117 Node* context = assembler->Parameter(Descriptor::kContext); |
122 | 118 |
123 assembler.Return(assembler.StringToNumber(context, input)); | 119 assembler->Return(assembler->StringToNumber(context, input)); |
124 } | 120 } |
125 | 121 |
126 void Builtins::Generate_ToName(compiler::CodeAssemblerState* state) { | 122 void Builtins::Generate_ToName(CodeStubAssembler* assembler) { |
127 typedef compiler::Node Node; | 123 typedef compiler::Node Node; |
128 typedef TypeConversionDescriptor Descriptor; | 124 typedef TypeConversionDescriptor Descriptor; |
129 CodeStubAssembler assembler(state); | |
130 | 125 |
131 Node* input = assembler.Parameter(Descriptor::kArgument); | 126 Node* input = assembler->Parameter(Descriptor::kArgument); |
132 Node* context = assembler.Parameter(Descriptor::kContext); | 127 Node* context = assembler->Parameter(Descriptor::kContext); |
133 | 128 |
134 assembler.Return(assembler.ToName(context, input)); | 129 assembler->Return(assembler->ToName(context, input)); |
135 } | 130 } |
136 | 131 |
137 // static | 132 // static |
138 void Builtins::Generate_NonNumberToNumber(compiler::CodeAssemblerState* state) { | 133 void Builtins::Generate_NonNumberToNumber(CodeStubAssembler* assembler) { |
139 typedef compiler::Node Node; | 134 typedef compiler::Node Node; |
140 typedef TypeConversionDescriptor Descriptor; | 135 typedef TypeConversionDescriptor Descriptor; |
141 CodeStubAssembler assembler(state); | |
142 | 136 |
143 Node* input = assembler.Parameter(Descriptor::kArgument); | 137 Node* input = assembler->Parameter(Descriptor::kArgument); |
144 Node* context = assembler.Parameter(Descriptor::kContext); | 138 Node* context = assembler->Parameter(Descriptor::kContext); |
145 | 139 |
146 assembler.Return(assembler.NonNumberToNumber(context, input)); | 140 assembler->Return(assembler->NonNumberToNumber(context, input)); |
147 } | 141 } |
148 | 142 |
149 // ES6 section 7.1.3 ToNumber ( argument ) | 143 // ES6 section 7.1.3 ToNumber ( argument ) |
150 void Builtins::Generate_ToNumber(compiler::CodeAssemblerState* state) { | 144 void Builtins::Generate_ToNumber(CodeStubAssembler* assembler) { |
151 typedef compiler::Node Node; | 145 typedef compiler::Node Node; |
152 typedef TypeConversionDescriptor Descriptor; | 146 typedef TypeConversionDescriptor Descriptor; |
153 CodeStubAssembler assembler(state); | |
154 | 147 |
155 Node* input = assembler.Parameter(Descriptor::kArgument); | 148 Node* input = assembler->Parameter(Descriptor::kArgument); |
156 Node* context = assembler.Parameter(Descriptor::kContext); | 149 Node* context = assembler->Parameter(Descriptor::kContext); |
157 | 150 |
158 assembler.Return(assembler.ToNumber(context, input)); | 151 assembler->Return(assembler->ToNumber(context, input)); |
159 } | 152 } |
160 | 153 |
161 void Builtins::Generate_ToString(compiler::CodeAssemblerState* state) { | 154 void Builtins::Generate_ToString(CodeStubAssembler* assembler) { |
162 typedef CodeStubAssembler::Label Label; | 155 typedef CodeStubAssembler::Label Label; |
163 typedef compiler::Node Node; | 156 typedef compiler::Node Node; |
164 typedef TypeConversionDescriptor Descriptor; | 157 typedef TypeConversionDescriptor Descriptor; |
165 CodeStubAssembler assembler(state); | |
166 | 158 |
167 Node* input = assembler.Parameter(Descriptor::kArgument); | 159 Node* input = assembler->Parameter(Descriptor::kArgument); |
168 Node* context = assembler.Parameter(Descriptor::kContext); | 160 Node* context = assembler->Parameter(Descriptor::kContext); |
169 | 161 |
170 Label is_number(&assembler); | 162 Label is_number(assembler); |
171 Label runtime(&assembler); | 163 Label runtime(assembler); |
172 | 164 |
173 assembler.GotoIf(assembler.TaggedIsSmi(input), &is_number); | 165 assembler->GotoIf(assembler->TaggedIsSmi(input), &is_number); |
174 | 166 |
175 Node* input_map = assembler.LoadMap(input); | 167 Node* input_map = assembler->LoadMap(input); |
176 Node* input_instance_type = assembler.LoadMapInstanceType(input_map); | 168 Node* input_instance_type = assembler->LoadMapInstanceType(input_map); |
177 | 169 |
178 Label not_string(&assembler); | 170 Label not_string(assembler); |
179 assembler.GotoUnless(assembler.IsStringInstanceType(input_instance_type), | 171 assembler->GotoUnless(assembler->IsStringInstanceType(input_instance_type), |
180 ¬_string); | 172 ¬_string); |
181 assembler.Return(input); | 173 assembler->Return(input); |
182 | 174 |
183 Label not_heap_number(&assembler); | 175 Label not_heap_number(assembler); |
184 | 176 |
185 assembler.Bind(¬_string); | 177 assembler->Bind(¬_string); |
186 { | 178 { |
187 assembler.GotoUnless( | 179 assembler->GotoUnless( |
188 assembler.WordEqual(input_map, assembler.HeapNumberMapConstant()), | 180 assembler->WordEqual(input_map, assembler->HeapNumberMapConstant()), |
189 ¬_heap_number); | 181 ¬_heap_number); |
190 assembler.Goto(&is_number); | 182 assembler->Goto(&is_number); |
191 } | 183 } |
192 | 184 |
193 assembler.Bind(&is_number); | 185 assembler->Bind(&is_number); |
194 { assembler.Return(assembler.NumberToString(context, input)); } | 186 { assembler->Return(assembler->NumberToString(context, input)); } |
195 | 187 |
196 assembler.Bind(¬_heap_number); | 188 assembler->Bind(¬_heap_number); |
197 { | 189 { |
198 assembler.GotoIf( | 190 assembler->GotoIf( |
199 assembler.Word32NotEqual(input_instance_type, | 191 assembler->Word32NotEqual(input_instance_type, |
200 assembler.Int32Constant(ODDBALL_TYPE)), | 192 assembler->Int32Constant(ODDBALL_TYPE)), |
201 &runtime); | 193 &runtime); |
202 assembler.Return( | 194 assembler->Return( |
203 assembler.LoadObjectField(input, Oddball::kToStringOffset)); | 195 assembler->LoadObjectField(input, Oddball::kToStringOffset)); |
204 } | 196 } |
205 | 197 |
206 assembler.Bind(&runtime); | 198 assembler->Bind(&runtime); |
207 { | 199 { |
208 assembler.Return(assembler.CallRuntime(Runtime::kToString, context, input)); | 200 assembler->Return( |
| 201 assembler->CallRuntime(Runtime::kToString, context, input)); |
209 } | 202 } |
210 } | 203 } |
211 | 204 |
212 Handle<Code> Builtins::OrdinaryToPrimitive(OrdinaryToPrimitiveHint hint) { | 205 Handle<Code> Builtins::OrdinaryToPrimitive(OrdinaryToPrimitiveHint hint) { |
213 switch (hint) { | 206 switch (hint) { |
214 case OrdinaryToPrimitiveHint::kNumber: | 207 case OrdinaryToPrimitiveHint::kNumber: |
215 return OrdinaryToPrimitive_Number(); | 208 return OrdinaryToPrimitive_Number(); |
216 case OrdinaryToPrimitiveHint::kString: | 209 case OrdinaryToPrimitiveHint::kString: |
217 return OrdinaryToPrimitive_String(); | 210 return OrdinaryToPrimitive_String(); |
218 } | 211 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 } | 276 } |
284 | 277 |
285 assembler->TailCallRuntime(Runtime::kThrowCannotConvertToPrimitive, context); | 278 assembler->TailCallRuntime(Runtime::kThrowCannotConvertToPrimitive, context); |
286 | 279 |
287 assembler->Bind(&return_result); | 280 assembler->Bind(&return_result); |
288 assembler->Return(var_result.value()); | 281 assembler->Return(var_result.value()); |
289 } | 282 } |
290 } // anonymous namespace | 283 } // anonymous namespace |
291 | 284 |
292 void Builtins::Generate_OrdinaryToPrimitive_Number( | 285 void Builtins::Generate_OrdinaryToPrimitive_Number( |
293 compiler::CodeAssemblerState* state) { | 286 CodeStubAssembler* assembler) { |
294 CodeStubAssembler assembler(state); | 287 Generate_OrdinaryToPrimitive(assembler, OrdinaryToPrimitiveHint::kNumber); |
295 Generate_OrdinaryToPrimitive(&assembler, OrdinaryToPrimitiveHint::kNumber); | |
296 } | 288 } |
297 | 289 |
298 void Builtins::Generate_OrdinaryToPrimitive_String( | 290 void Builtins::Generate_OrdinaryToPrimitive_String( |
299 compiler::CodeAssemblerState* state) { | 291 CodeStubAssembler* assembler) { |
300 CodeStubAssembler assembler(state); | 292 Generate_OrdinaryToPrimitive(assembler, OrdinaryToPrimitiveHint::kString); |
301 Generate_OrdinaryToPrimitive(&assembler, OrdinaryToPrimitiveHint::kString); | |
302 } | 293 } |
303 | 294 |
304 // ES6 section 7.1.2 ToBoolean ( argument ) | 295 // ES6 section 7.1.2 ToBoolean ( argument ) |
305 void Builtins::Generate_ToBoolean(compiler::CodeAssemblerState* state) { | 296 void Builtins::Generate_ToBoolean(CodeStubAssembler* assembler) { |
306 typedef compiler::Node Node; | 297 typedef compiler::Node Node; |
307 typedef CodeStubAssembler::Label Label; | 298 typedef CodeStubAssembler::Label Label; |
308 typedef TypeConversionDescriptor Descriptor; | 299 typedef TypeConversionDescriptor Descriptor; |
309 CodeStubAssembler assembler(state); | |
310 | 300 |
311 Node* value = assembler.Parameter(Descriptor::kArgument); | 301 Node* value = assembler->Parameter(Descriptor::kArgument); |
312 | 302 |
313 Label return_true(&assembler), return_false(&assembler); | 303 Label return_true(assembler), return_false(assembler); |
314 assembler.BranchIfToBooleanIsTrue(value, &return_true, &return_false); | 304 assembler->BranchIfToBooleanIsTrue(value, &return_true, &return_false); |
315 | 305 |
316 assembler.Bind(&return_true); | 306 assembler->Bind(&return_true); |
317 assembler.Return(assembler.BooleanConstant(true)); | 307 assembler->Return(assembler->BooleanConstant(true)); |
318 | 308 |
319 assembler.Bind(&return_false); | 309 assembler->Bind(&return_false); |
320 assembler.Return(assembler.BooleanConstant(false)); | 310 assembler->Return(assembler->BooleanConstant(false)); |
321 } | 311 } |
322 | 312 |
323 void Builtins::Generate_ToLength(compiler::CodeAssemblerState* state) { | 313 void Builtins::Generate_ToLength(CodeStubAssembler* assembler) { |
324 typedef CodeStubAssembler::Label Label; | 314 typedef CodeStubAssembler::Label Label; |
325 typedef compiler::Node Node; | 315 typedef compiler::Node Node; |
326 typedef CodeStubAssembler::Variable Variable; | 316 typedef CodeStubAssembler::Variable Variable; |
327 CodeStubAssembler assembler(state); | |
328 | 317 |
329 Node* context = assembler.Parameter(1); | 318 Node* context = assembler->Parameter(1); |
330 | 319 |
331 // We might need to loop once for ToNumber conversion. | 320 // We might need to loop once for ToNumber conversion. |
332 Variable var_len(&assembler, MachineRepresentation::kTagged); | 321 Variable var_len(assembler, MachineRepresentation::kTagged); |
333 Label loop(&assembler, &var_len); | 322 Label loop(assembler, &var_len); |
334 var_len.Bind(assembler.Parameter(0)); | 323 var_len.Bind(assembler->Parameter(0)); |
335 assembler.Goto(&loop); | 324 assembler->Goto(&loop); |
336 assembler.Bind(&loop); | 325 assembler->Bind(&loop); |
337 { | 326 { |
338 // Shared entry points. | 327 // Shared entry points. |
339 Label return_len(&assembler), | 328 Label return_len(assembler), |
340 return_two53minus1(&assembler, Label::kDeferred), | 329 return_two53minus1(assembler, Label::kDeferred), |
341 return_zero(&assembler, Label::kDeferred); | 330 return_zero(assembler, Label::kDeferred); |
342 | 331 |
343 // Load the current {len} value. | 332 // Load the current {len} value. |
344 Node* len = var_len.value(); | 333 Node* len = var_len.value(); |
345 | 334 |
346 // Check if {len} is a positive Smi. | 335 // Check if {len} is a positive Smi. |
347 assembler.GotoIf(assembler.WordIsPositiveSmi(len), &return_len); | 336 assembler->GotoIf(assembler->WordIsPositiveSmi(len), &return_len); |
348 | 337 |
349 // Check if {len} is a (negative) Smi. | 338 // Check if {len} is a (negative) Smi. |
350 assembler.GotoIf(assembler.TaggedIsSmi(len), &return_zero); | 339 assembler->GotoIf(assembler->TaggedIsSmi(len), &return_zero); |
351 | 340 |
352 // Check if {len} is a HeapNumber. | 341 // Check if {len} is a HeapNumber. |
353 Label if_lenisheapnumber(&assembler), | 342 Label if_lenisheapnumber(assembler), |
354 if_lenisnotheapnumber(&assembler, Label::kDeferred); | 343 if_lenisnotheapnumber(assembler, Label::kDeferred); |
355 assembler.Branch(assembler.IsHeapNumberMap(assembler.LoadMap(len)), | 344 assembler->Branch(assembler->IsHeapNumberMap(assembler->LoadMap(len)), |
356 &if_lenisheapnumber, &if_lenisnotheapnumber); | 345 &if_lenisheapnumber, &if_lenisnotheapnumber); |
357 | 346 |
358 assembler.Bind(&if_lenisheapnumber); | 347 assembler->Bind(&if_lenisheapnumber); |
359 { | 348 { |
360 // Load the floating-point value of {len}. | 349 // Load the floating-point value of {len}. |
361 Node* len_value = assembler.LoadHeapNumberValue(len); | 350 Node* len_value = assembler->LoadHeapNumberValue(len); |
362 | 351 |
363 // Check if {len} is not greater than zero. | 352 // Check if {len} is not greater than zero. |
364 assembler.GotoUnless(assembler.Float64GreaterThan( | 353 assembler->GotoUnless(assembler->Float64GreaterThan( |
365 len_value, assembler.Float64Constant(0.0)), | 354 len_value, assembler->Float64Constant(0.0)), |
366 &return_zero); | 355 &return_zero); |
367 | 356 |
368 // Check if {len} is greater than or equal to 2^53-1. | 357 // Check if {len} is greater than or equal to 2^53-1. |
369 assembler.GotoIf( | 358 assembler->GotoIf( |
370 assembler.Float64GreaterThanOrEqual( | 359 assembler->Float64GreaterThanOrEqual( |
371 len_value, assembler.Float64Constant(kMaxSafeInteger)), | 360 len_value, assembler->Float64Constant(kMaxSafeInteger)), |
372 &return_two53minus1); | 361 &return_two53minus1); |
373 | 362 |
374 // Round the {len} towards -Infinity. | 363 // Round the {len} towards -Infinity. |
375 Node* value = assembler.Float64Floor(len_value); | 364 Node* value = assembler->Float64Floor(len_value); |
376 Node* result = assembler.ChangeFloat64ToTagged(value); | 365 Node* result = assembler->ChangeFloat64ToTagged(value); |
377 assembler.Return(result); | 366 assembler->Return(result); |
378 } | 367 } |
379 | 368 |
380 assembler.Bind(&if_lenisnotheapnumber); | 369 assembler->Bind(&if_lenisnotheapnumber); |
381 { | 370 { |
382 // Need to convert {len} to a Number first. | 371 // Need to convert {len} to a Number first. |
383 Callable callable = CodeFactory::NonNumberToNumber(assembler.isolate()); | 372 Callable callable = CodeFactory::NonNumberToNumber(assembler->isolate()); |
384 var_len.Bind(assembler.CallStub(callable, context, len)); | 373 var_len.Bind(assembler->CallStub(callable, context, len)); |
385 assembler.Goto(&loop); | 374 assembler->Goto(&loop); |
386 } | 375 } |
387 | 376 |
388 assembler.Bind(&return_len); | 377 assembler->Bind(&return_len); |
389 assembler.Return(var_len.value()); | 378 assembler->Return(var_len.value()); |
390 | 379 |
391 assembler.Bind(&return_two53minus1); | 380 assembler->Bind(&return_two53minus1); |
392 assembler.Return(assembler.NumberConstant(kMaxSafeInteger)); | 381 assembler->Return(assembler->NumberConstant(kMaxSafeInteger)); |
393 | 382 |
394 assembler.Bind(&return_zero); | 383 assembler->Bind(&return_zero); |
395 assembler.Return(assembler.SmiConstant(Smi::kZero)); | 384 assembler->Return(assembler->SmiConstant(Smi::kZero)); |
396 } | 385 } |
397 } | 386 } |
398 | 387 |
399 void Builtins::Generate_ToInteger(compiler::CodeAssemblerState* state) { | 388 void Builtins::Generate_ToInteger(CodeStubAssembler* assembler) { |
400 typedef TypeConversionDescriptor Descriptor; | 389 typedef TypeConversionDescriptor Descriptor; |
401 CodeStubAssembler assembler(state); | |
402 | 390 |
403 compiler::Node* input = assembler.Parameter(Descriptor::kArgument); | 391 compiler::Node* input = assembler->Parameter(Descriptor::kArgument); |
404 compiler::Node* context = assembler.Parameter(Descriptor::kContext); | 392 compiler::Node* context = assembler->Parameter(Descriptor::kContext); |
405 | 393 |
406 assembler.Return(assembler.ToInteger(context, input)); | 394 assembler->Return(assembler->ToInteger(context, input)); |
407 } | 395 } |
408 | 396 |
409 // ES6 section 7.1.13 ToObject (argument) | 397 // ES6 section 7.1.13 ToObject (argument) |
410 void Builtins::Generate_ToObject(compiler::CodeAssemblerState* state) { | 398 void Builtins::Generate_ToObject(CodeStubAssembler* assembler) { |
411 typedef compiler::Node Node; | 399 typedef compiler::Node Node; |
412 typedef CodeStubAssembler::Label Label; | 400 typedef CodeStubAssembler::Label Label; |
413 typedef CodeStubAssembler::Variable Variable; | 401 typedef CodeStubAssembler::Variable Variable; |
414 typedef TypeConversionDescriptor Descriptor; | 402 typedef TypeConversionDescriptor Descriptor; |
415 CodeStubAssembler assembler(state); | |
416 | 403 |
417 Label if_number(&assembler, Label::kDeferred), if_notsmi(&assembler), | 404 Label if_number(assembler, Label::kDeferred), if_notsmi(assembler), |
418 if_jsreceiver(&assembler), if_noconstructor(&assembler, Label::kDeferred), | 405 if_jsreceiver(assembler), if_noconstructor(assembler, Label::kDeferred), |
419 if_wrapjsvalue(&assembler); | 406 if_wrapjsvalue(assembler); |
420 | 407 |
421 Node* object = assembler.Parameter(Descriptor::kArgument); | 408 Node* object = assembler->Parameter(Descriptor::kArgument); |
422 Node* context = assembler.Parameter(Descriptor::kContext); | 409 Node* context = assembler->Parameter(Descriptor::kContext); |
423 | 410 |
424 Variable constructor_function_index_var(&assembler, | 411 Variable constructor_function_index_var(assembler, |
425 MachineType::PointerRepresentation()); | 412 MachineType::PointerRepresentation()); |
426 | 413 |
427 assembler.Branch(assembler.TaggedIsSmi(object), &if_number, &if_notsmi); | 414 assembler->Branch(assembler->TaggedIsSmi(object), &if_number, &if_notsmi); |
428 | 415 |
429 assembler.Bind(&if_notsmi); | 416 assembler->Bind(&if_notsmi); |
430 Node* map = assembler.LoadMap(object); | 417 Node* map = assembler->LoadMap(object); |
431 | 418 |
432 assembler.GotoIf(assembler.IsHeapNumberMap(map), &if_number); | 419 assembler->GotoIf(assembler->IsHeapNumberMap(map), &if_number); |
433 | 420 |
434 Node* instance_type = assembler.LoadMapInstanceType(map); | 421 Node* instance_type = assembler->LoadMapInstanceType(map); |
435 assembler.GotoIf(assembler.IsJSReceiverInstanceType(instance_type), | 422 assembler->GotoIf(assembler->IsJSReceiverInstanceType(instance_type), |
436 &if_jsreceiver); | 423 &if_jsreceiver); |
437 | 424 |
438 Node* constructor_function_index = | 425 Node* constructor_function_index = |
439 assembler.LoadMapConstructorFunctionIndex(map); | 426 assembler->LoadMapConstructorFunctionIndex(map); |
440 assembler.GotoIf(assembler.WordEqual(constructor_function_index, | 427 assembler->GotoIf(assembler->WordEqual(constructor_function_index, |
441 assembler.IntPtrConstant( | 428 assembler->IntPtrConstant( |
442 Map::kNoConstructorFunctionIndex)), | 429 Map::kNoConstructorFunctionIndex)), |
443 &if_noconstructor); | 430 &if_noconstructor); |
444 constructor_function_index_var.Bind(constructor_function_index); | 431 constructor_function_index_var.Bind(constructor_function_index); |
445 assembler.Goto(&if_wrapjsvalue); | 432 assembler->Goto(&if_wrapjsvalue); |
446 | 433 |
447 assembler.Bind(&if_number); | 434 assembler->Bind(&if_number); |
448 constructor_function_index_var.Bind( | 435 constructor_function_index_var.Bind( |
449 assembler.IntPtrConstant(Context::NUMBER_FUNCTION_INDEX)); | 436 assembler->IntPtrConstant(Context::NUMBER_FUNCTION_INDEX)); |
450 assembler.Goto(&if_wrapjsvalue); | 437 assembler->Goto(&if_wrapjsvalue); |
451 | 438 |
452 assembler.Bind(&if_wrapjsvalue); | 439 assembler->Bind(&if_wrapjsvalue); |
453 Node* native_context = assembler.LoadNativeContext(context); | 440 Node* native_context = assembler->LoadNativeContext(context); |
454 Node* constructor = assembler.LoadFixedArrayElement( | 441 Node* constructor = assembler->LoadFixedArrayElement( |
455 native_context, constructor_function_index_var.value(), 0, | 442 native_context, constructor_function_index_var.value(), 0, |
456 CodeStubAssembler::INTPTR_PARAMETERS); | 443 CodeStubAssembler::INTPTR_PARAMETERS); |
457 Node* initial_map = assembler.LoadObjectField( | 444 Node* initial_map = assembler->LoadObjectField( |
458 constructor, JSFunction::kPrototypeOrInitialMapOffset); | 445 constructor, JSFunction::kPrototypeOrInitialMapOffset); |
459 Node* js_value = assembler.Allocate(JSValue::kSize); | 446 Node* js_value = assembler->Allocate(JSValue::kSize); |
460 assembler.StoreMapNoWriteBarrier(js_value, initial_map); | 447 assembler->StoreMapNoWriteBarrier(js_value, initial_map); |
461 assembler.StoreObjectFieldRoot(js_value, JSValue::kPropertiesOffset, | 448 assembler->StoreObjectFieldRoot(js_value, JSValue::kPropertiesOffset, |
462 Heap::kEmptyFixedArrayRootIndex); | 449 Heap::kEmptyFixedArrayRootIndex); |
463 assembler.StoreObjectFieldRoot(js_value, JSObject::kElementsOffset, | 450 assembler->StoreObjectFieldRoot(js_value, JSObject::kElementsOffset, |
464 Heap::kEmptyFixedArrayRootIndex); | 451 Heap::kEmptyFixedArrayRootIndex); |
465 assembler.StoreObjectField(js_value, JSValue::kValueOffset, object); | 452 assembler->StoreObjectField(js_value, JSValue::kValueOffset, object); |
466 assembler.Return(js_value); | 453 assembler->Return(js_value); |
467 | 454 |
468 assembler.Bind(&if_noconstructor); | 455 assembler->Bind(&if_noconstructor); |
469 assembler.TailCallRuntime( | 456 assembler->TailCallRuntime( |
470 Runtime::kThrowUndefinedOrNullToObject, context, | 457 Runtime::kThrowUndefinedOrNullToObject, context, |
471 assembler.HeapConstant( | 458 assembler->HeapConstant(assembler->factory()->NewStringFromAsciiChecked( |
472 assembler.factory()->NewStringFromAsciiChecked("ToObject", TENURED))); | 459 "ToObject", TENURED))); |
473 | 460 |
474 assembler.Bind(&if_jsreceiver); | 461 assembler->Bind(&if_jsreceiver); |
475 assembler.Return(object); | 462 assembler->Return(object); |
476 } | 463 } |
477 | 464 |
478 // ES6 section 12.5.5 typeof operator | 465 // ES6 section 12.5.5 typeof operator |
479 void Builtins::Generate_Typeof(compiler::CodeAssemblerState* state) { | 466 void Builtins::Generate_Typeof(CodeStubAssembler* assembler) { |
480 typedef compiler::Node Node; | 467 typedef compiler::Node Node; |
481 typedef TypeofDescriptor Descriptor; | 468 typedef TypeofDescriptor Descriptor; |
482 CodeStubAssembler assembler(state); | |
483 | 469 |
484 Node* object = assembler.Parameter(Descriptor::kObject); | 470 Node* object = assembler->Parameter(Descriptor::kObject); |
485 Node* context = assembler.Parameter(Descriptor::kContext); | 471 Node* context = assembler->Parameter(Descriptor::kContext); |
486 | 472 |
487 assembler.Return(assembler.Typeof(object, context)); | 473 assembler->Return(assembler->Typeof(object, context)); |
488 } | 474 } |
489 | 475 |
490 } // namespace internal | 476 } // namespace internal |
491 } // namespace v8 | 477 } // namespace v8 |
OLD | NEW |