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

Side by Side Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 650843002: [turbofan] Embed the actual backing store address for typed loads/stores. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add comment. Created 6 years, 2 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/compiler/js-typed-lowering.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 "src/compiler/access-builder.h" 5 #include "src/compiler/access-builder.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/js-operator.h" 7 #include "src/compiler/js-operator.h"
8 #include "src/compiler/js-typed-lowering.h" 8 #include "src/compiler/js-typed-lowering.h"
9 #include "src/compiler/machine-operator.h" 9 #include "src/compiler/machine-operator.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
11 #include "src/compiler/typer.h" 11 #include "src/compiler/typer.h"
12 #include "test/unittests/compiler/compiler-test-utils.h" 12 #include "test/unittests/compiler/compiler-test-utils.h"
13 #include "test/unittests/compiler/graph-unittest.h" 13 #include "test/unittests/compiler/graph-unittest.h"
14 #include "testing/gmock-support.h" 14 #include "testing/gtest-support.h"
15
16 using testing::_;
17 using testing::AllOf;
18 using testing::Capture;
19 using testing::CaptureEq;
20 15
21 namespace v8 { 16 namespace v8 {
22 namespace internal { 17 namespace internal {
23 namespace compiler { 18 namespace compiler {
24 19
25 namespace { 20 namespace {
26 21
27 const ExternalArrayType kExternalArrayTypes[] = { 22 const ExternalArrayType kExternalArrayTypes[] = {
28 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) kExternal##Type##Array, 23 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) kExternal##Type##Array,
29 TYPED_ARRAYS(TYPED_ARRAY_CASE) 24 TYPED_ARRAYS(TYPED_ARRAY_CASE)
(...skipping 25 matching lines...) Expand all
55 NodeProperties::SetBounds(node, Bounds(Type::None(), type)); 50 NodeProperties::SetBounds(node, Bounds(Type::None(), type));
56 return node; 51 return node;
57 } 52 }
58 53
59 Handle<JSArrayBuffer> NewArrayBuffer(void* bytes, size_t byte_length) { 54 Handle<JSArrayBuffer> NewArrayBuffer(void* bytes, size_t byte_length) {
60 Handle<JSArrayBuffer> buffer = factory()->NewJSArrayBuffer(); 55 Handle<JSArrayBuffer> buffer = factory()->NewJSArrayBuffer();
61 Runtime::SetupArrayBuffer(isolate(), buffer, true, bytes, byte_length); 56 Runtime::SetupArrayBuffer(isolate(), buffer, true, bytes, byte_length);
62 return buffer; 57 return buffer;
63 } 58 }
64 59
60 Matcher<Node*> IsIntPtrConstant(intptr_t value) {
61 return sizeof(value) == 4 ? IsInt32Constant(static_cast<int32_t>(value))
62 : IsInt64Constant(static_cast<int64_t>(value));
63 }
64
65 JSOperatorBuilder* javascript() { return &javascript_; } 65 JSOperatorBuilder* javascript() { return &javascript_; }
66 66
67 private: 67 private:
68 JSOperatorBuilder javascript_; 68 JSOperatorBuilder javascript_;
69 }; 69 };
70 70
71 71
72 // ----------------------------------------------------------------------------- 72 // -----------------------------------------------------------------------------
73 // JSLoadProperty 73 // JSLoadProperty
74 74
(...skipping 16 matching lines...) Expand all
91 Node* control = graph()->start(); 91 Node* control = graph()->start();
92 Node* node = graph()->NewNode(javascript()->LoadProperty(feedback), base, 92 Node* node = graph()->NewNode(javascript()->LoadProperty(feedback), base,
93 key, context); 93 key, context);
94 if (FLAG_turbo_deoptimization) { 94 if (FLAG_turbo_deoptimization) {
95 node->AppendInput(zone(), UndefinedConstant()); 95 node->AppendInput(zone(), UndefinedConstant());
96 } 96 }
97 node->AppendInput(zone(), effect); 97 node->AppendInput(zone(), effect);
98 node->AppendInput(zone(), control); 98 node->AppendInput(zone(), control);
99 Reduction r = Reduce(node); 99 Reduction r = Reduce(node);
100 100
101 Capture<Node*> elements;
102 ASSERT_TRUE(r.Changed()); 101 ASSERT_TRUE(r.Changed());
103 EXPECT_THAT( 102 EXPECT_THAT(
104 r.replacement(), 103 r.replacement(),
105 IsLoadElement( 104 IsLoadElement(AccessBuilder::ForTypedArrayElement(type, true),
106 AccessBuilder::ForTypedArrayElement(type, true), 105 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
107 IsLoadField(AccessBuilder::ForExternalArrayPointer(), 106 key, IsInt32Constant(static_cast<int>(kLength)), effect,
108 AllOf(CaptureEq(&elements), 107 control));
109 IsLoadField(AccessBuilder::ForJSObjectElements(),
110 base, _)),
111 CaptureEq(&elements)),
112 key, IsInt32Constant(static_cast<int>(kLength)), effect, control));
113 } 108 }
114 } 109 }
115 110
116 111
117 // ----------------------------------------------------------------------------- 112 // -----------------------------------------------------------------------------
118 // JSStoreProperty 113 // JSStoreProperty
119 114
120 115
121 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) { 116 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) {
122 const size_t kLength = 17; 117 const size_t kLength = 17;
(...skipping 13 matching lines...) Expand all
136 Node* control = graph()->start(); 131 Node* control = graph()->start();
137 Node* node = graph()->NewNode(javascript()->StoreProperty(strict_mode), 132 Node* node = graph()->NewNode(javascript()->StoreProperty(strict_mode),
138 base, key, value, context); 133 base, key, value, context);
139 if (FLAG_turbo_deoptimization) { 134 if (FLAG_turbo_deoptimization) {
140 node->AppendInput(zone(), UndefinedConstant()); 135 node->AppendInput(zone(), UndefinedConstant());
141 } 136 }
142 node->AppendInput(zone(), effect); 137 node->AppendInput(zone(), effect);
143 node->AppendInput(zone(), control); 138 node->AppendInput(zone(), control);
144 Reduction r = Reduce(node); 139 Reduction r = Reduce(node);
145 140
146 Capture<Node*> elements;
147 ASSERT_TRUE(r.Changed()); 141 ASSERT_TRUE(r.Changed());
148 EXPECT_THAT( 142 EXPECT_THAT(r.replacement(),
149 r.replacement(), 143 IsStoreElement(
150 IsStoreElement( 144 AccessBuilder::ForTypedArrayElement(type, true),
151 AccessBuilder::ForTypedArrayElement(type, true), 145 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
152 IsLoadField( 146 key, IsInt32Constant(static_cast<int>(kLength)), value,
153 AccessBuilder::ForExternalArrayPointer(), 147 effect, control));
154 AllOf(CaptureEq(&elements),
155 IsLoadField(AccessBuilder::ForJSObjectElements(), base,
156 _)),
157 CaptureEq(&elements)),
158 key, IsInt32Constant(static_cast<int>(kLength)), value, effect,
159 control));
160 } 148 }
161 } 149 }
162 } 150 }
163 151
164 } // namespace compiler 152 } // namespace compiler
165 } // namespace internal 153 } // namespace internal
166 } // namespace v8 154 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698