Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 18876004: Use BuildGrowElementsCapacity for the TransitionElementsKind stub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/hydrogen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 } 521 }
522 522
523 523
524 Handle<Code> KeyedStoreFastElementStub::GenerateCode() { 524 Handle<Code> KeyedStoreFastElementStub::GenerateCode() {
525 return DoGenerateCode(this); 525 return DoGenerateCode(this);
526 } 526 }
527 527
528 528
529 template <> 529 template <>
530 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { 530 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
531 Zone* zone = this->zone();
532
533 HValue* js_array = GetParameter(0); 531 HValue* js_array = GetParameter(0);
534 HValue* map = GetParameter(1); 532 HValue* map = GetParameter(1);
535 533
536 info()->MarkAsSavesCallerDoubles(); 534 info()->MarkAsSavesCallerDoubles();
537 535
538 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); 536 Add<HTrapAllocationMemento>(js_array);
539 537
540 HInstruction* array_length = 538 HInstruction* array_length =
541 AddLoad(js_array, HObjectAccess::ForArrayLength()); 539 AddLoad(js_array, HObjectAccess::ForArrayLength());
542 array_length->set_type(HType::Smi()); 540 array_length->set_type(HType::Smi());
543 541
544 ElementsKind to_kind = casted_stub()->to_kind();
545 BuildNewSpaceArrayCheck(array_length, to_kind);
546
547 IfBuilder if_builder(this); 542 IfBuilder if_builder(this);
548 543
549 if_builder.If<HCompareNumericAndBranch>(array_length, 544 if_builder.IfNot<HCompareNumericAndBranch>(array_length,
550 graph()->GetConstant0(), 545 graph()->GetConstant0(),
551 Token::EQ); 546 Token::EQ);
552 if_builder.Then(); 547 if_builder.Then();
553 548
554 // Nothing to do, just change the map.
555
556 if_builder.Else();
557
558 HInstruction* elements = AddLoadElements(js_array); 549 HInstruction* elements = AddLoadElements(js_array);
559 550
560 HInstruction* elements_length = AddLoadFixedArrayLength(elements); 551 HInstruction* elements_length = AddLoadFixedArrayLength(elements);
561 552
562 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( 553 BuildGrowElementsCapacity(js_array, elements,
563 context(), to_kind, elements_length); 554 casted_stub()->from_kind(),
564 555 casted_stub()->to_kind(),
565 BuildCopyElements(context(), elements, 556 array_length, elements_length);
566 casted_stub()->from_kind(), new_elements,
567 to_kind, array_length, elements_length);
568
569 AddStore(js_array, HObjectAccess::ForElementsPointer(), new_elements);
570 557
571 if_builder.End(); 558 if_builder.End();
572 559
573 AddStore(js_array, HObjectAccess::ForMap(), map); 560 AddStore(js_array, HObjectAccess::ForMap(), map);
574 561
575 return js_array; 562 return js_array;
576 } 563 }
577 564
578 565
579 Handle<Code> TransitionElementsKindStub::GenerateCode() { 566 Handle<Code> TransitionElementsKindStub::GenerateCode() {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 return value; 899 return value;
913 } 900 }
914 901
915 902
916 Handle<Code> StoreGlobalStub::GenerateCode() { 903 Handle<Code> StoreGlobalStub::GenerateCode() {
917 return DoGenerateCode(this); 904 return DoGenerateCode(this);
918 } 905 }
919 906
920 907
921 } } // namespace v8::internal 908 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698