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

Side by Side Diff: test/unittests/compiler/js-builtin-reducer-unittest.cc

Issue 2037453003: [turbofan] Add new StringFromCharCode simplified operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Mitigate verifier blowup after early optimization. Created 4 years, 6 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/compiler/verifier.cc ('k') | test/unittests/compiler/node-test-utils.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 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/js-builtin-reducer.h" 5 #include "src/compiler/js-builtin-reducer.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/node-properties.h" 7 #include "src/compiler/node-properties.h"
8 #include "src/compiler/simplified-operator.h" 8 #include "src/compiler/simplified-operator.h"
9 #include "src/compiler/typer.h" 9 #include "src/compiler/typer.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 JSObject::GetProperty(isolate()->global_object(), 42 JSObject::GetProperty(isolate()->global_object(),
43 isolate()->factory()->NewStringFromAsciiChecked( 43 isolate()->factory()->NewStringFromAsciiChecked(
44 "Math")).ToHandleChecked(); 44 "Math")).ToHandleChecked();
45 Handle<JSFunction> f = Handle<JSFunction>::cast( 45 Handle<JSFunction> f = Handle<JSFunction>::cast(
46 Object::GetProperty( 46 Object::GetProperty(
47 m, isolate()->factory()->NewStringFromAsciiChecked(name)) 47 m, isolate()->factory()->NewStringFromAsciiChecked(name))
48 .ToHandleChecked()); 48 .ToHandleChecked());
49 return HeapConstant(f); 49 return HeapConstant(f);
50 } 50 }
51 51
52 Node* StringFunction(const char* name) {
53 Handle<Object> m =
54 JSObject::GetProperty(
55 isolate()->global_object(),
56 isolate()->factory()->NewStringFromAsciiChecked("String"))
57 .ToHandleChecked();
58 Handle<JSFunction> f = Handle<JSFunction>::cast(
59 Object::GetProperty(
60 m, isolate()->factory()->NewStringFromAsciiChecked(name))
61 .ToHandleChecked());
62 return HeapConstant(f);
63 }
64
52 JSOperatorBuilder* javascript() { return &javascript_; } 65 JSOperatorBuilder* javascript() { return &javascript_; }
53 66
54 private: 67 private:
55 JSOperatorBuilder javascript_; 68 JSOperatorBuilder javascript_;
56 }; 69 };
57 70
58 71
59 namespace { 72 namespace {
60 73
61 Type* const kIntegral32Types[] = {Type::UnsignedSmall(), Type::Negative32(), 74 Type* const kIntegral32Types[] = {Type::UnsignedSmall(), Type::Negative32(),
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 Node* call = graph()->NewNode(javascript()->CallFunction(3), function, 195 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
183 UndefinedConstant(), p0, context, frame_state, 196 UndefinedConstant(), p0, context, frame_state,
184 frame_state, effect, control); 197 frame_state, effect, control);
185 Reduction r = Reduce(call); 198 Reduction r = Reduce(call);
186 199
187 ASSERT_TRUE(r.Changed()); 200 ASSERT_TRUE(r.Changed());
188 EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0)); 201 EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0));
189 } 202 }
190 } 203 }
191 204
205 // -----------------------------------------------------------------------------
206 // String.fromCharCode
207
208 TEST_F(JSBuiltinReducerTest, StringFromCharCode) {
209 Node* function = StringFunction("fromCharCode");
210
211 Node* effect = graph()->start();
212 Node* control = graph()->start();
213 Node* context = UndefinedConstant();
214 Node* frame_state = graph()->start();
215 TRACED_FOREACH(Type*, t0, kNumberTypes) {
216 Node* p0 = Parameter(t0, 0);
217 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
218 UndefinedConstant(), p0, context, frame_state,
219 frame_state, effect, control);
220 Reduction r = Reduce(call);
221
222 ASSERT_TRUE(r.Changed());
223 EXPECT_THAT(r.replacement(), IsStringFromCharCode(p0));
224 }
225 }
226
192 } // namespace compiler 227 } // namespace compiler
193 } // namespace internal 228 } // namespace internal
194 } // namespace v8 229 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/verifier.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698