| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 IfBuilder checker_; | 99 IfBuilder checker_; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 enum ArgumentClass { | 102 enum ArgumentClass { |
| 103 NONE, | 103 NONE, |
| 104 SINGLE, | 104 SINGLE, |
| 105 MULTIPLE | 105 MULTIPLE |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 HValue* BuildArrayConstructor(ElementsKind kind, | 108 HValue* BuildArrayConstructor(ElementsKind kind, |
| 109 bool disable_allocation_sites, | 109 ContextCheckMode context_mode, |
| 110 AllocationSiteOverrideMode override_mode, |
| 110 ArgumentClass argument_class); | 111 ArgumentClass argument_class); |
| 111 HValue* BuildInternalArrayConstructor(ElementsKind kind, | 112 HValue* BuildInternalArrayConstructor(ElementsKind kind, |
| 112 ArgumentClass argument_class); | 113 ArgumentClass argument_class); |
| 113 | 114 |
| 114 private: | 115 private: |
| 115 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder); | 116 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder); |
| 116 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder, | 117 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder, |
| 117 ElementsKind kind); | 118 ElementsKind kind); |
| 118 | 119 |
| 119 SmartArrayPointer<HParameter*> parameters_; | 120 SmartArrayPointer<HParameter*> parameters_; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 308 |
| 308 template <> | 309 template <> |
| 309 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { | 310 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { |
| 310 Zone* zone = this->zone(); | 311 Zone* zone = this->zone(); |
| 311 Factory* factory = isolate()->factory(); | 312 Factory* factory = isolate()->factory(); |
| 312 HValue* undefined = graph()->GetConstantUndefined(); | 313 HValue* undefined = graph()->GetConstantUndefined(); |
| 313 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); | 314 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); |
| 314 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); | 315 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); |
| 315 int length = casted_stub()->length(); | 316 int length = casted_stub()->length(); |
| 316 | 317 |
| 317 HInstruction* boilerplate = | 318 HInstruction* allocation_site = |
| 318 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), | 319 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), |
| 319 GetParameter(1), | 320 GetParameter(1), |
| 320 NULL, | 321 NULL, |
| 321 FAST_ELEMENTS)); | 322 FAST_ELEMENTS)); |
| 322 | |
| 323 IfBuilder checker(this); | 323 IfBuilder checker(this); |
| 324 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); | 324 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, undefined); |
| 325 checker.Then(); | 325 checker.Then(); |
| 326 | 326 |
| 327 HObjectAccess access = HObjectAccess::ForAllocationSiteInfoSite(); |
| 328 HInstruction* boilerplate = AddLoad(allocation_site, access); |
| 327 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { | 329 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { |
| 328 HValue* elements = AddLoadElements(boilerplate); | 330 HValue* elements = AddLoadElements(boilerplate); |
| 329 | 331 |
| 330 IfBuilder if_fixed_cow(this); | 332 IfBuilder if_fixed_cow(this); |
| 331 if_fixed_cow.IfCompareMap(elements, factory->fixed_cow_array_map()); | 333 if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map()); |
| 332 if_fixed_cow.Then(); | 334 if_fixed_cow.Then(); |
| 333 environment()->Push(BuildCloneShallowArray(context(), | 335 environment()->Push(BuildCloneShallowArray(context(), |
| 334 boilerplate, | 336 boilerplate, |
| 337 allocation_site, |
| 335 alloc_site_mode, | 338 alloc_site_mode, |
| 336 FAST_ELEMENTS, | 339 FAST_ELEMENTS, |
| 337 0/*copy-on-write*/)); | 340 0/*copy-on-write*/)); |
| 338 if_fixed_cow.Else(); | 341 if_fixed_cow.Else(); |
| 339 | 342 |
| 340 IfBuilder if_fixed(this); | 343 IfBuilder if_fixed(this); |
| 341 if_fixed.IfCompareMap(elements, factory->fixed_array_map()); | 344 if_fixed.If<HCompareMap>(elements, factory->fixed_array_map()); |
| 342 if_fixed.Then(); | 345 if_fixed.Then(); |
| 343 environment()->Push(BuildCloneShallowArray(context(), | 346 environment()->Push(BuildCloneShallowArray(context(), |
| 344 boilerplate, | 347 boilerplate, |
| 348 allocation_site, |
| 345 alloc_site_mode, | 349 alloc_site_mode, |
| 346 FAST_ELEMENTS, | 350 FAST_ELEMENTS, |
| 347 length)); | 351 length)); |
| 348 if_fixed.Else(); | 352 if_fixed.Else(); |
| 349 environment()->Push(BuildCloneShallowArray(context(), | 353 environment()->Push(BuildCloneShallowArray(context(), |
| 350 boilerplate, | 354 boilerplate, |
| 355 allocation_site, |
| 351 alloc_site_mode, | 356 alloc_site_mode, |
| 352 FAST_DOUBLE_ELEMENTS, | 357 FAST_DOUBLE_ELEMENTS, |
| 353 length)); | 358 length)); |
| 354 } else { | 359 } else { |
| 355 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); | 360 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); |
| 356 environment()->Push(BuildCloneShallowArray(context(), | 361 environment()->Push(BuildCloneShallowArray(context(), |
| 357 boilerplate, | 362 boilerplate, |
| 363 allocation_site, |
| 358 alloc_site_mode, | 364 alloc_site_mode, |
| 359 elements_kind, | 365 elements_kind, |
| 360 length)); | 366 length)); |
| 361 } | 367 } |
| 362 | 368 |
| 363 HValue* result = environment()->Pop(); | 369 HValue* result = environment()->Pop(); |
| 364 checker.ElseDeopt(); | 370 checker.ElseDeopt(); |
| 365 return result; | 371 return result; |
| 366 } | 372 } |
| 367 | 373 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 384 | 390 |
| 385 IfBuilder checker(this); | 391 IfBuilder checker(this); |
| 386 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); | 392 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); |
| 387 checker.And(); | 393 checker.And(); |
| 388 | 394 |
| 389 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; | 395 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; |
| 390 HValue* boilerplate_size = | 396 HValue* boilerplate_size = |
| 391 AddInstruction(new(zone) HInstanceSize(boilerplate)); | 397 AddInstruction(new(zone) HInstanceSize(boilerplate)); |
| 392 HValue* size_in_words = | 398 HValue* size_in_words = |
| 393 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2)); | 399 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2)); |
| 394 checker.IfCompare(boilerplate_size, size_in_words, Token::EQ); | 400 checker.If<HCompareNumericAndBranch>(boilerplate_size, |
| 401 size_in_words, Token::EQ); |
| 395 checker.Then(); | 402 checker.Then(); |
| 396 | 403 |
| 397 HValue* size_in_bytes = AddInstruction(new(zone) HConstant(size)); | 404 HValue* size_in_bytes = AddInstruction(new(zone) HConstant(size)); |
| 398 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; | 405 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; |
| 399 if (isolate()->heap()->ShouldGloballyPretenure()) { | 406 if (isolate()->heap()->ShouldGloballyPretenure()) { |
| 400 flags = static_cast<HAllocate::Flags>( | 407 flags = static_cast<HAllocate::Flags>( |
| 401 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); | 408 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); |
| 402 } | 409 } |
| 403 | 410 |
| 404 HInstruction* object = AddInstruction(new(zone) | 411 HInstruction* object = AddInstruction(new(zone) |
| 405 HAllocate(context(), size_in_bytes, HType::JSObject(), flags)); | 412 HAllocate(context(), size_in_bytes, HType::JSObject(), flags)); |
| 406 | 413 |
| 407 for (int i = 0; i < size; i += kPointerSize) { | 414 for (int i = 0; i < size; i += kPointerSize) { |
| 408 HObjectAccess access = HObjectAccess::ForJSObjectOffset(i); | 415 HObjectAccess access = HObjectAccess::ForJSObjectOffset(i); |
| 409 AddStore(object, access, AddLoad(boilerplate, access)); | 416 AddStore(object, access, AddLoad(boilerplate, access)); |
| 410 } | 417 } |
| 411 | 418 |
| 412 checker.ElseDeopt(); | 419 checker.ElseDeopt(); |
| 413 return object; | 420 return object; |
| 414 } | 421 } |
| 415 | 422 |
| 416 | 423 |
| 417 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { | 424 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { |
| 418 return DoGenerateCode(this); | 425 return DoGenerateCode(this); |
| 419 } | 426 } |
| 420 | 427 |
| 421 | 428 |
| 422 template <> | 429 template <> |
| 430 HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() { |
| 431 Zone* zone = this->zone(); |
| 432 |
| 433 HValue* size = AddInstruction(new(zone) HConstant(AllocationSite::kSize)); |
| 434 HAllocate::Flags flags = HAllocate::DefaultFlags(); |
| 435 flags = static_cast<HAllocate::Flags>( |
| 436 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); |
| 437 HInstruction* object = AddInstruction(new(zone) |
| 438 HAllocate(context(), size, HType::JSObject(), flags)); |
| 439 |
| 440 // Store the map |
| 441 Handle<Map> allocation_site_map(isolate()->heap()->allocation_site_map(), |
| 442 isolate()); |
| 443 AddStoreMapConstant(object, allocation_site_map); |
| 444 |
| 445 // Store the payload (smi elements kind) |
| 446 HValue* initial_elements_kind = AddInstruction(new(zone) HConstant( |
| 447 GetInitialFastElementsKind())); |
| 448 AddInstruction(new(zone) HStoreNamedField(object, |
| 449 HObjectAccess::ForAllocationSitePayload(), initial_elements_kind)); |
| 450 |
| 451 // We use a hammer (SkipWriteBarrier()) to indicate that we know the input |
| 452 // cell is really a Cell, and so no write barrier is needed. |
| 453 // TODO(mvstanton): Add a debug_code check to verify the input cell is really |
| 454 // a cell. (perhaps with a new instruction, HAssert). |
| 455 HInstruction* cell = GetParameter(0); |
| 456 HObjectAccess access = HObjectAccess::ForCellValue(); |
| 457 HStoreNamedField* store = AddStore(cell, access, object); |
| 458 store->SkipWriteBarrier(); |
| 459 return cell; |
| 460 } |
| 461 |
| 462 |
| 463 Handle<Code> CreateAllocationSiteStub::GenerateCode() { |
| 464 return DoGenerateCode(this); |
| 465 } |
| 466 |
| 467 |
| 468 template <> |
| 423 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { | 469 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { |
| 424 HInstruction* load = BuildUncheckedMonomorphicElementAccess( | 470 HInstruction* load = BuildUncheckedMonomorphicElementAccess( |
| 425 GetParameter(0), GetParameter(1), NULL, NULL, | 471 GetParameter(0), GetParameter(1), NULL, NULL, |
| 426 casted_stub()->is_js_array(), casted_stub()->elements_kind(), | 472 casted_stub()->is_js_array(), casted_stub()->elements_kind(), |
| 427 false, NEVER_RETURN_HOLE, STANDARD_STORE); | 473 false, NEVER_RETURN_HOLE, STANDARD_STORE); |
| 428 return load; | 474 return load; |
| 429 } | 475 } |
| 430 | 476 |
| 431 | 477 |
| 432 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { | 478 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 539 |
| 494 HInstruction* array_length = | 540 HInstruction* array_length = |
| 495 AddLoad(js_array, HObjectAccess::ForArrayLength()); | 541 AddLoad(js_array, HObjectAccess::ForArrayLength()); |
| 496 array_length->set_type(HType::Smi()); | 542 array_length->set_type(HType::Smi()); |
| 497 | 543 |
| 498 ElementsKind to_kind = casted_stub()->to_kind(); | 544 ElementsKind to_kind = casted_stub()->to_kind(); |
| 499 BuildNewSpaceArrayCheck(array_length, to_kind); | 545 BuildNewSpaceArrayCheck(array_length, to_kind); |
| 500 | 546 |
| 501 IfBuilder if_builder(this); | 547 IfBuilder if_builder(this); |
| 502 | 548 |
| 503 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ); | 549 if_builder.If<HCompareNumericAndBranch>(array_length, |
| 550 graph()->GetConstant0(), |
| 551 Token::EQ); |
| 504 if_builder.Then(); | 552 if_builder.Then(); |
| 505 | 553 |
| 506 // Nothing to do, just change the map. | 554 // Nothing to do, just change the map. |
| 507 | 555 |
| 508 if_builder.Else(); | 556 if_builder.Else(); |
| 509 | 557 |
| 510 HInstruction* elements = AddLoadElements(js_array); | 558 HInstruction* elements = AddLoadElements(js_array); |
| 511 | 559 |
| 512 HInstruction* elements_length = | 560 HInstruction* elements_length = AddLoadFixedArrayLength(elements); |
| 513 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); | |
| 514 | 561 |
| 515 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( | 562 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( |
| 516 context(), to_kind, elements_length); | 563 context(), to_kind, elements_length); |
| 517 | 564 |
| 518 BuildCopyElements(context(), elements, | 565 BuildCopyElements(context(), elements, |
| 519 casted_stub()->from_kind(), new_elements, | 566 casted_stub()->from_kind(), new_elements, |
| 520 to_kind, array_length, elements_length); | 567 to_kind, array_length, elements_length); |
| 521 | 568 |
| 522 AddStore(js_array, HObjectAccess::ForElementsPointer(), new_elements); | 569 AddStore(js_array, HObjectAccess::ForElementsPointer(), new_elements); |
| 523 | 570 |
| 524 if_builder.End(); | 571 if_builder.End(); |
| 525 | 572 |
| 526 AddStore(js_array, HObjectAccess::ForMap(), map); | 573 AddStore(js_array, HObjectAccess::ForMap(), map); |
| 527 | 574 |
| 528 return js_array; | 575 return js_array; |
| 529 } | 576 } |
| 530 | 577 |
| 531 | 578 |
| 532 Handle<Code> TransitionElementsKindStub::GenerateCode() { | 579 Handle<Code> TransitionElementsKindStub::GenerateCode() { |
| 533 return DoGenerateCode(this); | 580 return DoGenerateCode(this); |
| 534 } | 581 } |
| 535 | 582 |
| 536 HValue* CodeStubGraphBuilderBase::BuildArrayConstructor( | 583 HValue* CodeStubGraphBuilderBase::BuildArrayConstructor( |
| 537 ElementsKind kind, bool disable_allocation_sites, | 584 ElementsKind kind, |
| 585 ContextCheckMode context_mode, |
| 586 AllocationSiteOverrideMode override_mode, |
| 538 ArgumentClass argument_class) { | 587 ArgumentClass argument_class) { |
| 539 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); | 588 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); |
| 589 if (context_mode == CONTEXT_CHECK_REQUIRED) { |
| 590 HInstruction* array_function = BuildGetArrayFunction(context()); |
| 591 ArrayContextChecker checker(this, constructor, array_function); |
| 592 } |
| 593 |
| 540 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); | 594 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); |
| 541 HInstruction* array_function = BuildGetArrayFunction(context()); | 595 // Walk through the property cell to the AllocationSite |
| 542 | 596 HValue* alloc_site = AddInstruction(new(zone()) HLoadNamedField(property_cell, |
| 543 ArrayContextChecker(this, constructor, array_function); | 597 HObjectAccess::ForCellValue())); |
| 544 JSArrayBuilder array_builder(this, kind, property_cell, | 598 JSArrayBuilder array_builder(this, kind, alloc_site, constructor, |
| 545 disable_allocation_sites); | 599 override_mode); |
| 546 HValue* result = NULL; | 600 HValue* result = NULL; |
| 547 switch (argument_class) { | 601 switch (argument_class) { |
| 548 case NONE: | 602 case NONE: |
| 549 result = array_builder.AllocateEmptyArray(); | 603 result = array_builder.AllocateEmptyArray(); |
| 550 break; | 604 break; |
| 551 case SINGLE: | 605 case SINGLE: |
| 552 result = BuildArraySingleArgumentConstructor(&array_builder); | 606 result = BuildArraySingleArgumentConstructor(&array_builder); |
| 553 break; | 607 break; |
| 554 case MULTIPLE: | 608 case MULTIPLE: |
| 555 result = BuildArrayNArgumentsConstructor(&array_builder, kind); | 609 result = BuildArrayNArgumentsConstructor(&array_builder, kind); |
| 556 break; | 610 break; |
| 557 } | 611 } |
| 612 |
| 558 return result; | 613 return result; |
| 559 } | 614 } |
| 560 | 615 |
| 561 | 616 |
| 562 HValue* CodeStubGraphBuilderBase::BuildInternalArrayConstructor( | 617 HValue* CodeStubGraphBuilderBase::BuildInternalArrayConstructor( |
| 563 ElementsKind kind, ArgumentClass argument_class) { | 618 ElementsKind kind, ArgumentClass argument_class) { |
| 564 HValue* constructor = GetParameter( | 619 HValue* constructor = GetParameter( |
| 565 InternalArrayConstructorStubBase::kConstructor); | 620 InternalArrayConstructorStubBase::kConstructor); |
| 566 JSArrayBuilder array_builder(this, kind, constructor); | 621 JSArrayBuilder array_builder(this, kind, constructor); |
| 567 | 622 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 592 HInstruction* argument = AddInstruction( | 647 HInstruction* argument = AddInstruction( |
| 593 new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero)); | 648 new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero)); |
| 594 | 649 |
| 595 HConstant* max_alloc_length = | 650 HConstant* max_alloc_length = |
| 596 new(zone()) HConstant(JSObject::kInitialMaxFastElementArray); | 651 new(zone()) HConstant(JSObject::kInitialMaxFastElementArray); |
| 597 AddInstruction(max_alloc_length); | 652 AddInstruction(max_alloc_length); |
| 598 const int initial_capacity = JSArray::kPreallocatedArrayElements; | 653 const int initial_capacity = JSArray::kPreallocatedArrayElements; |
| 599 HConstant* initial_capacity_node = new(zone()) HConstant(initial_capacity); | 654 HConstant* initial_capacity_node = new(zone()) HConstant(initial_capacity); |
| 600 AddInstruction(initial_capacity_node); | 655 AddInstruction(initial_capacity_node); |
| 601 | 656 |
| 602 HBoundsCheck* checked_arg = AddBoundsCheck(argument, max_alloc_length); | 657 HBoundsCheck* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length); |
| 603 IfBuilder if_builder(this); | 658 IfBuilder if_builder(this); |
| 604 if_builder.IfCompare(checked_arg, constant_zero, Token::EQ); | 659 if_builder.If<HCompareNumericAndBranch>(checked_arg, constant_zero, |
| 660 Token::EQ); |
| 605 if_builder.Then(); | 661 if_builder.Then(); |
| 606 Push(initial_capacity_node); // capacity | 662 Push(initial_capacity_node); // capacity |
| 607 Push(constant_zero); // length | 663 Push(constant_zero); // length |
| 608 if_builder.Else(); | 664 if_builder.Else(); |
| 609 Push(checked_arg); // capacity | 665 Push(checked_arg); // capacity |
| 610 Push(checked_arg); // length | 666 Push(checked_arg); // length |
| 611 if_builder.End(); | 667 if_builder.End(); |
| 612 | 668 |
| 613 // Figure out total size | 669 // Figure out total size |
| 614 HValue* length = Pop(); | 670 HValue* length = Pop(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 645 | 701 |
| 646 AddInstruction(new(zone()) HStoreKeyed(elements, key, argument, kind)); | 702 AddInstruction(new(zone()) HStoreKeyed(elements, key, argument, kind)); |
| 647 builder.EndBody(); | 703 builder.EndBody(); |
| 648 return new_object; | 704 return new_object; |
| 649 } | 705 } |
| 650 | 706 |
| 651 | 707 |
| 652 template <> | 708 template <> |
| 653 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { | 709 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { |
| 654 ElementsKind kind = casted_stub()->elements_kind(); | 710 ElementsKind kind = casted_stub()->elements_kind(); |
| 655 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); | 711 ContextCheckMode context_mode = casted_stub()->context_mode(); |
| 656 return BuildArrayConstructor(kind, disable_allocation_sites, NONE); | 712 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); |
| 713 return BuildArrayConstructor(kind, context_mode, override_mode, NONE); |
| 657 } | 714 } |
| 658 | 715 |
| 659 | 716 |
| 660 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() { | 717 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() { |
| 661 return DoGenerateCode(this); | 718 return DoGenerateCode(this); |
| 662 } | 719 } |
| 663 | 720 |
| 664 | 721 |
| 665 template <> | 722 template <> |
| 666 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: | 723 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: |
| 667 BuildCodeStub() { | 724 BuildCodeStub() { |
| 668 ElementsKind kind = casted_stub()->elements_kind(); | 725 ElementsKind kind = casted_stub()->elements_kind(); |
| 669 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); | 726 ContextCheckMode context_mode = casted_stub()->context_mode(); |
| 670 return BuildArrayConstructor(kind, disable_allocation_sites, SINGLE); | 727 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); |
| 728 return BuildArrayConstructor(kind, context_mode, override_mode, SINGLE); |
| 671 } | 729 } |
| 672 | 730 |
| 673 | 731 |
| 674 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() { | 732 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() { |
| 675 return DoGenerateCode(this); | 733 return DoGenerateCode(this); |
| 676 } | 734 } |
| 677 | 735 |
| 678 | 736 |
| 679 template <> | 737 template <> |
| 680 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { | 738 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { |
| 681 ElementsKind kind = casted_stub()->elements_kind(); | 739 ElementsKind kind = casted_stub()->elements_kind(); |
| 682 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); | 740 ContextCheckMode context_mode = casted_stub()->context_mode(); |
| 683 return BuildArrayConstructor(kind, disable_allocation_sites, MULTIPLE); | 741 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); |
| 742 return BuildArrayConstructor(kind, context_mode, override_mode, MULTIPLE); |
| 684 } | 743 } |
| 685 | 744 |
| 686 | 745 |
| 687 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { | 746 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { |
| 688 return DoGenerateCode(this); | 747 return DoGenerateCode(this); |
| 689 } | 748 } |
| 690 | 749 |
| 691 | 750 |
| 692 template <> | 751 template <> |
| 693 HValue* CodeStubGraphBuilder<InternalArrayNoArgumentConstructorStub>:: | 752 HValue* CodeStubGraphBuilder<InternalArrayNoArgumentConstructorStub>:: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 : graph()->GetConstantUndefined(); | 808 : graph()->GetConstantUndefined(); |
| 750 } | 809 } |
| 751 | 810 |
| 752 | 811 |
| 753 Handle<Code> CompareNilICStub::GenerateCode() { | 812 Handle<Code> CompareNilICStub::GenerateCode() { |
| 754 return DoGenerateCode(this); | 813 return DoGenerateCode(this); |
| 755 } | 814 } |
| 756 | 815 |
| 757 | 816 |
| 758 template <> | 817 template <> |
| 818 HValue* CodeStubGraphBuilder<UnaryOpStub>::BuildCodeInitializedStub() { |
| 819 UnaryOpStub* stub = casted_stub(); |
| 820 Handle<Type> type = stub->GetType(graph()->isolate()); |
| 821 HValue* input = GetParameter(0); |
| 822 |
| 823 // Prevent unwanted HChange being inserted to ensure that the stub |
| 824 // deopts on newly encountered types. |
| 825 if (!type->Maybe(Type::Double())) { |
| 826 input = AddInstruction(new(zone()) |
| 827 HForceRepresentation(input, Representation::Smi())); |
| 828 } |
| 829 |
| 830 if (!type->Is(Type::Number())) { |
| 831 // If we expect to see other things than Numbers, we will create a generic |
| 832 // stub, which handles all numbers and calls into the runtime for the rest. |
| 833 IfBuilder if_number(this); |
| 834 if_number.If<HIsNumberAndBranch>(input); |
| 835 if_number.Then(); |
| 836 HInstruction* res = BuildUnaryMathOp(input, type, stub->operation()); |
| 837 if_number.Return(AddInstruction(res)); |
| 838 if_number.Else(); |
| 839 HValue* function = AddLoadJSBuiltin(stub->ToJSBuiltin(), context()); |
| 840 Add<HPushArgument>(GetParameter(0)); |
| 841 HValue* result = Add<HInvokeFunction>(context(), function, 1); |
| 842 if_number.Return(result); |
| 843 if_number.End(); |
| 844 return graph()->GetConstantUndefined(); |
| 845 } |
| 846 |
| 847 return AddInstruction(BuildUnaryMathOp(input, type, stub->operation())); |
| 848 } |
| 849 |
| 850 |
| 851 Handle<Code> UnaryOpStub::GenerateCode() { |
| 852 return DoGenerateCode(this); |
| 853 } |
| 854 |
| 855 |
| 856 template <> |
| 759 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { | 857 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { |
| 760 ToBooleanStub* stub = casted_stub(); | 858 ToBooleanStub* stub = casted_stub(); |
| 761 | 859 |
| 762 IfBuilder if_true(this); | 860 IfBuilder if_true(this); |
| 763 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); | 861 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); |
| 764 if_true.Then(); | 862 if_true.Then(); |
| 765 if_true.Return(graph()->GetConstant1()); | 863 if_true.Return(graph()->GetConstant1()); |
| 766 if_true.Else(); | 864 if_true.Else(); |
| 767 if_true.End(); | 865 if_true.End(); |
| 768 return graph()->GetConstant0(); | 866 return graph()->GetConstant0(); |
| 769 } | 867 } |
| 770 | 868 |
| 771 | 869 |
| 772 Handle<Code> ToBooleanStub::GenerateCode() { | 870 Handle<Code> ToBooleanStub::GenerateCode() { |
| 773 return DoGenerateCode(this); | 871 return DoGenerateCode(this); |
| 774 } | 872 } |
| 775 | 873 |
| 776 | 874 |
| 875 template <> |
| 876 HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() { |
| 877 StoreGlobalStub* stub = casted_stub(); |
| 878 Handle<Object> hole(isolate()->heap()->the_hole_value(), isolate()); |
| 879 Handle<Object> placeholer_value(Smi::FromInt(0), isolate()); |
| 880 Handle<PropertyCell> placeholder_cell = |
| 881 isolate()->factory()->NewPropertyCell(placeholer_value); |
| 882 |
| 883 HParameter* receiver = GetParameter(0); |
| 884 HParameter* value = GetParameter(2); |
| 885 |
| 886 if (stub->is_constant()) { |
| 887 // Assume every store to a constant value changes it. |
| 888 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); |
| 889 set_current_block(NULL); |
| 890 } else { |
| 891 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged()); |
| 892 |
| 893 // Check that the map of the global has not changed: use a placeholder map |
| 894 // that will be replaced later with the global object's map. |
| 895 Handle<Map> placeholder_map = isolate()->factory()->meta_map(); |
| 896 AddInstruction(HCheckMaps::New(receiver, placeholder_map, zone())); |
| 897 |
| 898 // Load the payload of the global parameter cell. A hole indicates that the |
| 899 // property has been deleted and that the store must be handled by the |
| 900 // runtime. |
| 901 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); |
| 902 HValue* cell_contents = Add<HLoadNamedField>(cell, access); |
| 903 IfBuilder builder(this); |
| 904 HValue* hole_value = Add<HConstant>(hole, Representation::Tagged()); |
| 905 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); |
| 906 builder.Then(); |
| 907 builder.Deopt(); |
| 908 builder.Else(); |
| 909 Add<HStoreNamedField>(cell, access, value); |
| 910 builder.End(); |
| 911 } |
| 912 return value; |
| 913 } |
| 914 |
| 915 |
| 916 Handle<Code> StoreGlobalStub::GenerateCode() { |
| 917 return DoGenerateCode(this); |
| 918 } |
| 919 |
| 920 |
| 777 } } // namespace v8::internal | 921 } } // namespace v8::internal |
| OLD | NEW |