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

Side by Side Diff: test/cctest/compiler/test-run-properties.cc

Issue 1257223002: Revert of Remove ExternalArray, derived types, and element kinds (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « src/x87/lithium-x87.cc ('k') | test/cctest/test-api.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 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "test/cctest/compiler/function-tester.h" 7 #include "test/cctest/compiler/function-tester.h"
8 8
9 using namespace v8::internal; 9 using namespace v8::internal;
10 using namespace v8::internal::compiler; 10 using namespace v8::internal::compiler;
11 11
12 template <typename U> 12 template <typename U>
13 static void TypedArrayLoadHelper(const char* array_type) { 13 static void TypedArrayLoadHelper(const char* array_type) {
14 static const uint32_t kValues[] = { 14 static const uint32_t kValues[] = {
15 0x00000000, 0x00000001, 0x00000023, 0x00000042, 0x12345678, 0x87654321, 15 0x00000000, 0x00000001, 0x00000023, 0x00000042, 0x12345678, 0x87654321,
16 0x0000003f, 0x0000007f, 0x00003fff, 0x00007fff, 0x3fffffff, 0x7fffffff, 16 0x0000003f, 0x0000007f, 0x00003fff, 0x00007fff, 0x3fffffff, 0x7fffffff,
17 0x000000ff, 0x00000080, 0x0000ffff, 0x00008000, 0xffffffff, 0x80000000}; 17 0x000000ff, 0x00000080, 0x0000ffff, 0x00008000, 0xffffffff, 0x80000000};
18 EmbeddedVector<char, 1024> values_buffer; 18 EmbeddedVector<char, 1024> values_buffer;
19 StringBuilder values_builder(values_buffer.start(), values_buffer.length()); 19 StringBuilder values_builder(values_buffer.start(), values_buffer.length());
20 for (size_t i = 0; i < arraysize(kValues); ++i) { 20 for (size_t i = 0; i < arraysize(kValues); ++i) {
21 values_builder.AddFormatted("a[%d] = 0x%08x;", i, kValues[i]); 21 values_builder.AddFormatted("a[%d] = 0x%08x;", i, kValues[i]);
22 } 22 }
23 23
24 // Note that below source creates two different typed arrays with the same 24 // Note that below source creates two different typed arrays with distinct
25 // elements kind to get coverage for both (on heap / with external backing 25 // elements kind to get coverage for both access patterns:
26 // store) access patterns. 26 // - IsFixedTypedArrayElementsKind(x)
27 // - IsExternalArrayElementsKind(y)
27 const char* source = 28 const char* source =
28 "(function(a) {" 29 "(function(a) {"
29 " var x = (a = new %sArray(%d)); %s;" 30 " var x = (a = new %sArray(%d)); %s;"
30 " var y = (a = new %sArray(%d)); %s; %%TypedArrayGetBuffer(y);" 31 " var y = (a = new %sArray(%d)); %s; %%TypedArrayGetBuffer(y);"
31 " if (!%%HasFixed%sElements(x)) %%AbortJS('x');" 32 " if (!%%HasFixed%sElements(x)) %%AbortJS('x');"
32 " if (!%%HasFixed%sElements(y)) %%AbortJS('y');" 33 " if (!%%HasExternal%sElements(y)) %%AbortJS('y');"
33 " function f(a,b) {" 34 " function f(a,b) {"
34 " a = a | 0; b = b | 0;" 35 " a = a | 0; b = b | 0;"
35 " return x[a] + y[b];" 36 " return x[a] + y[b];"
36 " }" 37 " }"
37 " return f;" 38 " return f;"
38 "})()"; 39 "})()";
39 EmbeddedVector<char, 1024> source_buffer; 40 EmbeddedVector<char, 1024> source_buffer;
40 SNPrintF(source_buffer, source, array_type, arraysize(kValues), 41 SNPrintF(source_buffer, source, array_type, arraysize(kValues),
41 values_buffer.start(), array_type, arraysize(kValues), 42 values_buffer.start(), array_type, arraysize(kValues),
42 values_buffer.start(), array_type, array_type); 43 values_buffer.start(), array_type, array_type);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 static const uint32_t kValues[] = { 77 static const uint32_t kValues[] = {
77 0x00000000, 0x00000001, 0x00000023, 0x00000042, 0x12345678, 0x87654321, 78 0x00000000, 0x00000001, 0x00000023, 0x00000042, 0x12345678, 0x87654321,
78 0x0000003f, 0x0000007f, 0x00003fff, 0x00007fff, 0x3fffffff, 0x7fffffff, 79 0x0000003f, 0x0000007f, 0x00003fff, 0x00007fff, 0x3fffffff, 0x7fffffff,
79 0x000000ff, 0x00000080, 0x0000ffff, 0x00008000, 0xffffffff, 0x80000000}; 80 0x000000ff, 0x00000080, 0x0000ffff, 0x00008000, 0xffffffff, 0x80000000};
80 EmbeddedVector<char, 1024> values_buffer; 81 EmbeddedVector<char, 1024> values_buffer;
81 StringBuilder values_builder(values_buffer.start(), values_buffer.length()); 82 StringBuilder values_builder(values_buffer.start(), values_buffer.length());
82 for (size_t i = 0; i < arraysize(kValues); ++i) { 83 for (size_t i = 0; i < arraysize(kValues); ++i) {
83 values_builder.AddFormatted("a[%d] = 0x%08x;", i, kValues[i]); 84 values_builder.AddFormatted("a[%d] = 0x%08x;", i, kValues[i]);
84 } 85 }
85 86
86 // Note that below source creates two different typed arrays with the same 87 // Note that below source creates two different typed arrays with distinct
87 // elements kind to get coverage for both (on heap/with external backing 88 // elements kind to get coverage for both access patterns:
88 // store) access patterns. 89 // - IsFixedTypedArrayElementsKind(x)
90 // - IsExternalArrayElementsKind(y)
89 const char* source = 91 const char* source =
90 "(function(a) {" 92 "(function(a) {"
91 " var x = (a = new %sArray(%d)); %s;" 93 " var x = (a = new %sArray(%d)); %s;"
92 " var y = (a = new %sArray(%d)); %s; %%TypedArrayGetBuffer(y);" 94 " var y = (a = new %sArray(%d)); %s; %%TypedArrayGetBuffer(y);"
93 " if (!%%HasFixed%sElements(x)) %%AbortJS('x');" 95 " if (!%%HasFixed%sElements(x)) %%AbortJS('x');"
94 " if (!%%HasFixed%sElements(y)) %%AbortJS('y');" 96 " if (!%%HasExternal%sElements(y)) %%AbortJS('y');"
95 " function f(a,b) {" 97 " function f(a,b) {"
96 " a = a | 0; b = b | 0;" 98 " a = a | 0; b = b | 0;"
97 " var t = x[a];" 99 " var t = x[a];"
98 " x[a] = y[b];" 100 " x[a] = y[b];"
99 " y[b] = t;" 101 " y[b] = t;"
100 " t = y[b];" 102 " t = y[b];"
101 " y[b] = x[a];" 103 " y[b] = x[a];"
102 " x[a] = t;" 104 " x[a] = t;"
103 " return x[a] + y[b];" 105 " return x[a] + y[b];"
104 " }" 106 " }"
(...skipping 25 matching lines...) Expand all
130 TypedArrayStoreHelper<int8_t>("Int8"); 132 TypedArrayStoreHelper<int8_t>("Int8");
131 TypedArrayStoreHelper<uint8_t>("Uint8"); 133 TypedArrayStoreHelper<uint8_t>("Uint8");
132 TypedArrayStoreHelper<int16_t>("Int16"); 134 TypedArrayStoreHelper<int16_t>("Int16");
133 TypedArrayStoreHelper<uint16_t>("Uint16"); 135 TypedArrayStoreHelper<uint16_t>("Uint16");
134 TypedArrayStoreHelper<int32_t>("Int32"); 136 TypedArrayStoreHelper<int32_t>("Int32");
135 TypedArrayStoreHelper<uint32_t>("Uint32"); 137 TypedArrayStoreHelper<uint32_t>("Uint32");
136 TypedArrayStoreHelper<float>("Float32"); 138 TypedArrayStoreHelper<float>("Float32");
137 TypedArrayStoreHelper<double>("Float64"); 139 TypedArrayStoreHelper<double>("Float64");
138 // TODO(mstarzinger): Add tests for ClampedUint8. 140 // TODO(mstarzinger): Add tests for ClampedUint8.
139 } 141 }
OLDNEW
« no previous file with comments | « src/x87/lithium-x87.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698