| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/bailout-reason.h" | 7 #include "src/bailout-reason.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/field-index.h" | 9 #include "src/field-index.h" |
| 10 #include "src/hydrogen.h" | 10 #include "src/hydrogen.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 return BuildNumberToString(number, Type::Number(zone())); | 315 return BuildNumberToString(number, Type::Number(zone())); |
| 316 } | 316 } |
| 317 | 317 |
| 318 | 318 |
| 319 Handle<Code> NumberToStringStub::GenerateCode() { | 319 Handle<Code> NumberToStringStub::GenerateCode() { |
| 320 return DoGenerateCode(this); | 320 return DoGenerateCode(this); |
| 321 } | 321 } |
| 322 | 322 |
| 323 | 323 |
| 324 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). | 324 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). |
| 325 // Possible optimizations: put the type string into the oddballs. | |
| 326 template <> | 325 template <> |
| 327 HValue* CodeStubGraphBuilder<TypeofStub>::BuildCodeStub() { | 326 HValue* CodeStubGraphBuilder<TypeofStub>::BuildCodeStub() { |
| 328 Factory* factory = isolate()->factory(); | 327 Factory* factory = isolate()->factory(); |
| 329 HConstant* number_string = Add<HConstant>(factory->number_string()); | 328 HConstant* number_string = Add<HConstant>(factory->number_string()); |
| 330 HValue* object = GetParameter(TypeofStub::kObject); | 329 HValue* object = GetParameter(TypeofStub::kObject); |
| 331 | 330 |
| 332 IfBuilder is_smi(this); | 331 IfBuilder is_smi(this); |
| 333 HValue* smi_check = is_smi.If<HIsSmiAndBranch>(object); | 332 HValue* smi_check = is_smi.If<HIsSmiAndBranch>(object); |
| 334 is_smi.Then(); | 333 is_smi.Then(); |
| 335 { Push(number_string); } | 334 { Push(number_string); } |
| 336 is_smi.Else(); | 335 is_smi.Else(); |
| 337 { | 336 { |
| 338 IfBuilder is_number(this); | 337 IfBuilder is_number(this); |
| 339 is_number.If<HCompareMap>(object, isolate()->factory()->heap_number_map()); | 338 is_number.If<HCompareMap>(object, isolate()->factory()->heap_number_map()); |
| 340 is_number.Then(); | 339 is_number.Then(); |
| 341 { Push(number_string); } | 340 { Push(number_string); } |
| 342 is_number.Else(); | 341 is_number.Else(); |
| 343 { | 342 { |
| 344 HConstant* undefined_string = Add<HConstant>(factory->undefined_string()); | |
| 345 HValue* map = AddLoadMap(object, smi_check); | 343 HValue* map = AddLoadMap(object, smi_check); |
| 346 HValue* instance_type = Add<HLoadNamedField>( | 344 HValue* instance_type = Add<HLoadNamedField>( |
| 347 map, nullptr, HObjectAccess::ForMapInstanceType()); | 345 map, nullptr, HObjectAccess::ForMapInstanceType()); |
| 348 IfBuilder is_string(this); | 346 IfBuilder is_string(this); |
| 349 is_string.If<HCompareNumericAndBranch>( | 347 is_string.If<HCompareNumericAndBranch>( |
| 350 instance_type, Add<HConstant>(FIRST_NONSTRING_TYPE), Token::LT); | 348 instance_type, Add<HConstant>(FIRST_NONSTRING_TYPE), Token::LT); |
| 351 is_string.Then(); | 349 is_string.Then(); |
| 352 { Push(Add<HConstant>(factory->string_string())); } | 350 { Push(Add<HConstant>(factory->string_string())); } |
| 353 is_string.Else(); | 351 is_string.Else(); |
| 354 { | 352 { |
| 355 HConstant* object_string = Add<HConstant>(factory->object_string()); | 353 HConstant* object_string = Add<HConstant>(factory->object_string()); |
| 356 IfBuilder is_oddball(this); | 354 IfBuilder is_oddball(this); |
| 357 is_oddball.If<HCompareNumericAndBranch>( | 355 is_oddball.If<HCompareNumericAndBranch>( |
| 358 instance_type, Add<HConstant>(ODDBALL_TYPE), Token::EQ); | 356 instance_type, Add<HConstant>(ODDBALL_TYPE), Token::EQ); |
| 359 is_oddball.Then(); | 357 is_oddball.Then(); |
| 360 { | 358 { |
| 361 IfBuilder is_true_or_false(this); | 359 Push(Add<HLoadNamedField>(object, nullptr, |
| 362 is_true_or_false.If<HCompareObjectEqAndBranch>( | 360 HObjectAccess::ForOddballTypeOf())); |
| 363 object, graph()->GetConstantTrue()); | |
| 364 is_true_or_false.OrIf<HCompareObjectEqAndBranch>( | |
| 365 object, graph()->GetConstantFalse()); | |
| 366 is_true_or_false.Then(); | |
| 367 { Push(Add<HConstant>(factory->boolean_string())); } | |
| 368 is_true_or_false.Else(); | |
| 369 { | |
| 370 IfBuilder is_null(this); | |
| 371 is_null.If<HCompareObjectEqAndBranch>(object, | |
| 372 graph()->GetConstantNull()); | |
| 373 is_null.Then(); | |
| 374 { Push(object_string); } | |
| 375 is_null.Else(); | |
| 376 { Push(undefined_string); } | |
| 377 } | |
| 378 is_true_or_false.End(); | |
| 379 } | 361 } |
| 380 is_oddball.Else(); | 362 is_oddball.Else(); |
| 381 { | 363 { |
| 382 IfBuilder is_symbol(this); | 364 IfBuilder is_symbol(this); |
| 383 is_symbol.If<HCompareNumericAndBranch>( | 365 is_symbol.If<HCompareNumericAndBranch>( |
| 384 instance_type, Add<HConstant>(SYMBOL_TYPE), Token::EQ); | 366 instance_type, Add<HConstant>(SYMBOL_TYPE), Token::EQ); |
| 385 is_symbol.Then(); | 367 is_symbol.Then(); |
| 386 { Push(Add<HConstant>(factory->symbol_string())); } | 368 { Push(Add<HConstant>(factory->symbol_string())); } |
| 387 is_symbol.Else(); | 369 is_symbol.Else(); |
| 388 { | 370 { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 { Push(Add<HConstant>(factory->bool8x16_string())); } | 432 { Push(Add<HConstant>(factory->bool8x16_string())); } |
| 451 is_bool8x16.Else(); | 433 is_bool8x16.Else(); |
| 452 { | 434 { |
| 453 // Is it an undetectable object? | 435 // Is it an undetectable object? |
| 454 IfBuilder is_undetectable(this); | 436 IfBuilder is_undetectable(this); |
| 455 is_undetectable.If<HIsUndetectableAndBranch>( | 437 is_undetectable.If<HIsUndetectableAndBranch>( |
| 456 object); | 438 object); |
| 457 is_undetectable.Then(); | 439 is_undetectable.Then(); |
| 458 { | 440 { |
| 459 // typeof an undetectable object is 'undefined'. | 441 // typeof an undetectable object is 'undefined'. |
| 460 Push(undefined_string); | 442 Push(Add<HConstant>(factory->undefined_string())); |
| 461 } | 443 } |
| 462 is_undetectable.Else(); | 444 is_undetectable.Else(); |
| 463 { | 445 { |
| 464 // For any kind of object not handled above, the | 446 // For any kind of object not handled above, the |
| 465 // spec rule for host objects gives that it is | 447 // spec rule for host objects gives that it is |
| 466 // okay to return "object". | 448 // okay to return "object". |
| 467 Push(object_string); | 449 Push(object_string); |
| 468 } | 450 } |
| 469 } | 451 } |
| 470 } | 452 } |
| (...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2274 return Pop(); | 2256 return Pop(); |
| 2275 } | 2257 } |
| 2276 | 2258 |
| 2277 | 2259 |
| 2278 Handle<Code> KeyedLoadGenericStub::GenerateCode() { | 2260 Handle<Code> KeyedLoadGenericStub::GenerateCode() { |
| 2279 return DoGenerateCode(this); | 2261 return DoGenerateCode(this); |
| 2280 } | 2262 } |
| 2281 | 2263 |
| 2282 } // namespace internal | 2264 } // namespace internal |
| 2283 } // namespace v8 | 2265 } // namespace v8 |
| OLD | NEW |