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

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

Issue 516853002: Preliminary lowering of typed array loads in TF. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixups after rebase. Created 6 years, 3 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 | « test/cctest/compiler/function-tester.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #include "test/cctest/compiler/function-tester.h"
8
9 using namespace v8::internal;
10 using namespace v8::internal::compiler;
11
12 template <typename U>
13 static void TypedArrayLoadHelper(const char* array_type) {
14 const int64_t values[] = {
15 0x00000000, 0x00000001, 0x00000023, 0x00000042, 0x12345678, 0x87654321,
16 0x0000003f, 0x0000007f, 0x00003fff, 0x00007fff, 0x3fffffff, 0x7fffffff,
17 0x000000ff, 0x00000080, 0x0000ffff, 0x00008000, 0xffffffff, 0x80000000,
18 };
19 size_t size = arraysize(values);
20 EmbeddedVector<char, 1024> values_buffer;
21 StringBuilder values_builder(values_buffer.start(), values_buffer.length());
22 for (unsigned i = 0; i < size; i++) {
23 values_builder.AddFormatted("a[%d] = 0x%08x;", i, values[i]);
24 }
25
26 // Note that below source creates two different typed arrays with distinct
27 // elements kind to get coverage for both access patterns:
28 // - IsFixedTypedArrayElementsKind(x)
29 // - IsExternalArrayElementsKind(y)
30 const char* source =
31 "(function(a) {"
32 " var x = (a = new %1$sArray(%2$d)); %3$s;"
33 " var y = (a = new %1$sArray(%2$d)); %3$s; %%TypedArrayGetBuffer(y);"
34 " if (!%%HasFixed%1$sElements(x)) %%AbortJS('x');"
35 " if (!%%HasExternal%1$sElements(y)) %%AbortJS('y');"
36 " function f(a,b) {"
37 " a = a | 0; b = b | 0;"
38 " return x[a] + y[b];"
39 " }"
40 " return f;"
41 "})()";
42 EmbeddedVector<char, 1024> source_buffer;
43 SNPrintF(source_buffer, source, array_type, size, values_buffer.start());
44
45 FunctionTester T(
46 source_buffer.start(),
47 CompilationInfo::kContextSpecializing | CompilationInfo::kTypingEnabled);
48 for (unsigned i = 0; i < size; i++) {
49 for (unsigned j = 0; j < size; j++) {
50 double value_a = static_cast<U>(values[i]);
51 double value_b = static_cast<U>(values[j]);
52 double expected = value_a + value_b;
53 T.CheckCall(T.Val(expected), T.Val(i), T.Val(j));
54 }
55 }
56 }
57
58
59 TEST(TypedArrayLoad) {
60 FLAG_typed_array_max_size_in_heap = 256;
61 TypedArrayLoadHelper<int8_t>("Int8");
62 TypedArrayLoadHelper<uint8_t>("Uint8");
63 TypedArrayLoadHelper<int16_t>("Int16");
64 TypedArrayLoadHelper<uint16_t>("Uint16");
65 TypedArrayLoadHelper<int32_t>("Int32");
66 TypedArrayLoadHelper<uint32_t>("Uint32");
67 TypedArrayLoadHelper<double>("Float64");
68 // TODO(mstarzinger): Add tests for Float32.
69 // TODO(mstarzinger): Add tests for ClampedUint8.
70 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698