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