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

Side by Side Diff: src/hydrogen-uint32-analysis.cc

Issue 288383002: Allow comparison in UINT32 mode. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 | « src/arm64/lithium-codegen-arm64.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "hydrogen-uint32-analysis.h" 5 #include "hydrogen-uint32-analysis.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 9
10 10
11 static bool IsUnsignedLoad(HLoadKeyed* instr) {
12 switch (instr->elements_kind()) {
13 case EXTERNAL_UINT8_ELEMENTS:
14 case EXTERNAL_UINT16_ELEMENTS:
15 case EXTERNAL_UINT32_ELEMENTS:
16 case EXTERNAL_UINT8_CLAMPED_ELEMENTS:
17 case UINT8_ELEMENTS:
18 case UINT16_ELEMENTS:
19 case UINT32_ELEMENTS:
20 case UINT8_CLAMPED_ELEMENTS:
21 return true;
22 default:
23 return false;
24 }
25 }
26
27
28 static bool IsUint32Operation(HValue* instr) {
29 return instr->IsShr() ||
30 (instr->IsLoadKeyed() && IsUnsignedLoad(HLoadKeyed::cast(instr))) ||
31 (instr->IsInteger32Constant() && instr->GetInteger32Constant() >= 0);
32 }
33
34
11 bool HUint32AnalysisPhase::IsSafeUint32Use(HValue* val, HValue* use) { 35 bool HUint32AnalysisPhase::IsSafeUint32Use(HValue* val, HValue* use) {
12 // Operations that operate on bits are safe. 36 // Operations that operate on bits are safe.
13 if (use->IsBitwise() || use->IsShl() || use->IsSar() || use->IsShr()) { 37 if (use->IsBitwise() || use->IsShl() || use->IsSar() || use->IsShr()) {
14 return true; 38 return true;
15 } else if (use->IsSimulate()) { 39 } else if (use->IsSimulate()) {
16 // Deoptimization has special support for uint32. 40 // Deoptimization has special support for uint32.
17 return true; 41 return true;
18 } else if (use->IsChange()) { 42 } else if (use->IsChange()) {
19 // Conversions have special support for uint32. 43 // Conversions have special support for uint32.
20 // This ASSERT guards that the conversion in question is actually 44 // This ASSERT guards that the conversion in question is actually
21 // implemented. Do not extend the whitelist without adding 45 // implemented. Do not extend the whitelist without adding
22 // support to LChunkBuilder::DoChange(). 46 // support to LChunkBuilder::DoChange().
23 ASSERT(HChange::cast(use)->to().IsDouble() || 47 ASSERT(HChange::cast(use)->to().IsDouble() ||
24 HChange::cast(use)->to().IsSmi() || 48 HChange::cast(use)->to().IsSmi() ||
25 HChange::cast(use)->to().IsTagged()); 49 HChange::cast(use)->to().IsTagged());
26 return true; 50 return true;
27 } else if (use->IsStoreKeyed()) { 51 } else if (use->IsStoreKeyed()) {
28 HStoreKeyed* store = HStoreKeyed::cast(use); 52 HStoreKeyed* store = HStoreKeyed::cast(use);
29 if (store->is_external()) { 53 if (store->is_external()) {
30 // Storing a value into an external integer array is a bit level 54 // Storing a value into an external integer array is a bit level
31 // operation. 55 // operation.
32 if (store->value() == val) { 56 if (store->value() == val) {
33 // Clamping or a conversion to double should have beed inserted. 57 // Clamping or a conversion to double should have beed inserted.
34 ASSERT(store->elements_kind() != EXTERNAL_UINT8_CLAMPED_ELEMENTS); 58 ASSERT(store->elements_kind() != EXTERNAL_UINT8_CLAMPED_ELEMENTS);
35 ASSERT(store->elements_kind() != EXTERNAL_FLOAT32_ELEMENTS); 59 ASSERT(store->elements_kind() != EXTERNAL_FLOAT32_ELEMENTS);
36 ASSERT(store->elements_kind() != EXTERNAL_FLOAT64_ELEMENTS); 60 ASSERT(store->elements_kind() != EXTERNAL_FLOAT64_ELEMENTS);
37 return true; 61 return true;
38 } 62 }
39 } 63 }
64 } else if (use->IsCompareNumericAndBranch()) {
65 HCompareNumericAndBranch* c = HCompareNumericAndBranch::cast(use);
66 return IsUint32Operation(c->left()) && IsUint32Operation(c->right());
40 } 67 }
41 68
42 return false; 69 return false;
43 } 70 }
44 71
45 72
46 // Iterate over all uses and verify that they are uint32 safe: either don't 73 // Iterate over all uses and verify that they are uint32 safe: either don't
47 // distinguish between int32 and uint32 due to their bitwise nature or 74 // distinguish between int32 and uint32 due to their bitwise nature or
48 // have special support for uint32 values. 75 // have special support for uint32 values.
49 // Encountered phis are optimistically treated as safe uint32 uses, 76 // Encountered phis are optimistically treated as safe uint32 uses,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 231
205 // Some phis might have been optimistically marked with kUint32 flag. 232 // Some phis might have been optimistically marked with kUint32 flag.
206 // Remove this flag from those phis that are unsafe and propagate 233 // Remove this flag from those phis that are unsafe and propagate
207 // this information transitively potentially clearing kUint32 flag 234 // this information transitively potentially clearing kUint32 flag
208 // from some non-phi operations that are used as operands to unsafe phis. 235 // from some non-phi operations that are used as operands to unsafe phis.
209 UnmarkUnsafePhis(); 236 UnmarkUnsafePhis();
210 } 237 }
211 238
212 239
213 } } // namespace v8::internal 240 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm64/lithium-codegen-arm64.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698