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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 snippets[i].code_snippet, kFunctionName); | 324 snippets[i].code_snippet, kFunctionName); |
325 | 325 |
326 BytecodeGraphTester tester(isolate, zone, script.start()); | 326 BytecodeGraphTester tester(isolate, zone, script.start()); |
327 auto callable = tester.GetCallable<Handle<Object>>(); | 327 auto callable = tester.GetCallable<Handle<Object>>(); |
328 Handle<Object> return_value = | 328 Handle<Object> return_value = |
329 callable(snippets[i].parameter(0)).ToHandleChecked(); | 329 callable(snippets[i].parameter(0)).ToHandleChecked(); |
330 CHECK(return_value->SameValue(*snippets[i].return_value())); | 330 CHECK(return_value->SameValue(*snippets[i].return_value())); |
331 } | 331 } |
332 } | 332 } |
333 | 333 |
| 334 |
| 335 TEST(BytecodeGraphBuilderPropertyCall) { |
| 336 HandleAndZoneScope scope; |
| 337 Isolate* isolate = scope.main_isolate(); |
| 338 Zone* zone = scope.main_zone(); |
| 339 Factory* factory = isolate->factory(); |
| 340 |
| 341 ExpectedSnippet<1> snippets[] = { |
| 342 {"return p1.func();", |
| 343 {factory->NewNumberFromInt(25), |
| 344 BytecodeGraphTester::NewObject("({func() { return 25; }})")}}, |
| 345 {"return p1.func('abc');", |
| 346 {factory->NewStringFromStaticChars("abc"), |
| 347 BytecodeGraphTester::NewObject("({func(a) { return a; }})")}}, |
| 348 {"return p1.func(1, 2, 3, 4, 5, 6, 7, 8);", |
| 349 {factory->NewNumberFromInt(36), |
| 350 BytecodeGraphTester::NewObject( |
| 351 "({func(a, b, c, d, e, f, g, h) {\n" |
| 352 " return a + b + c + d + e + f + g + h;}})")}}, |
| 353 }; |
| 354 |
| 355 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
| 356 for (size_t i = 0; i < num_snippets; i++) { |
| 357 ScopedVector<char> script(2048); |
| 358 SNPrintF(script, "function %s(p1) { %s };\n%s({func() {}});", kFunctionName, |
| 359 snippets[i].code_snippet, kFunctionName); |
| 360 |
| 361 BytecodeGraphTester tester(isolate, zone, script.start()); |
| 362 auto callable = tester.GetCallable<Handle<Object>>(); |
| 363 Handle<Object> return_value = |
| 364 callable(snippets[i].parameter(0)).ToHandleChecked(); |
| 365 CHECK(return_value->SameValue(*snippets[i].return_value())); |
| 366 } |
| 367 } |
| 368 |
334 } // namespace compiler | 369 } // namespace compiler |
335 } // namespace internal | 370 } // namespace internal |
336 } // namespace v8 | 371 } // namespace v8 |
OLD | NEW |