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

Side by Side Diff: src/hydrogen-dehoist.cc

Issue 74113002: Limit size of dehoistable array indices (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 | « src/elements-kind.cc ('k') | src/hydrogen-instructions.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 constant = HConstant::cast(binary_operation->right()); 46 constant = HConstant::cast(binary_operation->right());
47 } else { 47 } else {
48 return; 48 return;
49 } 49 }
50 50
51 if (!constant->HasInteger32Value()) return; 51 if (!constant->HasInteger32Value()) return;
52 int32_t sign = binary_operation->IsSub() ? -1 : 1; 52 int32_t sign = binary_operation->IsSub() ? -1 : 1;
53 int32_t value = constant->Integer32Value() * sign; 53 int32_t value = constant->Integer32Value() * sign;
54 // We limit offset values to 30 bits because we want to avoid the risk of 54 // We limit offset values to 30 bits because we want to avoid the risk of
55 // overflows when the offset is added to the object header size. 55 // overflows when the offset is added to the object header size.
56 if (value >= 1 << 30 || value < 0) return; 56 if (value >= 1 << array_operation->MaxIndexOffsetBits() || value < 0) return;
57 array_operation->SetKey(subexpression); 57 array_operation->SetKey(subexpression);
58 if (binary_operation->HasNoUses()) { 58 if (binary_operation->HasNoUses()) {
59 binary_operation->DeleteAndReplaceWith(NULL); 59 binary_operation->DeleteAndReplaceWith(NULL);
60 } 60 }
61 array_operation->SetIndexOffset(static_cast<uint32_t>(value)); 61 array_operation->SetIndexOffset(static_cast<uint32_t>(value));
62 array_operation->SetDehoisted(true); 62 array_operation->SetDehoisted(true);
63 } 63 }
64 64
65 65
66 void HDehoistIndexComputationsPhase::Run() { 66 void HDehoistIndexComputationsPhase::Run() {
67 const ZoneList<HBasicBlock*>* blocks(graph()->blocks()); 67 const ZoneList<HBasicBlock*>* blocks(graph()->blocks());
68 for (int i = 0; i < blocks->length(); ++i) { 68 for (int i = 0; i < blocks->length(); ++i) {
69 for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) { 69 for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) {
70 HInstruction* instr = it.Current(); 70 HInstruction* instr = it.Current();
71 if (instr->IsLoadKeyed()) { 71 if (instr->IsLoadKeyed()) {
72 DehoistArrayIndex(HLoadKeyed::cast(instr)); 72 DehoistArrayIndex(HLoadKeyed::cast(instr));
73 } else if (instr->IsStoreKeyed()) { 73 } else if (instr->IsStoreKeyed()) {
74 DehoistArrayIndex(HStoreKeyed::cast(instr)); 74 DehoistArrayIndex(HStoreKeyed::cast(instr));
75 } 75 }
76 } 76 }
77 } 77 }
78 } 78 }
79 79
80 } } // namespace v8::internal 80 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements-kind.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698