OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 247 |
248 BytecodeGraphTester tester(isolate, zone, script.start()); | 248 BytecodeGraphTester tester(isolate, zone, script.start()); |
249 auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); | 249 auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); |
250 Handle<Object> return_value = | 250 Handle<Object> return_value = |
251 callable(snippets[i].parameter(0), snippets[i].parameter(1)) | 251 callable(snippets[i].parameter(0), snippets[i].parameter(1)) |
252 .ToHandleChecked(); | 252 .ToHandleChecked(); |
253 CHECK(return_value->SameValue(*snippets[i].return_value())); | 253 CHECK(return_value->SameValue(*snippets[i].return_value())); |
254 } | 254 } |
255 } | 255 } |
256 | 256 |
| 257 |
| 258 TEST(BytecodeGraphBuilderNamedLoad) { |
| 259 HandleAndZoneScope scope; |
| 260 Isolate* isolate = scope.main_isolate(); |
| 261 Zone* zone = scope.main_zone(); |
| 262 Factory* factory = isolate->factory(); |
| 263 |
| 264 ExpectedSnippet<0> snippets[] = { |
| 265 {"var a = { val: 10 }; return a.val;", {factory->NewNumberFromInt(10)}}, |
| 266 {"var a = { val: 10, name:'abc' }; return a.name;", |
| 267 {factory->NewStringFromStaticChars("abc")}}}; |
| 268 |
| 269 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
| 270 for (size_t i = 0; i < num_snippets; i++) { |
| 271 ScopedVector<char> script(1024); |
| 272 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, |
| 273 snippets[i].code_snippet, kFunctionName); |
| 274 |
| 275 BytecodeGraphTester tester(isolate, zone, script.start()); |
| 276 auto callable = tester.GetCallable<>(); |
| 277 Handle<Object> return_value = callable().ToHandleChecked(); |
| 278 CHECK(return_value->SameValue(*snippets[i].return_value())); |
| 279 } |
| 280 } |
| 281 |
257 } // namespace compiler | 282 } // namespace compiler |
258 } // namespace internal | 283 } // namespace internal |
259 } // namespace v8 | 284 } // namespace v8 |
OLD | NEW |