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 = AddLoadFixedArrayLength(elements); | 516 HInstruction* elements_length = AddLoadFixedArrayLength(elements); |
514 | 517 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 | 602 |
600 HConstant* max_alloc_length = | 603 HConstant* max_alloc_length = |
601 new(zone()) HConstant(JSObject::kInitialMaxFastElementArray); | 604 new(zone()) HConstant(JSObject::kInitialMaxFastElementArray); |
602 AddInstruction(max_alloc_length); | 605 AddInstruction(max_alloc_length); |
603 const int initial_capacity = JSArray::kPreallocatedArrayElements; | 606 const int initial_capacity = JSArray::kPreallocatedArrayElements; |
604 HConstant* initial_capacity_node = new(zone()) HConstant(initial_capacity); | 607 HConstant* initial_capacity_node = new(zone()) HConstant(initial_capacity); |
605 AddInstruction(initial_capacity_node); | 608 AddInstruction(initial_capacity_node); |
606 | 609 |
607 HBoundsCheck* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length); | 610 HBoundsCheck* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length); |
608 IfBuilder if_builder(this); | 611 IfBuilder if_builder(this); |
609 if_builder.IfCompare(checked_arg, constant_zero, Token::EQ); | 612 if_builder.If<HCompareNumericAndBranch>(checked_arg, constant_zero, |
| 613 Token::EQ); |
610 if_builder.Then(); | 614 if_builder.Then(); |
611 Push(initial_capacity_node); // capacity | 615 Push(initial_capacity_node); // capacity |
612 Push(constant_zero); // length | 616 Push(constant_zero); // length |
613 if_builder.Else(); | 617 if_builder.Else(); |
614 Push(checked_arg); // capacity | 618 Push(checked_arg); // capacity |
615 Push(checked_arg); // length | 619 Push(checked_arg); // length |
616 if_builder.End(); | 620 if_builder.End(); |
617 | 621 |
618 // Figure out total size | 622 // Figure out total size |
619 HValue* length = Pop(); | 623 HValue* length = Pop(); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 | 835 |
832 HParameter* receiver = GetParameter(0); | 836 HParameter* receiver = GetParameter(0); |
833 HParameter* value = GetParameter(2); | 837 HParameter* value = GetParameter(2); |
834 | 838 |
835 if (stub->is_constant()) { | 839 if (stub->is_constant()) { |
836 // Assume every store to a constant value changes it. | 840 // Assume every store to a constant value changes it. |
837 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); | 841 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); |
838 set_current_block(NULL); | 842 set_current_block(NULL); |
839 } else { | 843 } else { |
840 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged()); | 844 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged()); |
841 // Check that the map of the global has not changed. | 845 |
842 AddInstruction(HCheckMaps::New(receiver, | 846 // Check that the map of the global has not changed: use a placeholder map |
843 Handle<Map>(isolate()->heap()->meta_map()), | 847 // that will be replaced later with the global object's map. |
844 zone())); | 848 Handle<Map> placeholder_map = isolate()->factory()->meta_map(); |
| 849 AddInstruction(HCheckMaps::New(receiver, placeholder_map, zone())); |
845 | 850 |
846 // Load the payload of the global parameter cell. A hole indicates that the | 851 // Load the payload of the global parameter cell. A hole indicates that the |
847 // property has been deleted and that the store must be handled by the | 852 // property has been deleted and that the store must be handled by the |
848 // runtime. | 853 // runtime. |
849 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); | 854 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); |
850 HValue* cell_contents = Add<HLoadNamedField>(cell, access); | 855 HValue* cell_contents = Add<HLoadNamedField>(cell, access); |
851 IfBuilder builder(this); | 856 IfBuilder builder(this); |
852 HValue* hole_value = Add<HConstant>(hole, Representation::Tagged()); | 857 HValue* hole_value = Add<HConstant>(hole, Representation::Tagged()); |
853 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); | 858 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); |
854 builder.Then(); | 859 builder.Then(); |
855 builder.Deopt(); | 860 builder.Deopt(); |
856 builder.Else(); | 861 builder.Else(); |
857 Add<HStoreNamedField>(cell, access, value); | 862 Add<HStoreNamedField>(cell, access, value); |
858 builder.End(); | 863 builder.End(); |
859 } | 864 } |
860 return value; | 865 return value; |
861 } | 866 } |
862 | 867 |
863 | 868 |
864 Handle<Code> StoreGlobalStub::GenerateCode() { | 869 Handle<Code> StoreGlobalStub::GenerateCode() { |
865 return DoGenerateCode(this); | 870 return DoGenerateCode(this); |
866 } | 871 } |
867 | 872 |
868 | 873 |
869 } } // namespace v8::internal | 874 } } // namespace v8::internal |
OLD | NEW |