Chromium Code Reviews| 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 FAST_ELEMENTS)); | 322 FAST_ELEMENTS)); |
| 323 | 323 |
| 324 IfBuilder checker(this); | 324 IfBuilder checker(this); |
| 325 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); | 325 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); |
| 326 checker.Then(); | 326 checker.Then(); |
| 327 | 327 |
| 328 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { | 328 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { |
| 329 HValue* elements = AddLoadElements(boilerplate); | 329 HValue* elements = AddLoadElements(boilerplate); |
| 330 | 330 |
| 331 IfBuilder if_fixed_cow(this); | 331 IfBuilder if_fixed_cow(this); |
| 332 if_fixed_cow.IfCompareMap(elements, factory->fixed_cow_array_map()); | 332 if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map()); |
| 333 if_fixed_cow.Then(); | 333 if_fixed_cow.Then(); |
| 334 environment()->Push(BuildCloneShallowArray(context(), | 334 environment()->Push(BuildCloneShallowArray(context(), |
| 335 boilerplate, | 335 boilerplate, |
| 336 alloc_site_mode, | 336 alloc_site_mode, |
| 337 FAST_ELEMENTS, | 337 FAST_ELEMENTS, |
| 338 0/*copy-on-write*/)); | 338 0/*copy-on-write*/)); |
| 339 if_fixed_cow.Else(); | 339 if_fixed_cow.Else(); |
| 340 | 340 |
| 341 IfBuilder if_fixed(this); | 341 IfBuilder if_fixed(this); |
| 342 if_fixed.IfCompareMap(elements, factory->fixed_array_map()); | 342 if_fixed.If<HCompareMap>(elements, factory->fixed_array_map()); |
| 343 if_fixed.Then(); | 343 if_fixed.Then(); |
| 344 environment()->Push(BuildCloneShallowArray(context(), | 344 environment()->Push(BuildCloneShallowArray(context(), |
| 345 boilerplate, | 345 boilerplate, |
| 346 alloc_site_mode, | 346 alloc_site_mode, |
| 347 FAST_ELEMENTS, | 347 FAST_ELEMENTS, |
| 348 length)); | 348 length)); |
| 349 if_fixed.Else(); | 349 if_fixed.Else(); |
| 350 environment()->Push(BuildCloneShallowArray(context(), | 350 environment()->Push(BuildCloneShallowArray(context(), |
| 351 boilerplate, | 351 boilerplate, |
| 352 alloc_site_mode, | 352 alloc_site_mode, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 | 385 |
| 386 IfBuilder checker(this); | 386 IfBuilder checker(this); |
| 387 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); | 387 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); |
| 388 checker.And(); | 388 checker.And(); |
| 389 | 389 |
| 390 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; | 390 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; |
| 391 HValue* boilerplate_size = | 391 HValue* boilerplate_size = |
| 392 AddInstruction(new(zone) HInstanceSize(boilerplate)); | 392 AddInstruction(new(zone) HInstanceSize(boilerplate)); |
| 393 HValue* size_in_words = | 393 HValue* size_in_words = |
| 394 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2)); | 394 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2)); |
| 395 checker.IfCompare(boilerplate_size, size_in_words, Token::EQ); | 395 checker.If<HCompareNumericAndBranch>(boilerplate_size, |
| 396 size_in_words, Token::EQ); | |
| 396 checker.Then(); | 397 checker.Then(); |
| 397 | 398 |
| 398 HValue* size_in_bytes = AddInstruction(new(zone) HConstant(size)); | 399 HValue* size_in_bytes = AddInstruction(new(zone) HConstant(size)); |
| 399 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; | 400 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; |
| 400 if (isolate()->heap()->ShouldGloballyPretenure()) { | 401 if (isolate()->heap()->ShouldGloballyPretenure()) { |
| 401 flags = static_cast<HAllocate::Flags>( | 402 flags = static_cast<HAllocate::Flags>( |
| 402 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); | 403 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); |
| 403 } | 404 } |
| 404 | 405 |
| 405 HInstruction* object = AddInstruction(new(zone) | 406 HInstruction* object = AddInstruction(new(zone) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 | 495 |
| 495 HInstruction* array_length = | 496 HInstruction* array_length = |
| 496 AddLoad(js_array, HObjectAccess::ForArrayLength()); | 497 AddLoad(js_array, HObjectAccess::ForArrayLength()); |
| 497 array_length->set_type(HType::Smi()); | 498 array_length->set_type(HType::Smi()); |
| 498 | 499 |
| 499 ElementsKind to_kind = casted_stub()->to_kind(); | 500 ElementsKind to_kind = casted_stub()->to_kind(); |
| 500 BuildNewSpaceArrayCheck(array_length, to_kind); | 501 BuildNewSpaceArrayCheck(array_length, to_kind); |
| 501 | 502 |
| 502 IfBuilder if_builder(this); | 503 IfBuilder if_builder(this); |
| 503 | 504 |
| 504 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ); | 505 if_builder.If<HCompareNumericAndBranch>(array_length, |
| 506 graph()->GetConstant0(), | |
| 507 Token::EQ); | |
| 505 if_builder.Then(); | 508 if_builder.Then(); |
| 506 | 509 |
| 507 // Nothing to do, just change the map. | 510 // Nothing to do, just change the map. |
| 508 | 511 |
| 509 if_builder.Else(); | 512 if_builder.Else(); |
| 510 | 513 |
| 511 HInstruction* elements = AddLoadElements(js_array); | 514 HInstruction* elements = AddLoadElements(js_array); |
| 512 | 515 |
| 513 HInstruction* elements_length = | 516 HInstruction* elements_length = |
| 514 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); | 517 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 | 603 |
| 601 HConstant* max_alloc_length = | 604 HConstant* max_alloc_length = |
| 602 new(zone()) HConstant(JSObject::kInitialMaxFastElementArray); | 605 new(zone()) HConstant(JSObject::kInitialMaxFastElementArray); |
| 603 AddInstruction(max_alloc_length); | 606 AddInstruction(max_alloc_length); |
| 604 const int initial_capacity = JSArray::kPreallocatedArrayElements; | 607 const int initial_capacity = JSArray::kPreallocatedArrayElements; |
| 605 HConstant* initial_capacity_node = new(zone()) HConstant(initial_capacity); | 608 HConstant* initial_capacity_node = new(zone()) HConstant(initial_capacity); |
| 606 AddInstruction(initial_capacity_node); | 609 AddInstruction(initial_capacity_node); |
| 607 | 610 |
| 608 HBoundsCheck* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length); | 611 HBoundsCheck* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length); |
| 609 IfBuilder if_builder(this); | 612 IfBuilder if_builder(this); |
| 610 if_builder.IfCompare(checked_arg, constant_zero, Token::EQ); | 613 if_builder.If<HCompareNumericAndBranch>(checked_arg, constant_zero, |
| 614 Token::EQ); | |
| 611 if_builder.Then(); | 615 if_builder.Then(); |
| 612 Push(initial_capacity_node); // capacity | 616 Push(initial_capacity_node); // capacity |
| 613 Push(constant_zero); // length | 617 Push(constant_zero); // length |
| 614 if_builder.Else(); | 618 if_builder.Else(); |
| 615 Push(checked_arg); // capacity | 619 Push(checked_arg); // capacity |
| 616 Push(checked_arg); // length | 620 Push(checked_arg); // length |
| 617 if_builder.End(); | 621 if_builder.End(); |
| 618 | 622 |
| 619 // Figure out total size | 623 // Figure out total size |
| 620 HValue* length = Pop(); | 624 HValue* length = Pop(); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 793 | 797 |
| 794 HParameter* receiver = GetParameter(0); | 798 HParameter* receiver = GetParameter(0); |
| 795 HParameter* value = GetParameter(2); | 799 HParameter* value = GetParameter(2); |
| 796 | 800 |
| 797 if (stub->is_constant()) { | 801 if (stub->is_constant()) { |
| 798 // Assume every store to a constant value changes it. | 802 // Assume every store to a constant value changes it. |
| 799 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); | 803 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); |
| 800 set_current_block(NULL); | 804 set_current_block(NULL); |
| 801 } else { | 805 } else { |
| 802 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged()); | 806 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged()); |
| 803 // Check that the map of the global has not changed. | 807 |
| 804 AddInstruction(HCheckMaps::New(receiver, | 808 // Check that the map of the global has not changed: use a placeholder map |
| 805 Handle<Map>(isolate()->heap()->meta_map()), | 809 // that will be replaced later with the global object's map. |
| 806 zone())); | 810 Handle<Map> placeholder_map(Handle<Map>(isolate()->heap()->meta_map())); |
|
Michael Starzinger
2013/07/01 12:30:39
nit: Just use "Handle<Map> placeholder_map = isola
danno
2013/07/05 09:52:39
Done.
| |
| 811 AddInstruction(HCheckMaps::New(receiver, placeholder_map, zone())); | |
| 807 | 812 |
| 808 // Load the payload of the global parameter cell. A hole indicates that the | 813 // Load the payload of the global parameter cell. A hole indicates that the |
| 809 // property has been deleted and that the store must be handled by the | 814 // property has been deleted and that the store must be handled by the |
| 810 // runtime. | 815 // runtime. |
| 811 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); | 816 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); |
| 812 HValue* cell_contents = Add<HLoadNamedField>(cell, access); | 817 HValue* cell_contents = Add<HLoadNamedField>(cell, access); |
| 813 IfBuilder builder(this); | 818 IfBuilder builder(this); |
| 814 HValue* hole_value = Add<HConstant>(hole, Representation::Tagged()); | 819 HValue* hole_value = Add<HConstant>(hole, Representation::Tagged()); |
| 815 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); | 820 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); |
| 816 builder.Then(); | 821 builder.Then(); |
| 817 builder.Deopt(); | 822 builder.Deopt(); |
| 818 builder.Else(); | 823 builder.Else(); |
| 819 Add<HStoreNamedField>(cell, access, value); | 824 Add<HStoreNamedField>(cell, access, value); |
| 820 builder.End(); | 825 builder.End(); |
| 821 } | 826 } |
| 822 return value; | 827 return value; |
| 823 } | 828 } |
| 824 | 829 |
| 825 | 830 |
| 826 Handle<Code> StoreGlobalStub::GenerateCode() { | 831 Handle<Code> StoreGlobalStub::GenerateCode() { |
| 827 return DoGenerateCode(this); | 832 return DoGenerateCode(this); |
| 828 } | 833 } |
| 829 | 834 |
| 830 | 835 |
| 831 } } // namespace v8::internal | 836 } } // namespace v8::internal |
| OLD | NEW |