OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 351 |
352 | 352 |
353 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { | 353 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { |
354 return DoGenerateCode(this); | 354 return DoGenerateCode(this); |
355 } | 355 } |
356 | 356 |
357 | 357 |
358 template <> | 358 template <> |
359 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { | 359 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { |
360 Zone* zone = this->zone(); | 360 Zone* zone = this->zone(); |
361 Factory* factory = isolate()->factory(); | |
362 HValue* undefined = graph()->GetConstantUndefined(); | 361 HValue* undefined = graph()->GetConstantUndefined(); |
363 | 362 |
364 HInstruction* boilerplate = | 363 HInstruction* boilerplate = |
365 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), | 364 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), |
366 GetParameter(1), | 365 GetParameter(1), |
367 NULL, | 366 NULL, |
368 FAST_ELEMENTS)); | 367 FAST_ELEMENTS)); |
369 | 368 |
370 IfBuilder checker(this); | 369 IfBuilder checker(this); |
371 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); | 370 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); |
372 checker.And(); | 371 checker.And(); |
373 | 372 |
374 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; | 373 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; |
375 HValue* boilerplate_size = | 374 HValue* boilerplate_size = |
376 AddInstruction(new(zone) HInstanceSize(boilerplate)); | 375 AddInstruction(new(zone) HInstanceSize(boilerplate)); |
377 HValue* size_in_words = | 376 HValue* size_in_words = |
378 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2, | 377 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2, |
379 Representation::Integer32())); | 378 Representation::Integer32())); |
380 checker.IfCompare(boilerplate_size, size_in_words, Token::EQ); | 379 checker.IfCompare(boilerplate_size, size_in_words, Token::EQ); |
381 checker.Then(); | 380 checker.Then(); |
382 | 381 |
383 HValue* size_in_bytes = | 382 HValue* size_in_bytes = |
384 AddInstruction(new(zone) HConstant(size, Representation::Integer32())); | 383 AddInstruction(new(zone) HConstant(size, Representation::Integer32())); |
385 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; | 384 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; |
386 if (FLAG_pretenure_literals) { | 385 if (FLAG_pretenure_literals) { |
387 flags = static_cast<HAllocate::Flags>( | 386 flags = static_cast<HAllocate::Flags>( |
388 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); | 387 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); |
389 } | 388 } |
390 HInstruction* object = | 389 |
391 AddInstruction(new(zone) HAllocate(context(), | 390 HInstruction* object = AddInstruction(new(zone) |
392 size_in_bytes, | 391 HAllocate(context(), size_in_bytes, HType::JSObject(), flags)); |
393 HType::JSObject(), | |
394 flags)); | |
395 | 392 |
396 for (int i = 0; i < size; i += kPointerSize) { | 393 for (int i = 0; i < size; i += kPointerSize) { |
397 HInstruction* value = | 394 HObjectAccess access = HObjectAccess::ForJSObjectOffset(i); |
398 AddInstruction(new(zone) HLoadNamedField( | 395 AddStore(object, access, AddLoad(boilerplate, access)); |
399 boilerplate, true, Representation::Tagged(), i)); | |
400 AddInstruction(new(zone) HStoreNamedField(object, | |
401 factory->empty_string(), | |
402 value, true, | |
403 Representation::Tagged(), i)); | |
404 } | 396 } |
405 | 397 |
406 checker.ElseDeopt(); | 398 checker.ElseDeopt(); |
407 return object; | 399 return object; |
408 } | 400 } |
409 | 401 |
410 | 402 |
411 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { | 403 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { |
412 return DoGenerateCode(this); | 404 return DoGenerateCode(this); |
413 } | 405 } |
414 | 406 |
415 | 407 |
416 template <> | 408 template <> |
417 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { | 409 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { |
418 HInstruction* load = BuildUncheckedMonomorphicElementAccess( | 410 HInstruction* load = BuildUncheckedMonomorphicElementAccess( |
419 GetParameter(0), GetParameter(1), NULL, NULL, | 411 GetParameter(0), GetParameter(1), NULL, NULL, |
420 casted_stub()->is_js_array(), casted_stub()->elements_kind(), | 412 casted_stub()->is_js_array(), casted_stub()->elements_kind(), |
421 false, STANDARD_STORE, Representation::Tagged()); | 413 false, STANDARD_STORE, Representation::Tagged()); |
422 return load; | 414 return load; |
423 } | 415 } |
424 | 416 |
425 | 417 |
426 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { | 418 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { |
427 return DoGenerateCode(this); | 419 return DoGenerateCode(this); |
428 } | 420 } |
429 | 421 |
430 | 422 |
431 template<> | 423 template<> |
432 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() { | 424 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() { |
433 Representation representation = casted_stub()->representation(); | 425 HObjectAccess access = casted_stub()->is_inobject() ? |
434 HInstruction* load = AddInstruction(DoBuildLoadNamedField( | 426 HObjectAccess::ForJSObjectOffset(casted_stub()->offset()) : |
435 GetParameter(0), casted_stub()->is_inobject(), | 427 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset()); |
436 representation, casted_stub()->offset())); | 428 return AddInstruction(BuildLoadNamedField(GetParameter(0), access, |
437 return load; | 429 casted_stub()->representation())); |
438 } | 430 } |
439 | 431 |
440 | 432 |
441 Handle<Code> LoadFieldStub::GenerateCode() { | 433 Handle<Code> LoadFieldStub::GenerateCode() { |
442 return DoGenerateCode(this); | 434 return DoGenerateCode(this); |
443 } | 435 } |
444 | 436 |
445 | 437 |
446 template<> | 438 template<> |
447 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() { | 439 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() { |
448 Representation representation = casted_stub()->representation(); | 440 HObjectAccess access = casted_stub()->is_inobject() ? |
449 HInstruction* load = AddInstruction(DoBuildLoadNamedField( | 441 HObjectAccess::ForJSObjectOffset(casted_stub()->offset()) : |
450 GetParameter(0), casted_stub()->is_inobject(), | 442 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset()); |
451 representation, casted_stub()->offset())); | 443 return AddInstruction(BuildLoadNamedField(GetParameter(0), access, |
452 return load; | 444 casted_stub()->representation())); |
453 } | 445 } |
454 | 446 |
455 | 447 |
456 Handle<Code> KeyedLoadFieldStub::GenerateCode() { | 448 Handle<Code> KeyedLoadFieldStub::GenerateCode() { |
457 return DoGenerateCode(this); | 449 return DoGenerateCode(this); |
458 } | 450 } |
459 | 451 |
460 | 452 |
461 template <> | 453 template <> |
462 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { | 454 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { |
(...skipping 16 matching lines...) Expand all Loading... |
479 Zone* zone = this->zone(); | 471 Zone* zone = this->zone(); |
480 | 472 |
481 HValue* js_array = GetParameter(0); | 473 HValue* js_array = GetParameter(0); |
482 HValue* map = GetParameter(1); | 474 HValue* map = GetParameter(1); |
483 | 475 |
484 info()->MarkAsSavesCallerDoubles(); | 476 info()->MarkAsSavesCallerDoubles(); |
485 | 477 |
486 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); | 478 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); |
487 | 479 |
488 HInstruction* array_length = | 480 HInstruction* array_length = |
489 AddInstruction(HLoadNamedField::NewArrayLength( | 481 AddLoad(js_array, HObjectAccess::ForArrayLength()); |
490 zone, js_array, js_array, HType::Smi())); | 482 array_length->set_type(HType::Smi()); |
491 | 483 |
492 ElementsKind to_kind = casted_stub()->to_kind(); | 484 ElementsKind to_kind = casted_stub()->to_kind(); |
493 BuildNewSpaceArrayCheck(array_length, to_kind); | 485 BuildNewSpaceArrayCheck(array_length, to_kind); |
494 | 486 |
495 IfBuilder if_builder(this); | 487 IfBuilder if_builder(this); |
496 | 488 |
497 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ); | 489 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ); |
498 if_builder.Then(); | 490 if_builder.Then(); |
499 | 491 |
500 // Nothing to do, just change the map. | 492 // Nothing to do, just change the map. |
501 | 493 |
502 if_builder.Else(); | 494 if_builder.Else(); |
503 | 495 |
504 HInstruction* elements = AddLoadElements(js_array); | 496 HInstruction* elements = AddLoadElements(js_array); |
505 | 497 |
506 HInstruction* elements_length = | 498 HInstruction* elements_length = |
507 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); | 499 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); |
508 | 500 |
509 HValue* new_elements = | 501 HValue* new_elements = |
510 BuildAllocateAndInitializeElements(context(), to_kind, elements_length); | 502 BuildAllocateAndInitializeElements(context(), to_kind, elements_length); |
511 | 503 |
512 BuildCopyElements(context(), elements, | 504 BuildCopyElements(context(), elements, |
513 casted_stub()->from_kind(), new_elements, | 505 casted_stub()->from_kind(), new_elements, |
514 to_kind, array_length, elements_length); | 506 to_kind, array_length, elements_length); |
515 | 507 |
516 Factory* factory = isolate()->factory(); | 508 AddStore(js_array, HObjectAccess::ForElementsPointer(), new_elements); |
517 | |
518 AddInstruction(new(zone) HStoreNamedField(js_array, | |
519 factory->elements_field_string(), | |
520 new_elements, true, | |
521 Representation::Tagged(), | |
522 JSArray::kElementsOffset)); | |
523 | 509 |
524 if_builder.End(); | 510 if_builder.End(); |
525 | 511 |
526 AddInstruction(new(zone) HStoreNamedField(js_array, factory->length_string(), | 512 AddStore(js_array, HObjectAccess::ForMap(), map); |
527 map, true, | 513 |
528 Representation::Tagged(), | |
529 JSArray::kMapOffset)); | |
530 return js_array; | 514 return js_array; |
531 } | 515 } |
532 | 516 |
533 | 517 |
534 Handle<Code> TransitionElementsKindStub::GenerateCode() { | 518 Handle<Code> TransitionElementsKindStub::GenerateCode() { |
535 return DoGenerateCode(this); | 519 return DoGenerateCode(this); |
536 } | 520 } |
537 | 521 |
538 | 522 |
539 template <> | 523 template <> |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 ? graph()->GetConstantSmi1() | 677 ? graph()->GetConstantSmi1() |
694 : graph()->GetConstantUndefined(); | 678 : graph()->GetConstantUndefined(); |
695 } | 679 } |
696 | 680 |
697 | 681 |
698 Handle<Code> CompareNilICStub::GenerateCode() { | 682 Handle<Code> CompareNilICStub::GenerateCode() { |
699 return DoGenerateCode(this); | 683 return DoGenerateCode(this); |
700 } | 684 } |
701 | 685 |
702 } } // namespace v8::internal | 686 } } // namespace v8::internal |
OLD | NEW |