diff options
author | Michaël Zasso <targos@protonmail.com> | 2017-05-02 10:50:00 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2017-05-06 20:02:35 +0200 |
commit | 60d1aac8d225e844e68ae48e8f3d58802e635fbe (patch) | |
tree | 922f347dd054db18d88666fad7181e5a777f4022 /deps/v8/test | |
parent | 73d9c0f903ae371cd5011af64c3a6f69a1bda978 (diff) | |
download | node-new-60d1aac8d225e844e68ae48e8f3d58802e635fbe.tar.gz |
deps: update V8 to 5.8.283.38
PR-URL: https://github.com/nodejs/node/pull/12784
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Diffstat (limited to 'deps/v8/test')
693 files changed, 29976 insertions, 9842 deletions
diff --git a/deps/v8/test/BUILD.gn b/deps/v8/test/BUILD.gn index af6ae95745..09d3fb6058 100644 --- a/deps/v8/test/BUILD.gn +++ b/deps/v8/test/BUILD.gn @@ -31,7 +31,6 @@ group("gn_all") { ":bot_default_run", ":default_run", ":mozilla_run", - ":simdjs_run", "test262:test262_run", ] } @@ -185,14 +184,6 @@ v8_isolate_run("preparser") { isolate = "preparser/preparser.isolate" } -v8_isolate_run("simdjs") { - deps = [ - "..:d8_run", - ] - - isolate = "simdjs/simdjs.isolate" -} - v8_isolate_run("unittests") { deps = [ "unittests:unittests", diff --git a/deps/v8/test/cctest/BUILD.gn b/deps/v8/test/cctest/BUILD.gn index 54e733c2dc..1cc0f84167 100644 --- a/deps/v8/test/cctest/BUILD.gn +++ b/deps/v8/test/cctest/BUILD.gn @@ -60,6 +60,7 @@ v8_executable("cctest") { "compiler/test-run-wasm-machops.cc", "compiler/value-helper.h", "expression-type-collector-macros.h", + "ffi/test-ffi.cc", "gay-fixed.cc", "gay-fixed.h", "gay-precision.cc", @@ -91,12 +92,14 @@ v8_executable("cctest") { "libplatform/test-tracing.cc", "libsampler/test-sampler.cc", "parsing/test-parse-decision.cc", + "parsing/test-preparser.cc", "parsing/test-scanner-streams.cc", "parsing/test-scanner.cc", "print-extension.cc", "print-extension.h", "profiler-extension.cc", "profiler-extension.h", + "scope-test-helper.h", "test-access-checks.cc", "test-accessor-assembler.cc", "test-accessors.cc", @@ -148,6 +151,7 @@ v8_executable("cctest") { "test-liveedit.cc", "test-lockers.cc", "test-log.cc", + "test-managed.cc", "test-mementos.cc", "test-modules.cc", "test-object.cc", @@ -160,7 +164,6 @@ v8_executable("cctest") { "test-representation.cc", "test-sampler-api.cc", "test-serialize.cc", - "test-simd.cc", "test-strings.cc", "test-strtod.cc", "test-symbols.cc", @@ -183,7 +186,7 @@ v8_executable("cctest") { "trace-extension.cc", "trace-extension.h", "types-fuzz.h", - "wasm/test-managed.cc", + "unicode-helpers.h", "wasm/test-run-wasm-64.cc", "wasm/test-run-wasm-asmjs.cc", "wasm/test-run-wasm-interpreter.cc", @@ -192,6 +195,7 @@ v8_executable("cctest") { "wasm/test-run-wasm-relocation.cc", "wasm/test-run-wasm.cc", "wasm/test-wasm-breakpoints.cc", + "wasm/test-wasm-interpreter-entry.cc", "wasm/test-wasm-stack.cc", "wasm/test-wasm-trap-position.cc", "wasm/wasm-run-utils.h", @@ -206,6 +210,7 @@ v8_executable("cctest") { "test-disasm-arm.cc", "test-macro-assembler-arm.cc", "test-run-wasm-relocation-arm.cc", + "test-simulator-arm.cc", "wasm/test-run-wasm-simd.cc", ] } else if (v8_current_cpu == "arm64") { @@ -360,7 +365,12 @@ v8_executable("cctest") { # crbug.com/676417: Suppress symbol import warning from linker. if (is_win && is_component_build) { - ldflags = [ "/ignore:4217" ] + ldflags += [ + "/ignore:4217", + "/ignore:4049", + ] + remove_configs = [ "//build/config/win:default_incremental_linking" ] + configs += [ "//build/config/win:no_incremental_linking" ] } if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64" || diff --git a/deps/v8/test/cctest/asmjs/test-asm-typer.cc b/deps/v8/test/cctest/asmjs/test-asm-typer.cc index 892c968d1d..d01260fac2 100644 --- a/deps/v8/test/cctest/asmjs/test-asm-typer.cc +++ b/deps/v8/test/cctest/asmjs/test-asm-typer.cc @@ -45,33 +45,32 @@ class AsmTyperHarnessBuilder { : source_(source), validation_type_(type), handles_(), - zone_(handles_.main_zone()), isolate_(CcTest::i_isolate()), - ast_value_factory_(zone_, isolate_->ast_string_constants(), - isolate_->heap()->HashSeed()), factory_(isolate_->factory()), source_code_( factory_->NewStringFromUtf8(CStrVector(source)).ToHandleChecked()), - script_(factory_->NewScript(source_code_)) { - ParseInfo info(zone_, script_); - info.set_allow_lazy_parsing(false); - info.set_toplevel(true); - info.set_ast_value_factory(&ast_value_factory_); - info.set_ast_value_factory_owned(false); - Parser parser(&info); - - if (!Compiler::ParseAndAnalyze(&info)) { + script_(factory_->NewScript(source_code_)), + info_(script_), + ast_value_factory_(info_.zone(), isolate_->ast_string_constants(), + isolate_->heap()->HashSeed()) { + info_.set_allow_lazy_parsing(false); + info_.set_toplevel(true); + info_.set_ast_value_factory(&ast_value_factory_); + info_.set_ast_value_factory_owned(false); + Parser parser(&info_); + + if (!Compiler::ParseAndAnalyze(&info_)) { std::cerr << "Failed to parse:\n" << source_ << "\n"; CHECK(false); } - outer_scope_ = info.script_scope(); - module_ = info.scope() + outer_scope_ = info_.script_scope(); + module_ = info_.scope() ->declarations() ->AtForTest(0) ->AsFunctionDeclaration() ->fun(); - typer_.reset(new AsmTyper(isolate_, zone_, script_, module_)); + typer_.reset(new AsmTyper(isolate_, zone(), script_, module_)); if (validation_type_ == ValidateStatement || validation_type_ == ValidateExpression) { @@ -104,7 +103,7 @@ class AsmTyperHarnessBuilder { if (var->IsUnallocated()) { var->AllocateTo(VariableLocation::LOCAL, -1); } - auto* var_info = new (zone_) AsmTyper::VariableInfo(type); + auto* var_info = new (zone()) AsmTyper::VariableInfo(type); var_info->set_mutability(AsmTyper::VariableInfo::kLocal); CHECK(typer_->AddLocal(var, var_info)); return this; @@ -116,7 +115,7 @@ class AsmTyperHarnessBuilder { var->AllocateTo(VariableLocation::MODULE, -1); } if (type != nullptr) { - auto* var_info = new (zone_) AsmTyper::VariableInfo(type); + auto* var_info = new (zone()) AsmTyper::VariableInfo(type); var_info->set_mutability(AsmTyper::VariableInfo::kMutableGlobal); CHECK(typer_->AddGlobal(var, var_info)); } @@ -125,12 +124,12 @@ class AsmTyperHarnessBuilder { AsmTyperHarnessBuilder* WithGlobal( VariableName var_name, std::function<AsmType*(Zone*)> type_creator) { - return WithGlobal(var_name, type_creator(zone_)); + return WithGlobal(var_name, type_creator(zone())); } AsmTyperHarnessBuilder* WithUndefinedGlobal( VariableName var_name, std::function<AsmType*(Zone*)> type_creator) { - auto* type = type_creator(zone_); + auto* type = type_creator(zone()); CHECK(type->AsFunctionType() != nullptr || type->AsFunctionTableType() != nullptr); WithGlobal(var_name, type); @@ -157,7 +156,8 @@ class AsmTyperHarnessBuilder { CHECK(false); case AsmTyper::kFFI: stdlib_map = nullptr; - var_info = new (zone_) AsmTyper::VariableInfo(AsmType::FFIType(zone_)); + var_info = + new (zone()) AsmTyper::VariableInfo(AsmType::FFIType(zone())); var_info->set_mutability(AsmTyper::VariableInfo::kImmutableGlobal); break; case AsmTyper::kInfinity: @@ -176,7 +176,7 @@ class AsmTyperHarnessBuilder { } CHECK(var_info != nullptr); - var_info = var_info->Clone(zone_); + var_info = var_info->Clone(zone()); } CHECK(typer_->AddGlobal(var, var_info)); @@ -193,7 +193,7 @@ class AsmTyperHarnessBuilder { AsmTyperHarnessBuilder* WithStdlib(VariableName var_name) { auto* var = DeclareVariable(var_name); auto* var_info = - AsmTyper::VariableInfo::ForSpecialSymbol(zone_, AsmTyper::kStdlib); + AsmTyper::VariableInfo::ForSpecialSymbol(zone(), AsmTyper::kStdlib); CHECK(typer_->AddGlobal(var, var_info)); return this; } @@ -201,7 +201,7 @@ class AsmTyperHarnessBuilder { AsmTyperHarnessBuilder* WithHeap(VariableName var_name) { auto* var = DeclareVariable(var_name); auto* var_info = - AsmTyper::VariableInfo::ForSpecialSymbol(zone_, AsmTyper::kHeap); + AsmTyper::VariableInfo::ForSpecialSymbol(zone(), AsmTyper::kHeap); CHECK(typer_->AddGlobal(var, var_info)); return this; } @@ -209,7 +209,7 @@ class AsmTyperHarnessBuilder { AsmTyperHarnessBuilder* WithFFI(VariableName var_name) { auto* var = DeclareVariable(var_name); auto* var_info = - AsmTyper::VariableInfo::ForSpecialSymbol(zone_, AsmTyper::kFFI); + AsmTyper::VariableInfo::ForSpecialSymbol(zone(), AsmTyper::kFFI); CHECK(typer_->AddGlobal(var, var_info)); return this; } @@ -305,7 +305,7 @@ class AsmTyperHarnessBuilder { } bool ValidateAllStatements(FunctionDeclaration* fun_decl) { - AsmTyper::FlattenedStatements iter(zone_, fun_decl->fun()->body()); + AsmTyper::FlattenedStatements iter(zone(), fun_decl->fun()->body()); while (auto* curr = iter.Next()) { if (typer_->ValidateStatement(curr) == AsmType::None()) { return false; @@ -315,7 +315,7 @@ class AsmTyperHarnessBuilder { } AsmType* ValidateExpressionStatment(FunctionDeclaration* fun_decl) { - AsmTyper::FlattenedStatements iter(zone_, fun_decl->fun()->body()); + AsmTyper::FlattenedStatements iter(zone(), fun_decl->fun()->body()); AsmType* ret = AsmType::None(); bool last_was_expression_statement = false; while (auto* curr = iter.Next()) { @@ -337,15 +337,17 @@ class AsmTyperHarnessBuilder { return ret; } + Zone* zone() { return info_.zone(); } + std::string source_; ValidationType validation_type_; HandleAndZoneScope handles_; - Zone* zone_; Isolate* isolate_; - AstValueFactory ast_value_factory_; Factory* factory_; Handle<String> source_code_; Handle<Script> script_; + ParseInfo info_; + AstValueFactory ast_value_factory_; DeclarationScope* outer_scope_; FunctionLiteral* module_; @@ -856,9 +858,10 @@ TEST(ErrorsInFunction) { "}\n", "Undeclared identifier in return statement"}, {"function f() {\n" + " var i = 0;\n" " return i?0:1;\n" "}\n", - "Invalid return type expression"}, + "Type mismatch in return statement"}, {"function f() {\n" " return stdlib.Math.E;" "}\n", diff --git a/deps/v8/test/cctest/ast-types-fuzz.h b/deps/v8/test/cctest/ast-types-fuzz.h index ba6286d54a..c156ec5c75 100644 --- a/deps/v8/test/cctest/ast-types-fuzz.h +++ b/deps/v8/test/cctest/ast-types-fuzz.h @@ -116,6 +116,7 @@ class AstTypes { for (int i = 0; i < 30; ++i) { types.push_back(Fuzz()); } + USE(isolate_); // Currently unused. } Handle<i::Map> object_map; @@ -287,19 +288,6 @@ class AstTypes { } return type; } - case 8: { // simd - static const int num_simd_types = -#define COUNT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) +1 - SIMD128_TYPES(COUNT_SIMD_TYPE); -#undef COUNT_SIMD_TYPE - AstType* (*simd_constructors[num_simd_types])(Isolate*, Zone*) = { -#define COUNT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) &AstType::Name, - SIMD128_TYPES(COUNT_SIMD_TYPE) -#undef COUNT_SIMD_TYPE - }; - return simd_constructors[rng_->NextInt(num_simd_types)](isolate_, - zone_); - } default: { // union int n = rng_->NextInt(10); AstType* type = None; diff --git a/deps/v8/test/cctest/cctest.cc b/deps/v8/test/cctest/cctest.cc index c987d8d375..e578a7a141 100644 --- a/deps/v8/test/cctest/cctest.cc +++ b/deps/v8/test/cctest/cctest.cc @@ -30,6 +30,7 @@ #include "include/libplatform/libplatform.h" #include "src/debug/debug.h" +#include "src/objects-inl.h" #include "test/cctest/print-extension.h" #include "test/cctest/profiler-extension.h" #include "test/cctest/trace-extension.h" diff --git a/deps/v8/test/cctest/cctest.gyp b/deps/v8/test/cctest/cctest.gyp index 1eff6c0c6d..93cbf9edcb 100644 --- a/deps/v8/test/cctest/cctest.gyp +++ b/deps/v8/test/cctest/cctest.gyp @@ -81,6 +81,7 @@ 'cctest.cc', 'cctest.h', 'expression-type-collector-macros.h', + 'ffi/test-ffi.cc', 'interpreter/interpreter-tester.cc', 'interpreter/interpreter-tester.h', 'interpreter/source-position-matcher.cc', @@ -112,12 +113,14 @@ 'libplatform/test-tracing.cc', 'libsampler/test-sampler.cc', 'parsing/test-parse-decision.cc', + 'parsing/test-preparser.cc', 'parsing/test-scanner-streams.cc', 'parsing/test-scanner.cc', 'print-extension.cc', 'print-extension.h', 'profiler-extension.cc', 'profiler-extension.h', + 'scope-test-helper.h', 'test-access-checks.cc', 'test-accessor-assembler.cc', 'test-accessors.cc', @@ -168,6 +171,7 @@ 'test-liveedit.cc', 'test-lockers.cc', 'test-log.cc', + 'test-managed.cc', 'test-mementos.cc', 'test-modules.cc', 'test-object.cc', @@ -180,7 +184,6 @@ 'test-representation.cc', 'test-sampler-api.cc', 'test-serialize.cc', - 'test-simd.cc', 'test-strings.cc', 'test-symbols.cc', 'test-strtod.cc', @@ -204,7 +207,7 @@ 'trace-extension.cc', 'trace-extension.h', 'types-fuzz.h', - 'wasm/test-managed.cc', + 'unicode-helpers.h', 'wasm/test-run-wasm.cc', 'wasm/test-run-wasm-64.cc', 'wasm/test-run-wasm-asmjs.cc', @@ -213,6 +216,7 @@ 'wasm/test-run-wasm-module.cc', 'wasm/test-run-wasm-relocation.cc', 'wasm/test-wasm-breakpoints.cc', + 'wasm/test-wasm-interpreter-entry.cc', 'wasm/test-wasm-stack.cc', 'wasm/test-wasm-trap-position.cc', 'wasm/wasm-run-utils.h', @@ -247,6 +251,7 @@ 'test-disasm-arm.cc', 'test-macro-assembler-arm.cc', 'test-run-wasm-relocation-arm.cc', + 'test-simulator-arm.cc', 'wasm/test-run-wasm-simd-lowering.cc' ], 'cctest_sources_arm64': [ ### gcmole(arch:arm64) ### diff --git a/deps/v8/test/cctest/cctest.status b/deps/v8/test/cctest/cctest.status index e5ac07cd0e..6994888d73 100644 --- a/deps/v8/test/cctest/cctest.status +++ b/deps/v8/test/cctest/cctest.status @@ -32,6 +32,10 @@ ############################################################################## + # This test is so detailed in it's look at the literals array, I can't + # maintain it until the CL is done. + 'test-heap-profiler/AllocationSitesAreVisible': [FAIL], + # BUG(382): Weird test. Can't guarantee that it never times out. 'test-api/ApplyInterruption': [PASS, TIMEOUT], @@ -102,6 +106,7 @@ 'test-debug/CallFunctionInDebugger': [PASS, ['mode == debug', SLOW]], 'test-strings/StringOOM*': [PASS, ['mode == debug', SKIP]], 'test-serialize/CustomSnapshotDataBlobImmortalImmovableRoots': [PASS, ['mode == debug', SKIP]], + 'test-parsing/ObjectRestNegativeTestSlow': [PASS, ['mode == debug', SKIP]], }], # ALWAYS ############################################################################## @@ -146,6 +151,9 @@ 'test-api/ExternalFloatArray': [SKIP], 'test-api/Float32Array': [SKIP], 'test-api/Float64Array': [SKIP], + + # BUG(v8:5193): Flaky crash. + 'test-sampler/LibSamplerCollectSample': [SKIP], }], # 'arch == arm64 and mode == debug and simulator_run == True' ############################################################################## @@ -210,9 +218,20 @@ # BUG(5193): Flaky timeout. 'test-sampler/LibSamplerCollectSample': [PASS, ['arch == x64', SKIP]], + + # BUG(5920): Flaky crash. + 'test-serialize/PartialSerializerContext': [PASS, ['arch == x64 and mode == debug', SKIP]], }], # 'system == windows' ############################################################################## +['system == macos', { + # BUG(v8:5193) Flaky failures. + 'test-cpu-profiler/FunctionApplySample': [SKIP], + 'test-cpu-profiler/JsNativeJsSample': [SKIP], + 'test-cpu-profiler/JsNativeJsRuntimeJsSampleMultiple': [SKIP], +}], # 'system == macos' + +############################################################################## ['arch == arm', { 'test-cpu-profiler/CollectDeoptEvents': [PASS, FAIL], @@ -296,6 +315,10 @@ 'test-gap-resolver/FuzzResolver': [SKIP], 'test-run-wasm/RunWasmCompiled_MultiReturnSelect_f32': [SKIP], 'test-run-wasm/RunWasmCompiled_MultiReturnSelect_f64': [SKIP], + 'test-run-wasm/RunWasmCompiled_SignallingNanSurvivesI32ReinterpretF32': [SKIP], + 'test-run-wasm-64/RunWasmCompiled_SignallingNanSurvivesI64ReinterpretF64': [SKIP], + 'test-run-wasm/RunWasmInterpreted_SignallingNanSurvivesI32ReinterpretF32': [SKIP], + 'test-run-wasm-64/RunWasmInterpreted_SignallingNanSurvivesI64ReinterpretF64': [SKIP], }], # 'arch == x87' ############################################################################## @@ -345,9 +368,6 @@ ['variant == turbofan or variant == ignition_turbofan', { # BUG(4751). Flaky with Ignition. 'test-cpu-profiler/JsNativeJsSample': [SKIP], - - # TODO(vogelheim,5548): Turbofan does support cached accessors. - 'test-api-accessors/CachedAccessorCrankshaft': [FAIL], }], # variant == turbofan or variant == ignition_turbofan ############################################################################## diff --git a/deps/v8/test/cctest/compiler/codegen-tester.cc b/deps/v8/test/cctest/compiler/codegen-tester.cc index 9b5a9d90a2..63b3a3dc64 100644 --- a/deps/v8/test/cctest/compiler/codegen-tester.cc +++ b/deps/v8/test/cctest/compiler/codegen-tester.cc @@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" +#include "src/objects-inl.h" +#include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" namespace v8 { diff --git a/deps/v8/test/cctest/compiler/codegen-tester.h b/deps/v8/test/cctest/compiler/codegen-tester.h index 90c32ce99e..ca20e6fb6d 100644 --- a/deps/v8/test/cctest/compiler/codegen-tester.h +++ b/deps/v8/test/cctest/compiler/codegen-tester.h @@ -10,6 +10,7 @@ #include "src/compiler/pipeline.h" #include "src/compiler/raw-machine-assembler.h" #include "src/simulator.h" +#include "test/cctest/cctest.h" #include "test/cctest/compiler/call-tester.h" namespace v8 { diff --git a/deps/v8/test/cctest/compiler/function-tester.cc b/deps/v8/test/cctest/compiler/function-tester.cc index c88713a6dc..436d46f4cd 100644 --- a/deps/v8/test/cctest/compiler/function-tester.cc +++ b/deps/v8/test/cctest/compiler/function-tester.cc @@ -155,9 +155,8 @@ Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph, } Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { - Zone zone(function->GetIsolate()->allocator(), ZONE_NAME); - ParseInfo parse_info(&zone, handle(function->shared())); - CompilationInfo info(&parse_info, function); + ParseInfo parse_info(handle(function->shared())); + CompilationInfo info(parse_info.zone(), &parse_info, function); info.SetOptimizing(); info.MarkAsDeoptimizationEnabled(); @@ -185,9 +184,8 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { // Compile the given machine graph instead of the source of the function // and replace the JSFunction's code with the result. Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) { - Zone zone(function->GetIsolate()->allocator(), ZONE_NAME); - ParseInfo parse_info(&zone, handle(function->shared())); - CompilationInfo info(&parse_info, function); + ParseInfo parse_info(handle(function->shared())); + CompilationInfo info(parse_info.zone(), &parse_info, function); CHECK(parsing::ParseFunction(info.parse_info())); info.SetOptimizing(); diff --git a/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc b/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc index 17400abe53..663b66b74d 100644 --- a/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc +++ b/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "src/basic-block-profiler.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" diff --git a/deps/v8/test/cctest/compiler/test-branch-combine.cc b/deps/v8/test/cctest/compiler/test-branch-combine.cc index edaf7b6ac1..ab17ff0992 100644 --- a/deps/v8/test/cctest/compiler/test-branch-combine.cc +++ b/deps/v8/test/cctest/compiler/test-branch-combine.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/value-helper.h" diff --git a/deps/v8/test/cctest/compiler/test-code-assembler.cc b/deps/v8/test/cctest/compiler/test-code-assembler.cc index 90fdc2b7ae..e851f61f8f 100644 --- a/deps/v8/test/cctest/compiler/test-code-assembler.cc +++ b/deps/v8/test/cctest/compiler/test-code-assembler.cc @@ -5,6 +5,7 @@ #include "src/code-factory.h" #include "src/compiler/code-assembler.h" #include "src/isolate.h" +#include "src/objects-inl.h" #include "test/cctest/compiler/code-assembler-tester.h" #include "test/cctest/compiler/function-tester.h" diff --git a/deps/v8/test/cctest/compiler/test-instruction.cc b/deps/v8/test/cctest/compiler/test-instruction.cc index 15749b8950..2d2546690b 100644 --- a/deps/v8/test/cctest/compiler/test-instruction.cc +++ b/deps/v8/test/cctest/compiler/test-instruction.cc @@ -12,6 +12,7 @@ #include "src/compiler/operator.h" #include "src/compiler/schedule.h" #include "src/compiler/scheduler.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" namespace v8 { diff --git a/deps/v8/test/cctest/compiler/test-js-context-specialization.cc b/deps/v8/test/cctest/compiler/test-js-context-specialization.cc index d8122c4fdb..f3e0ed3bc2 100644 --- a/deps/v8/test/cctest/compiler/test-js-context-specialization.cc +++ b/deps/v8/test/cctest/compiler/test-js-context-specialization.cc @@ -8,6 +8,9 @@ #include "src/compiler/js-operator.h" #include "src/compiler/node-matchers.h" #include "src/compiler/node-properties.h" +#include "src/factory.h" +#include "src/objects-inl.h" +#include "src/property.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/function-tester.h" #include "test/cctest/compiler/graph-builder-tester.h" diff --git a/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc b/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc index 03c4282542..360672c41a 100644 --- a/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc +++ b/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc @@ -264,11 +264,11 @@ TEST(AddNumber1) { TEST(NumberBinops) { JSTypedLoweringTester R; const Operator* ops[] = { - R.javascript.Add(R.binop_hints), R.simplified.NumberAdd(), - R.javascript.Subtract(R.binop_hints), R.simplified.NumberSubtract(), - R.javascript.Multiply(R.binop_hints), R.simplified.NumberMultiply(), - R.javascript.Divide(R.binop_hints), R.simplified.NumberDivide(), - R.javascript.Modulus(R.binop_hints), R.simplified.NumberModulus(), + R.javascript.Add(R.binop_hints), R.simplified.NumberAdd(), + R.javascript.Subtract(), R.simplified.NumberSubtract(), + R.javascript.Multiply(), R.simplified.NumberMultiply(), + R.javascript.Divide(), R.simplified.NumberDivide(), + R.javascript.Modulus(), R.simplified.NumberModulus(), }; for (size_t i = 0; i < arraysize(kNumberTypes); ++i) { @@ -310,11 +310,11 @@ class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester { public: JSBitwiseShiftTypedLoweringTester() : JSTypedLoweringTester() { int i = 0; - set(i++, javascript.ShiftLeft(binop_hints), true); + set(i++, javascript.ShiftLeft(), true); set(i++, simplified.NumberShiftLeft(), false); - set(i++, javascript.ShiftRight(binop_hints), true); + set(i++, javascript.ShiftRight(), true); set(i++, simplified.NumberShiftRight(), false); - set(i++, javascript.ShiftRightLogical(binop_hints), false); + set(i++, javascript.ShiftRightLogical(), false); set(i++, simplified.NumberShiftRightLogical(), false); } static const int kNumberOps = 6; @@ -366,11 +366,11 @@ class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester { public: JSBitwiseTypedLoweringTester() : JSTypedLoweringTester() { int i = 0; - set(i++, javascript.BitwiseOr(binop_hints), true); + set(i++, javascript.BitwiseOr(), true); set(i++, simplified.NumberBitwiseOr(), true); - set(i++, javascript.BitwiseXor(binop_hints), true); + set(i++, javascript.BitwiseXor(), true); set(i++, simplified.NumberBitwiseXor(), true); - set(i++, javascript.BitwiseAnd(binop_hints), true); + set(i++, javascript.BitwiseAnd(), true); set(i++, simplified.NumberBitwiseAnd(), true); } static const int kNumberOps = 6; @@ -899,13 +899,13 @@ TEST(RemovePureNumberBinopEffects) { R.simplified.NumberEqual(), R.javascript.Add(R.binop_hints), R.simplified.NumberAdd(), - R.javascript.Subtract(R.binop_hints), + R.javascript.Subtract(), R.simplified.NumberSubtract(), - R.javascript.Multiply(R.binop_hints), + R.javascript.Multiply(), R.simplified.NumberMultiply(), - R.javascript.Divide(R.binop_hints), + R.javascript.Divide(), R.simplified.NumberDivide(), - R.javascript.Modulus(R.binop_hints), + R.javascript.Modulus(), R.simplified.NumberModulus(), R.javascript.LessThan(R.compare_hints), R.simplified.NumberLessThan(), @@ -931,8 +931,8 @@ TEST(OrderNumberBinopEffects1) { JSTypedLoweringTester R; const Operator* ops[] = { - R.javascript.Subtract(R.binop_hints), R.simplified.NumberSubtract(), - R.javascript.Multiply(R.binop_hints), R.simplified.NumberMultiply(), + R.javascript.Subtract(), R.simplified.NumberSubtract(), + R.javascript.Multiply(), R.simplified.NumberMultiply(), }; for (size_t j = 0; j < arraysize(ops); j += 2) { @@ -956,9 +956,9 @@ TEST(OrderNumberBinopEffects2) { JSTypedLoweringTester R; const Operator* ops[] = { - R.javascript.Add(R.binop_hints), R.simplified.NumberAdd(), - R.javascript.Subtract(R.binop_hints), R.simplified.NumberSubtract(), - R.javascript.Multiply(R.binop_hints), R.simplified.NumberMultiply(), + R.javascript.Add(R.binop_hints), R.simplified.NumberAdd(), + R.javascript.Subtract(), R.simplified.NumberSubtract(), + R.javascript.Multiply(), R.simplified.NumberMultiply(), }; for (size_t j = 0; j < arraysize(ops); j += 2) { diff --git a/deps/v8/test/cctest/compiler/test-jump-threading.cc b/deps/v8/test/cctest/compiler/test-jump-threading.cc index a756254d82..f115989f43 100644 --- a/deps/v8/test/cctest/compiler/test-jump-threading.cc +++ b/deps/v8/test/cctest/compiler/test-jump-threading.cc @@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/compiler/instruction.h" #include "src/compiler/instruction-codes.h" +#include "src/compiler/instruction.h" #include "src/compiler/jump-threading.h" +#include "src/source-position.h" #include "test/cctest/cctest.h" namespace v8 { diff --git a/deps/v8/test/cctest/compiler/test-linkage.cc b/deps/v8/test/cctest/compiler/test-linkage.cc index fef3415984..aed67b8233 100644 --- a/deps/v8/test/cctest/compiler/test-linkage.cc +++ b/deps/v8/test/cctest/compiler/test-linkage.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/api.h" #include "src/code-factory.h" #include "src/code-stubs.h" #include "src/compilation-info.h" @@ -14,6 +15,7 @@ #include "src/compiler/operator.h" #include "src/compiler/pipeline.h" #include "src/compiler/schedule.h" +#include "src/objects-inl.h" #include "src/parsing/parse-info.h" #include "src/zone/zone.h" #include "test/cctest/cctest.h" @@ -34,7 +36,7 @@ static Handle<JSFunction> Compile(const char* source) { Handle<SharedFunctionInfo> shared = Compiler::GetSharedFunctionInfoForScript( source_code, Handle<String>(), 0, 0, v8::ScriptOriginOptions(), Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, NULL, - v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false); + v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE); return isolate->factory()->NewFunctionFromSharedFunctionInfo( shared, isolate->native_context()); } @@ -43,8 +45,8 @@ static Handle<JSFunction> Compile(const char* source) { TEST(TestLinkageCreate) { HandleAndZoneScope handles; Handle<JSFunction> function = Compile("a + b"); - ParseInfo parse_info(handles.main_zone(), handle(function->shared())); - CompilationInfo info(&parse_info, function); + ParseInfo parse_info(handle(function->shared())); + CompilationInfo info(parse_info.zone(), &parse_info, function); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); CHECK(descriptor); } @@ -59,8 +61,8 @@ TEST(TestLinkageJSFunctionIncoming) { Handle<JSFunction> function = Handle<JSFunction>::cast(v8::Utils::OpenHandle( *v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); - ParseInfo parse_info(handles.main_zone(), handle(function->shared())); - CompilationInfo info(&parse_info, function); + ParseInfo parse_info(handle(function->shared())); + CompilationInfo info(parse_info.zone(), &parse_info, function); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); CHECK(descriptor); @@ -75,8 +77,8 @@ TEST(TestLinkageJSFunctionIncoming) { TEST(TestLinkageJSCall) { HandleAndZoneScope handles; Handle<JSFunction> function = Compile("a + c"); - ParseInfo parse_info(handles.main_zone(), handle(function->shared())); - CompilationInfo info(&parse_info, function); + ParseInfo parse_info(handle(function->shared())); + CompilationInfo info(parse_info.zone(), &parse_info, function); for (int i = 0; i < 32; i++) { CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( diff --git a/deps/v8/test/cctest/compiler/test-loop-assignment-analysis.cc b/deps/v8/test/cctest/compiler/test-loop-assignment-analysis.cc index b70df3563c..eaf972d0c8 100644 --- a/deps/v8/test/cctest/compiler/test-loop-assignment-analysis.cc +++ b/deps/v8/test/cctest/compiler/test-loop-assignment-analysis.cc @@ -33,8 +33,8 @@ struct TestHelper : public HandleAndZoneScope { void CheckLoopAssignedCount(int expected, const char* var_name) { // TODO(titzer): don't scope analyze every single time. - ParseInfo parse_info(main_zone(), handle(function->shared())); - CompilationInfo info(&parse_info, function); + ParseInfo parse_info(handle(function->shared())); + CompilationInfo info(parse_info.zone(), &parse_info, function); CHECK(parsing::ParseFunction(&parse_info)); CHECK(Rewriter::Rewrite(&parse_info)); diff --git a/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc b/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc index 15bd72c4d4..b146080618 100644 --- a/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc +++ b/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc @@ -8,6 +8,7 @@ #include "src/compiler/machine-operator-reducer.h" #include "src/compiler/operator-properties.h" #include "src/compiler/typer.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" diff --git a/deps/v8/test/cctest/compiler/test-multiple-return.cc b/deps/v8/test/cctest/compiler/test-multiple-return.cc index 39824b5155..2ab5050c99 100644 --- a/deps/v8/test/cctest/compiler/test-multiple-return.cc +++ b/deps/v8/test/cctest/compiler/test-multiple-return.cc @@ -13,6 +13,7 @@ #include "src/compiler.h" #include "src/compiler/linkage.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/value-helper.h" diff --git a/deps/v8/test/cctest/compiler/test-representation-change.cc b/deps/v8/test/cctest/compiler/test-representation-change.cc index c8519faeb5..94bd460850 100644 --- a/deps/v8/test/cctest/compiler/test-representation-change.cc +++ b/deps/v8/test/cctest/compiler/test-representation-change.cc @@ -4,14 +4,14 @@ #include <limits> +#include "src/compiler/node-matchers.h" +#include "src/compiler/representation-change.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/graph-builder-tester.h" #include "test/cctest/compiler/value-helper.h" -#include "src/compiler/node-matchers.h" -#include "src/compiler/representation-change.h" - namespace v8 { namespace internal { namespace compiler { diff --git a/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc b/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc index ea7fcd6449..b21447ef30 100644 --- a/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc +++ b/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc @@ -74,9 +74,9 @@ class BytecodeGraphCallable { class BytecodeGraphTester { public: - BytecodeGraphTester(Isolate* isolate, Zone* zone, const char* script, + BytecodeGraphTester(Isolate* isolate, const char* script, const char* filter = kFunctionName) - : isolate_(isolate), zone_(zone), script_(script) { + : isolate_(isolate), script_(script) { i::FLAG_ignition = true; i::FLAG_always_opt = false; i::FLAG_allow_natives_syntax = true; @@ -108,7 +108,6 @@ class BytecodeGraphTester { private: Isolate* isolate_; - Zone* zone_; const char* script_; Handle<JSFunction> GetFunction(const char* functionName) { @@ -123,9 +122,9 @@ class BytecodeGraphTester { // TODO(mstarzinger): We should be able to prime CompilationInfo without // having to instantiate a ParseInfo first. Fix this! - ParseInfo parse_info(zone_, handle(function->shared())); + ParseInfo parse_info(handle(function->shared())); - CompilationInfo compilation_info(&parse_info, function); + CompilationInfo compilation_info(parse_info.zone(), &parse_info, function); compilation_info.SetOptimizing(); compilation_info.MarkAsDeoptimizationEnabled(); compilation_info.MarkAsOptimizeFromBytecode(); @@ -187,7 +186,6 @@ struct ExpectedSnippet { TEST(BytecodeGraphBuilderReturnStatements) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -212,7 +210,7 @@ TEST(BytecodeGraphBuilderReturnStatements) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -223,7 +221,6 @@ TEST(BytecodeGraphBuilderReturnStatements) { TEST(BytecodeGraphBuilderPrimitiveExpressions) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -239,7 +236,7 @@ TEST(BytecodeGraphBuilderPrimitiveExpressions) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -250,7 +247,6 @@ TEST(BytecodeGraphBuilderPrimitiveExpressions) { TEST(BytecodeGraphBuilderTwoParameterTests) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<2> snippets[] = { @@ -297,7 +293,7 @@ TEST(BytecodeGraphBuilderTwoParameterTests) { SNPrintF(script, "function %s(p1, p2) { %s }\n%s(0, 0);", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0), snippets[i].parameter(1)) @@ -310,7 +306,6 @@ TEST(BytecodeGraphBuilderTwoParameterTests) { TEST(BytecodeGraphBuilderNamedLoad) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -341,7 +336,7 @@ TEST(BytecodeGraphBuilderNamedLoad) { SNPrintF(script, "function %s(p1) { %s };\n%s(0);", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -353,7 +348,6 @@ TEST(BytecodeGraphBuilderNamedLoad) { TEST(BytecodeGraphBuilderKeyedLoad) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<2> snippets[] = { @@ -397,7 +391,7 @@ TEST(BytecodeGraphBuilderKeyedLoad) { SNPrintF(script, "function %s(p1, p2) { %s };\n%s(0);", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0), snippets[i].parameter(1)) @@ -409,7 +403,6 @@ TEST(BytecodeGraphBuilderKeyedLoad) { void TestBytecodeGraphBuilderNamedStore(size_t shard) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -447,7 +440,7 @@ void TestBytecodeGraphBuilderNamedStore(size_t shard) { SNPrintF(script, "function %s(p1) { %s };\n%s({});", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -460,7 +453,6 @@ SHARD_TEST_BY_2(BytecodeGraphBuilderNamedStore) void TestBytecodeGraphBuilderKeyedStore(size_t shard) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<2> snippets[] = { @@ -506,7 +498,7 @@ void TestBytecodeGraphBuilderKeyedStore(size_t shard) { SNPrintF(script, "function %s(p1, p2) { %s };\n%s({});", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -519,7 +511,6 @@ SHARD_TEST_BY_2(BytecodeGraphBuilderKeyedStore) TEST(BytecodeGraphBuilderPropertyCall) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -541,7 +532,7 @@ TEST(BytecodeGraphBuilderPropertyCall) { SNPrintF(script, "function %s(p1) { %s };\n%s({func() {}});", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -553,7 +544,6 @@ TEST(BytecodeGraphBuilderPropertyCall) { TEST(BytecodeGraphBuilderCallNew) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -580,7 +570,7 @@ TEST(BytecodeGraphBuilderCallNew) { }; for (size_t i = 0; i < arraysize(snippets); i++) { - BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet); + BytecodeGraphTester tester(isolate, snippets[i].code_snippet); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -591,7 +581,6 @@ TEST(BytecodeGraphBuilderCallNew) { TEST(BytecodeGraphBuilderCreateClosure) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -618,7 +607,7 @@ TEST(BytecodeGraphBuilderCreateClosure) { }; for (size_t i = 0; i < arraysize(snippets); i++) { - BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet); + BytecodeGraphTester tester(isolate, snippets[i].code_snippet); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -629,7 +618,6 @@ TEST(BytecodeGraphBuilderCreateClosure) { TEST(BytecodeGraphBuilderCallRuntime) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -645,7 +633,7 @@ TEST(BytecodeGraphBuilderCallRuntime) { }; for (size_t i = 0; i < arraysize(snippets); i++) { - BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet); + BytecodeGraphTester tester(isolate, snippets[i].code_snippet); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -656,7 +644,6 @@ TEST(BytecodeGraphBuilderCallRuntime) { TEST(BytecodeGraphBuilderInvokeIntrinsic) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -667,7 +654,7 @@ TEST(BytecodeGraphBuilderInvokeIntrinsic) { }; for (size_t i = 0; i < arraysize(snippets); i++) { - BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet); + BytecodeGraphTester tester(isolate, snippets[i].code_snippet); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -678,7 +665,6 @@ TEST(BytecodeGraphBuilderInvokeIntrinsic) { void TestBytecodeGraphBuilderGlobals(size_t shard) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -717,7 +703,7 @@ void TestBytecodeGraphBuilderGlobals(size_t shard) { for (size_t i = 0; i < arraysize(snippets); i++) { if ((i % 2) != shard) continue; - BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet); + BytecodeGraphTester tester(isolate, snippets[i].code_snippet); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -734,7 +720,6 @@ TEST(BytecodeGraphBuilderToObject) { TEST(BytecodeGraphBuilderToName) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -767,7 +752,7 @@ TEST(BytecodeGraphBuilderToName) { SNPrintF(script, "function %s() { %s }\n%s({});", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -778,7 +763,6 @@ TEST(BytecodeGraphBuilderToName) { TEST(BytecodeGraphBuilderLogicalNot) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -798,7 +782,7 @@ TEST(BytecodeGraphBuilderLogicalNot) { SNPrintF(script, "function %s(p1) { %s }\n%s({});", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -810,7 +794,6 @@ TEST(BytecodeGraphBuilderLogicalNot) { TEST(BytecodeGraphBuilderTypeOf) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -835,7 +818,7 @@ TEST(BytecodeGraphBuilderTypeOf) { SNPrintF(script, "function %s(p1) { %s }\n%s({});", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -847,7 +830,6 @@ TEST(BytecodeGraphBuilderTypeOf) { TEST(BytecodeGraphBuilderCountOperation) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -889,7 +871,7 @@ TEST(BytecodeGraphBuilderCountOperation) { SNPrintF(script, "function %s(p1) { %s }\n%s({});", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -901,7 +883,6 @@ TEST(BytecodeGraphBuilderCountOperation) { TEST(BytecodeGraphBuilderDelete) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -928,7 +909,7 @@ TEST(BytecodeGraphBuilderDelete) { SNPrintF(script, "function %s(p1) { %s }\n%s({});", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -940,7 +921,6 @@ TEST(BytecodeGraphBuilderDelete) { TEST(BytecodeGraphBuilderDeleteGlobal) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -981,7 +961,7 @@ TEST(BytecodeGraphBuilderDeleteGlobal) { ScopedVector<char> script(1024); SNPrintF(script, "%s %s({});", snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -992,7 +972,6 @@ TEST(BytecodeGraphBuilderDeleteGlobal) { TEST(BytecodeGraphBuilderDeleteLookupSlot) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); // TODO(mythria): Add more tests when we have support for LdaLookupSlot. @@ -1018,7 +997,7 @@ TEST(BytecodeGraphBuilderDeleteLookupSlot) { SNPrintF(script, "%s %s %s", function_prologue, snippets[i].code_snippet, function_epilogue); - BytecodeGraphTester tester(isolate, zone, script.start(), "t"); + BytecodeGraphTester tester(isolate, script.start(), "t"); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1029,7 +1008,6 @@ TEST(BytecodeGraphBuilderDeleteLookupSlot) { TEST(BytecodeGraphBuilderLookupSlot) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); const char* function_prologue = "var f;" @@ -1059,7 +1037,7 @@ TEST(BytecodeGraphBuilderLookupSlot) { SNPrintF(script, "%s %s %s", function_prologue, snippets[i].code_snippet, function_epilogue); - BytecodeGraphTester tester(isolate, zone, script.start(), "t"); + BytecodeGraphTester tester(isolate, script.start(), "t"); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1069,7 +1047,6 @@ TEST(BytecodeGraphBuilderLookupSlot) { TEST(BytecodeGraphBuilderLookupContextSlot) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); // Testing with eval called in the current context. @@ -1087,7 +1064,7 @@ TEST(BytecodeGraphBuilderLookupContextSlot) { inner_eval_prologue, inner_eval_snippets[i].code_snippet, inner_eval_epilogue, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*inner_eval_snippets[i].return_value())); @@ -1109,7 +1086,7 @@ TEST(BytecodeGraphBuilderLookupContextSlot) { outer_eval_prologue, outer_eval_snippets[i].code_snippet, outer_eval_epilogue, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*outer_eval_snippets[i].return_value())); @@ -1119,7 +1096,6 @@ TEST(BytecodeGraphBuilderLookupContextSlot) { TEST(BytecodeGraphBuilderLookupGlobalSlot) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); // Testing with eval called in the current context. @@ -1137,7 +1113,7 @@ TEST(BytecodeGraphBuilderLookupGlobalSlot) { inner_eval_prologue, inner_eval_snippets[i].code_snippet, inner_eval_epilogue, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*inner_eval_snippets[i].return_value())); @@ -1159,7 +1135,7 @@ TEST(BytecodeGraphBuilderLookupGlobalSlot) { outer_eval_prologue, outer_eval_snippets[i].code_snippet, outer_eval_epilogue, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*outer_eval_snippets[i].return_value())); @@ -1169,7 +1145,6 @@ TEST(BytecodeGraphBuilderLookupGlobalSlot) { TEST(BytecodeGraphBuilderLookupSlotWide) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); const char* function_prologue = @@ -1201,7 +1176,7 @@ TEST(BytecodeGraphBuilderLookupSlotWide) { SNPrintF(script, "%s %s %s", function_prologue, snippets[i].code_snippet, function_epilogue); - BytecodeGraphTester tester(isolate, zone, script.start(), "t"); + BytecodeGraphTester tester(isolate, script.start(), "t"); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1212,7 +1187,6 @@ TEST(BytecodeGraphBuilderLookupSlotWide) { TEST(BytecodeGraphBuilderCallLookupSlot) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); ExpectedSnippet<0> snippets[] = { {"g = function(){ return 2 }; eval(''); return g();", @@ -1230,7 +1204,7 @@ TEST(BytecodeGraphBuilderCallLookupSlot) { ScopedVector<char> script(1024); SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1241,7 +1215,6 @@ TEST(BytecodeGraphBuilderCallLookupSlot) { TEST(BytecodeGraphBuilderEval) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -1282,7 +1255,7 @@ TEST(BytecodeGraphBuilderEval) { ScopedVector<char> script(1024); SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1293,7 +1266,6 @@ TEST(BytecodeGraphBuilderEval) { TEST(BytecodeGraphBuilderEvalParams) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); ExpectedSnippet<1> snippets[] = { {"var x = 10; return eval('x + p1;');", @@ -1310,7 +1282,7 @@ TEST(BytecodeGraphBuilderEvalParams) { ScopedVector<char> script(1024); SNPrintF(script, "function %s(p1) { %s }\n%s(0);", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -1322,7 +1294,6 @@ TEST(BytecodeGraphBuilderEvalParams) { TEST(BytecodeGraphBuilderEvalGlobal) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -1338,7 +1309,7 @@ TEST(BytecodeGraphBuilderEvalGlobal) { }; for (size_t i = 0; i < arraysize(snippets); i++) { - BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet); + BytecodeGraphTester tester(isolate, snippets[i].code_snippet); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1400,7 +1371,6 @@ const char* get_code_snippet(Token::Value opcode) { TEST(BytecodeGraphBuilderCompare) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); Handle<Object> lhs_values[] = { factory->NewNumberFromInt(10), factory->NewHeapNumber(3.45), @@ -1419,7 +1389,7 @@ TEST(BytecodeGraphBuilderCompare) { SNPrintF(script, "function %s(p1, p2) { %s }\n%s({}, {});", kFunctionName, get_code_snippet(kCompareOperators[i]), kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); for (size_t j = 0; j < arraysize(lhs_values); j++) { for (size_t k = 0; k < arraysize(rhs_values); k++) { @@ -1437,7 +1407,6 @@ TEST(BytecodeGraphBuilderCompare) { TEST(BytecodeGraphBuilderTestIn) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<2> snippets[] = { @@ -1473,7 +1442,7 @@ TEST(BytecodeGraphBuilderTestIn) { SNPrintF(script, "function %s(p1, p2) { %s }\n%s({}, {});", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0), snippets[i].parameter(1)) @@ -1486,7 +1455,6 @@ TEST(BytecodeGraphBuilderTestIn) { TEST(BytecodeGraphBuilderTestInstanceOf) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -1505,7 +1473,7 @@ TEST(BytecodeGraphBuilderTestInstanceOf) { SNPrintF(script, "function %s(p1) { %s }\n%s({});", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -1516,7 +1484,6 @@ TEST(BytecodeGraphBuilderTestInstanceOf) { TEST(BytecodeGraphBuilderTryCatch) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); ExpectedSnippet<0> snippets[] = { {"var a = 1; try { a = 2 } catch(e) { a = 3 }; return a;", @@ -1535,7 +1502,7 @@ TEST(BytecodeGraphBuilderTryCatch) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1545,7 +1512,6 @@ TEST(BytecodeGraphBuilderTryCatch) { TEST(BytecodeGraphBuilderTryFinally1) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); ExpectedSnippet<0> snippets[] = { {"var a = 1; try { a = a + 1; } finally { a = a + 2; }; return a;", @@ -1573,7 +1539,7 @@ TEST(BytecodeGraphBuilderTryFinally1) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1583,7 +1549,6 @@ TEST(BytecodeGraphBuilderTryFinally1) { TEST(BytecodeGraphBuilderTryFinally2) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); ExpectedSnippet<0, const char*> snippets[] = { {"var a = 1; try { a = 2; throw 23; } finally { a = 3 }; return a;", @@ -1597,7 +1562,7 @@ TEST(BytecodeGraphBuilderTryFinally2) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); v8::Local<v8::String> message = tester.CheckThrowsReturnMessage()->Get(); v8::Local<v8::String> expected_string = v8_str(snippets[i].return_value()); CHECK( @@ -1609,7 +1574,6 @@ TEST(BytecodeGraphBuilderTryFinally2) { TEST(BytecodeGraphBuilderThrow) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); // TODO(mythria): Add more tests when real try-catch and deoptimization // information are supported. @@ -1626,7 +1590,7 @@ TEST(BytecodeGraphBuilderThrow) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); v8::Local<v8::String> message = tester.CheckThrowsReturnMessage()->Get(); v8::Local<v8::String> expected_string = v8_str(snippets[i].return_value()); CHECK( @@ -1639,7 +1603,6 @@ TEST(BytecodeGraphBuilderThrow) { TEST(BytecodeGraphBuilderContext) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -1687,7 +1650,7 @@ TEST(BytecodeGraphBuilderContext) { ScopedVector<char> script(1024); SNPrintF(script, "%s", snippets[i].code_snippet); - BytecodeGraphTester tester(isolate, zone, script.start(), "f"); + BytecodeGraphTester tester(isolate, script.start(), "f"); auto callable = tester.GetCallable<>("f"); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1698,7 +1661,6 @@ TEST(BytecodeGraphBuilderContext) { TEST(BytecodeGraphBuilderLoadContext) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -1752,7 +1714,7 @@ TEST(BytecodeGraphBuilderLoadContext) { ScopedVector<char> script(1024); SNPrintF(script, "%s", snippets[i].code_snippet); - BytecodeGraphTester tester(isolate, zone, script.start(), "*"); + BytecodeGraphTester tester(isolate, script.start(), "*"); auto callable = tester.GetCallable<Handle<Object>>("f"); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -1764,7 +1726,6 @@ TEST(BytecodeGraphBuilderLoadContext) { TEST(BytecodeGraphBuilderCreateArgumentsNoParameters) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -1784,7 +1745,7 @@ TEST(BytecodeGraphBuilderCreateArgumentsNoParameters) { ScopedVector<char> script(1024); SNPrintF(script, "%s\n%s();", snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1795,7 +1756,6 @@ TEST(BytecodeGraphBuilderCreateArgumentsNoParameters) { TEST(BytecodeGraphBuilderCreateArguments) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<3> snippets[] = { @@ -1827,7 +1787,7 @@ TEST(BytecodeGraphBuilderCreateArguments) { ScopedVector<char> script(1024); SNPrintF(script, "%s\n%s();", snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>, Handle<Object>, Handle<Object>>(); Handle<Object> return_value = @@ -1841,7 +1801,6 @@ TEST(BytecodeGraphBuilderCreateArguments) { TEST(BytecodeGraphBuilderCreateRestArguments) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<3> snippets[] = { @@ -1870,7 +1829,7 @@ TEST(BytecodeGraphBuilderCreateRestArguments) { ScopedVector<char> script(1024); SNPrintF(script, "%s\n%s();", snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>, Handle<Object>, Handle<Object>>(); Handle<Object> return_value = @@ -1884,7 +1843,6 @@ TEST(BytecodeGraphBuilderCreateRestArguments) { TEST(BytecodeGraphBuilderRegExpLiterals) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -1909,7 +1867,7 @@ TEST(BytecodeGraphBuilderRegExpLiterals) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1920,7 +1878,6 @@ TEST(BytecodeGraphBuilderRegExpLiterals) { TEST(BytecodeGraphBuilderArrayLiterals) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -1949,7 +1906,7 @@ TEST(BytecodeGraphBuilderArrayLiterals) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -1960,7 +1917,6 @@ TEST(BytecodeGraphBuilderArrayLiterals) { TEST(BytecodeGraphBuilderObjectLiterals) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -2013,7 +1969,7 @@ TEST(BytecodeGraphBuilderObjectLiterals) { ScopedVector<char> script(4096); SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2024,7 +1980,6 @@ TEST(BytecodeGraphBuilderObjectLiterals) { TEST(BytecodeGraphBuilderIf) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -2122,7 +2077,7 @@ TEST(BytecodeGraphBuilderIf) { SNPrintF(script, "function %s(p1) { %s };\n%s(0);", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -2134,7 +2089,6 @@ TEST(BytecodeGraphBuilderIf) { TEST(BytecodeGraphBuilderConditionalOperator) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<1> snippets[] = { @@ -2153,7 +2107,7 @@ TEST(BytecodeGraphBuilderConditionalOperator) { SNPrintF(script, "function %s(p1) { %s };\n%s(0);", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -2165,7 +2119,6 @@ TEST(BytecodeGraphBuilderConditionalOperator) { TEST(BytecodeGraphBuilderSwitch) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); const char* switch_code = @@ -2201,7 +2154,7 @@ TEST(BytecodeGraphBuilderSwitch) { SNPrintF(script, "function %s(p1) { %s };\n%s(0);", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -2212,7 +2165,6 @@ TEST(BytecodeGraphBuilderSwitch) { TEST(BytecodeGraphBuilderSwitchMerge) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); const char* switch_code = @@ -2250,7 +2202,7 @@ TEST(BytecodeGraphBuilderSwitchMerge) { SNPrintF(script, "function %s(p1) { %s };\n%s(0);", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0)).ToHandleChecked(); @@ -2261,7 +2213,6 @@ TEST(BytecodeGraphBuilderSwitchMerge) { TEST(BytecodeGraphBuilderNestedSwitch) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); const char* switch_code = @@ -2309,7 +2260,7 @@ TEST(BytecodeGraphBuilderNestedSwitch) { SNPrintF(script, "function %s(p1, p2) { %s };\n%s(0, 0);", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); Handle<Object> return_value = callable(snippets[i].parameter(0), snippets[i].parameter(1)) @@ -2322,7 +2273,6 @@ TEST(BytecodeGraphBuilderNestedSwitch) { TEST(BytecodeGraphBuilderBreakableBlocks) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -2352,7 +2302,7 @@ TEST(BytecodeGraphBuilderBreakableBlocks) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2363,7 +2313,6 @@ TEST(BytecodeGraphBuilderBreakableBlocks) { TEST(BytecodeGraphBuilderWhile) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -2401,7 +2350,7 @@ TEST(BytecodeGraphBuilderWhile) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2412,7 +2361,6 @@ TEST(BytecodeGraphBuilderWhile) { TEST(BytecodeGraphBuilderDo) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -2450,7 +2398,7 @@ TEST(BytecodeGraphBuilderDo) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2461,7 +2409,6 @@ TEST(BytecodeGraphBuilderDo) { TEST(BytecodeGraphBuilderFor) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -2544,7 +2491,7 @@ TEST(BytecodeGraphBuilderFor) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2555,7 +2502,6 @@ TEST(BytecodeGraphBuilderFor) { TEST(BytecodeGraphBuilderForIn) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { {"var sum = 0;\n" @@ -2616,7 +2562,7 @@ TEST(BytecodeGraphBuilderForIn) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2627,7 +2573,6 @@ TEST(BytecodeGraphBuilderForIn) { TEST(BytecodeGraphBuilderForOf) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { {" var r = 0;\n" @@ -2709,7 +2654,7 @@ TEST(BytecodeGraphBuilderForOf) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2745,8 +2690,7 @@ void TestJumpWithConstantsAndWideConstants(size_t shard) { HandleAndZoneScope scope; auto isolate = scope.main_isolate(); auto factory = isolate->factory(); - auto zone = scope.main_zone(); - BytecodeGraphTester tester(isolate, zone, script.c_str()); + BytecodeGraphTester tester(isolate, script.c_str()); auto callable = tester.GetCallable<Handle<Object>>(); for (int a = 0; a < 3; a++) { Handle<Object> return_val = @@ -2764,7 +2708,6 @@ TEST(BytecodeGraphBuilderDoExpressions) { FLAG_harmony_do_expressions = true; HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { {"var a = do {}; return a;", {factory->undefined_value()}}, @@ -2782,7 +2725,7 @@ TEST(BytecodeGraphBuilderDoExpressions) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2794,7 +2737,6 @@ TEST(BytecodeGraphBuilderDoExpressions) { TEST(BytecodeGraphBuilderWithStatement) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); ExpectedSnippet<0> snippets[] = { {"with({x:42}) return x;", {handle(Smi::FromInt(42), isolate)}}, @@ -2821,7 +2763,7 @@ TEST(BytecodeGraphBuilderWithStatement) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2831,7 +2773,6 @@ TEST(BytecodeGraphBuilderWithStatement) { TEST(BytecodeGraphBuilderConstDeclaration) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -2868,7 +2809,7 @@ TEST(BytecodeGraphBuilderConstDeclaration) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2880,7 +2821,7 @@ TEST(BytecodeGraphBuilderConstDeclaration) { SNPrintF(script, "function %s() {'use strict'; %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2890,7 +2831,6 @@ TEST(BytecodeGraphBuilderConstDeclaration) { TEST(BytecodeGraphBuilderConstDeclarationLookupSlots) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); Factory* factory = isolate->factory(); ExpectedSnippet<0> snippets[] = { @@ -2910,7 +2850,7 @@ TEST(BytecodeGraphBuilderConstDeclarationLookupSlots) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2922,7 +2862,7 @@ TEST(BytecodeGraphBuilderConstDeclarationLookupSlots) { SNPrintF(script, "function %s() {'use strict'; %s }\n%s();", kFunctionName, snippets[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*snippets[i].return_value())); @@ -2932,7 +2872,6 @@ TEST(BytecodeGraphBuilderConstDeclarationLookupSlots) { TEST(BytecodeGraphBuilderConstInLookupContextChain) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); const char* prologue = "function OuterMost() {\n" @@ -2970,7 +2909,7 @@ TEST(BytecodeGraphBuilderConstInLookupContextChain) { SNPrintF(script, "%s %s %s", prologue, const_decl[i].code_snippet, epilogue); - BytecodeGraphTester tester(isolate, zone, script.start(), "*"); + BytecodeGraphTester tester(isolate, script.start(), "*"); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*const_decl[i].return_value())); @@ -2980,7 +2919,6 @@ TEST(BytecodeGraphBuilderConstInLookupContextChain) { TEST(BytecodeGraphBuilderIllegalConstDeclaration) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); ExpectedSnippet<0, const char*> illegal_const_decl[] = { {"const x = x = 10 + 3; return x;", @@ -3003,7 +2941,7 @@ TEST(BytecodeGraphBuilderIllegalConstDeclaration) { SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, illegal_const_decl[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); v8::Local<v8::String> message = tester.CheckThrowsReturnMessage()->Get(); v8::Local<v8::String> expected_string = v8_str(illegal_const_decl[i].return_value()); @@ -3018,7 +2956,7 @@ TEST(BytecodeGraphBuilderIllegalConstDeclaration) { SNPrintF(script, "function %s() {'use strict'; %s }\n%s();", kFunctionName, illegal_const_decl[i].code_snippet, kFunctionName); - BytecodeGraphTester tester(isolate, zone, script.start()); + BytecodeGraphTester tester(isolate, script.start()); v8::Local<v8::String> message = tester.CheckThrowsReturnMessage()->Get(); v8::Local<v8::String> expected_string = v8_str(illegal_const_decl[i].return_value()); @@ -3036,7 +2974,6 @@ static void DebugEventCounter(const v8::Debug::EventDetails& event_details) { TEST(BytecodeGraphBuilderDebuggerStatement) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); - Zone* zone = scope.main_zone(); v8::Debug::SetDebugEventListener(CcTest::isolate(), DebugEventCounter); @@ -3047,7 +2984,7 @@ TEST(BytecodeGraphBuilderDebuggerStatement) { "f();", {isolate->factory()->undefined_value()}}; - BytecodeGraphTester tester(isolate, zone, snippet.code_snippet); + BytecodeGraphTester tester(isolate, snippet.code_snippet); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); diff --git a/deps/v8/test/cctest/compiler/test-run-calls-to-external-references.cc b/deps/v8/test/cctest/compiler/test-run-calls-to-external-references.cc index 0bc6ff3998..efea4ce4cc 100644 --- a/deps/v8/test/cctest/compiler/test-run-calls-to-external-references.cc +++ b/deps/v8/test/cctest/compiler/test-run-calls-to-external-references.cc @@ -2,6 +2,7 @@ // source code is governed by a BSD-style license that can be found in the // LICENSE file. +#include "src/objects-inl.h" #include "src/wasm/wasm-external-refs.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" diff --git a/deps/v8/test/cctest/compiler/test-run-jsbranches.cc b/deps/v8/test/cctest/compiler/test-run-jsbranches.cc index 502295e471..76cb9a2843 100644 --- a/deps/v8/test/cctest/compiler/test-run-jsbranches.cc +++ b/deps/v8/test/cctest/compiler/test-run-jsbranches.cc @@ -104,70 +104,6 @@ TEST(ForStatement) { T.CheckCall(T.Val("str"), T.Val("str"), T.Val("str")); } - -static void TestForIn(const char* code) { - FunctionTester T(code); - T.CheckCall(T.undefined(), T.undefined()); - T.CheckCall(T.undefined(), T.null()); - T.CheckCall(T.undefined(), T.NewObject("({})")); - T.CheckCall(T.undefined(), T.Val(1)); - T.CheckCall(T.Val("2"), T.Val("str")); - T.CheckCall(T.Val("a"), T.NewObject("({'a' : 1})")); - T.CheckCall(T.Val("2"), T.NewObject("([1, 2, 3])")); - T.CheckCall(T.Val("a"), T.NewObject("({'a' : 1, 'b' : 1})"), T.Val("b")); - T.CheckCall(T.Val("1"), T.NewObject("([1, 2, 3])"), T.Val("2")); -} - - -TEST(ForInStatement) { - // Variable assignment. - TestForIn( - "(function(a, b) {" - "var last;" - "for (var x in a) {" - " if (b) { delete a[b]; b = undefined; }" - " last = x;" - "}" - "return last;})"); - // Indexed assignment. - TestForIn( - "(function(a, b) {" - "var array = [0, 1, undefined];" - "for (array[2] in a) {" - " if (b) { delete a[b]; b = undefined; }" - "}" - "return array[2];})"); - // Named assignment. - TestForIn( - "(function(a, b) {" - "var obj = {'a' : undefined};" - "for (obj.a in a) {" - " if (b) { delete a[b]; b = undefined; }" - "}" - "return obj.a;})"); -} - - -TEST(ForInContinueStatement) { - const char* src = - "(function(a,b) {" - " var r = '-';" - " for (var x in a) {" - " r += 'A-';" - " if (b) continue;" - " r += 'B-';" - " }" - " return r;" - "})"; - FunctionTester T(src); - - T.CheckCall(T.Val("-A-B-"), T.NewObject("({x:1})"), T.false_value()); - T.CheckCall(T.Val("-A-B-A-B-"), T.NewObject("({x:1,y:2})"), T.false_value()); - T.CheckCall(T.Val("-A-"), T.NewObject("({x:1})"), T.true_value()); - T.CheckCall(T.Val("-A-A-"), T.NewObject("({x:1,y:2})"), T.true_value()); -} - - TEST(ForOfContinueStatement) { const char* src = "(function(a,b) {" diff --git a/deps/v8/test/cctest/compiler/test-run-load-store.cc b/deps/v8/test/cctest/compiler/test-run-load-store.cc index 559e6fd02a..bf42188207 100644 --- a/deps/v8/test/cctest/compiler/test-run-load-store.cc +++ b/deps/v8/test/cctest/compiler/test-run-load-store.cc @@ -9,6 +9,7 @@ #include "src/base/bits.h" #include "src/base/utils/random-number-generator.h" #include "src/codegen.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/graph-builder-tester.h" diff --git a/deps/v8/test/cctest/compiler/test-run-machops.cc b/deps/v8/test/cctest/compiler/test-run-machops.cc index 195f0a91dc..5414c553bd 100644 --- a/deps/v8/test/cctest/compiler/test-run-machops.cc +++ b/deps/v8/test/cctest/compiler/test-run-machops.cc @@ -10,6 +10,7 @@ #include "src/base/ieee754.h" #include "src/base/utils/random-number-generator.h" #include "src/codegen.h" +#include "src/objects-inl.h" #include "src/utils.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" @@ -6709,6 +6710,37 @@ TEST(ParentFramePointer) { CHECK_EQ(1, r.Call(1)); } +#if V8_TARGET_ARCH_64_BIT + +TEST(Regression5923) { + { + BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Int64()); + m.Return(m.Int64Add( + m.Word64Shr(m.Parameter(0), m.Int64Constant(4611686018427387888)), + m.Parameter(0))); + int64_t input = 16; + m.Call(input); + } + { + BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Int64()); + m.Return(m.Int64Add( + m.Parameter(0), + m.Word64Shr(m.Parameter(0), m.Int64Constant(4611686018427387888)))); + int64_t input = 16; + m.Call(input); + } +} + +TEST(Regression5951) { + BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Int64()); + m.Return(m.Word64And(m.Word64Shr(m.Parameter(0), m.Int64Constant(0)), + m.Int64Constant(0xffffffffffffffffl))); + int64_t input = 1234; + CHECK_EQ(input, m.Call(input)); +} + +#endif // V8_TARGET_ARCH_64_BIT + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-native-calls.cc b/deps/v8/test/cctest/compiler/test-run-native-calls.cc index e877d258b5..fb35744904 100644 --- a/deps/v8/test/cctest/compiler/test-run-native-calls.cc +++ b/deps/v8/test/cctest/compiler/test-run-native-calls.cc @@ -7,6 +7,7 @@ #include "src/compiler/linkage.h" #include "src/compiler/raw-machine-assembler.h" #include "src/machine-type.h" +#include "src/objects-inl.h" #include "src/register-configuration.h" #include "test/cctest/cctest.h" diff --git a/deps/v8/test/cctest/compiler/test-run-stubs.cc b/deps/v8/test/cctest/compiler/test-run-stubs.cc index 8b6519eac5..0d618bda65 100644 --- a/deps/v8/test/cctest/compiler/test-run-stubs.cc +++ b/deps/v8/test/cctest/compiler/test-run-stubs.cc @@ -12,6 +12,7 @@ #include "src/compiler/linkage.h" #include "src/compiler/machine-operator.h" #include "src/compiler/pipeline.h" +#include "src/objects-inl.h" #include "test/cctest/compiler/function-tester.h" namespace v8 { diff --git a/deps/v8/test/cctest/compiler/test-run-wasm-machops.cc b/deps/v8/test/cctest/compiler/test-run-wasm-machops.cc index 9359b25779..cbf2b2a0a3 100644 --- a/deps/v8/test/cctest/compiler/test-run-wasm-machops.cc +++ b/deps/v8/test/cctest/compiler/test-run-wasm-machops.cc @@ -9,6 +9,7 @@ #include "src/base/bits.h" #include "src/base/utils/random-number-generator.h" #include "src/codegen.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/graph-builder-tester.h" @@ -26,13 +27,13 @@ static void UpdateMemoryReferences(Handle<Code> code, Address old_base, RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_SIZE_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemoryReference(mode) || - RelocInfo::IsWasmMemorySizeReference(mode)) { - // Patch addresses with change in memory start address - it.rinfo()->update_wasm_memory_reference(old_base, new_base, old_size, - new_size); - modified = true; + if (RelocInfo::IsWasmMemoryReference(mode)) { + it.rinfo()->update_wasm_memory_reference(old_base, new_base); + } else { + DCHECK(RelocInfo::IsWasmMemorySizeReference(mode)); + it.rinfo()->update_wasm_memory_size(old_size, new_size); } + modified = true; } if (modified) { Assembler::FlushICache(isolate, code->instruction_start(), diff --git a/deps/v8/test/cctest/compiler/value-helper.h b/deps/v8/test/cctest/compiler/value-helper.h index 297bccb05b..dc74f8d1ed 100644 --- a/deps/v8/test/cctest/compiler/value-helper.h +++ b/deps/v8/test/cctest/compiler/value-helper.h @@ -300,6 +300,18 @@ class ValueHelper { return std::vector<double>(&values[0], &values[arraysize(values)]); } + static const std::vector<int16_t> int16_vector() { + static const int16_t kValues[] = { + 0, 1, 2, INT16_MAX - 1, INT16_MAX, INT16_MIN, INT16_MIN + 1, -2, -1}; + return std::vector<int16_t>(&kValues[0], &kValues[arraysize(kValues)]); + } + + static const std::vector<int8_t> int8_vector() { + static const int8_t kValues[] = { + 0, 1, 2, INT8_MAX - 1, INT8_MAX, INT8_MIN, INT8_MIN + 1, -2, -1}; + return std::vector<int8_t>(&kValues[0], &kValues[arraysize(kValues)]); + } + static const std::vector<uint32_t> ror_vector() { static const uint32_t kValues[31] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, @@ -317,6 +329,8 @@ class ValueHelper { #define FOR_INT32_INPUTS(var) FOR_INPUTS(int32_t, int32, var) #define FOR_UINT32_INPUTS(var) FOR_INPUTS(uint32_t, uint32, var) +#define FOR_INT16_INPUTS(var) FOR_INPUTS(int16_t, int16, var) +#define FOR_INT8_INPUTS(var) FOR_INPUTS(int8_t, int8, var) #define FOR_INT64_INPUTS(var) FOR_INPUTS(int64_t, int64, var) #define FOR_UINT64_INPUTS(var) FOR_INPUTS(uint64_t, uint64, var) #define FOR_FLOAT32_INPUTS(var) FOR_INPUTS(float, float32, var) diff --git a/deps/v8/test/cctest/ffi/OWNERS b/deps/v8/test/cctest/ffi/OWNERS new file mode 100644 index 0000000000..dc9a9780a6 --- /dev/null +++ b/deps/v8/test/cctest/ffi/OWNERS @@ -0,0 +1,2 @@ +mattloring@google.com +ofrobots@google.com diff --git a/deps/v8/test/cctest/ffi/test-ffi.cc b/deps/v8/test/cctest/ffi/test-ffi.cc new file mode 100644 index 0000000000..9d87244e94 --- /dev/null +++ b/deps/v8/test/cctest/ffi/test-ffi.cc @@ -0,0 +1,222 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/api.h" +#include "src/codegen.h" +#include "src/ffi/ffi-compiler.h" +#include "src/objects-inl.h" +#include "test/cctest/cctest.h" + +namespace v8 { +namespace internal { +namespace ffi { + +static void hello_world() { printf("hello world from native code\n"); } + +TEST(Run_FFI_Hello) { + Isolate* isolate = CcTest::InitIsolateOnce(); + HandleScope scope(isolate); + + Handle<String> name = + isolate->factory()->InternalizeUtf8String("hello_world"); + Handle<Object> undefined = isolate->factory()->undefined_value(); + + AccountingAllocator allocator; + Zone zone(&allocator, ZONE_NAME); + FFISignature::Builder sig_builder(&zone, 0, 0); + NativeFunction func = {sig_builder.Build(), + reinterpret_cast<uint8_t*>(hello_world)}; + + Handle<JSFunction> jsfunc = CompileJSToNativeWrapper(isolate, name, func); + + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, 0, nullptr).ToHandleChecked(); + + CHECK(result->IsUndefined(isolate)); +} + +static int add2(int x, int y) { return x + y; } + +TEST(Run_FFI_add2) { + Isolate* isolate = CcTest::InitIsolateOnce(); + HandleScope scope(isolate); + + Handle<String> name = isolate->factory()->InternalizeUtf8String("add2"); + Handle<Object> undefined = isolate->factory()->undefined_value(); + + AccountingAllocator allocator; + Zone zone(&allocator, ZONE_NAME); + FFISignature::Builder sig_builder(&zone, 1, 2); + sig_builder.AddReturn(FFIType::kInt32); + sig_builder.AddParam(FFIType::kInt32); + sig_builder.AddParam(FFIType::kInt32); + NativeFunction func = {sig_builder.Build(), reinterpret_cast<uint8_t*>(add2)}; + + Handle<JSFunction> jsfunc = CompileJSToNativeWrapper(isolate, name, func); + + // Simple math should work. + { + Handle<Object> args[] = {isolate->factory()->NewNumber(1.0), + isolate->factory()->NewNumber(41.0)}; + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + CHECK_EQ(42.0, result->Number()); + } + + // Truncate floating point to integer. + { + Handle<Object> args[] = {isolate->factory()->NewNumber(1.9), + isolate->factory()->NewNumber(41.0)}; + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + CHECK_EQ(42.0, result->Number()); + } + + // INT_MAX + 1 should wrap. + { + Handle<Object> args[] = {isolate->factory()->NewNumber(kMaxInt), + isolate->factory()->NewNumber(1)}; + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + CHECK_EQ(kMinInt, result->Number()); + } + + // INT_MIN + -1 should wrap. + { + Handle<Object> args[] = {isolate->factory()->NewNumber(kMinInt), + isolate->factory()->NewNumber(-1)}; + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + CHECK_EQ(kMaxInt, result->Number()); + } + + // Numbers get truncated to the 32 least significant bits. + { + Handle<Object> args[] = {isolate->factory()->NewNumber(1ull << 40), + isolate->factory()->NewNumber(-1)}; + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + CHECK_EQ(-1, result->Number()); + } + + // String '57' converts to 57. + { + Handle<Object> args[] = { + isolate->factory()->NewStringFromAsciiChecked("57"), + isolate->factory()->NewNumber(41.0)}; + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + CHECK_EQ(98.0, result->Number()); + } + + // String 'foo' converts to 0. + { + Handle<Object> args[] = { + isolate->factory()->NewStringFromAsciiChecked("foo"), + isolate->factory()->NewNumber(41.0)}; + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + CHECK_EQ(41.0, result->Number()); + } + + // String '58o' converts to 0. + { + Handle<Object> args[] = { + isolate->factory()->NewStringFromAsciiChecked("58o"), + isolate->factory()->NewNumber(41.0)}; + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + CHECK_EQ(41.0, result->Number()); + } + + // NaN converts to 0. + { + Handle<Object> args[] = {isolate->factory()->nan_value(), + isolate->factory()->NewNumber(41.0)}; + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + CHECK_EQ(41.0, result->Number()); + } + + // null converts to 0. + { + Handle<Object> args[] = {isolate->factory()->null_value(), + isolate->factory()->NewNumber(41.0)}; + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + CHECK_EQ(41.0, result->Number()); + } +} + +static int add6(int a, int b, int c, int d, int e, int f) { + return a + b + c + d + e + f; +} + +TEST(Run_FFI_add6) { + Isolate* isolate = CcTest::InitIsolateOnce(); + HandleScope scope(isolate); + + Handle<String> name = isolate->factory()->InternalizeUtf8String("add6"); + Handle<Object> undefined = isolate->factory()->undefined_value(); + + AccountingAllocator allocator; + Zone zone(&allocator, ZONE_NAME); + FFISignature::Builder sig_builder(&zone, 1, 7); + sig_builder.AddReturn(FFIType::kInt32); + for (int i = 0; i < 7; i++) { + sig_builder.AddParam(FFIType::kInt32); + } + NativeFunction func = {sig_builder.Build(), reinterpret_cast<uint8_t*>(add6)}; + + Handle<JSFunction> jsfunc = CompileJSToNativeWrapper(isolate, name, func); + Handle<Object> args[] = { + isolate->factory()->NewNumber(1), isolate->factory()->NewNumber(2), + isolate->factory()->NewNumber(3), isolate->factory()->NewNumber(4), + isolate->factory()->NewNumber(5), isolate->factory()->NewNumber(6)}; + + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + + CHECK_EQ(21.0, result->Number()); + + { + // Ensure builtin frames are generated + FLAG_allow_natives_syntax = true; + v8::Local<v8::Value> res = CompileRun( + "var o = { valueOf: function() { %DebugTrace(); return 1; } }; o;"); + Handle<JSReceiver> param(v8::Utils::OpenHandle(v8::Object::Cast(*res))); + Handle<Object> args[] = {param, + isolate->factory()->NewNumber(2), + isolate->factory()->NewNumber(3), + isolate->factory()->NewNumber(4), + isolate->factory()->NewNumber(5), + isolate->factory()->NewNumber(6), + isolate->factory()->NewNumber(21)}; + + Handle<Object> result = + Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) + .ToHandleChecked(); + CHECK_EQ(21.0, result->Number()); + CHECK_EQ( + 1.0, + res->NumberValue( + reinterpret_cast<v8::Isolate*>(isolate)->GetCurrentContext()) + .ToChecked()); + } +} + +} // namespace ffi +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/heap/heap-tester.h b/deps/v8/test/cctest/heap/heap-tester.h index acfbe92bb6..289439c182 100644 --- a/deps/v8/test/cctest/heap/heap-tester.h +++ b/deps/v8/test/cctest/heap/heap-tester.h @@ -5,7 +5,6 @@ #ifndef HEAP_HEAP_TESTER_H_ #define HEAP_HEAP_TESTER_H_ -#include "src/handles.h" #include "src/heap/spaces.h" // Tests that should have access to private methods of {v8::internal::Heap}. @@ -56,6 +55,9 @@ namespace v8 { namespace internal { +template <typename T> +class Handle; + class HeapTester { public: #define DECLARE_STATIC(Name) static void Test##Name(); diff --git a/deps/v8/test/cctest/heap/test-alloc.cc b/deps/v8/test/cctest/heap/test-alloc.cc index 3485c0ab07..27070c9da8 100644 --- a/deps/v8/test/cctest/heap/test-alloc.cc +++ b/deps/v8/test/cctest/heap/test-alloc.cc @@ -48,7 +48,7 @@ AllocationResult v8::internal::HeapTester::AllocateAfterFailures() { // Make sure we can allocate through optimized allocation functions // for specific kinds. heap->AllocateFixedArray(100).ToObjectChecked(); - heap->AllocateHeapNumber(0.42).ToObjectChecked(); + heap->AllocateHeapNumber().ToObjectChecked(); Object* object = heap->AllocateJSObject( *CcTest::i_isolate()->object_function()).ToObjectChecked(); heap->CopyJSObject(JSObject::cast(object)).ToObjectChecked(); diff --git a/deps/v8/test/cctest/heap/test-heap.cc b/deps/v8/test/cctest/heap/test-heap.cc index 7dc7123b65..3042ca8df8 100644 --- a/deps/v8/test/cctest/heap/test-heap.cc +++ b/deps/v8/test/cctest/heap/test-heap.cc @@ -28,9 +28,12 @@ #include <stdlib.h> #include <utility> +#include "src/api.h" +#include "src/assembler-inl.h" #include "src/code-stubs.h" #include "src/compilation-cache.h" #include "src/context-measure.h" +#include "src/debug/debug.h" #include "src/deoptimizer.h" #include "src/elements.h" #include "src/execution.h" @@ -38,11 +41,15 @@ #include "src/field-type.h" #include "src/global-handles.h" #include "src/heap/gc-tracer.h" +#include "src/heap/incremental-marking.h" +#include "src/heap/mark-compact.h" #include "src/heap/memory-reducer.h" #include "src/ic/ic.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" #include "src/regexp/jsregexp.h" #include "src/snapshot/snapshot.h" +#include "src/transitions.h" #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-tester.h" #include "test/cctest/heap/heap-utils.h" @@ -68,14 +75,68 @@ TEST(HeapMaps) { Heap* heap = CcTest::heap(); CheckMap(heap->meta_map(), MAP_TYPE, Map::kSize); CheckMap(heap->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); -#define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ - CheckMap(heap->type##_map(), SIMD128_VALUE_TYPE, Type::kSize); - SIMD128_TYPES(SIMD128_TYPE) -#undef SIMD128_TYPE CheckMap(heap->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel); } +static void VerifyStoredPrototypeMap(Isolate* isolate, + int stored_map_context_index, + int stored_ctor_context_index) { + Handle<Context> context = isolate->native_context(); + + Handle<Map> this_map(Map::cast(context->get(stored_map_context_index))); + + Handle<JSFunction> fun( + JSFunction::cast(context->get(stored_ctor_context_index))); + Handle<JSObject> proto(JSObject::cast(fun->initial_map()->prototype())); + Handle<Map> that_map(proto->map()); + + CHECK(proto->HasFastProperties()); + CHECK_EQ(*this_map, *that_map); +} + +// Checks that critical maps stored on the context (mostly used for fast-path +// checks) are unchanged after initialization. +TEST(ContextMaps) { + CcTest::InitializeVM(); + Isolate* isolate = CcTest::i_isolate(); + HandleScope handle_scope(isolate); + + VerifyStoredPrototypeMap(isolate, + Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX, + Context::STRING_FUNCTION_INDEX); + VerifyStoredPrototypeMap(isolate, Context::REGEXP_PROTOTYPE_MAP_INDEX, + Context::REGEXP_FUNCTION_INDEX); + VerifyStoredPrototypeMap(isolate, Context::PROMISE_PROTOTYPE_MAP_INDEX, + Context::PROMISE_FUNCTION_INDEX); +} + +TEST(InitialObjects) { + LocalContext env; + HandleScope scope(CcTest::i_isolate()); + Handle<Context> context = v8::Utils::OpenHandle(*env); + // Initial ArrayIterator prototype. + CHECK_EQ( + context->initial_array_iterator_prototype(), + *v8::Utils::OpenHandle(*CompileRun("[][Symbol.iterator]().__proto__"))); + // Initial ArrayIterator prototype map. + CHECK_EQ(context->initial_array_iterator_prototype_map(), + context->initial_array_iterator_prototype()->map()); + // Initial Array prototype. + CHECK_EQ(context->initial_array_prototype(), + *v8::Utils::OpenHandle(*CompileRun("Array.prototype"))); + // Initial Generator prototype. + CHECK_EQ(context->initial_generator_prototype(), + *v8::Utils::OpenHandle( + *CompileRun("(function*(){}).__proto__.prototype"))); + // Initial Iterator prototype. + CHECK_EQ(context->initial_iterator_prototype(), + *v8::Utils::OpenHandle( + *CompileRun("[][Symbol.iterator]().__proto__.__proto__"))); + // Initial Object prototype. + CHECK_EQ(context->initial_object_prototype(), + *v8::Utils::OpenHandle(*CompileRun("Object.prototype"))); +} static void CheckOddball(Isolate* isolate, Object* obj, const char* string) { CHECK(obj->IsOddball()); @@ -266,206 +327,6 @@ TEST(HeapObjects) { CheckFindCodeObject(isolate); } - -template <typename T, typename LANE_TYPE, int LANES> -static void CheckSimdValue(T* value, LANE_TYPE lane_values[LANES], - LANE_TYPE other_value) { - // Check against lane_values, and check that all lanes can be set to - // other_value without disturbing the other lanes. - for (int i = 0; i < LANES; i++) { - CHECK_EQ(lane_values[i], value->get_lane(i)); - } - for (int i = 0; i < LANES; i++) { - value->set_lane(i, other_value); // change the value - for (int j = 0; j < LANES; j++) { - if (i != j) - CHECK_EQ(lane_values[j], value->get_lane(j)); - else - CHECK_EQ(other_value, value->get_lane(j)); - } - value->set_lane(i, lane_values[i]); // restore the lane - } - CHECK(value->BooleanValue()); // SIMD values are 'true'. -} - - -TEST(SimdObjects) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - Factory* factory = isolate->factory(); - - HandleScope sc(isolate); - - // Float32x4 - { - float lanes[4] = {1, 2, 3, 4}; - float quiet_NaN = std::numeric_limits<float>::quiet_NaN(); - float signaling_NaN = std::numeric_limits<float>::signaling_NaN(); - - Handle<Float32x4> value = factory->NewFloat32x4(lanes); - CHECK(value->IsFloat32x4()); - CheckSimdValue<Float32x4, float, 4>(*value, lanes, 3.14f); - - // Check special lane values. - value->set_lane(1, -0.0); - CHECK_EQ(-0.0f, value->get_lane(1)); - CHECK(std::signbit(value->get_lane(1))); // Sign bit should be preserved. - value->set_lane(2, quiet_NaN); - CHECK(std::isnan(value->get_lane(2))); - value->set_lane(3, signaling_NaN); - CHECK(std::isnan(value->get_lane(3))); - -#ifdef OBJECT_PRINT - // Check value printing. - { - value = factory->NewFloat32x4(lanes); - std::ostringstream os; - value->Float32x4Print(os); - CHECK_EQ("1, 2, 3, 4", os.str()); - } - { - float special_lanes[4] = {0, -0.0, quiet_NaN, signaling_NaN}; - value = factory->NewFloat32x4(special_lanes); - std::ostringstream os; - value->Float32x4Print(os); - // Value printing doesn't preserve signed zeroes. - CHECK_EQ("0, 0, NaN, NaN", os.str()); - } -#endif // OBJECT_PRINT - } - // Int32x4 - { - int32_t lanes[4] = {1, 2, 3, 4}; - - Handle<Int32x4> value = factory->NewInt32x4(lanes); - CHECK(value->IsInt32x4()); - CheckSimdValue<Int32x4, int32_t, 4>(*value, lanes, 3); - -#ifdef OBJECT_PRINT - std::ostringstream os; - value->Int32x4Print(os); - CHECK_EQ("1, 2, 3, 4", os.str()); -#endif // OBJECT_PRINT - } - // Uint32x4 - { - uint32_t lanes[4] = {1, 2, 3, 4}; - - Handle<Uint32x4> value = factory->NewUint32x4(lanes); - CHECK(value->IsUint32x4()); - CheckSimdValue<Uint32x4, uint32_t, 4>(*value, lanes, 3); - -#ifdef OBJECT_PRINT - std::ostringstream os; - value->Uint32x4Print(os); - CHECK_EQ("1, 2, 3, 4", os.str()); -#endif // OBJECT_PRINT - } - // Bool32x4 - { - bool lanes[4] = {true, false, true, false}; - - Handle<Bool32x4> value = factory->NewBool32x4(lanes); - CHECK(value->IsBool32x4()); - CheckSimdValue<Bool32x4, bool, 4>(*value, lanes, false); - -#ifdef OBJECT_PRINT - std::ostringstream os; - value->Bool32x4Print(os); - CHECK_EQ("true, false, true, false", os.str()); -#endif // OBJECT_PRINT - } - // Int16x8 - { - int16_t lanes[8] = {1, 2, 3, 4, 5, 6, 7, 8}; - - Handle<Int16x8> value = factory->NewInt16x8(lanes); - CHECK(value->IsInt16x8()); - CheckSimdValue<Int16x8, int16_t, 8>(*value, lanes, 32767); - -#ifdef OBJECT_PRINT - std::ostringstream os; - value->Int16x8Print(os); - CHECK_EQ("1, 2, 3, 4, 5, 6, 7, 8", os.str()); -#endif // OBJECT_PRINT - } - // Uint16x8 - { - uint16_t lanes[8] = {1, 2, 3, 4, 5, 6, 7, 8}; - - Handle<Uint16x8> value = factory->NewUint16x8(lanes); - CHECK(value->IsUint16x8()); - CheckSimdValue<Uint16x8, uint16_t, 8>(*value, lanes, 32767); - -#ifdef OBJECT_PRINT - std::ostringstream os; - value->Uint16x8Print(os); - CHECK_EQ("1, 2, 3, 4, 5, 6, 7, 8", os.str()); -#endif // OBJECT_PRINT - } - // Bool16x8 - { - bool lanes[8] = {true, false, true, false, true, false, true, false}; - - Handle<Bool16x8> value = factory->NewBool16x8(lanes); - CHECK(value->IsBool16x8()); - CheckSimdValue<Bool16x8, bool, 8>(*value, lanes, false); - -#ifdef OBJECT_PRINT - std::ostringstream os; - value->Bool16x8Print(os); - CHECK_EQ("true, false, true, false, true, false, true, false", os.str()); -#endif // OBJECT_PRINT - } - // Int8x16 - { - int8_t lanes[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; - - Handle<Int8x16> value = factory->NewInt8x16(lanes); - CHECK(value->IsInt8x16()); - CheckSimdValue<Int8x16, int8_t, 16>(*value, lanes, 127); - -#ifdef OBJECT_PRINT - std::ostringstream os; - value->Int8x16Print(os); - CHECK_EQ("1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16", os.str()); -#endif // OBJECT_PRINT - } - // Uint8x16 - { - uint8_t lanes[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; - - Handle<Uint8x16> value = factory->NewUint8x16(lanes); - CHECK(value->IsUint8x16()); - CheckSimdValue<Uint8x16, uint8_t, 16>(*value, lanes, 127); - -#ifdef OBJECT_PRINT - std::ostringstream os; - value->Uint8x16Print(os); - CHECK_EQ("1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16", os.str()); -#endif // OBJECT_PRINT - } - // Bool8x16 - { - bool lanes[16] = {true, false, true, false, true, false, true, false, - true, false, true, false, true, false, true, false}; - - Handle<Bool8x16> value = factory->NewBool8x16(lanes); - CHECK(value->IsBool8x16()); - CheckSimdValue<Bool8x16, bool, 16>(*value, lanes, false); - -#ifdef OBJECT_PRINT - std::ostringstream os; - value->Bool8x16Print(os); - CHECK_EQ( - "true, false, true, false, true, false, true, false, true, false, " - "true, false, true, false, true, false", - os.str()); -#endif // OBJECT_PRINT - } -} - - TEST(Tagging) { CcTest::InitializeVM(); int request = 24; @@ -1646,37 +1507,37 @@ TEST(CompilationCacheCachingBehavior) { } // The script should be in the cache now. - MaybeHandle<SharedFunctionInfo> info = compilation_cache->LookupScript( + InfoVectorPair pair = compilation_cache->LookupScript( source, Handle<Object>(), 0, 0, v8::ScriptOriginOptions(true, false), native_context, language_mode); - CHECK(!info.is_null()); + CHECK(pair.has_shared()); // Check that the code cache entry survives at least on GC. // (Unless --optimize-for-size, in which case it might get collected // immediately.) if (!FLAG_optimize_for_size) { CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); - info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, + pair = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, v8::ScriptOriginOptions(true, false), native_context, language_mode); - CHECK(!info.is_null()); + CHECK(pair.has_shared()); } // Progress code age until it's old and ready for GC. const int kAgingThreshold = 6; for (int i = 0; i < kAgingThreshold; i++) { - info.ToHandleChecked()->code()->MakeOlder(); - if (info.ToHandleChecked()->HasBytecodeArray()) { - info.ToHandleChecked()->bytecode_array()->MakeOlder(); + pair.shared()->code()->MakeOlder(); + if (pair.shared()->HasBytecodeArray()) { + pair.shared()->bytecode_array()->MakeOlder(); } } CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); // Ensure code aging cleared the entry from the cache. - info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, + pair = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, v8::ScriptOriginOptions(true, false), native_context, language_mode); - CHECK(info.is_null()); + CHECK(!pair.has_shared()); } @@ -2015,16 +1876,12 @@ HEAP_TEST(TestSizeOfObjects) { TEST(TestAlignmentCalculations) { // Maximum fill amounts are consistent. int maximum_double_misalignment = kDoubleSize - kPointerSize; - int maximum_simd128_misalignment = kSimd128Size - kPointerSize; int max_word_fill = Heap::GetMaximumFillToAlign(kWordAligned); CHECK_EQ(0, max_word_fill); int max_double_fill = Heap::GetMaximumFillToAlign(kDoubleAligned); CHECK_EQ(maximum_double_misalignment, max_double_fill); int max_double_unaligned_fill = Heap::GetMaximumFillToAlign(kDoubleUnaligned); CHECK_EQ(maximum_double_misalignment, max_double_unaligned_fill); - int max_simd128_unaligned_fill = - Heap::GetMaximumFillToAlign(kSimd128Unaligned); - CHECK_EQ(maximum_simd128_misalignment, max_simd128_unaligned_fill); Address base = static_cast<Address>(NULL); int fill = 0; @@ -2046,16 +1903,6 @@ TEST(TestAlignmentCalculations) { CHECK_EQ(maximum_double_misalignment, fill); fill = Heap::GetFillToAlign(base + kPointerSize, kDoubleUnaligned); CHECK_EQ(0, fill); - - // 128 bit SIMD types have 2 or 4 possible alignments, depending on platform. - fill = Heap::GetFillToAlign(base, kSimd128Unaligned); - CHECK_EQ((3 * kPointerSize) & kSimd128AlignmentMask, fill); - fill = Heap::GetFillToAlign(base + kPointerSize, kSimd128Unaligned); - CHECK_EQ((2 * kPointerSize) & kSimd128AlignmentMask, fill); - fill = Heap::GetFillToAlign(base + 2 * kPointerSize, kSimd128Unaligned); - CHECK_EQ(kPointerSize, fill); - fill = Heap::GetFillToAlign(base + 3 * kPointerSize, kSimd128Unaligned); - CHECK_EQ(0, fill); } @@ -2123,42 +1970,6 @@ TEST(TestAlignedAllocation) { filler->Size() == kPointerSize); CHECK_EQ(kPointerSize + double_misalignment, *top_addr - start); } - - // Now test SIMD alignment. There are 2 or 4 possible alignments, depending - // on platform. - start = AlignNewSpace(kSimd128Unaligned, 0); - obj = NewSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); - CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); - // There is no filler. - CHECK_EQ(kPointerSize, *top_addr - start); - start = AlignNewSpace(kSimd128Unaligned, kPointerSize); - obj = NewSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); - CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); - // There is a filler object before the object. - filler = HeapObject::FromAddress(start); - CHECK(obj != filler && filler->IsFiller() && - filler->Size() == kSimd128Size - kPointerSize); - CHECK_EQ(kPointerSize + kSimd128Size - kPointerSize, *top_addr - start); - - if (double_misalignment) { - // Test the 2 other alignments possible on 32 bit platforms. - start = AlignNewSpace(kSimd128Unaligned, 2 * kPointerSize); - obj = NewSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); - CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); - // There is a filler object before the object. - filler = HeapObject::FromAddress(start); - CHECK(obj != filler && filler->IsFiller() && - filler->Size() == 2 * kPointerSize); - CHECK_EQ(kPointerSize + 2 * kPointerSize, *top_addr - start); - start = AlignNewSpace(kSimd128Unaligned, 3 * kPointerSize); - obj = NewSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); - CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); - // There is a filler object before the object. - filler = HeapObject::FromAddress(start); - CHECK(obj != filler && filler->IsFiller() && - filler->Size() == kPointerSize); - CHECK_EQ(kPointerSize + kPointerSize, *top_addr - start); - } } @@ -2207,83 +2018,41 @@ TEST(TestAlignedOverAllocation) { const intptr_t double_misalignment = kDoubleSize - kPointerSize; Address start; HeapObject* obj; - HeapObject* filler1; - HeapObject* filler2; + HeapObject* filler; if (double_misalignment) { start = AlignOldSpace(kDoubleAligned, 0); obj = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); // The object is aligned, and a filler object is created after. CHECK(IsAddressAligned(obj->address(), kDoubleAlignment)); - filler1 = HeapObject::FromAddress(start + kPointerSize); - CHECK(obj != filler1 && filler1->IsFiller() && - filler1->Size() == kPointerSize); + filler = HeapObject::FromAddress(start + kPointerSize); + CHECK(obj != filler && filler->IsFiller() && + filler->Size() == kPointerSize); // Try the opposite alignment case. start = AlignOldSpace(kDoubleAligned, kPointerSize); obj = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); CHECK(IsAddressAligned(obj->address(), kDoubleAlignment)); - filler1 = HeapObject::FromAddress(start); - CHECK(obj != filler1); - CHECK(filler1->IsFiller()); - CHECK(filler1->Size() == kPointerSize); - CHECK(obj != filler1 && filler1->IsFiller() && - filler1->Size() == kPointerSize); + filler = HeapObject::FromAddress(start); + CHECK(obj != filler); + CHECK(filler->IsFiller()); + CHECK(filler->Size() == kPointerSize); + CHECK(obj != filler && filler->IsFiller() && + filler->Size() == kPointerSize); // Similarly for kDoubleUnaligned. start = AlignOldSpace(kDoubleUnaligned, 0); obj = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); // The object is aligned, and a filler object is created after. CHECK(IsAddressAligned(obj->address(), kDoubleAlignment, kPointerSize)); - filler1 = HeapObject::FromAddress(start + kPointerSize); - CHECK(obj != filler1 && filler1->IsFiller() && - filler1->Size() == kPointerSize); + filler = HeapObject::FromAddress(start + kPointerSize); + CHECK(obj != filler && filler->IsFiller() && + filler->Size() == kPointerSize); // Try the opposite alignment case. start = AlignOldSpace(kDoubleUnaligned, kPointerSize); obj = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); CHECK(IsAddressAligned(obj->address(), kDoubleAlignment, kPointerSize)); - filler1 = HeapObject::FromAddress(start); - CHECK(obj != filler1 && filler1->IsFiller() && - filler1->Size() == kPointerSize); - } - - // Now test SIMD alignment. There are 2 or 4 possible alignments, depending - // on platform. - start = AlignOldSpace(kSimd128Unaligned, 0); - obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); - CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); - // There is a filler object after the object. - filler1 = HeapObject::FromAddress(start + kPointerSize); - CHECK(obj != filler1 && filler1->IsFiller() && - filler1->Size() == kSimd128Size - kPointerSize); - start = AlignOldSpace(kSimd128Unaligned, kPointerSize); - obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); - CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); - // There is a filler object before the object. - filler1 = HeapObject::FromAddress(start); - CHECK(obj != filler1 && filler1->IsFiller() && - filler1->Size() == kSimd128Size - kPointerSize); - - if (double_misalignment) { - // Test the 2 other alignments possible on 32 bit platforms. - start = AlignOldSpace(kSimd128Unaligned, 2 * kPointerSize); - obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); - CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); - // There are filler objects before and after the object. - filler1 = HeapObject::FromAddress(start); - CHECK(obj != filler1 && filler1->IsFiller() && - filler1->Size() == 2 * kPointerSize); - filler2 = HeapObject::FromAddress(start + 3 * kPointerSize); - CHECK(obj != filler2 && filler2->IsFiller() && - filler2->Size() == kPointerSize); - start = AlignOldSpace(kSimd128Unaligned, 3 * kPointerSize); - obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); - CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); - // There are filler objects before and after the object. - filler1 = HeapObject::FromAddress(start); - CHECK(obj != filler1 && filler1->IsFiller() && - filler1->Size() == kPointerSize); - filler2 = HeapObject::FromAddress(start + 2 * kPointerSize); - CHECK(obj != filler2 && filler2->IsFiller() && - filler2->Size() == 2 * kPointerSize); + filler = HeapObject::FromAddress(start); + CHECK(obj != filler && filler->IsFiller() && + filler->Size() == kPointerSize); } } @@ -2338,6 +2107,10 @@ TEST(GrowAndShrinkNewSpace) { return; } + // Make sure we're in a consistent state to start out. + CcTest::CollectGarbage(NEW_SPACE); + CcTest::CollectGarbage(NEW_SPACE); + // Explicitly growing should double the space capacity. size_t old_capacity, new_capacity; old_capacity = new_space->TotalCapacity(); @@ -3739,12 +3512,12 @@ static void CheckVectorIC(Handle<JSFunction> f, int slot_index, InlineCacheState desired_state) { Handle<FeedbackVector> vector = Handle<FeedbackVector>(f->feedback_vector()); FeedbackVectorHelper helper(vector); - FeedbackVectorSlot slot = helper.slot(slot_index); - if (vector->GetKind(slot) == FeedbackVectorSlotKind::LOAD_IC) { + FeedbackSlot slot = helper.slot(slot_index); + if (vector->IsLoadIC(slot)) { LoadICNexus nexus(vector, slot); CHECK(nexus.StateFromFeedback() == desired_state); } else { - CHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, vector->GetKind(slot)); + CHECK(vector->IsKeyedLoadIC(slot)); KeyedLoadICNexus nexus(vector, slot); CHECK(nexus.StateFromFeedback() == desired_state); } @@ -3766,12 +3539,12 @@ TEST(IncrementalMarkingPreservesMonomorphicConstructor) { CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked()))); Handle<FeedbackVector> vector(f->feedback_vector()); - CHECK(vector->Get(FeedbackVectorSlot(0))->IsWeakCell()); + CHECK(vector->Get(FeedbackSlot(0))->IsWeakCell()); heap::SimulateIncrementalMarking(CcTest::heap()); CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); - CHECK(vector->Get(FeedbackVectorSlot(0))->IsWeakCell()); + CHECK(vector->Get(FeedbackSlot(0))->IsWeakCell()); } TEST(IncrementalMarkingPreservesMonomorphicIC) { @@ -4296,10 +4069,6 @@ TEST(Regress513507) { if (!code->is_optimized_code()) return; } - Handle<FeedbackVector> vector = - FeedbackVector::New(isolate, handle(shared->feedback_metadata())); - Handle<LiteralsArray> lit = - LiteralsArray::New(isolate, vector, shared->num_literals()); Handle<Context> context(isolate->context()); // Add the new code several times to the optimized code map and also set an @@ -4308,211 +4077,11 @@ TEST(Regress513507) { FLAG_gc_interval = 1000; for (int i = 0; i < 10; ++i) { BailoutId id = BailoutId(i); - SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); + SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, id); } } #endif // DEBUG -TEST(Regress514122) { - if (!i::FLAG_incremental_marking) return; - i::FLAG_allow_natives_syntax = true; - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - LocalContext env; - Heap* heap = isolate->heap(); - HandleScope scope(isolate); - - // Perfrom one initial GC to enable code flushing. - CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); - - // Prepare function whose optimized code map we can use. - Handle<SharedFunctionInfo> shared; - { - HandleScope inner_scope(isolate); - CompileRun( - "function f() { return 1 }" - "f(); %OptimizeFunctionOnNextCall(f); f();"); - - Handle<JSFunction> f = Handle<JSFunction>::cast( - v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( - CcTest::global()->Get(env.local(), v8_str("f")).ToLocalChecked()))); - shared = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); - CompileRun("f = null"); - } - - // Prepare optimized code that we can use. - Handle<Code> code; - { - HandleScope inner_scope(isolate); - CompileRun( - "function g() { return 2 }" - "g(); %OptimizeFunctionOnNextCall(g); g();"); - - Handle<JSFunction> g = Handle<JSFunction>::cast( - v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( - CcTest::global()->Get(env.local(), v8_str("g")).ToLocalChecked()))); - code = inner_scope.CloseAndEscape(handle(g->code(), isolate)); - if (!code->is_optimized_code()) return; - } - - Handle<FeedbackVector> vector = - FeedbackVector::New(isolate, handle(shared->feedback_metadata())); - Handle<LiteralsArray> lit = - LiteralsArray::New(isolate, vector, shared->num_literals(), TENURED); - Handle<Context> context(isolate->context()); - - // Add the code several times to the optimized code map. - for (int i = 0; i < 3; ++i) { - HandleScope inner_scope(isolate); - BailoutId id = BailoutId(i); - SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); - } - shared->optimized_code_map()->Print(); - - // Add the code with a literals array to be evacuated. - Page* evac_page; - { - HandleScope inner_scope(isolate); - AlwaysAllocateScope always_allocate(isolate); - // Make sure literal is placed on an old-space evacuation candidate. - heap::SimulateFullSpace(heap->old_space()); - - // Make sure there the number of literals is > 0. - Handle<LiteralsArray> lit = LiteralsArray::New(isolate, vector, 23); - - evac_page = Page::FromAddress(lit->address()); - BailoutId id = BailoutId(100); - SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); - } - - // Heap is ready, force {lit_page} to become an evacuation candidate and - // simulate incremental marking to enqueue optimized code map. - FLAG_manual_evacuation_candidates_selection = true; - heap::ForceEvacuationCandidate(evac_page); - heap::SimulateIncrementalMarking(heap); - - // No matter whether reachable or not, {boomer} is doomed. - Handle<Object> boomer(shared->optimized_code_map(), isolate); - - // Add the code several times to the optimized code map. This will leave old - // copies of the optimized code map unreachable but still marked. - for (int i = 3; i < 6; ++i) { - HandleScope inner_scope(isolate); - BailoutId id = BailoutId(i); - SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); - } - - // Trigger a GC to flush out the bug. - CcTest::CollectGarbage(i::OLD_SPACE); - boomer->Print(); -} - -TEST(OptimizedCodeMapReuseEntries) { - i::FLAG_allow_natives_syntax = true; - // BUG(v8:4598): Since TurboFan doesn't treat maps in code weakly, we can't - // run this test. - if (i::FLAG_turbo) return; - CcTest::InitializeVM(); - v8::Isolate* v8_isolate = CcTest::isolate(); - Isolate* isolate = CcTest::i_isolate(); - HandleScope scope(isolate); - - // Create 3 contexts, allow the 2nd one to be disposed, and verify that - // a 4th context will re-use the weak slots in the optimized code map - // to hold data, rather than expanding the map. - v8::Local<v8::Context> c1 = v8::Context::New(v8_isolate); - const char* source = "function foo(x) { var l = [1]; return x+l[0]; }"; - v8::ScriptCompiler::Source script_source( - v8::String::NewFromUtf8(v8_isolate, source, v8::NewStringType::kNormal) - .ToLocalChecked()); - v8::Local<v8::UnboundScript> indep = - v8::ScriptCompiler::CompileUnboundScript(v8_isolate, &script_source) - .ToLocalChecked(); - const char* toplevel = "foo(3); %OptimizeFunctionOnNextCall(foo); foo(3);"; - // Perfrom one initial GC to enable code flushing. - CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); - - c1->Enter(); - indep->BindToCurrentContext()->Run(c1).ToLocalChecked(); - CompileRun(toplevel); - - Handle<SharedFunctionInfo> shared; - Handle<JSFunction> foo = Handle<JSFunction>::cast( - v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( - CcTest::global()->Get(c1, v8_str("foo")).ToLocalChecked()))); - CHECK(foo->shared()->is_compiled()); - shared = handle(foo->shared()); - c1->Exit(); - - { - HandleScope scope(isolate); - v8::Local<v8::Context> c2 = v8::Context::New(v8_isolate); - c2->Enter(); - indep->BindToCurrentContext()->Run(c2).ToLocalChecked(); - CompileRun(toplevel); - c2->Exit(); - } - - { - HandleScope scope(isolate); - v8::Local<v8::Context> c3 = v8::Context::New(v8_isolate); - c3->Enter(); - indep->BindToCurrentContext()->Run(c3).ToLocalChecked(); - CompileRun(toplevel); - c3->Exit(); - - // Now, collect garbage. Context c2 should have no roots to it, and it's - // entry in the optimized code map should be free for a new context. - for (int i = 0; i < 4; i++) { - CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); - } - - Handle<FixedArray> optimized_code_map = - handle(shared->optimized_code_map()); - // There should be 3 entries in the map. - CHECK_EQ( - 3, ((optimized_code_map->length() - SharedFunctionInfo::kEntriesStart) / - SharedFunctionInfo::kEntryLength)); - // But one of them (formerly for c2) should be cleared. - int cleared_count = 0; - for (int i = SharedFunctionInfo::kEntriesStart; - i < optimized_code_map->length(); - i += SharedFunctionInfo::kEntryLength) { - cleared_count += - WeakCell::cast( - optimized_code_map->get(i + SharedFunctionInfo::kContextOffset)) - ->cleared() - ? 1 - : 0; - } - CHECK_EQ(1, cleared_count); - - // Verify that a new context uses the cleared entry rather than creating a - // new - // optimized code map array. - v8::Local<v8::Context> c4 = v8::Context::New(v8_isolate); - c4->Enter(); - indep->BindToCurrentContext()->Run(c4).ToLocalChecked(); - CompileRun(toplevel); - c4->Exit(); - CHECK_EQ(*optimized_code_map, shared->optimized_code_map()); - - // Now each entry is in use. - cleared_count = 0; - for (int i = SharedFunctionInfo::kEntriesStart; - i < optimized_code_map->length(); - i += SharedFunctionInfo::kEntryLength) { - cleared_count += - WeakCell::cast( - optimized_code_map->get(i + SharedFunctionInfo::kContextOffset)) - ->cleared() - ? 1 - : 0; - } - CHECK_EQ(0, cleared_count); - } -} - TEST(Regress513496) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); @@ -4558,9 +4127,9 @@ TEST(Regress513496) { } // Lookup the optimized code and keep it alive. - CodeAndLiterals result = shared->SearchOptimizedCodeMap( + Code* result = shared->SearchOptimizedCodeMap( isolate->context()->native_context(), BailoutId::None()); - Handle<Code> optimized_code(result.code, isolate); + Handle<Code> optimized_code(result, isolate); // Finish a full GC cycle so that the unoptimized code of 'g' is flushed even // though the optimized code for 'f' is reachable via the optimized code map. @@ -4780,7 +4349,6 @@ TEST(EnsureAllocationSiteDependentCodesProcessed) { TEST(CellsInOptimizedCodeAreWeak) { if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; - i::FLAG_weak_embedded_objects_in_optimized_code = true; i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); @@ -4825,7 +4393,6 @@ TEST(CellsInOptimizedCodeAreWeak) { TEST(ObjectsInOptimizedCodeAreWeak) { if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; - i::FLAG_weak_embedded_objects_in_optimized_code = true; i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); @@ -4867,7 +4434,6 @@ TEST(ObjectsInOptimizedCodeAreWeak) { TEST(NewSpaceObjectsInOptimizedCode) { if (i::FLAG_always_opt || !i::FLAG_crankshaft || i::FLAG_turbo) return; - i::FLAG_weak_embedded_objects_in_optimized_code = true; i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); @@ -4930,7 +4496,6 @@ TEST(NewSpaceObjectsInOptimizedCode) { TEST(NoWeakHashTableLeakWithIncrementalMarking) { if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; if (!i::FLAG_incremental_marking) return; - i::FLAG_weak_embedded_objects_in_optimized_code = true; i::FLAG_allow_natives_syntax = true; i::FLAG_compilation_cache = false; i::FLAG_retain_maps_for_n_gc = 0; @@ -5134,18 +4699,18 @@ TEST(WeakFunctionInConstructor) { Handle<FeedbackVector> feedback_vector = Handle<FeedbackVector>(createObj->feedback_vector(), CcTest::i_isolate()); for (int i = 0; i < 20; i++) { - Object* slot_value = feedback_vector->Get(FeedbackVectorSlot(0)); + Object* slot_value = feedback_vector->Get(FeedbackSlot(0)); CHECK(slot_value->IsWeakCell()); if (WeakCell::cast(slot_value)->cleared()) break; CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); } - Object* slot_value = feedback_vector->Get(FeedbackVectorSlot(0)); + Object* slot_value = feedback_vector->Get(FeedbackSlot(0)); CHECK(slot_value->IsWeakCell() && WeakCell::cast(slot_value)->cleared()); CompileRun( "function coat() { this.x = 6; }" "createObj(coat);"); - slot_value = feedback_vector->Get(FeedbackVectorSlot(0)); + slot_value = feedback_vector->Get(FeedbackSlot(0)); CHECK(slot_value->IsWeakCell() && !WeakCell::cast(slot_value)->cleared()); } @@ -5334,19 +4899,15 @@ Handle<JSFunction> GetFunctionByName(Isolate* isolate, const char* name) { void CheckIC(Handle<JSFunction> function, Code::Kind kind, int slot_index, InlineCacheState state) { - if (kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC || - kind == Code::CALL_IC) { + if (kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC) { FeedbackVector* vector = function->feedback_vector(); - FeedbackVectorSlot slot(slot_index); + FeedbackSlot slot(slot_index); if (kind == Code::LOAD_IC) { LoadICNexus nexus(vector, slot); CHECK_EQ(nexus.StateFromFeedback(), state); } else if (kind == Code::KEYED_LOAD_IC) { KeyedLoadICNexus nexus(vector, slot); CHECK_EQ(nexus.StateFromFeedback(), state); - } else if (kind == Code::CALL_IC) { - CallICNexus nexus(vector, slot); - CHECK_EQ(nexus.StateFromFeedback(), state); } } else { Code* ic = FindFirstIC(function->code(), kind); @@ -5742,7 +5303,7 @@ TEST(Regress388880) { Handle<String> name = factory->NewStringFromStaticChars("foo"); name = factory->InternalizeString(name); Handle<Map> map2 = - Map::CopyWithField(map1, name, FieldType::Any(isolate), NONE, + Map::CopyWithField(map1, name, FieldType::Any(isolate), NONE, kMutable, Representation::Tagged(), OMIT_TRANSITION) .ToHandleChecked(); @@ -5943,18 +5504,6 @@ TEST(RegressArrayListGC) { } -#ifdef DEBUG -TEST(PathTracer) { - CcTest::InitializeVM(); - v8::HandleScope scope(CcTest::isolate()); - - v8::Local<v8::Value> result = CompileRun("'abc'"); - Handle<Object> o = v8::Utils::OpenHandle(*result); - CcTest::i_isolate()->heap()->TracePathToObject(*o); -} -#endif // DEBUG - - TEST(WritableVsImmortalRoots) { for (int i = 0; i < Heap::kStrongRootListLength; ++i) { Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); @@ -6158,6 +5707,7 @@ TEST(NewSpaceAllocationCounter) { Heap* heap = isolate->heap(); size_t counter1 = heap->NewSpaceAllocationCounter(); CcTest::CollectGarbage(NEW_SPACE); + CcTest::CollectGarbage(NEW_SPACE); // Ensure new space is empty. const size_t kSize = 1024; AllocateInSpace(isolate, kSize, NEW_SPACE); size_t counter2 = heap->NewSpaceAllocationCounter(); diff --git a/deps/v8/test/cctest/heap/test-incremental-marking.cc b/deps/v8/test/cctest/heap/test-incremental-marking.cc index 642a3584e7..ce1fb34951 100644 --- a/deps/v8/test/cctest/heap/test-incremental-marking.cc +++ b/deps/v8/test/cctest/heap/test-incremental-marking.cc @@ -18,6 +18,9 @@ #include "src/full-codegen/full-codegen.h" #include "src/global-handles.h" +#include "src/heap/incremental-marking.h" +#include "src/heap/spaces.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-utils.h" diff --git a/deps/v8/test/cctest/heap/test-mark-compact.cc b/deps/v8/test/cctest/heap/test-mark-compact.cc index ee37d070ac..9f749c5f42 100644 --- a/deps/v8/test/cctest/heap/test-mark-compact.cc +++ b/deps/v8/test/cctest/heap/test-mark-compact.cc @@ -43,6 +43,7 @@ #include "src/global-handles.h" #include "src/heap/mark-compact-inl.h" #include "src/heap/mark-compact.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-tester.h" #include "test/cctest/heap/heap-utils.h" diff --git a/deps/v8/test/cctest/heap/test-page-promotion.cc b/deps/v8/test/cctest/heap/test-page-promotion.cc index 3d9999513a..6d6e70046c 100644 --- a/deps/v8/test/cctest/heap/test-page-promotion.cc +++ b/deps/v8/test/cctest/heap/test-page-promotion.cc @@ -115,7 +115,7 @@ UNINITIALIZED_TEST(PagePromotion_NewToNewJSArrayBuffer) { // Allocate a buffer we would like to check against. Handle<JSArrayBuffer> buffer = i_isolate->factory()->NewJSArrayBuffer(SharedFlag::kNotShared); - JSArrayBuffer::SetupAllocatingData(buffer, i_isolate, 100); + CHECK(JSArrayBuffer::SetupAllocatingData(buffer, i_isolate, 100)); std::vector<Handle<FixedArray>> handles; // Simulate a full space, filling the interesting page with live objects. heap::SimulateFullSpace(heap->new_space(), &handles); diff --git a/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc b/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc index 8f34308ee0..2a1731f75a 100644 --- a/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc +++ b/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc @@ -11,7 +11,9 @@ #include "include/libplatform/libplatform.h" #include "include/v8.h" +#include "src/api.h" #include "src/base/logging.h" +#include "src/objects-inl.h" #include "src/runtime/runtime.h" #include "src/interpreter/bytecode-array-iterator.h" @@ -70,7 +72,11 @@ v8::Local<v8::Script> BytecodeExpectationsPrinter::CompileScript( v8::Local<v8::Module> BytecodeExpectationsPrinter::CompileModule( const char* program) const { - v8::ScriptCompiler::Source source(V8StringFromUTF8(program)); + ScriptOrigin origin( + Local<v8::Value>(), Local<v8::Integer>(), Local<v8::Integer>(), + Local<v8::Boolean>(), Local<v8::Integer>(), Local<v8::Value>(), + Local<v8::Boolean>(), Local<v8::Boolean>(), True(isolate_)); + v8::ScriptCompiler::Source source(V8StringFromUTF8(program), origin); return v8::ScriptCompiler::CompileModule(isolate_, &source).ToLocalChecked(); } @@ -171,13 +177,13 @@ void BytecodeExpectationsPrinter::PrintBytecodeOperand( stream << '(' << register_value.index() << ')'; } } else { - stream << 'U' << size_tag << '('; - switch (op_type) { case OperandType::kFlag8: + stream << 'U' << size_tag << '('; stream << bytecode_iterator.GetFlagOperand(op_index); break; case OperandType::kIdx: { + stream << 'U' << size_tag << '('; uint32_t idx = bytecode_iterator.GetIndexOperand(op_index); if (bytecode == Bytecode::kCallJSRuntime && op_index == 0) { stream << "%" << NameForNativeContextIntrinsicIndex(idx); @@ -187,21 +193,26 @@ void BytecodeExpectationsPrinter::PrintBytecodeOperand( break; } case OperandType::kUImm: + stream << 'U' << size_tag << '('; stream << bytecode_iterator.GetUnsignedImmediateOperand(op_index); break; case OperandType::kImm: + stream << 'I' << size_tag << '('; stream << bytecode_iterator.GetImmediateOperand(op_index); break; case OperandType::kRegCount: + stream << 'U' << size_tag << '('; stream << bytecode_iterator.GetRegisterCountOperand(op_index); break; case OperandType::kRuntimeId: { + stream << 'U' << size_tag << '('; Runtime::FunctionId id = bytecode_iterator.GetRuntimeIdOperand(op_index); stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; break; } case OperandType::kIntrinsicId: { + stream << 'U' << size_tag << '('; Runtime::FunctionId id = bytecode_iterator.GetIntrinsicIdOperand(op_index); stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden index 2d57edf4a0..da9ea93bd9 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden @@ -14,7 +14,7 @@ parameter count: 1 bytecode array length: 6 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(9), + /* 34 S> */ B(CreateArrayLiteral), U8(0), U8(2), U8(9), /* 51 S> */ B(Return), ] constant pool: [ @@ -32,18 +32,18 @@ parameter count: 1 bytecode array length: 35 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(9), + /* 45 S> */ B(CreateArrayLiteral), U8(0), U8(3), U8(9), B(Star), R(2), B(LdaZero), B(Star), R(1), B(Ldar), R(0), - /* 54 E> */ B(StaKeyedPropertySloppy), R(2), R(1), U8(3), - B(LdaSmi), U8(1), + /* 54 E> */ B(StaKeyedPropertySloppy), R(2), R(1), U8(4), + B(LdaSmi), I8(1), B(Star), R(1), - /* 59 E> */ B(AddSmi), U8(1), R(0), U8(2), - B(StaKeyedPropertySloppy), R(2), R(1), U8(3), + /* 59 E> */ B(AddSmi), I8(1), R(0), U8(2), + B(StaKeyedPropertySloppy), R(2), R(1), U8(4), B(Ldar), R(2), /* 66 S> */ B(Return), ] @@ -62,7 +62,7 @@ parameter count: 1 bytecode array length: 6 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateArrayLiteral), U8(0), U8(2), U8(0), + /* 34 S> */ B(CreateArrayLiteral), U8(0), U8(4), U8(0), /* 62 S> */ B(Return), ] constant pool: [ @@ -80,30 +80,30 @@ parameter count: 1 bytecode array length: 65 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(CreateArrayLiteral), U8(0), U8(2), U8(0), + /* 45 S> */ B(CreateArrayLiteral), U8(0), U8(9), U8(0), B(Star), R(2), B(LdaZero), B(Star), R(1), - B(CreateArrayLiteral), U8(1), U8(0), U8(9), + B(CreateArrayLiteral), U8(1), U8(2), U8(9), B(Star), R(4), B(LdaZero), B(Star), R(3), B(Ldar), R(0), - /* 56 E> */ B(StaKeyedPropertySloppy), R(4), R(3), U8(2), + /* 56 E> */ B(StaKeyedPropertySloppy), R(4), R(3), U8(3), B(Ldar), R(4), - B(StaKeyedPropertySloppy), R(2), R(1), U8(7), - B(LdaSmi), U8(1), + B(StaKeyedPropertySloppy), R(2), R(1), U8(10), + B(LdaSmi), I8(1), B(Star), R(1), - B(CreateArrayLiteral), U8(2), U8(1), U8(9), + B(CreateArrayLiteral), U8(2), U8(6), U8(9), B(Star), R(4), B(LdaZero), B(Star), R(3), - /* 68 E> */ B(AddSmi), U8(2), R(0), U8(4), - B(StaKeyedPropertySloppy), R(4), R(3), U8(5), + /* 68 E> */ B(AddSmi), I8(2), R(0), U8(5), + B(StaKeyedPropertySloppy), R(4), R(3), U8(7), B(Ldar), R(4), - B(StaKeyedPropertySloppy), R(2), R(1), U8(7), + B(StaKeyedPropertySloppy), R(2), R(1), U8(10), B(Ldar), R(2), /* 77 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiteralsWide.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiteralsWide.golden index 1dcfc48cbc..6755fb80a0 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiteralsWide.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiteralsWide.golden @@ -783,7 +783,7 @@ bytecodes: [ B(Star), R(0), /* 2591 S> */ B(LdaConstant), U8(255), B(Star), R(0), - /* 2601 S> */ B(Wide), B(CreateArrayLiteral), U16(256), U16(0), U8(9), + /* 2601 S> */ B(Wide), B(CreateArrayLiteral), U16(256), U16(2), U8(9), /* 2619 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden index 4ea65897ff..afc009f7d8 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden @@ -17,15 +17,15 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 49 S> */ B(LdaSmi), U8(1), + /* 49 S> */ B(LdaSmi), I8(1), B(Star), R(1), - /* 52 S> */ B(LdaSmi), U8(2), + /* 52 S> */ B(LdaSmi), I8(2), B(Star), R(0), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(Star), R(1), - B(LdaSmi), U8(4), + B(LdaSmi), I8(4), B(Star), R(0), - B(LdaSmi), U8(5), + B(LdaSmi), I8(5), B(Star), R(1), /* 89 S> */ B(Return), ] @@ -45,9 +45,9 @@ parameter count: 1 bytecode array length: 13 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(55), + /* 42 S> */ B(LdaSmi), I8(55), B(Star), R(0), - /* 57 S> */ B(LdaSmi), U8(100), + /* 57 S> */ B(LdaSmi), I8(100), B(Star), R(0), B(Star), R(1), /* 65 S> */ B(Nop), @@ -69,14 +69,14 @@ parameter count: 1 bytecode array length: 28 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(55), + /* 42 S> */ B(LdaSmi), I8(55), B(Star), R(0), - /* 46 S> */ B(LdaSmi), U8(100), + /* 46 S> */ B(LdaSmi), I8(100), B(Mov), R(0), R(1), B(Star), R(0), /* 52 E> */ B(Add), R(1), U8(2), B(Star), R(1), - B(LdaSmi), U8(101), + B(LdaSmi), I8(101), B(Star), R(0), /* 64 E> */ B(Add), R(1), U8(3), B(Star), R(0), @@ -100,13 +100,13 @@ parameter count: 1 bytecode array length: 29 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(55), + /* 42 S> */ B(LdaSmi), I8(55), B(Star), R(0), - /* 46 S> */ B(LdaSmi), U8(56), + /* 46 S> */ B(LdaSmi), I8(56), B(Star), R(0), /* 59 E> */ B(Sub), R(0), U8(2), B(Star), R(1), - B(LdaSmi), U8(57), + B(LdaSmi), I8(57), B(Star), R(0), /* 63 E> */ B(Add), R(1), U8(3), B(Star), R(0), @@ -131,18 +131,18 @@ parameter count: 1 bytecode array length: 37 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(55), + /* 42 S> */ B(LdaSmi), I8(55), B(Star), R(0), - /* 76 S> */ B(LdaSmi), U8(1), + /* 76 S> */ B(LdaSmi), I8(1), B(Mov), R(0), R(2), B(Star), R(0), /* 56 E> */ B(Add), R(2), U8(2), B(Star), R(2), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(0), /* 66 E> */ B(Add), R(2), U8(3), B(Star), R(2), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(Star), R(0), /* 76 E> */ B(Add), R(2), U8(4), B(Star), R(1), @@ -165,18 +165,18 @@ parameter count: 1 bytecode array length: 37 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(55), + /* 42 S> */ B(LdaSmi), I8(55), B(Star), R(0), - /* 76 S> */ B(LdaSmi), U8(1), + /* 76 S> */ B(LdaSmi), I8(1), B(Mov), R(0), R(1), B(Star), R(0), /* 56 E> */ B(Add), R(1), U8(2), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(0), /* 66 E> */ B(Add), R(1), U8(3), B(Star), R(1), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(Star), R(0), /* 76 E> */ B(Add), R(1), U8(4), B(Star), R(0), @@ -198,31 +198,31 @@ parameter count: 1 bytecode array length: 72 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), B(Star), R(0), - /* 50 S> */ B(LdaSmi), U8(20), + /* 50 S> */ B(LdaSmi), I8(20), B(Star), R(1), - /* 54 S> */ B(LdaSmi), U8(1), + /* 54 S> */ B(LdaSmi), I8(1), B(Mov), R(0), R(2), B(Star), R(0), /* 63 E> */ B(Add), R(2), U8(2), B(Star), R(2), - /* 78 E> */ B(AddSmi), U8(1), R(0), U8(3), + /* 78 E> */ B(AddSmi), I8(1), R(0), U8(3), B(Star), R(3), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(1), /* 83 E> */ B(Mul), R(3), U8(4), /* 73 E> */ B(Add), R(2), U8(5), B(Star), R(2), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(Star), R(1), /* 93 E> */ B(Add), R(2), U8(6), B(Star), R(2), - B(LdaSmi), U8(4), + B(LdaSmi), I8(4), B(Star), R(0), /* 103 E> */ B(Add), R(2), U8(7), B(Star), R(2), - B(LdaSmi), U8(5), + B(LdaSmi), I8(5), B(Star), R(1), /* 113 E> */ B(Add), R(2), U8(8), B(Star), R(2), @@ -245,9 +245,9 @@ parameter count: 1 bytecode array length: 43 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(17), + /* 42 S> */ B(LdaSmi), I8(17), B(Star), R(0), - /* 46 S> */ B(LdaSmi), U8(1), + /* 46 S> */ B(LdaSmi), I8(1), B(Star), R(1), B(Ldar), R(0), /* 55 E> */ B(Add), R(1), U8(2), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/BasicBlockToBoolean.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/BasicBlockToBoolean.golden index 547e83590e..acb9c36ce3 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/BasicBlockToBoolean.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/BasicBlockToBoolean.golden @@ -14,13 +14,13 @@ parameter count: 1 bytecode array length: 18 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(JumpIfToBooleanTrue), U8(8), B(LdaZero), /* 56 E> */ B(TestLessThan), R(0), U8(2), B(JumpIfFalse), U8(5), - /* 63 S> */ B(LdaSmi), U8(1), + /* 63 S> */ B(LdaSmi), I8(1), /* 75 S> */ B(Return), B(LdaUndefined), /* 75 S> */ B(Return), @@ -39,13 +39,13 @@ parameter count: 1 bytecode array length: 18 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(JumpIfToBooleanFalse), U8(11), B(LdaZero), /* 56 E> */ B(TestLessThan), R(0), U8(2), B(JumpIfFalse), U8(5), - /* 63 S> */ B(LdaSmi), U8(1), + /* 63 S> */ B(LdaSmi), I8(1), /* 75 S> */ B(Return), B(LdaUndefined), /* 75 S> */ B(Return), @@ -64,15 +64,15 @@ parameter count: 1 bytecode array length: 23 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(JumpIfToBooleanTrue), U8(8), B(LdaZero), /* 57 E> */ B(TestLessThan), R(0), U8(2), B(JumpIfFalse), U8(6), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Jump), U8(4), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(Star), R(0), B(LdaUndefined), /* 71 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/BasicLoops.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/BasicLoops.golden index d0c7f4934c..3bb478f3c4 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/BasicLoops.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/BasicLoops.golden @@ -68,27 +68,27 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 53 S> */ B(LdaSmi), U8(1), + /* 53 S> */ B(LdaSmi), I8(1), B(Star), R(1), - /* 65 S> */ B(LdaSmi), U8(10), + /* 65 S> */ B(LdaSmi), I8(10), /* 65 E> */ B(TestLessThan), R(0), U8(2), B(JumpIfFalse), U8(38), /* 56 E> */ B(StackCheck), - /* 75 S> */ B(LdaSmi), U8(12), + /* 75 S> */ B(LdaSmi), I8(12), /* 81 E> */ B(Mul), R(1), U8(3), B(Star), R(1), - /* 89 S> */ B(LdaSmi), U8(1), + /* 89 S> */ B(LdaSmi), I8(1), /* 95 E> */ B(Add), R(0), U8(4), B(Star), R(0), - /* 102 S> */ B(LdaSmi), U8(3), + /* 102 S> */ B(LdaSmi), I8(3), /* 108 E> */ B(TestEqual), R(0), U8(5), B(JumpIfFalse), U8(4), /* 114 S> */ B(Jump), U8(11), - /* 126 S> */ B(LdaSmi), U8(4), + /* 126 S> */ B(LdaSmi), I8(4), /* 132 E> */ B(TestEqual), R(0), U8(6), B(JumpIfFalse), U8(4), /* 138 S> */ B(Jump), U8(5), - B(JumpLoop), U8(-40), U8(0), + B(JumpLoop), U8(40), I8(0), /* 147 S> */ B(Ldar), R(1), /* 157 S> */ B(Return), ] @@ -122,26 +122,26 @@ bytecodes: [ /* 68 E> */ B(TestLessThan), R(0), U8(2), B(JumpIfFalse), U8(4), /* 73 S> */ B(Jump), U8(45), - /* 85 S> */ B(LdaSmi), U8(3), + /* 85 S> */ B(LdaSmi), I8(3), /* 91 E> */ B(TestEqual), R(0), U8(3), B(JumpIfFalse), U8(4), /* 97 S> */ B(Jump), U8(39), - /* 106 S> */ B(LdaSmi), U8(4), + /* 106 S> */ B(LdaSmi), I8(4), /* 112 E> */ B(TestEqual), R(0), U8(4), B(JumpIfFalse), U8(4), /* 118 S> */ B(Jump), U8(30), - /* 127 S> */ B(LdaSmi), U8(10), + /* 127 S> */ B(LdaSmi), I8(10), /* 133 E> */ B(TestEqual), R(0), U8(5), B(JumpIfFalse), U8(4), /* 140 S> */ B(Jump), U8(18), - /* 152 S> */ B(LdaSmi), U8(5), + /* 152 S> */ B(LdaSmi), I8(5), /* 158 E> */ B(TestEqual), R(0), U8(6), B(JumpIfFalse), U8(4), /* 164 S> */ B(Jump), U8(12), - /* 173 S> */ B(LdaSmi), U8(1), + /* 173 S> */ B(LdaSmi), I8(1), /* 179 E> */ B(Add), R(0), U8(7), B(Star), R(0), - B(JumpLoop), U8(-52), U8(0), + B(JumpLoop), U8(52), I8(0), /* 186 S> */ B(Ldar), R(0), /* 196 S> */ B(Return), ] @@ -171,19 +171,19 @@ bytecodes: [ /* 42 S> */ B(LdaZero), B(Star), R(0), /* 45 E> */ B(StackCheck), - /* 71 S> */ B(LdaSmi), U8(3), + /* 71 S> */ B(LdaSmi), I8(3), /* 71 E> */ B(TestLessThan), R(0), U8(2), B(JumpIfFalse), U8(22), /* 62 E> */ B(StackCheck), - /* 82 S> */ B(LdaSmi), U8(2), + /* 82 S> */ B(LdaSmi), I8(2), /* 88 E> */ B(TestEqual), R(0), U8(3), B(JumpIfFalse), U8(4), /* 94 S> */ B(Jump), U8(12), - /* 105 S> */ B(LdaSmi), U8(1), + /* 105 S> */ B(LdaSmi), I8(1), /* 111 E> */ B(Add), R(0), U8(4), B(Star), R(0), - B(JumpLoop), U8(-24), U8(1), - /* 122 S> */ B(LdaSmi), U8(1), + B(JumpLoop), U8(24), I8(1), + /* 122 S> */ B(LdaSmi), I8(1), /* 128 E> */ B(Add), R(0), U8(5), B(Star), R(0), /* 135 S> */ B(Jump), U8(2), @@ -210,20 +210,20 @@ parameter count: 1 bytecode array length: 34 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), B(Star), R(0), - /* 54 S> */ B(LdaSmi), U8(1), + /* 54 S> */ B(LdaSmi), I8(1), B(Star), R(1), /* 64 S> */ B(Ldar), R(0), B(JumpIfToBooleanFalse), U8(20), /* 57 E> */ B(StackCheck), - /* 71 S> */ B(LdaSmi), U8(12), + /* 71 S> */ B(LdaSmi), I8(12), /* 77 E> */ B(Mul), R(1), U8(2), B(Star), R(1), - /* 85 S> */ B(LdaSmi), U8(1), + /* 85 S> */ B(LdaSmi), I8(1), /* 91 E> */ B(Sub), R(0), U8(3), B(Star), R(0), - B(JumpLoop), U8(-19), U8(0), + B(JumpLoop), U8(19), I8(0), /* 98 S> */ B(Ldar), R(1), /* 108 S> */ B(Return), ] @@ -250,27 +250,27 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 53 S> */ B(LdaSmi), U8(1), + /* 53 S> */ B(LdaSmi), I8(1), B(Star), R(1), /* 56 E> */ B(StackCheck), - /* 63 S> */ B(LdaSmi), U8(10), + /* 63 S> */ B(LdaSmi), I8(10), /* 69 E> */ B(Mul), R(1), U8(2), B(Star), R(1), - /* 77 S> */ B(LdaSmi), U8(5), + /* 77 S> */ B(LdaSmi), I8(5), /* 83 E> */ B(TestEqual), R(0), U8(3), B(JumpIfFalse), U8(4), /* 89 S> */ B(Jump), U8(28), - /* 98 S> */ B(LdaSmi), U8(6), + /* 98 S> */ B(LdaSmi), I8(6), /* 104 E> */ B(TestEqual), R(0), U8(4), B(JumpIfFalse), U8(4), /* 110 S> */ B(Jump), U8(9), - /* 122 S> */ B(LdaSmi), U8(1), + /* 122 S> */ B(LdaSmi), I8(1), /* 128 E> */ B(Add), R(0), U8(5), B(Star), R(0), - /* 144 S> */ B(LdaSmi), U8(10), + /* 144 S> */ B(LdaSmi), I8(10), /* 144 E> */ B(TestLessThan), R(0), U8(6), B(JumpIfFalse), U8(5), - B(JumpLoop), U8(-40), U8(0), + B(JumpLoop), U8(40), I8(0), /* 151 S> */ B(Ldar), R(1), /* 161 S> */ B(Return), ] @@ -294,19 +294,19 @@ parameter count: 1 bytecode array length: 32 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), B(Star), R(0), - /* 54 S> */ B(LdaSmi), U8(1), + /* 54 S> */ B(LdaSmi), I8(1), B(Star), R(1), /* 57 E> */ B(StackCheck), - /* 64 S> */ B(LdaSmi), U8(12), + /* 64 S> */ B(LdaSmi), I8(12), /* 70 E> */ B(Mul), R(1), U8(2), B(Star), R(1), - /* 78 S> */ B(LdaSmi), U8(1), + /* 78 S> */ B(LdaSmi), I8(1), /* 84 E> */ B(Sub), R(0), U8(3), B(Star), R(0), /* 98 S> */ B(JumpIfToBooleanFalse), U8(5), - B(JumpLoop), U8(-17), U8(0), + B(JumpLoop), U8(17), I8(0), /* 102 S> */ B(Ldar), R(1), /* 112 S> */ B(Return), ] @@ -333,20 +333,20 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 53 S> */ B(LdaSmi), U8(1), + /* 53 S> */ B(LdaSmi), I8(1), B(Star), R(1), /* 56 E> */ B(StackCheck), - /* 63 S> */ B(LdaSmi), U8(10), + /* 63 S> */ B(LdaSmi), I8(10), /* 69 E> */ B(Mul), R(1), U8(2), B(Star), R(1), - /* 77 S> */ B(LdaSmi), U8(5), + /* 77 S> */ B(LdaSmi), I8(5), /* 83 E> */ B(TestEqual), R(0), U8(3), B(JumpIfFalse), U8(4), /* 89 S> */ B(Jump), U8(18), - /* 98 S> */ B(LdaSmi), U8(1), + /* 98 S> */ B(LdaSmi), I8(1), /* 104 E> */ B(Add), R(0), U8(4), B(Star), R(0), - /* 111 S> */ B(LdaSmi), U8(6), + /* 111 S> */ B(LdaSmi), I8(6), /* 117 E> */ B(TestEqual), R(0), U8(5), B(JumpIfFalse), U8(4), /* 123 S> */ B(Jump), U8(2), @@ -376,24 +376,24 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 53 S> */ B(LdaSmi), U8(1), + /* 53 S> */ B(LdaSmi), I8(1), B(Star), R(1), /* 56 E> */ B(StackCheck), - /* 63 S> */ B(LdaSmi), U8(10), + /* 63 S> */ B(LdaSmi), I8(10), /* 69 E> */ B(Mul), R(1), U8(2), B(Star), R(1), - /* 77 S> */ B(LdaSmi), U8(5), + /* 77 S> */ B(LdaSmi), I8(5), /* 83 E> */ B(TestEqual), R(0), U8(3), B(JumpIfFalse), U8(4), /* 89 S> */ B(Jump), U8(21), - /* 98 S> */ B(LdaSmi), U8(1), + /* 98 S> */ B(LdaSmi), I8(1), /* 104 E> */ B(Add), R(0), U8(4), B(Star), R(0), - /* 111 S> */ B(LdaSmi), U8(6), + /* 111 S> */ B(LdaSmi), I8(6), /* 117 E> */ B(TestEqual), R(0), U8(5), B(JumpIfFalse), U8(4), /* 123 S> */ B(Jump), U8(2), - B(JumpLoop), U8(-33), U8(0), + B(JumpLoop), U8(33), I8(0), /* 149 S> */ B(Ldar), R(1), /* 159 S> */ B(Return), ] @@ -419,18 +419,18 @@ bytecodes: [ /* 42 S> */ B(LdaZero), B(Star), R(0), /* 45 E> */ B(StackCheck), - /* 58 S> */ B(LdaSmi), U8(1), + /* 58 S> */ B(LdaSmi), I8(1), /* 64 E> */ B(TestEqual), R(0), U8(2), B(JumpIfFalse), U8(4), /* 70 S> */ B(Jump), U8(21), - /* 79 S> */ B(LdaSmi), U8(2), + /* 79 S> */ B(LdaSmi), I8(2), /* 85 E> */ B(TestEqual), R(0), U8(3), B(JumpIfFalse), U8(4), /* 91 S> */ B(Jump), U8(9), - /* 103 S> */ B(LdaSmi), U8(1), + /* 103 S> */ B(LdaSmi), I8(1), /* 109 E> */ B(Add), R(0), U8(4), B(Star), R(0), - B(JumpLoop), U8(-26), U8(0), + B(JumpLoop), U8(26), I8(0), B(LdaUndefined), /* 116 S> */ B(Return), ] @@ -455,18 +455,18 @@ bytecodes: [ /* 47 S> */ B(LdaZero), B(Star), R(0), /* 34 E> */ B(StackCheck), - /* 56 S> */ B(LdaSmi), U8(1), + /* 56 S> */ B(LdaSmi), I8(1), /* 62 E> */ B(TestEqual), R(0), U8(2), B(JumpIfFalse), U8(4), /* 68 S> */ B(Jump), U8(21), - /* 77 S> */ B(LdaSmi), U8(2), + /* 77 S> */ B(LdaSmi), I8(2), /* 83 E> */ B(TestEqual), R(0), U8(3), B(JumpIfFalse), U8(4), /* 89 S> */ B(Jump), U8(9), - /* 101 S> */ B(LdaSmi), U8(1), + /* 101 S> */ B(LdaSmi), I8(1), /* 107 E> */ B(Add), R(0), U8(4), B(Star), R(0), - B(JumpLoop), U8(-26), U8(0), + B(JumpLoop), U8(26), I8(0), B(LdaUndefined), /* 114 S> */ B(Return), ] @@ -491,18 +491,18 @@ bytecodes: [ /* 42 S> */ B(LdaZero), B(Star), R(0), /* 45 E> */ B(StackCheck), - /* 68 S> */ B(LdaSmi), U8(1), + /* 68 S> */ B(LdaSmi), I8(1), /* 74 E> */ B(TestEqual), R(0), U8(3), B(JumpIfFalse), U8(4), /* 80 S> */ B(Jump), U8(21), - /* 89 S> */ B(LdaSmi), U8(2), + /* 89 S> */ B(LdaSmi), I8(2), /* 95 E> */ B(TestEqual), R(0), U8(4), B(JumpIfFalse), U8(4), /* 101 S> */ B(Jump), U8(2), - /* 55 S> */ B(LdaSmi), U8(1), + /* 55 S> */ B(LdaSmi), I8(1), /* 59 E> */ B(Add), R(0), U8(2), B(Star), R(0), - B(JumpLoop), U8(-26), U8(0), + B(JumpLoop), U8(26), I8(0), B(LdaUndefined), /* 113 S> */ B(Return), ] @@ -526,18 +526,18 @@ bytecodes: [ /* 47 S> */ B(LdaZero), B(Star), R(0), /* 34 E> */ B(StackCheck), - /* 66 S> */ B(LdaSmi), U8(1), + /* 66 S> */ B(LdaSmi), I8(1), /* 72 E> */ B(TestEqual), R(0), U8(3), B(JumpIfFalse), U8(4), /* 78 S> */ B(Jump), U8(21), - /* 87 S> */ B(LdaSmi), U8(2), + /* 87 S> */ B(LdaSmi), I8(2), /* 93 E> */ B(TestEqual), R(0), U8(4), B(JumpIfFalse), U8(4), /* 99 S> */ B(Jump), U8(2), - /* 53 S> */ B(LdaSmi), U8(1), + /* 53 S> */ B(LdaSmi), I8(1), /* 57 E> */ B(Add), R(0), U8(2), B(Star), R(0), - B(JumpLoop), U8(-26), U8(0), + B(JumpLoop), U8(26), I8(0), B(LdaUndefined), /* 111 S> */ B(Return), ] @@ -563,18 +563,18 @@ bytecodes: [ B(Star), R(0), /* 58 S> */ B(LdaZero), B(Star), R(1), - /* 63 S> */ B(LdaSmi), U8(100), + /* 63 S> */ B(LdaSmi), I8(100), /* 63 E> */ B(TestLessThan), R(1), U8(2), B(JumpIfFalse), U8(22), /* 45 E> */ B(StackCheck), - /* 85 S> */ B(LdaSmi), U8(1), + /* 85 S> */ B(LdaSmi), I8(1), /* 91 E> */ B(Add), R(0), U8(4), B(Star), R(0), /* 98 S> */ B(Jump), U8(2), - /* 72 S> */ B(LdaSmi), U8(1), + /* 72 S> */ B(LdaSmi), I8(1), /* 76 E> */ B(Add), R(1), U8(3), B(Star), R(1), - B(JumpLoop), U8(-24), U8(0), + B(JumpLoop), U8(24), I8(0), B(LdaUndefined), /* 110 S> */ B(Return), ] @@ -596,20 +596,20 @@ parameter count: 1 bytecode array length: 33 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 58 S> */ B(LdaSmi), U8(10), + /* 58 S> */ B(LdaSmi), I8(10), B(Star), R(1), /* 62 S> */ B(Ldar), R(1), B(JumpIfToBooleanFalse), U8(19), /* 45 E> */ B(StackCheck), - /* 74 S> */ B(LdaSmi), U8(12), + /* 74 S> */ B(LdaSmi), I8(12), /* 80 E> */ B(Mul), R(0), U8(3), B(Star), R(0), /* 67 S> */ B(Ldar), R(1), B(Dec), U8(2), B(Star), R(1), - B(JumpLoop), U8(-18), U8(0), + B(JumpLoop), U8(18), I8(0), /* 88 S> */ B(Ldar), R(0), /* 98 S> */ B(Return), ] @@ -662,17 +662,17 @@ bytecodes: [ /* 58 S> */ B(LdaZero), B(Star), R(1), /* 45 E> */ B(StackCheck), - /* 76 S> */ B(LdaSmi), U8(1), + /* 76 S> */ B(LdaSmi), I8(1), /* 82 E> */ B(Add), R(0), U8(3), B(Star), R(0), - /* 89 S> */ B(LdaSmi), U8(20), + /* 89 S> */ B(LdaSmi), I8(20), /* 95 E> */ B(TestEqual), R(0), U8(4), B(JumpIfFalse), U8(4), /* 102 S> */ B(Jump), U8(11), /* 69 S> */ B(Ldar), R(1), B(Inc), U8(2), B(Star), R(1), - B(JumpLoop), U8(-23), U8(0), + B(JumpLoop), U8(23), I8(0), /* 112 S> */ B(Ldar), R(0), /* 122 S> */ B(Return), ] @@ -710,7 +710,7 @@ bytecodes: [ B(StaCurrentContextSlot), U8(4), B(CreateClosure), U8(1), U8(2), U8(2), B(Star), R(0), - /* 73 S> */ B(LdaSmi), U8(1), + /* 73 S> */ B(LdaSmi), I8(1), /* 73 E> */ B(StaCurrentContextSlot), U8(4), B(Mov), R(0), R(2), /* 106 S> */ B(LdaCurrentContextSlot), U8(4), @@ -722,7 +722,7 @@ bytecodes: [ B(Inc), U8(3), /* 127 E> */ B(StaCurrentContextSlot), U8(4), B(PopContext), R(3), - B(JumpLoop), U8(-45), U8(0), + B(JumpLoop), U8(45), I8(0), B(LdaUndefined), /* 137 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/BreakableBlocks.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/BreakableBlocks.golden index ce343d01b3..61915b27ea 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/BreakableBlocks.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/BreakableBlocks.golden @@ -22,7 +22,7 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 56 S> */ B(LdaSmi), U8(1), + /* 56 S> */ B(LdaSmi), I8(1), /* 62 E> */ B(Add), R(0), U8(2), B(Star), R(0), /* 69 S> */ B(Jump), U8(2), @@ -56,13 +56,13 @@ bytecodes: [ B(Star), R(0), /* 71 S> */ B(LdaZero), B(Star), R(1), - /* 76 S> */ B(LdaSmi), U8(10), + /* 76 S> */ B(LdaSmi), I8(10), /* 76 E> */ B(TestLessThan), R(1), U8(2), B(JumpIfFalse), U8(54), /* 58 E> */ B(StackCheck), /* 106 S> */ B(LdaZero), B(Star), R(2), - /* 111 S> */ B(LdaSmi), U8(3), + /* 111 S> */ B(LdaSmi), I8(3), /* 111 E> */ B(TestLessThan), R(2), U8(4), B(JumpIfFalse), U8(34), /* 93 E> */ B(StackCheck), @@ -72,18 +72,18 @@ bytecodes: [ /* 142 S> */ B(Ldar), R(2), /* 148 E> */ B(Add), R(1), U8(7), B(Star), R(3), - B(LdaSmi), U8(12), + B(LdaSmi), I8(12), /* 152 E> */ B(TestEqual), R(3), U8(8), B(JumpIfFalse), U8(4), /* 161 S> */ B(Jump), U8(20), /* 118 S> */ B(Ldar), R(2), B(Inc), U8(5), B(Star), R(2), - B(JumpLoop), U8(-36), U8(1), + B(JumpLoop), U8(36), I8(1), /* 84 S> */ B(Ldar), R(1), B(Inc), U8(3), B(Star), R(1), - B(JumpLoop), U8(-56), U8(0), + B(JumpLoop), U8(56), I8(0), /* 188 S> */ B(Ldar), R(0), /* 200 S> */ B(Return), ] @@ -112,7 +112,7 @@ bytecodes: [ B(StaCurrentContextSlot), U8(4), B(CreateClosure), U8(1), U8(2), U8(2), B(Star), R(0), - /* 53 S> */ B(LdaSmi), U8(10), + /* 53 S> */ B(LdaSmi), I8(10), /* 53 E> */ B(StaCurrentContextSlot), U8(4), B(Mov), R(0), R(1), B(Ldar), R(0), @@ -150,7 +150,7 @@ bytecodes: [ B(LdaTheHole), B(StaCurrentContextSlot), U8(4), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), /* 42 E> */ B(StaCurrentContextSlot), U8(4), B(Ldar), R(closure), B(CreateBlockContext), U8(0), @@ -159,17 +159,17 @@ bytecodes: [ B(StaCurrentContextSlot), U8(4), B(CreateClosure), U8(1), U8(2), U8(2), B(Star), R(0), - /* 76 S> */ B(LdaSmi), U8(2), + /* 76 S> */ B(LdaSmi), I8(2), /* 76 E> */ B(StaCurrentContextSlot), U8(4), B(Mov), R(0), R(1), /* 118 S> */ B(LdaCurrentContextSlot), U8(4), B(JumpIfToBooleanFalse), U8(6), /* 125 S> */ B(PopContext), R(3), B(Jump), U8(8), - /* 142 S> */ B(LdaSmi), U8(3), + /* 142 S> */ B(LdaSmi), I8(3), /* 144 E> */ B(StaCurrentContextSlot), U8(4), B(PopContext), R(3), - /* 155 S> */ B(LdaSmi), U8(4), + /* 155 S> */ B(LdaSmi), I8(4), /* 157 E> */ B(StaCurrentContextSlot), U8(4), B(LdaUndefined), /* 162 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden new file mode 100644 index 0000000000..c2acbec102 --- /dev/null +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden @@ -0,0 +1,107 @@ +# +# Autogenerated by generate-bytecode-expectations. +# + +--- +wrap: yes + +--- +snippet: " + Math.max(...[1, 2, 3]); +" +frame size: 3 +parameter count: 1 +bytecode array length: 24 +bytecodes: [ + /* 30 E> */ B(StackCheck), + /* 34 S> */ B(LdaGlobal), U8(0), U8(4), + B(Star), R(1), + /* 38 E> */ B(LdaNamedProperty), R(1), U8(1), U8(6), + B(Star), R(0), + B(CreateArrayLiteral), U8(2), U8(8), U8(9), + B(Star), R(2), + /* 39 E> */ B(CallWithSpread), R(0), R(1), U8(2), + B(LdaUndefined), + /* 58 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["Math"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["max"], + CONSTANT_ELEMENTS_PAIR_TYPE, +] +handlers: [ +] + +--- +snippet: " + Math.max(0, ...[1, 2, 3]); +" +frame size: 4 +parameter count: 1 +bytecode array length: 27 +bytecodes: [ + /* 30 E> */ B(StackCheck), + /* 34 S> */ B(LdaGlobal), U8(0), U8(4), + B(Star), R(1), + /* 38 E> */ B(LdaNamedProperty), R(1), U8(1), U8(6), + B(Star), R(0), + B(LdaZero), + B(Star), R(2), + B(CreateArrayLiteral), U8(2), U8(8), U8(9), + B(Star), R(3), + /* 39 E> */ B(CallWithSpread), R(0), R(1), U8(3), + B(LdaUndefined), + /* 61 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["Math"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["max"], + CONSTANT_ELEMENTS_PAIR_TYPE, +] +handlers: [ +] + +--- +snippet: " + Math.max(0, ...[1, 2, 3], 4); +" +frame size: 8 +parameter count: 1 +bytecode array length: 60 +bytecodes: [ + /* 30 E> */ B(StackCheck), + /* 34 S> */ B(LdaUndefined), + B(Star), R(1), + /* 34 E> */ B(LdaGlobal), U8(0), U8(2), + B(Star), R(0), + B(LdaNamedProperty), R(0), U8(1), U8(4), + B(Star), R(2), + B(LdaUndefined), + B(Star), R(4), + B(CreateArrayLiteral), U8(2), U8(6), U8(9), + B(Star), R(5), + B(LdaUndefined), + B(Star), R(6), + B(CreateArrayLiteral), U8(3), U8(7), U8(9), + B(Star), R(7), + B(CallJSRuntime), U8(%spread_iterable), R(6), U8(2), + B(Star), R(6), + B(CreateArrayLiteral), U8(4), U8(8), U8(9), + B(Star), R(7), + B(CallJSRuntime), U8(%spread_arguments), R(4), U8(4), + B(Star), R(4), + B(Mov), R(0), R(3), + B(CallJSRuntime), U8(%reflect_apply), R(1), U8(4), + B(LdaUndefined), + /* 64 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["Math"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["max"], + CONSTANT_ELEMENTS_PAIR_TYPE, + CONSTANT_ELEMENTS_PAIR_TYPE, + CONSTANT_ELEMENTS_PAIR_TYPE, +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallGlobal.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallGlobal.golden index beb9a30222..88bf4420f2 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallGlobal.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallGlobal.golden @@ -45,11 +45,11 @@ bytecodes: [ B(Star), R(1), B(LdaGlobal), U8(0), U8(4), B(Star), R(0), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(2), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(3), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(Star), R(4), /* 46 E> */ B(Call), R(0), R(1), U8(4), U8(2), /* 58 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallLookupSlot.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallLookupSlot.golden index cad09007e5..fc7a6f7843 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallLookupSlot.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallLookupSlot.golden @@ -32,9 +32,9 @@ bytecodes: [ B(Star), R(3), B(LdaZero), B(Star), R(7), - B(LdaSmi), U8(30), + B(LdaSmi), I8(30), B(Star), R(8), - B(LdaSmi), U8(52), + B(LdaSmi), I8(52), B(Star), R(9), B(Mov), R(1), R(4), B(Mov), R(3), R(5), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallNew.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallNew.golden index f60f73e065..bd3067686d 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallNew.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallNew.golden @@ -19,7 +19,7 @@ bytecodes: [ /* 45 E> */ B(StackCheck), /* 50 S> */ B(LdaGlobal), U8(0), U8(4), B(Star), R(0), - /* 57 E> */ B(New), R(0), R(0), U8(0), U8(2), + /* 57 E> */ B(Construct), R(0), R(0), U8(0), U8(2), /* 68 S> */ B(Return), ] constant pool: [ @@ -41,10 +41,10 @@ bytecodes: [ /* 58 E> */ B(StackCheck), /* 63 S> */ B(LdaGlobal), U8(0), U8(4), B(Star), R(0), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(Star), R(1), B(Ldar), R(0), - /* 70 E> */ B(New), R(0), R(1), U8(1), U8(2), + /* 70 E> */ B(Construct), R(0), R(1), U8(1), U8(2), /* 82 S> */ B(Return), ] constant pool: [ @@ -71,14 +71,14 @@ bytecodes: [ /* 100 E> */ B(StackCheck), /* 105 S> */ B(LdaGlobal), U8(0), U8(4), B(Star), R(0), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(Star), R(1), - B(LdaSmi), U8(4), + B(LdaSmi), I8(4), B(Star), R(2), - B(LdaSmi), U8(5), + B(LdaSmi), I8(5), B(Star), R(3), B(Ldar), R(0), - /* 112 E> */ B(New), R(0), R(1), U8(3), U8(2), + /* 112 E> */ B(Construct), R(0), R(1), U8(3), U8(2), /* 130 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallRuntime.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallRuntime.golden index 31e697590e..45f504ede1 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallRuntime.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallRuntime.golden @@ -53,9 +53,9 @@ parameter count: 1 bytecode array length: 15 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 15 S> */ B(LdaSmi), U8(1), + /* 15 S> */ B(LdaSmi), I8(1), B(Star), R(0), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(1), B(CallRuntime), U16(Runtime::kAdd), R(0), U8(2), /* 33 S> */ B(Return), @@ -77,7 +77,7 @@ bytecodes: [ /* 10 E> */ B(StackCheck), /* 15 S> */ B(LdaUndefined), B(Star), R(0), - B(CreateArrayLiteral), U8(0), U8(0), U8(9), + B(CreateArrayLiteral), U8(0), U8(2), U8(9), B(Star), R(1), B(CallJSRuntime), U8(%spread_iterable), R(0), U8(2), /* 44 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassAndSuperClass.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassAndSuperClass.golden index 0c41685b86..9316f65b3f 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassAndSuperClass.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassAndSuperClass.golden @@ -36,7 +36,7 @@ bytecodes: [ B(Star), R(1), /* 117 E> */ B(Call), R(1), R(this), U8(1), U8(2), B(Star), R(1), - /* 126 E> */ B(AddSmi), U8(1), R(1), U8(8), + /* 126 E> */ B(AddSmi), I8(1), R(1), U8(8), /* 131 S> */ B(Return), ] constant pool: [ @@ -72,7 +72,7 @@ bytecodes: [ B(Star), R(2), B(LdaConstant), U8(1), B(Star), R(3), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(4), B(Mov), R(this), R(1), /* 138 E> */ B(CallRuntime), U16(Runtime::kStoreToSuper_Strict), R(1), U8(4), @@ -115,10 +115,10 @@ bytecodes: [ /* 113 E> */ B(StackCheck), /* 118 S> */ B(Ldar), R(1), B(GetSuperConstructor), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(3), B(Ldar), R(0), - /* 118 E> */ B(New), R(2), R(3), U8(1), U8(2), + /* 118 E> */ B(Construct), R(2), R(3), U8(1), U8(2), B(Star), R(2), B(Ldar), R(this), B(JumpIfNotHole), U8(4), @@ -131,7 +131,7 @@ bytecodes: [ B(Star), R(2), B(CallRuntime), U16(Runtime::kThrowReferenceError), R(2), U8(1), B(Star), R(2), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), /* 136 E> */ B(StaNamedPropertyStrict), R(2), U8(1), U8(4), B(Ldar), R(this), B(JumpIfNotHole), U8(11), @@ -171,7 +171,7 @@ bytecodes: [ /* 117 S> */ B(Ldar), R(1), B(GetSuperConstructor), R(2), B(Ldar), R(0), - /* 117 E> */ B(New), R(2), R(0), U8(0), U8(2), + /* 117 E> */ B(Construct), R(2), R(0), U8(0), U8(2), B(Star), R(2), B(Ldar), R(this), B(JumpIfNotHole), U8(4), @@ -184,7 +184,7 @@ bytecodes: [ B(Star), R(2), B(CallRuntime), U16(Runtime::kThrowReferenceError), R(2), U8(1), B(Star), R(2), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), /* 134 E> */ B(StaNamedPropertyStrict), R(2), U8(1), U8(4), B(Ldar), R(this), B(JumpIfNotHole), U8(11), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden index 7b283024c8..7ff8973bc6 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden @@ -25,9 +25,9 @@ bytecodes: [ B(Star), R(3), B(LdaTheHole), B(Star), R(4), - B(LdaSmi), U8(34), + B(LdaSmi), I8(34), B(Star), R(6), - B(Wide), B(LdaSmi), U16(148), + B(Wide), B(LdaSmi), I16(148), B(Star), R(7), B(Mov), R(3), R(5), B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(4), @@ -36,7 +36,7 @@ bytecodes: [ B(Star), R(6), B(CreateClosure), U8(2), U8(3), U8(2), B(Star), R(7), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(8), B(Ldar), R(7), B(StaDataPropertyInLiteral), R(4), R(6), U8(1), U8(4), @@ -76,9 +76,9 @@ bytecodes: [ B(Star), R(3), B(LdaTheHole), B(Star), R(4), - B(LdaSmi), U8(34), + B(LdaSmi), I8(34), B(Star), R(6), - B(Wide), B(LdaSmi), U16(148), + B(Wide), B(LdaSmi), I16(148), B(Star), R(7), B(Mov), R(3), R(5), B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(4), @@ -87,7 +87,7 @@ bytecodes: [ B(Star), R(6), B(CreateClosure), U8(2), U8(3), U8(2), B(Star), R(7), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(8), B(Ldar), R(7), B(StaDataPropertyInLiteral), R(4), R(6), U8(1), U8(4), @@ -135,22 +135,22 @@ bytecodes: [ B(Star), R(4), B(LdaTheHole), B(Star), R(5), - B(LdaSmi), U8(62), + B(LdaSmi), I8(62), B(Star), R(7), - B(Wide), B(LdaSmi), U16(128), + B(Wide), B(LdaSmi), I16(128), B(Star), R(8), B(Mov), R(4), R(6), B(CallRuntime), U16(Runtime::kDefineClass), R(5), U8(4), B(Star), R(5), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), /* 75 E> */ B(ToName), R(7), B(CreateClosure), U8(3), U8(3), U8(2), B(Star), R(8), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(9), B(Ldar), R(8), B(StaDataPropertyInLiteral), R(5), R(7), U8(3), U8(5), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), /* 106 E> */ B(ToName), R(7), B(LdaConstant), U8(4), B(TestEqualStrict), R(7), U8(0), @@ -202,9 +202,9 @@ bytecodes: [ B(Star), R(4), B(LdaTheHole), B(Star), R(5), - B(LdaSmi), U8(49), + B(LdaSmi), I8(49), B(Star), R(7), - B(LdaSmi), U8(86), + B(LdaSmi), I8(86), B(Star), R(8), B(Mov), R(4), R(6), B(CallRuntime), U16(Runtime::kDefineClass), R(5), U8(4), @@ -215,7 +215,7 @@ bytecodes: [ B(Star), R(1), B(Star), R(2), /* 87 S> */ B(Nop), - /* 94 E> */ B(New), R(2), R(0), U8(0), U8(3), + /* 94 E> */ B(Construct), R(2), R(0), U8(0), U8(3), /* 103 S> */ B(Return), ] constant pool: [ @@ -240,9 +240,9 @@ bytecodes: [ B(Star), R(4), B(LdaTheHole), B(Star), R(5), - B(LdaSmi), U8(35), + B(LdaSmi), I8(35), B(Star), R(7), - B(LdaSmi), U8(43), + B(LdaSmi), I8(43), B(Star), R(8), B(Mov), R(4), R(6), B(CallRuntime), U16(Runtime::kDefineClass), R(5), U8(4), @@ -255,9 +255,9 @@ bytecodes: [ B(Star), R(4), B(LdaTheHole), B(Star), R(5), - B(LdaSmi), U8(45), + B(LdaSmi), I8(45), B(Star), R(7), - B(LdaSmi), U8(73), + B(LdaSmi), I8(73), B(Star), R(8), B(Mov), R(4), R(6), B(CallRuntime), U16(Runtime::kDefineClass), R(5), U8(4), @@ -266,7 +266,7 @@ bytecodes: [ B(Star), R(7), B(CreateClosure), U8(3), U8(4), U8(2), B(Star), R(8), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(9), B(Ldar), R(8), B(StaDataPropertyInLiteral), R(6), R(7), U8(1), U8(5), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden index 273f3323eb..620031bf27 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden @@ -14,9 +14,9 @@ parameter count: 1 bytecode array length: 16 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(AddSmi), U8(2), R(0), U8(2), + /* 45 S> */ B(AddSmi), I8(2), R(0), U8(2), B(Mov), R(0), R(1), B(Star), R(0), B(LdaUndefined), @@ -36,9 +36,9 @@ parameter count: 1 bytecode array length: 17 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(LdaSmi), U8(2), + /* 45 S> */ B(LdaSmi), I8(2), B(Div), R(0), U8(2), B(Mov), R(0), R(1), B(Star), R(0), @@ -59,13 +59,13 @@ parameter count: 1 bytecode array length: 26 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), + /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), B(Mov), R(1), R(0), - /* 54 S> */ B(LdaNamedProperty), R(0), U8(1), U8(2), + /* 54 S> */ B(LdaNamedProperty), R(0), U8(1), U8(3), B(Star), R(2), - B(LdaSmi), U8(2), - B(Mul), R(2), U8(4), - /* 61 E> */ B(StaNamedPropertySloppy), R(0), U8(1), U8(5), + B(LdaSmi), I8(2), + B(Mul), R(2), U8(5), + /* 61 E> */ B(StaNamedPropertySloppy), R(0), U8(1), U8(6), B(LdaUndefined), /* 67 S> */ B(Return), ] @@ -85,15 +85,15 @@ parameter count: 1 bytecode array length: 29 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), + /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), B(Mov), R(1), R(0), - /* 52 S> */ B(LdaSmi), U8(1), + /* 52 S> */ B(LdaSmi), I8(1), B(Star), R(2), - B(LdaKeyedProperty), R(0), U8(2), + B(LdaKeyedProperty), R(0), U8(3), B(Star), R(3), - B(LdaSmi), U8(2), - B(BitwiseXor), R(3), U8(4), - /* 57 E> */ B(StaKeyedPropertySloppy), R(0), R(2), U8(5), + B(LdaSmi), I8(2), + B(BitwiseXor), R(3), U8(5), + /* 57 E> */ B(StaKeyedPropertySloppy), R(0), R(2), U8(6), B(LdaUndefined), /* 63 S> */ B(Return), ] @@ -114,12 +114,12 @@ bytecodes: [ B(CreateFunctionContext), U8(1), B(PushContext), R(0), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), /* 42 E> */ B(StaCurrentContextSlot), U8(4), /* 45 S> */ B(CreateClosure), U8(0), U8(2), U8(2), /* 75 S> */ B(LdaCurrentContextSlot), U8(4), B(Star), R(1), - B(BitwiseOrSmi), U8(24), R(1), U8(3), + B(BitwiseOrSmi), I8(24), R(1), U8(3), /* 77 E> */ B(StaCurrentContextSlot), U8(4), B(LdaUndefined), /* 84 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Conditional.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Conditional.golden index 049de5a8b3..db44e2bd87 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Conditional.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Conditional.golden @@ -14,7 +14,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(LdaSmi), U8(2), + /* 34 S> */ B(LdaSmi), I8(2), /* 52 S> */ B(Return), ] constant pool: [ @@ -31,7 +31,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(LdaSmi), U8(3), + /* 34 S> */ B(LdaSmi), I8(3), /* 60 S> */ B(Return), ] constant pool: [ @@ -50,12 +50,12 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 34 S> */ B(LdaZero), B(Star), R(0), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), /* 43 E> */ B(TestLessThan), R(0), U8(2), B(JumpIfFalse), U8(6), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Jump), U8(4), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 56 S> */ B(Return), ] constant pool: [ @@ -76,9 +76,9 @@ bytecodes: [ /* 42 S> */ B(LdaZero), B(Star), R(0), /* 45 S> */ B(JumpIfToBooleanFalse), U8(6), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Jump), U8(4), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 63 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ConstVariable.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ConstVariable.golden index f19879c9e2..6ba2ad4d94 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ConstVariable.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ConstVariable.golden @@ -16,7 +16,7 @@ bytecodes: [ B(LdaTheHole), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 44 S> */ B(LdaSmi), U8(10), + /* 44 S> */ B(LdaSmi), I8(10), B(Star), R(0), B(LdaUndefined), /* 48 S> */ B(Return), @@ -37,7 +37,7 @@ bytecodes: [ B(LdaTheHole), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 44 S> */ B(LdaSmi), U8(10), + /* 44 S> */ B(LdaSmi), I8(10), B(Star), R(0), /* 48 S> */ B(Nop), /* 58 S> */ B(Return), @@ -58,7 +58,7 @@ bytecodes: [ B(LdaTheHole), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 48 S> */ B(LdaSmi), U8(20), + /* 48 S> */ B(LdaSmi), I8(20), B(Star), R(1), B(Ldar), R(0), B(JumpIfNotHole), U8(11), @@ -87,9 +87,9 @@ bytecodes: [ B(LdaTheHole), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 44 S> */ B(LdaSmi), U8(10), + /* 44 S> */ B(LdaSmi), I8(10), B(Star), R(0), - /* 48 S> */ B(LdaSmi), U8(20), + /* 48 S> */ B(LdaSmi), I8(20), /* 50 E> */ B(CallRuntime), U16(Runtime::kThrowConstAssignError), R(0), U8(0), B(LdaUndefined), /* 56 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ConstVariableContextSlot.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ConstVariableContextSlot.golden index 8dc85b3326..c92627b183 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ConstVariableContextSlot.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ConstVariableContextSlot.golden @@ -20,7 +20,7 @@ bytecodes: [ B(CreateClosure), U8(0), U8(2), U8(2), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 44 S> */ B(LdaSmi), U8(10), + /* 44 S> */ B(LdaSmi), I8(10), /* 44 E> */ B(StaCurrentContextSlot), U8(4), B(LdaUndefined), /* 74 S> */ B(Return), @@ -46,9 +46,9 @@ bytecodes: [ B(CreateClosure), U8(0), U8(2), U8(2), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 44 S> */ B(LdaSmi), U8(10), + /* 44 S> */ B(LdaSmi), I8(10), /* 44 E> */ B(StaCurrentContextSlot), U8(4), - /* 74 S> */ B(LdaCurrentContextSlot), U8(4), + /* 74 S> */ B(LdaImmutableCurrentContextSlot), U8(4), /* 84 S> */ B(Return), ] constant pool: [ @@ -72,7 +72,7 @@ bytecodes: [ B(CreateClosure), U8(0), U8(2), U8(2), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 47 S> */ B(LdaSmi), U8(20), + /* 47 S> */ B(LdaSmi), I8(20), B(Star), R(2), B(LdaCurrentContextSlot), U8(4), B(JumpIfNotHole), U8(11), @@ -106,9 +106,9 @@ bytecodes: [ B(CreateClosure), U8(0), U8(2), U8(2), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 44 S> */ B(LdaSmi), U8(10), + /* 44 S> */ B(LdaSmi), I8(10), /* 44 E> */ B(StaCurrentContextSlot), U8(4), - /* 48 S> */ B(LdaSmi), U8(20), + /* 48 S> */ B(LdaSmi), I8(20), /* 50 E> */ B(CallRuntime), U16(Runtime::kThrowConstAssignError), R(0), U8(0), B(LdaUndefined), /* 82 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden index b0df006a63..dc8d7f67f2 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden @@ -36,7 +36,7 @@ bytecodes: [ B(CreateFunctionContext), U8(1), B(PushContext), R(0), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), /* 42 E> */ B(StaCurrentContextSlot), U8(4), /* 45 S> */ B(CreateClosure), U8(0), U8(2), U8(2), /* 75 S> */ B(Return), @@ -58,9 +58,9 @@ bytecodes: [ B(CreateFunctionContext), U8(2), B(PushContext), R(0), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), /* 42 E> */ B(StaCurrentContextSlot), U8(4), - /* 53 S> */ B(LdaSmi), U8(2), + /* 53 S> */ B(LdaSmi), I8(2), /* 53 E> */ B(StaCurrentContextSlot), U8(5), /* 56 S> */ B(CreateClosure), U8(0), U8(2), U8(2), /* 92 S> */ B(Return), @@ -111,14 +111,14 @@ bytecodes: [ B(LdaTheHole), B(StaCurrentContextSlot), U8(4), /* 30 E> */ B(StackCheck), - /* 56 S> */ B(LdaSmi), U8(1), + /* 56 S> */ B(LdaSmi), I8(1), /* 56 E> */ B(StaCurrentContextSlot), U8(4), B(Ldar), R(closure), B(CreateBlockContext), U8(0), B(PushContext), R(1), B(LdaTheHole), B(StaCurrentContextSlot), U8(4), - /* 69 S> */ B(LdaSmi), U8(2), + /* 69 S> */ B(LdaSmi), I8(2), /* 69 E> */ B(StaCurrentContextSlot), U8(4), /* 72 S> */ B(CreateClosure), U8(1), U8(2), U8(2), B(PopContext), R(0), @@ -906,7 +906,7 @@ bytecodes: [ B(LdaGlobal), U8(0), U8(4), B(Star), R(1), /* 3438 E> */ B(Call), R(1), R(2), U8(1), U8(2), - /* 3454 S> */ B(LdaSmi), U8(100), + /* 3454 S> */ B(LdaSmi), I8(100), /* 3454 E> */ B(Wide), B(StaCurrentContextSlot), U16(256), /* 3459 S> */ B(Wide), B(LdaCurrentContextSlot), U16(256), /* 3468 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CountOperators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CountOperators.golden index 61186cd887..512ad2668a 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CountOperators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CountOperators.golden @@ -14,7 +14,7 @@ parameter count: 1 bytecode array length: 10 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(Inc), U8(2), B(Star), R(0), @@ -34,7 +34,7 @@ parameter count: 1 bytecode array length: 16 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(ToNumber), R(1), B(Ldar), R(1), @@ -57,7 +57,7 @@ parameter count: 1 bytecode array length: 10 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(Dec), U8(2), B(Star), R(0), @@ -77,7 +77,7 @@ parameter count: 1 bytecode array length: 16 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(ToNumber), R(1), B(Ldar), R(1), @@ -100,13 +100,13 @@ parameter count: 1 bytecode array length: 26 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), + /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), B(Mov), R(1), R(0), - /* 54 S> */ B(LdaNamedProperty), R(0), U8(1), U8(2), + /* 54 S> */ B(LdaNamedProperty), R(0), U8(1), U8(3), B(ToNumber), R(2), B(Ldar), R(2), - B(Inc), U8(6), - /* 66 E> */ B(StaNamedPropertySloppy), R(0), U8(1), U8(4), + B(Inc), U8(7), + /* 66 E> */ B(StaNamedPropertySloppy), R(0), U8(1), U8(5), B(Ldar), R(2), /* 70 S> */ B(Return), ] @@ -126,11 +126,11 @@ parameter count: 1 bytecode array length: 20 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), + /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), B(Mov), R(1), R(0), - /* 54 S> */ B(LdaNamedProperty), R(0), U8(1), U8(2), - B(Dec), U8(6), - /* 65 E> */ B(StaNamedPropertySloppy), R(0), U8(1), U8(4), + /* 54 S> */ B(LdaNamedProperty), R(0), U8(1), U8(3), + B(Dec), U8(7), + /* 65 E> */ B(StaNamedPropertySloppy), R(0), U8(1), U8(5), /* 70 S> */ B(Return), ] constant pool: [ @@ -151,14 +151,14 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 45 S> */ B(LdaConstant), U8(0), B(Star), R(0), - /* 60 S> */ B(CreateObjectLiteral), U8(1), U8(0), U8(1), R(2), + /* 60 S> */ B(CreateObjectLiteral), U8(1), U8(2), U8(1), R(2), B(Mov), R(2), R(1), /* 72 S> */ B(Ldar), R(0), - /* 81 E> */ B(LdaKeyedProperty), R(1), U8(2), + /* 81 E> */ B(LdaKeyedProperty), R(1), U8(3), B(ToNumber), R(4), B(Ldar), R(4), - B(Dec), U8(6), - /* 86 E> */ B(StaKeyedPropertySloppy), R(1), R(0), U8(4), + B(Dec), U8(7), + /* 86 E> */ B(StaKeyedPropertySloppy), R(1), R(0), U8(5), B(Ldar), R(4), /* 90 S> */ B(Return), ] @@ -180,12 +180,12 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 45 S> */ B(LdaConstant), U8(0), B(Star), R(0), - /* 60 S> */ B(CreateObjectLiteral), U8(1), U8(0), U8(1), R(2), + /* 60 S> */ B(CreateObjectLiteral), U8(1), U8(2), U8(1), R(2), B(Mov), R(2), R(1), /* 72 S> */ B(Ldar), R(0), - /* 83 E> */ B(LdaKeyedProperty), R(1), U8(2), - B(Inc), U8(6), - /* 87 E> */ B(StaKeyedPropertySloppy), R(1), R(0), U8(4), + /* 83 E> */ B(LdaKeyedProperty), R(1), U8(3), + B(Inc), U8(7), + /* 87 E> */ B(StaKeyedPropertySloppy), R(1), R(0), U8(5), /* 90 S> */ B(Return), ] constant pool: [ @@ -206,7 +206,7 @@ bytecodes: [ B(CreateFunctionContext), U8(1), B(PushContext), R(1), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), /* 42 E> */ B(StaCurrentContextSlot), U8(4), /* 53 S> */ B(CreateClosure), U8(0), U8(2), U8(2), B(Star), R(0), @@ -232,7 +232,7 @@ bytecodes: [ B(CreateFunctionContext), U8(1), B(PushContext), R(1), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), /* 42 E> */ B(StaCurrentContextSlot), U8(4), /* 53 S> */ B(CreateClosure), U8(0), U8(2), U8(2), B(Star), R(0), @@ -259,17 +259,17 @@ parameter count: 1 bytecode array length: 28 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 44 S> */ B(LdaSmi), U8(1), + /* 44 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 55 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(9), + /* 55 S> */ B(CreateArrayLiteral), U8(0), U8(2), U8(9), B(Star), R(1), /* 63 S> */ B(Ldar), R(0), B(ToNumber), R(3), B(Ldar), R(3), - B(Inc), U8(2), + B(Inc), U8(3), B(Star), R(0), - B(LdaSmi), U8(2), - /* 79 E> */ B(StaKeyedPropertySloppy), R(1), R(3), U8(3), + B(LdaSmi), I8(2), + /* 79 E> */ B(StaKeyedPropertySloppy), R(1), R(3), U8(4), /* 84 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/DeadCodeRemoval.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/DeadCodeRemoval.golden index 6c4a7b5ac2..7e6f40a3b6 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/DeadCodeRemoval.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/DeadCodeRemoval.golden @@ -31,7 +31,7 @@ parameter count: 1 bytecode array length: 7 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 66 S> */ B(LdaSmi), U8(1), + /* 66 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(LdaUndefined), /* 69 S> */ B(Return), @@ -50,7 +50,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 46 S> */ B(LdaSmi), U8(1), + /* 46 S> */ B(LdaSmi), I8(1), /* 78 S> */ B(Return), ] constant pool: [ @@ -67,12 +67,12 @@ parameter count: 1 bytecode array length: 13 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(JumpIfToBooleanFalse), U8(5), - /* 54 S> */ B(LdaSmi), U8(1), + /* 54 S> */ B(LdaSmi), I8(1), /* 77 S> */ B(Return), - /* 67 S> */ B(LdaSmi), U8(2), + /* 67 S> */ B(LdaSmi), I8(2), /* 77 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/DeclareGlobals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/DeclareGlobals.golden index 91c3bb99d4..62dc163a70 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/DeclareGlobals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/DeclareGlobals.golden @@ -25,7 +25,7 @@ bytecodes: [ B(Star), R(1), B(LdaZero), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(3), B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), B(LdaUndefined), @@ -82,10 +82,10 @@ bytecodes: [ B(Star), R(1), B(LdaZero), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(3), B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), - /* 11 S> */ B(LdaSmi), U8(2), + /* 11 S> */ B(LdaSmi), I8(2), /* 12 E> */ B(StaGlobalSloppy), U8(1), U8(4), B(Star), R(0), /* 15 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Delete.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Delete.golden index e139fd65d1..08b3f47e13 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Delete.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Delete.golden @@ -14,7 +14,7 @@ parameter count: 1 bytecode array length: 14 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), + /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), B(Mov), R(1), R(0), /* 56 S> */ B(LdaConstant), U8(1), B(DeletePropertySloppy), R(0), @@ -36,7 +36,7 @@ parameter count: 1 bytecode array length: 14 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 56 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), + /* 56 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), B(Mov), R(1), R(0), /* 70 S> */ B(LdaConstant), U8(1), B(DeletePropertyStrict), R(0), @@ -58,9 +58,9 @@ parameter count: 1 bytecode array length: 14 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), + /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), B(Mov), R(1), R(0), - /* 56 S> */ B(LdaSmi), U8(2), + /* 56 S> */ B(LdaSmi), I8(2), B(DeletePropertySloppy), R(0), /* 76 S> */ B(Return), ] @@ -79,7 +79,7 @@ parameter count: 1 bytecode array length: 7 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), B(Star), R(0), /* 46 S> */ B(LdaFalse), /* 63 S> */ B(Return), @@ -103,13 +103,13 @@ bytecodes: [ B(CreateFunctionContext), U8(1), B(PushContext), R(0), /* 30 E> */ B(StackCheck), - /* 56 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), + /* 56 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), B(Ldar), R(1), /* 56 E> */ B(StaCurrentContextSlot), U8(4), - /* 64 S> */ B(CreateClosure), U8(1), U8(2), U8(2), - /* 93 S> */ B(LdaCurrentContextSlot), U8(4), + /* 64 S> */ B(CreateClosure), U8(1), U8(3), U8(2), + /* 93 S> */ B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(1), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(DeletePropertyStrict), R(1), /* 113 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/DoExpression.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/DoExpression.golden index 662ecf14d9..412c5ccbe6 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/DoExpression.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/DoExpression.golden @@ -33,7 +33,7 @@ parameter count: 1 bytecode array length: 12 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 55 S> */ B(LdaSmi), U8(100), + /* 55 S> */ B(LdaSmi), I8(100), B(Star), R(0), /* 42 S> */ B(LdaUndefined), B(Star), R(1), @@ -56,7 +56,7 @@ bytecode array length: 16 bytecodes: [ /* 30 E> */ B(StackCheck), /* 34 E> */ B(StackCheck), - /* 56 S> */ B(LdaSmi), U8(10), + /* 56 S> */ B(LdaSmi), I8(10), B(Star), R(0), /* 69 S> */ B(Inc), U8(2), B(Star), R(0), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Eval.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Eval.golden index a311aa9101..3a865c65db 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Eval.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Eval.golden @@ -30,9 +30,9 @@ bytecodes: [ B(Star), R(3), B(LdaZero), B(Star), R(7), - B(LdaSmi), U8(30), + B(LdaSmi), I8(30), B(Star), R(8), - B(LdaSmi), U8(41), + B(LdaSmi), I8(41), B(Star), R(9), B(Mov), R(1), R(4), B(Mov), R(3), R(5), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden new file mode 100644 index 0000000000..3b705f1799 --- /dev/null +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden @@ -0,0 +1,1803 @@ +# +# Autogenerated by generate-bytecode-expectations. +# + +--- +wrap: no +test function name: f +async iteration: yes + +--- +snippet: " + async function f() { + for await (let x of [1, 2, 3]) {} + } + f(); +" +frame size: 19 +parameter count: 1 +bytecode array length: 1055 +bytecodes: [ + B(Ldar), R(new_target), + B(JumpIfUndefined), U8(42), + B(CallRuntime), U16(Runtime::k_GeneratorGetContext), R(new_target), U8(1), + B(PushContext), R(4), + B(ResumeGenerator), R(new_target), + B(Star), R(3), + B(LdaZero), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrue), U8(136), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrueConstant), U8(13), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrueConstant), U8(15), + B(LdaSmi), I8(78), + B(Star), R(5), + B(CallRuntime), U16(Runtime::kAbort), R(5), U8(1), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CreateFunctionContext), U8(13), + B(PushContext), R(0), + B(Ldar), R(this), + B(StaCurrentContextSlot), U8(4), + /* 16 E> */ B(StackCheck), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(6), + B(Mov), R(closure), R(5), + B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(5), U8(2), + B(StaCurrentContextSlot), U8(5), + B(LdaUndefined), + B(Star), R(5), + B(CallJSRuntime), U8(%async_function_promise_create), R(5), U8(1), + B(StaCurrentContextSlot), U8(10), + B(Mov), R(context), R(7), + B(Mov), R(context), R(8), + B(Ldar), R(closure), + B(CreateBlockContext), U8(0), + B(PushContext), R(1), + B(LdaTheHole), + B(StaCurrentContextSlot), U8(4), + B(LdaZero), + B(StaContextSlot), R(1), U8(9), U8(0), + B(Mov), R(context), R(11), + B(Mov), R(context), R(12), + /* 43 S> */ B(CreateArrayLiteral), U8(1), U8(2), U8(9), + B(Star), R(13), + B(LdaNamedProperty), R(13), U8(2), U8(7), + B(JumpIfUndefined), U8(18), + B(JumpIfNull), U8(16), + B(Star), R(14), + B(CallProperty), R(14), R(13), U8(1), U8(9), + B(JumpIfJSReceiver), U8(24), + B(CallRuntime), U16(Runtime::kThrowSymbolAsyncIteratorInvalid), R(0), U8(0), + B(LdaNamedProperty), R(13), U8(3), U8(3), + B(Star), R(14), + B(CallProperty), R(14), R(13), U8(1), U8(5), + B(Star), R(14), + B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(14), U8(1), + /* 43 E> */ B(StaContextSlot), R(1), U8(7), U8(0), + B(LdaSmi), I8(-2), + B(TestEqual), R(3), U8(0), + B(JumpIfTrue), U8(17), + B(LdaZero), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrue), U8(75), + B(LdaSmi), I8(78), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kAbort), R(13), U8(1), + /* 40 S> */ B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(14), + B(LdaNamedProperty), R(14), U8(4), U8(13), + B(Star), R(13), + /* 40 E> */ B(CallProperty), R(13), R(14), U8(1), U8(11), + B(StaContextSlot), R(1), U8(11), U8(0), + /* 40 S> */ B(LdaUndefined), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaContextSlot), R(1), U8(11), U8(0), + B(Star), R(15), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(16), + B(CallJSRuntime), U8(%async_function_await_uncaught), R(13), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaZero), + B(SuspendGenerator), R(14), + B(Ldar), R(13), + /* 57 S> */ B(Return), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(14), U8(1), + B(Star), R(15), + B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(14), U8(1), + B(Star), R(16), + B(LdaZero), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(31), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(21), + B(Jump), U8(2), + B(LdaTrue), + B(Star), R(18), + B(Mov), R(15), R(17), + B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(17), U8(2), + B(Star), R(10), + B(LdaZero), + B(Star), R(9), + B(Jump), U8(155), + B(Ldar), R(15), + B(ReThrow), + B(Ldar), R(15), + /* 40 E> */ B(StaContextSlot), R(1), U8(8), U8(0), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(15), U8(1), + B(ToBooleanLogicalNot), + B(JumpIfFalse), U8(13), + B(LdaContextSlot), R(1), U8(8), U8(0), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), + B(LdaContextSlot), R(1), U8(8), U8(0), + B(Star), R(13), + B(LdaNamedProperty), R(13), U8(5), U8(15), + B(JumpIfToBooleanTrue), U8(56), + B(LdaContextSlot), R(1), U8(8), U8(0), + B(Star), R(13), + B(LdaNamedProperty), R(13), U8(6), U8(17), + B(StaContextSlot), R(1), U8(12), U8(0), + B(LdaSmi), I8(2), + B(StaContextSlot), R(1), U8(9), U8(0), + B(LdaContextSlot), R(1), U8(12), U8(0), + B(StaContextSlot), R(1), U8(6), U8(0), + /* 23 E> */ B(StackCheck), + B(Ldar), R(closure), + B(CreateBlockContext), U8(7), + B(PushContext), R(2), + B(LdaTheHole), + B(StaCurrentContextSlot), U8(4), + B(LdaContextSlot), R(1), U8(6), U8(0), + B(StaCurrentContextSlot), U8(4), + B(PopContext), R(2), + B(LdaZero), + B(StaContextSlot), R(1), U8(9), U8(0), + B(JumpLoop), U8(226), I8(0), + B(Jump), U8(48), + B(Star), R(13), + B(Ldar), R(closure), + B(CreateCatchContext), R(13), U8(8), U8(9), + B(Star), R(12), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(12), + B(PushContext), R(2), + B(LdaContextSlot), R(1), U8(9), U8(0), + B(Star), R(13), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(13), U8(19), + B(JumpIfFalse), U8(8), + B(LdaSmi), I8(1), + B(StaContextSlot), R(1), U8(9), U8(0), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kReThrow), R(13), U8(1), + B(PopContext), R(2), + B(LdaSmi), I8(-1), + B(Star), R(9), + B(Jump), U8(8), + B(Star), R(10), + B(LdaSmi), I8(1), + B(Star), R(9), + B(LdaTheHole), + B(SetPendingMessage), + B(Star), R(11), + B(LdaContextSlot), R(1), U8(9), U8(0), + B(Star), R(12), + B(LdaZero), + B(TestEqualStrict), R(12), U8(20), + B(JumpIfTrueConstant), U8(17), + B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(12), + B(LdaNamedProperty), R(12), U8(10), U8(21), + B(StaContextSlot), R(1), U8(13), U8(0), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(Star), R(12), + B(TestUndetectable), R(12), + B(JumpIfFalse), U8(4), + B(JumpConstant), U8(16), + B(LdaContextSlot), R(1), U8(9), U8(0), + B(Star), R(12), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(12), U8(24), + B(JumpIfFalse), U8(186), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(TypeOf), + B(Star), R(12), + B(LdaConstant), U8(11), + B(TestEqualStrict), R(12), U8(25), + B(JumpIfFalse), U8(4), + B(Jump), U8(18), + B(Wide), B(LdaSmi), I16(130), + B(Star), R(12), + B(LdaConstant), U8(12), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kNewTypeError), R(12), U8(2), + B(Throw), + B(Mov), R(context), R(12), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(Star), R(13), + B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(14), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(13), U8(2), + B(StaContextSlot), R(1), U8(14), U8(0), + B(LdaUndefined), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaContextSlot), R(1), U8(14), U8(0), + B(Star), R(15), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(16), + B(CallJSRuntime), U8(%async_function_await_caught), R(13), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaSmi), I8(1), + B(SuspendGenerator), R(14), + B(Ldar), R(13), + /* 57 S> */ B(Return), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(14), U8(1), + B(Star), R(15), + B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(14), U8(1), + B(Star), R(16), + B(LdaZero), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(39), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(29), + B(Jump), U8(2), + B(LdaTrue), + B(Star), R(18), + B(Mov), R(15), R(17), + B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(17), U8(2), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(Star), R(6), + B(LdaZero), + B(Star), R(5), + B(JumpConstant), U8(19), + B(Ldar), R(15), + B(ReThrow), + B(Ldar), R(15), + B(Jump), U8(20), + B(Star), R(13), + B(Ldar), R(closure), + B(CreateCatchContext), R(13), U8(8), U8(14), + B(Star), R(12), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(12), + B(PushContext), R(2), + B(PopContext), R(2), + B(Jump), U8(159), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(Star), R(12), + B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(13), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(12), U8(2), + B(StaContextSlot), R(1), U8(16), U8(0), + B(LdaUndefined), + B(Star), R(12), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(13), + B(LdaContextSlot), R(1), U8(16), U8(0), + B(Star), R(14), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(15), + B(CallJSRuntime), U8(%async_function_await_uncaught), R(12), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(12), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(13), + B(LdaSmi), I8(2), + B(SuspendGenerator), R(13), + B(Ldar), R(12), + /* 57 S> */ B(Return), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(13), U8(1), + B(Star), R(14), + B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(13), U8(1), + B(Star), R(15), + B(LdaZero), + B(TestEqualStrict), R(15), U8(0), + B(JumpIfTrue), U8(40), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(15), U8(0), + B(JumpIfTrue), U8(30), + B(Jump), U8(2), + B(LdaTrue), + B(Star), R(17), + B(Mov), R(14), R(16), + B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(16), U8(2), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(Star), R(6), + B(LdaSmi), I8(1), + B(Star), R(5), + B(Jump), U8(170), + B(Ldar), R(14), + B(ReThrow), + B(Ldar), R(14), + B(StaContextSlot), R(1), U8(15), U8(0), + B(LdaContextSlot), R(1), U8(15), U8(0), + B(Star), R(12), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(12), U8(1), + B(JumpIfToBooleanFalse), U8(4), + B(Jump), U8(13), + B(LdaContextSlot), R(1), U8(15), U8(0), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), + B(Ldar), R(11), + B(SetPendingMessage), + B(LdaZero), + B(TestEqualStrict), R(9), U8(0), + B(JumpIfTrue), U8(11), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(9), U8(0), + B(JumpIfTrue), U8(21), + B(Jump), U8(26), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(LdaSmi), I8(2), + B(Star), R(5), + B(Mov), R(10), R(6), + B(Jump), U8(101), + B(PopContext), R(1), + B(PopContext), R(1), + B(Ldar), R(10), + B(ReThrow), + B(PopContext), R(1), + B(LdaUndefined), + B(Star), R(9), + B(LdaCurrentContextSlot), U8(10), + B(Star), R(10), + B(LdaUndefined), + B(Star), R(11), + B(CallJSRuntime), U8(%promise_resolve), R(9), U8(3), + B(LdaCurrentContextSlot), U8(10), + B(Star), R(6), + B(LdaSmi), I8(3), + B(Star), R(5), + B(Jump), U8(68), + B(Jump), U8(54), + B(Star), R(9), + B(Ldar), R(closure), + B(CreateCatchContext), R(9), U8(8), U8(18), + B(Star), R(8), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(8), + B(PushContext), R(1), + B(LdaUndefined), + B(Star), R(9), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(10), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(11), + B(LdaFalse), + B(Star), R(12), + B(CallJSRuntime), U8(%promise_internal_reject), R(9), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(PopContext), R(1), + B(PopContext), R(1), + B(Star), R(6), + B(LdaSmi), I8(4), + B(Star), R(5), + B(Jump), U8(14), + B(LdaSmi), I8(-1), + B(Star), R(5), + B(Jump), U8(8), + B(Star), R(6), + B(LdaSmi), I8(5), + B(Star), R(5), + B(LdaTheHole), + B(SetPendingMessage), + B(Star), R(7), + B(LdaUndefined), + B(Star), R(8), + B(LdaCurrentContextSlot), U8(10), + B(Star), R(9), + B(CallJSRuntime), U8(%async_function_promise_release), R(8), U8(2), + B(Ldar), R(7), + B(SetPendingMessage), + B(LdaZero), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(39), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(35), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(31), + B(LdaSmi), I8(3), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(27), + B(LdaSmi), I8(4), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(23), + B(LdaSmi), I8(5), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(19), + B(Jump), U8(20), + B(Ldar), R(6), + /* 57 S> */ B(Return), + B(Ldar), R(6), + /* 57 S> */ B(Return), + B(Ldar), R(6), + /* 57 S> */ B(Return), + B(Ldar), R(6), + /* 57 S> */ B(Return), + B(Ldar), R(6), + /* 57 S> */ B(Return), + B(Ldar), R(6), + B(ReThrow), + B(LdaUndefined), + /* 57 S> */ B(Return), +] +constant pool: [ + FIXED_ARRAY_TYPE, + CONSTANT_ELEMENTS_PAIR_TYPE, + SYMBOL_TYPE, + SYMBOL_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], + FIXED_ARRAY_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"], + FIXED_ARRAY_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["function"], + ONE_BYTE_INTERNALIZED_STRING_TYPE [""], + Smi [572], + FIXED_ARRAY_TYPE, + Smi [714], + Smi [356], + Smi [382], + FIXED_ARRAY_TYPE, + Smi [320], +] +handlers: [ + [83, 962, 968], + [86, 908, 910], + [103, 432, 438], + [106, 384, 386], + [534, 661, 663], +] + +--- +snippet: " + async function f() { + for await (let x of [1, 2, 3]) { return x; } + } + f(); +" +frame size: 19 +parameter count: 1 +bytecode array length: 1115 +bytecodes: [ + B(Ldar), R(new_target), + B(JumpIfUndefined), U8(42), + B(CallRuntime), U16(Runtime::k_GeneratorGetContext), R(new_target), U8(1), + B(PushContext), R(4), + B(ResumeGenerator), R(new_target), + B(Star), R(3), + B(LdaZero), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrue), U8(136), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrueConstant), U8(13), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrueConstant), U8(15), + B(LdaSmi), I8(78), + B(Star), R(5), + B(CallRuntime), U16(Runtime::kAbort), R(5), U8(1), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CreateFunctionContext), U8(13), + B(PushContext), R(0), + B(Ldar), R(this), + B(StaCurrentContextSlot), U8(4), + /* 16 E> */ B(StackCheck), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(6), + B(Mov), R(closure), R(5), + B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(5), U8(2), + B(StaCurrentContextSlot), U8(5), + B(LdaUndefined), + B(Star), R(5), + B(CallJSRuntime), U8(%async_function_promise_create), R(5), U8(1), + B(StaCurrentContextSlot), U8(10), + B(Mov), R(context), R(7), + B(Mov), R(context), R(8), + B(Ldar), R(closure), + B(CreateBlockContext), U8(0), + B(PushContext), R(1), + B(LdaTheHole), + B(StaCurrentContextSlot), U8(4), + B(LdaZero), + B(StaContextSlot), R(1), U8(9), U8(0), + B(Mov), R(context), R(11), + B(Mov), R(context), R(12), + /* 43 S> */ B(CreateArrayLiteral), U8(1), U8(2), U8(9), + B(Star), R(13), + B(LdaNamedProperty), R(13), U8(2), U8(7), + B(JumpIfUndefined), U8(18), + B(JumpIfNull), U8(16), + B(Star), R(14), + B(CallProperty), R(14), R(13), U8(1), U8(9), + B(JumpIfJSReceiver), U8(24), + B(CallRuntime), U16(Runtime::kThrowSymbolAsyncIteratorInvalid), R(0), U8(0), + B(LdaNamedProperty), R(13), U8(3), U8(3), + B(Star), R(14), + B(CallProperty), R(14), R(13), U8(1), U8(5), + B(Star), R(14), + B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(14), U8(1), + /* 43 E> */ B(StaContextSlot), R(1), U8(7), U8(0), + B(LdaSmi), I8(-2), + B(TestEqual), R(3), U8(0), + B(JumpIfTrue), U8(17), + B(LdaZero), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrue), U8(75), + B(LdaSmi), I8(78), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kAbort), R(13), U8(1), + /* 40 S> */ B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(14), + B(LdaNamedProperty), R(14), U8(4), U8(13), + B(Star), R(13), + /* 40 E> */ B(CallProperty), R(13), R(14), U8(1), U8(11), + B(StaContextSlot), R(1), U8(11), U8(0), + /* 40 S> */ B(LdaUndefined), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaContextSlot), R(1), U8(11), U8(0), + B(Star), R(15), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(16), + B(CallJSRuntime), U8(%async_function_await_uncaught), R(13), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaZero), + B(SuspendGenerator), R(14), + B(Ldar), R(13), + /* 68 S> */ B(Return), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(14), U8(1), + B(Star), R(15), + B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(14), U8(1), + B(Star), R(16), + B(LdaZero), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(31), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(21), + B(Jump), U8(2), + B(LdaTrue), + B(Star), R(18), + B(Mov), R(15), R(17), + B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(17), U8(2), + B(Star), R(10), + B(LdaZero), + B(Star), R(9), + B(Jump), U8(167), + B(Ldar), R(15), + B(ReThrow), + B(Ldar), R(15), + /* 40 E> */ B(StaContextSlot), R(1), U8(8), U8(0), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(15), U8(1), + B(ToBooleanLogicalNot), + B(JumpIfFalse), U8(13), + B(LdaContextSlot), R(1), U8(8), U8(0), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), + B(LdaContextSlot), R(1), U8(8), U8(0), + B(Star), R(13), + B(LdaNamedProperty), R(13), U8(5), U8(15), + B(JumpIfToBooleanTrue), U8(68), + B(LdaContextSlot), R(1), U8(8), U8(0), + B(Star), R(13), + B(LdaNamedProperty), R(13), U8(6), U8(17), + B(StaContextSlot), R(1), U8(12), U8(0), + B(LdaSmi), I8(2), + B(StaContextSlot), R(1), U8(9), U8(0), + B(LdaContextSlot), R(1), U8(12), U8(0), + B(StaContextSlot), R(1), U8(6), U8(0), + /* 23 E> */ B(StackCheck), + B(Ldar), R(closure), + B(CreateBlockContext), U8(7), + B(PushContext), R(2), + B(LdaTheHole), + B(StaCurrentContextSlot), U8(4), + B(LdaContextSlot), R(1), U8(6), U8(0), + B(StaCurrentContextSlot), U8(4), + /* 56 S> */ B(LdaImmutableCurrentContextSlot), U8(4), + B(PopContext), R(2), + B(PopContext), R(2), + B(PopContext), R(2), + B(PopContext), R(2), + B(PopContext), R(2), + B(PopContext), R(2), + B(Star), R(10), + B(LdaSmi), I8(1), + B(Star), R(9), + B(Jump), U8(62), + B(Jump), U8(48), + B(Star), R(13), + B(Ldar), R(closure), + B(CreateCatchContext), R(13), U8(8), U8(9), + B(Star), R(12), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(12), + B(PushContext), R(2), + B(LdaContextSlot), R(1), U8(9), U8(0), + B(Star), R(13), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(13), U8(19), + B(JumpIfFalse), U8(8), + B(LdaSmi), I8(1), + B(StaContextSlot), R(1), U8(9), U8(0), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kReThrow), R(13), U8(1), + B(PopContext), R(2), + B(LdaSmi), I8(-1), + B(Star), R(9), + B(Jump), U8(8), + B(Star), R(10), + B(LdaSmi), I8(2), + B(Star), R(9), + B(LdaTheHole), + B(SetPendingMessage), + B(Star), R(11), + B(LdaContextSlot), R(1), U8(9), U8(0), + B(Star), R(12), + B(LdaZero), + B(TestEqualStrict), R(12), U8(20), + B(JumpIfTrueConstant), U8(17), + B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(12), + B(LdaNamedProperty), R(12), U8(10), U8(21), + B(StaContextSlot), R(1), U8(13), U8(0), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(Star), R(12), + B(TestUndetectable), R(12), + B(JumpIfFalse), U8(4), + B(JumpConstant), U8(16), + B(LdaContextSlot), R(1), U8(9), U8(0), + B(Star), R(12), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(12), U8(24), + B(JumpIfFalse), U8(186), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(TypeOf), + B(Star), R(12), + B(LdaConstant), U8(11), + B(TestEqualStrict), R(12), U8(25), + B(JumpIfFalse), U8(4), + B(Jump), U8(18), + B(Wide), B(LdaSmi), I16(130), + B(Star), R(12), + B(LdaConstant), U8(12), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kNewTypeError), R(12), U8(2), + B(Throw), + B(Mov), R(context), R(12), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(Star), R(13), + B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(14), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(13), U8(2), + B(StaContextSlot), R(1), U8(14), U8(0), + B(LdaUndefined), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaContextSlot), R(1), U8(14), U8(0), + B(Star), R(15), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(16), + B(CallJSRuntime), U8(%async_function_await_caught), R(13), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaSmi), I8(1), + B(SuspendGenerator), R(14), + B(Ldar), R(13), + /* 68 S> */ B(Return), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(14), U8(1), + B(Star), R(15), + B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(14), U8(1), + B(Star), R(16), + B(LdaZero), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(39), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(29), + B(Jump), U8(2), + B(LdaTrue), + B(Star), R(18), + B(Mov), R(15), R(17), + B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(17), U8(2), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(Star), R(6), + B(LdaZero), + B(Star), R(5), + B(JumpConstant), U8(19), + B(Ldar), R(15), + B(ReThrow), + B(Ldar), R(15), + B(Jump), U8(20), + B(Star), R(13), + B(Ldar), R(closure), + B(CreateCatchContext), R(13), U8(8), U8(14), + B(Star), R(12), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(12), + B(PushContext), R(2), + B(PopContext), R(2), + B(Jump), U8(159), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(Star), R(12), + B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(13), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(12), U8(2), + B(StaContextSlot), R(1), U8(16), U8(0), + B(LdaUndefined), + B(Star), R(12), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(13), + B(LdaContextSlot), R(1), U8(16), U8(0), + B(Star), R(14), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(15), + B(CallJSRuntime), U8(%async_function_await_uncaught), R(12), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(12), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(13), + B(LdaSmi), I8(2), + B(SuspendGenerator), R(13), + B(Ldar), R(12), + /* 68 S> */ B(Return), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(13), U8(1), + B(Star), R(14), + B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(13), U8(1), + B(Star), R(15), + B(LdaZero), + B(TestEqualStrict), R(15), U8(0), + B(JumpIfTrue), U8(40), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(15), U8(0), + B(JumpIfTrue), U8(30), + B(Jump), U8(2), + B(LdaTrue), + B(Star), R(17), + B(Mov), R(14), R(16), + B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(16), U8(2), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(Star), R(6), + B(LdaSmi), I8(1), + B(Star), R(5), + B(Jump), U8(194), + B(Ldar), R(14), + B(ReThrow), + B(Ldar), R(14), + B(StaContextSlot), R(1), U8(15), U8(0), + B(LdaContextSlot), R(1), U8(15), U8(0), + B(Star), R(12), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(12), U8(1), + B(JumpIfToBooleanFalse), U8(4), + B(Jump), U8(13), + B(LdaContextSlot), R(1), U8(15), U8(0), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), + B(Ldar), R(11), + B(SetPendingMessage), + B(LdaZero), + B(TestEqualStrict), R(9), U8(0), + B(JumpIfTrue), U8(18), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(9), U8(0), + B(JumpIfTrue), U8(28), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(9), U8(0), + B(JumpIfTrue), U8(38), + B(Jump), U8(43), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(LdaSmi), I8(2), + B(Star), R(5), + B(Mov), R(10), R(6), + B(Jump), U8(118), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(LdaSmi), I8(3), + B(Star), R(5), + B(Mov), R(10), R(6), + B(Jump), U8(101), + B(PopContext), R(1), + B(PopContext), R(1), + B(Ldar), R(10), + B(ReThrow), + B(PopContext), R(1), + B(LdaUndefined), + B(Star), R(9), + B(LdaCurrentContextSlot), U8(10), + B(Star), R(10), + B(LdaUndefined), + B(Star), R(11), + B(CallJSRuntime), U8(%promise_resolve), R(9), U8(3), + B(LdaCurrentContextSlot), U8(10), + B(Star), R(6), + B(LdaSmi), I8(4), + B(Star), R(5), + B(Jump), U8(68), + B(Jump), U8(54), + B(Star), R(9), + B(Ldar), R(closure), + B(CreateCatchContext), R(9), U8(8), U8(18), + B(Star), R(8), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(8), + B(PushContext), R(1), + B(LdaUndefined), + B(Star), R(9), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(10), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(11), + B(LdaFalse), + B(Star), R(12), + B(CallJSRuntime), U8(%promise_internal_reject), R(9), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(PopContext), R(1), + B(PopContext), R(1), + B(Star), R(6), + B(LdaSmi), I8(5), + B(Star), R(5), + B(Jump), U8(14), + B(LdaSmi), I8(-1), + B(Star), R(5), + B(Jump), U8(8), + B(Star), R(6), + B(LdaSmi), I8(6), + B(Star), R(5), + B(LdaTheHole), + B(SetPendingMessage), + B(Star), R(7), + B(LdaUndefined), + B(Star), R(8), + B(LdaCurrentContextSlot), U8(10), + B(Star), R(9), + B(CallJSRuntime), U8(%async_function_promise_release), R(8), U8(2), + B(Ldar), R(7), + B(SetPendingMessage), + B(LdaZero), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(46), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(42), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(38), + B(LdaSmi), I8(3), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(34), + B(LdaSmi), I8(4), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(44), + B(LdaSmi), I8(5), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(40), + B(LdaSmi), I8(6), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(36), + B(Jump), U8(37), + B(Ldar), R(6), + /* 68 S> */ B(Return), + B(Ldar), R(6), + /* 68 S> */ B(Return), + B(Ldar), R(6), + /* 68 S> */ B(Return), + B(LdaCurrentContextSlot), U8(10), + B(Star), R(9), + B(LdaUndefined), + B(Star), R(8), + B(Mov), R(6), R(10), + B(CallJSRuntime), U8(%promise_resolve), R(8), U8(3), + B(Ldar), R(9), + /* 68 S> */ B(Return), + B(Ldar), R(6), + /* 68 S> */ B(Return), + B(Ldar), R(6), + /* 68 S> */ B(Return), + B(Ldar), R(6), + B(ReThrow), + B(LdaUndefined), + /* 68 S> */ B(Return), +] +constant pool: [ + FIXED_ARRAY_TYPE, + CONSTANT_ELEMENTS_PAIR_TYPE, + SYMBOL_TYPE, + SYMBOL_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], + FIXED_ARRAY_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"], + FIXED_ARRAY_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["function"], + ONE_BYTE_INTERNALIZED_STRING_TYPE [""], + Smi [584], + FIXED_ARRAY_TYPE, + Smi [726], + Smi [356], + Smi [382], + FIXED_ARRAY_TYPE, + Smi [344], +] +handlers: [ + [83, 998, 1004], + [86, 944, 946], + [103, 444, 450], + [106, 396, 398], + [546, 673, 675], +] + +--- +snippet: " + async function f() { + for await (let x of [10, 20, 30]) { + if (x == 10) continue; + if (x == 20) break; + } + } + f(); +" +frame size: 19 +parameter count: 1 +bytecode array length: 1092 +bytecodes: [ + B(Ldar), R(new_target), + B(JumpIfUndefined), U8(42), + B(CallRuntime), U16(Runtime::k_GeneratorGetContext), R(new_target), U8(1), + B(PushContext), R(4), + B(ResumeGenerator), R(new_target), + B(Star), R(3), + B(LdaZero), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrue), U8(136), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrueConstant), U8(13), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrueConstant), U8(15), + B(LdaSmi), I8(78), + B(Star), R(5), + B(CallRuntime), U16(Runtime::kAbort), R(5), U8(1), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CreateFunctionContext), U8(13), + B(PushContext), R(0), + B(Ldar), R(this), + B(StaCurrentContextSlot), U8(4), + /* 16 E> */ B(StackCheck), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(6), + B(Mov), R(closure), R(5), + B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(5), U8(2), + B(StaCurrentContextSlot), U8(5), + B(LdaUndefined), + B(Star), R(5), + B(CallJSRuntime), U8(%async_function_promise_create), R(5), U8(1), + B(StaCurrentContextSlot), U8(10), + B(Mov), R(context), R(7), + B(Mov), R(context), R(8), + B(Ldar), R(closure), + B(CreateBlockContext), U8(0), + B(PushContext), R(1), + B(LdaTheHole), + B(StaCurrentContextSlot), U8(4), + B(LdaZero), + B(StaContextSlot), R(1), U8(9), U8(0), + B(Mov), R(context), R(11), + B(Mov), R(context), R(12), + /* 43 S> */ B(CreateArrayLiteral), U8(1), U8(2), U8(9), + B(Star), R(13), + B(LdaNamedProperty), R(13), U8(2), U8(7), + B(JumpIfUndefined), U8(18), + B(JumpIfNull), U8(16), + B(Star), R(14), + B(CallProperty), R(14), R(13), U8(1), U8(9), + B(JumpIfJSReceiver), U8(24), + B(CallRuntime), U16(Runtime::kThrowSymbolAsyncIteratorInvalid), R(0), U8(0), + B(LdaNamedProperty), R(13), U8(3), U8(3), + B(Star), R(14), + B(CallProperty), R(14), R(13), U8(1), U8(5), + B(Star), R(14), + B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(14), U8(1), + /* 43 E> */ B(StaContextSlot), R(1), U8(7), U8(0), + B(LdaSmi), I8(-2), + B(TestEqual), R(3), U8(0), + B(JumpIfTrue), U8(17), + B(LdaZero), + B(TestEqualStrict), R(3), U8(0), + B(JumpIfTrue), U8(75), + B(LdaSmi), I8(78), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kAbort), R(13), U8(1), + /* 40 S> */ B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(14), + B(LdaNamedProperty), R(14), U8(4), U8(13), + B(Star), R(13), + /* 40 E> */ B(CallProperty), R(13), R(14), U8(1), U8(11), + B(StaContextSlot), R(1), U8(11), U8(0), + /* 40 S> */ B(LdaUndefined), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaContextSlot), R(1), U8(11), U8(0), + B(Star), R(15), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(16), + B(CallJSRuntime), U8(%async_function_await_uncaught), R(13), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaZero), + B(SuspendGenerator), R(14), + B(Ldar), R(13), + /* 114 S> */ B(Return), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(14), U8(1), + B(Star), R(15), + B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(14), U8(1), + B(Star), R(16), + B(LdaZero), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(31), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(21), + B(Jump), U8(2), + B(LdaTrue), + B(Star), R(18), + B(Mov), R(15), R(17), + B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(17), U8(2), + B(Star), R(10), + B(LdaZero), + B(Star), R(9), + B(Jump), U8(192), + B(Ldar), R(15), + B(ReThrow), + B(Ldar), R(15), + /* 40 E> */ B(StaContextSlot), R(1), U8(8), U8(0), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(15), U8(1), + B(ToBooleanLogicalNot), + B(JumpIfFalse), U8(13), + B(LdaContextSlot), R(1), U8(8), U8(0), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), + B(LdaContextSlot), R(1), U8(8), U8(0), + B(Star), R(13), + B(LdaNamedProperty), R(13), U8(5), U8(15), + B(JumpIfToBooleanTrue), U8(93), + B(LdaContextSlot), R(1), U8(8), U8(0), + B(Star), R(13), + B(LdaNamedProperty), R(13), U8(6), U8(17), + B(StaContextSlot), R(1), U8(12), U8(0), + B(LdaSmi), I8(2), + B(StaContextSlot), R(1), U8(9), U8(0), + B(LdaContextSlot), R(1), U8(12), U8(0), + B(StaContextSlot), R(1), U8(6), U8(0), + /* 23 E> */ B(StackCheck), + B(Ldar), R(closure), + B(CreateBlockContext), U8(7), + B(PushContext), R(2), + B(LdaTheHole), + B(StaCurrentContextSlot), U8(4), + B(LdaContextSlot), R(1), U8(6), U8(0), + B(StaCurrentContextSlot), U8(4), + /* 63 S> */ B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(13), + B(LdaSmi), I8(10), + /* 69 E> */ B(TestEqual), R(13), U8(19), + B(JumpIfFalse), U8(8), + /* 76 S> */ B(PopContext), R(2), + B(PopContext), R(2), + B(Jump), U8(26), + /* 90 S> */ B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(13), + B(LdaSmi), I8(20), + /* 96 E> */ B(TestEqual), R(13), U8(20), + B(JumpIfFalse), U8(8), + /* 103 S> */ B(PopContext), R(2), + B(PopContext), R(2), + B(Jump), U8(15), + B(PopContext), R(2), + B(LdaZero), + B(StaContextSlot), R(1), U8(9), U8(0), + B(Wide), B(JumpLoop), U16(261), I16(0), + B(Jump), U8(48), + B(Star), R(13), + B(Ldar), R(closure), + B(CreateCatchContext), R(13), U8(8), U8(9), + B(Star), R(12), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(12), + B(PushContext), R(2), + B(LdaContextSlot), R(1), U8(9), U8(0), + B(Star), R(13), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(13), U8(21), + B(JumpIfFalse), U8(8), + B(LdaSmi), I8(1), + B(StaContextSlot), R(1), U8(9), U8(0), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kReThrow), R(13), U8(1), + B(PopContext), R(2), + B(LdaSmi), I8(-1), + B(Star), R(9), + B(Jump), U8(8), + B(Star), R(10), + B(LdaSmi), I8(1), + B(Star), R(9), + B(LdaTheHole), + B(SetPendingMessage), + B(Star), R(11), + B(LdaContextSlot), R(1), U8(9), U8(0), + B(Star), R(12), + B(LdaZero), + B(TestEqualStrict), R(12), U8(22), + B(JumpIfTrueConstant), U8(17), + B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(12), + B(LdaNamedProperty), R(12), U8(10), U8(23), + B(StaContextSlot), R(1), U8(13), U8(0), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(Star), R(12), + B(TestUndetectable), R(12), + B(JumpIfFalse), U8(4), + B(JumpConstant), U8(16), + B(LdaContextSlot), R(1), U8(9), U8(0), + B(Star), R(12), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(12), U8(26), + B(JumpIfFalse), U8(186), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(TypeOf), + B(Star), R(12), + B(LdaConstant), U8(11), + B(TestEqualStrict), R(12), U8(27), + B(JumpIfFalse), U8(4), + B(Jump), U8(18), + B(Wide), B(LdaSmi), I16(130), + B(Star), R(12), + B(LdaConstant), U8(12), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kNewTypeError), R(12), U8(2), + B(Throw), + B(Mov), R(context), R(12), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(Star), R(13), + B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(14), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(13), U8(2), + B(StaContextSlot), R(1), U8(14), U8(0), + B(LdaUndefined), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaContextSlot), R(1), U8(14), U8(0), + B(Star), R(15), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(16), + B(CallJSRuntime), U8(%async_function_await_caught), R(13), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(13), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(14), + B(LdaSmi), I8(1), + B(SuspendGenerator), R(14), + B(Ldar), R(13), + /* 114 S> */ B(Return), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(14), U8(1), + B(Star), R(15), + B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(14), U8(1), + B(Star), R(16), + B(LdaZero), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(39), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(16), U8(0), + B(JumpIfTrue), U8(29), + B(Jump), U8(2), + B(LdaTrue), + B(Star), R(18), + B(Mov), R(15), R(17), + B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(17), U8(2), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(Star), R(6), + B(LdaZero), + B(Star), R(5), + B(JumpConstant), U8(19), + B(Ldar), R(15), + B(ReThrow), + B(Ldar), R(15), + B(Jump), U8(20), + B(Star), R(13), + B(Ldar), R(closure), + B(CreateCatchContext), R(13), U8(8), U8(14), + B(Star), R(12), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(12), + B(PushContext), R(2), + B(PopContext), R(2), + B(Jump), U8(159), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(Star), R(12), + B(LdaContextSlot), R(1), U8(7), U8(0), + B(Star), R(13), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(12), U8(2), + B(StaContextSlot), R(1), U8(16), U8(0), + B(LdaUndefined), + B(Star), R(12), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(13), + B(LdaContextSlot), R(1), U8(16), U8(0), + B(Star), R(14), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(15), + B(CallJSRuntime), U8(%async_function_await_uncaught), R(12), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(12), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), + B(Star), R(13), + B(LdaSmi), I8(2), + B(SuspendGenerator), R(13), + B(Ldar), R(12), + /* 114 S> */ B(Return), + B(LdaSmi), I8(-2), + B(Star), R(3), + B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(13), U8(1), + B(Star), R(14), + B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(13), U8(1), + B(Star), R(15), + B(LdaZero), + B(TestEqualStrict), R(15), U8(0), + B(JumpIfTrue), U8(40), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(15), U8(0), + B(JumpIfTrue), U8(30), + B(Jump), U8(2), + B(LdaTrue), + B(Star), R(17), + B(Mov), R(14), R(16), + B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(16), U8(2), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(Star), R(6), + B(LdaSmi), I8(1), + B(Star), R(5), + B(Jump), U8(170), + B(Ldar), R(14), + B(ReThrow), + B(Ldar), R(14), + B(StaContextSlot), R(1), U8(15), U8(0), + B(LdaContextSlot), R(1), U8(15), U8(0), + B(Star), R(12), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(12), U8(1), + B(JumpIfToBooleanFalse), U8(4), + B(Jump), U8(13), + B(LdaContextSlot), R(1), U8(15), U8(0), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), + B(Ldar), R(11), + B(SetPendingMessage), + B(LdaZero), + B(TestEqualStrict), R(9), U8(0), + B(JumpIfTrue), U8(11), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(9), U8(0), + B(JumpIfTrue), U8(21), + B(Jump), U8(26), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(PopContext), R(1), + B(LdaSmi), I8(2), + B(Star), R(5), + B(Mov), R(10), R(6), + B(Jump), U8(101), + B(PopContext), R(1), + B(PopContext), R(1), + B(Ldar), R(10), + B(ReThrow), + B(PopContext), R(1), + B(LdaUndefined), + B(Star), R(9), + B(LdaCurrentContextSlot), U8(10), + B(Star), R(10), + B(LdaUndefined), + B(Star), R(11), + B(CallJSRuntime), U8(%promise_resolve), R(9), U8(3), + B(LdaCurrentContextSlot), U8(10), + B(Star), R(6), + B(LdaSmi), I8(3), + B(Star), R(5), + B(Jump), U8(68), + B(Jump), U8(54), + B(Star), R(9), + B(Ldar), R(closure), + B(CreateCatchContext), R(9), U8(8), U8(18), + B(Star), R(8), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(8), + B(PushContext), R(1), + B(LdaUndefined), + B(Star), R(9), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(Star), R(10), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(11), + B(LdaFalse), + B(Star), R(12), + B(CallJSRuntime), U8(%promise_internal_reject), R(9), U8(4), + B(LdaContextSlot), R(1), U8(10), U8(0), + B(PopContext), R(1), + B(PopContext), R(1), + B(Star), R(6), + B(LdaSmi), I8(4), + B(Star), R(5), + B(Jump), U8(14), + B(LdaSmi), I8(-1), + B(Star), R(5), + B(Jump), U8(8), + B(Star), R(6), + B(LdaSmi), I8(5), + B(Star), R(5), + B(LdaTheHole), + B(SetPendingMessage), + B(Star), R(7), + B(LdaUndefined), + B(Star), R(8), + B(LdaCurrentContextSlot), U8(10), + B(Star), R(9), + B(CallJSRuntime), U8(%async_function_promise_release), R(8), U8(2), + B(Ldar), R(7), + B(SetPendingMessage), + B(LdaZero), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(39), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(35), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(31), + B(LdaSmi), I8(3), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(27), + B(LdaSmi), I8(4), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(23), + B(LdaSmi), I8(5), + B(TestEqualStrict), R(5), U8(0), + B(JumpIfTrue), U8(19), + B(Jump), U8(20), + B(Ldar), R(6), + /* 114 S> */ B(Return), + B(Ldar), R(6), + /* 114 S> */ B(Return), + B(Ldar), R(6), + /* 114 S> */ B(Return), + B(Ldar), R(6), + /* 114 S> */ B(Return), + B(Ldar), R(6), + /* 114 S> */ B(Return), + B(Ldar), R(6), + B(ReThrow), + B(LdaUndefined), + /* 114 S> */ B(Return), +] +constant pool: [ + FIXED_ARRAY_TYPE, + CONSTANT_ELEMENTS_PAIR_TYPE, + SYMBOL_TYPE, + SYMBOL_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], + FIXED_ARRAY_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"], + FIXED_ARRAY_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["function"], + ONE_BYTE_INTERNALIZED_STRING_TYPE [""], + Smi [609], + FIXED_ARRAY_TYPE, + Smi [751], + Smi [356], + Smi [382], + FIXED_ARRAY_TYPE, + Smi [320], +] +handlers: [ + [83, 999, 1005], + [86, 945, 947], + [103, 469, 475], + [106, 421, 423], + [571, 698, 700], +] + +--- +snippet: " + async function f() { + var x = { 'a': 1, 'b': 2 }; + for (x['a'] of [1,2,3]) { return x['a']; } + } + f(); +" +frame size: 14 +parameter count: 1 +bytecode array length: 596 +bytecodes: [ + B(Ldar), R(new_target), + B(JumpIfUndefined), U8(22), + B(CallRuntime), U16(Runtime::k_GeneratorGetContext), R(new_target), U8(1), + B(PushContext), R(3), + B(ResumeGenerator), R(new_target), + B(Star), R(2), + B(LdaSmi), I8(78), + B(Star), R(4), + B(CallRuntime), U16(Runtime::kAbort), R(4), U8(1), + B(LdaSmi), I8(-2), + B(Star), R(2), + B(CreateFunctionContext), U8(10), + B(PushContext), R(0), + B(Ldar), R(this), + B(StaCurrentContextSlot), U8(4), + /* 16 E> */ B(StackCheck), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(5), + B(Mov), R(closure), R(4), + B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(4), U8(2), + B(StaCurrentContextSlot), U8(5), + B(LdaUndefined), + B(Star), R(4), + B(CallJSRuntime), U8(%async_function_promise_create), R(4), U8(1), + B(StaCurrentContextSlot), U8(13), + B(Mov), R(context), R(6), + B(Mov), R(context), R(7), + /* 31 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(8), + B(Ldar), R(8), + /* 31 E> */ B(StaCurrentContextSlot), U8(6), + B(LdaZero), + B(StaCurrentContextSlot), U8(9), + B(Mov), R(context), R(10), + B(Mov), R(context), R(11), + /* 68 S> */ B(CreateArrayLiteral), U8(1), U8(3), U8(9), + B(Star), R(12), + B(LdaNamedProperty), R(12), U8(2), U8(4), + B(Star), R(13), + B(CallProperty), R(13), R(12), U8(1), U8(6), + B(JumpIfJSReceiver), U8(7), + B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), + /* 68 E> */ B(StaCurrentContextSlot), U8(7), + /* 65 S> */ B(LdaCurrentContextSlot), U8(7), + B(Star), R(13), + B(LdaNamedProperty), R(13), U8(3), U8(10), + B(Star), R(12), + /* 65 E> */ B(CallProperty), R(12), R(13), U8(1), U8(8), + /* 65 E> */ B(StaCurrentContextSlot), U8(8), + B(Star), R(12), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(12), U8(1), + B(ToBooleanLogicalNot), + B(JumpIfFalse), U8(11), + B(LdaCurrentContextSlot), U8(8), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), + B(LdaCurrentContextSlot), U8(8), + B(Star), R(12), + B(LdaNamedProperty), R(12), U8(4), U8(12), + B(JumpIfToBooleanTrue), U8(42), + B(LdaImmutableCurrentContextSlot), U8(6), + B(Star), R(12), + B(LdaCurrentContextSlot), U8(8), + B(Star), R(13), + /* 58 E> */ B(LdaNamedProperty), R(13), U8(5), U8(14), + B(StaCurrentContextSlot), U8(10), + B(LdaSmi), I8(2), + B(StaCurrentContextSlot), U8(9), + B(LdaCurrentContextSlot), U8(10), + B(StaNamedPropertySloppy), R(12), U8(6), U8(16), + /* 53 E> */ B(StackCheck), + /* 79 S> */ B(LdaImmutableCurrentContextSlot), U8(6), + B(Star), R(12), + /* 87 E> */ B(LdaNamedProperty), R(12), U8(6), U8(18), + B(Star), R(9), + B(LdaZero), + B(Star), R(8), + B(Jump), U8(62), + B(Jump), U8(48), + B(Star), R(12), + B(Ldar), R(closure), + B(CreateCatchContext), R(12), U8(7), U8(8), + B(Star), R(11), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(11), + B(PushContext), R(1), + B(LdaContextSlot), R(1), U8(9), U8(0), + B(Star), R(12), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(12), U8(20), + B(JumpIfFalse), U8(8), + B(LdaSmi), I8(1), + B(StaContextSlot), R(1), U8(9), U8(0), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kReThrow), R(12), U8(1), + B(PopContext), R(1), + B(LdaSmi), I8(-1), + B(Star), R(8), + B(Jump), U8(8), + B(Star), R(9), + B(LdaSmi), I8(1), + B(Star), R(8), + B(LdaTheHole), + B(SetPendingMessage), + B(Star), R(10), + B(LdaCurrentContextSlot), U8(9), + B(Star), R(11), + B(LdaZero), + B(TestEqualStrict), R(11), U8(21), + B(JumpIfTrue), U8(135), + B(LdaCurrentContextSlot), U8(7), + B(Star), R(11), + B(LdaNamedProperty), R(11), U8(9), U8(22), + B(StaCurrentContextSlot), U8(11), + B(LdaCurrentContextSlot), U8(11), + B(Star), R(11), + B(TestUndetectable), R(11), + B(JumpIfFalse), U8(4), + B(Jump), U8(115), + B(LdaCurrentContextSlot), U8(9), + B(Star), R(11), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(11), U8(25), + B(JumpIfFalse), U8(69), + B(LdaCurrentContextSlot), U8(11), + B(TypeOf), + B(Star), R(11), + B(LdaConstant), U8(10), + B(TestEqualStrict), R(11), U8(26), + B(JumpIfFalse), U8(4), + B(Jump), U8(18), + B(Wide), B(LdaSmi), I16(130), + B(Star), R(11), + B(LdaConstant), U8(11), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kNewTypeError), R(11), U8(2), + B(Throw), + B(Mov), R(context), R(11), + B(LdaCurrentContextSlot), U8(11), + B(Star), R(12), + B(LdaCurrentContextSlot), U8(7), + B(Star), R(13), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(12), U8(2), + B(Jump), U8(20), + B(Star), R(12), + B(Ldar), R(closure), + B(CreateCatchContext), R(12), U8(7), U8(12), + B(Star), R(11), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(11), + B(PushContext), R(1), + B(PopContext), R(1), + B(Jump), U8(37), + B(LdaCurrentContextSlot), U8(11), + B(Star), R(11), + B(LdaCurrentContextSlot), U8(7), + B(Star), R(12), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(11), U8(2), + B(StaCurrentContextSlot), U8(12), + B(LdaCurrentContextSlot), U8(12), + B(Star), R(11), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(11), U8(1), + B(JumpIfToBooleanFalse), U8(4), + B(Jump), U8(11), + B(LdaCurrentContextSlot), U8(12), + B(Star), R(11), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), + B(Ldar), R(10), + B(SetPendingMessage), + B(LdaZero), + B(TestEqualStrict), R(8), U8(0), + B(JumpIfTrue), U8(11), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(8), U8(0), + B(JumpIfTrue), U8(12), + B(Jump), U8(13), + B(LdaZero), + B(Star), R(4), + B(Mov), R(9), R(5), + B(Jump), U8(95), + B(Ldar), R(9), + B(ReThrow), + B(LdaUndefined), + B(Star), R(8), + B(LdaCurrentContextSlot), U8(13), + B(Star), R(9), + B(LdaUndefined), + B(Star), R(10), + B(CallJSRuntime), U8(%promise_resolve), R(8), U8(3), + B(LdaCurrentContextSlot), U8(13), + B(Star), R(5), + B(LdaSmi), I8(1), + B(Star), R(4), + B(Jump), U8(68), + B(Jump), U8(54), + B(Star), R(8), + B(Ldar), R(closure), + B(CreateCatchContext), R(8), U8(7), U8(13), + B(Star), R(7), + B(LdaTheHole), + B(SetPendingMessage), + B(Ldar), R(7), + B(PushContext), R(1), + B(LdaUndefined), + B(Star), R(8), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(Star), R(9), + B(LdaImmutableCurrentContextSlot), U8(4), + B(Star), R(10), + B(LdaFalse), + B(Star), R(11), + B(CallJSRuntime), U8(%promise_internal_reject), R(8), U8(4), + B(LdaContextSlot), R(1), U8(13), U8(0), + B(PopContext), R(1), + B(PopContext), R(1), + B(Star), R(5), + B(LdaSmi), I8(2), + B(Star), R(4), + B(Jump), U8(14), + B(LdaSmi), I8(-1), + B(Star), R(4), + B(Jump), U8(8), + B(Star), R(5), + B(LdaSmi), I8(3), + B(Star), R(4), + B(LdaTheHole), + B(SetPendingMessage), + B(Star), R(6), + B(LdaUndefined), + B(Star), R(7), + B(LdaCurrentContextSlot), U8(13), + B(Star), R(8), + B(CallJSRuntime), U8(%async_function_promise_release), R(7), U8(2), + B(Ldar), R(6), + B(SetPendingMessage), + B(LdaZero), + B(TestEqualStrict), R(4), U8(0), + B(JumpIfTrue), U8(25), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(4), U8(0), + B(JumpIfTrue), U8(35), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(4), U8(0), + B(JumpIfTrue), U8(31), + B(LdaSmi), I8(3), + B(TestEqualStrict), R(4), U8(0), + B(JumpIfTrue), U8(27), + B(Jump), U8(28), + B(LdaCurrentContextSlot), U8(13), + B(Star), R(8), + B(LdaUndefined), + B(Star), R(7), + B(Mov), R(5), R(9), + B(CallJSRuntime), U8(%promise_resolve), R(7), U8(3), + B(Ldar), R(8), + /* 96 S> */ B(Return), + B(Ldar), R(5), + /* 96 S> */ B(Return), + B(Ldar), R(5), + /* 96 S> */ B(Return), + B(Ldar), R(5), + B(ReThrow), + B(LdaUndefined), + /* 96 S> */ B(Return), +] +constant pool: [ + FIXED_ARRAY_TYPE, + CONSTANT_ELEMENTS_PAIR_TYPE, + SYMBOL_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], + ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"], + FIXED_ARRAY_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["function"], + ONE_BYTE_INTERNALIZED_STRING_TYPE [""], + FIXED_ARRAY_TYPE, + FIXED_ARRAY_TYPE, +] +handlers: [ + [63, 509, 515], + [66, 455, 457], + [81, 243, 249], + [84, 195, 197], + [333, 345, 347], +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden index e03f83d3fc..a0e62b8519 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden @@ -85,7 +85,7 @@ bytecodes: [ /* 85 S> */ B(Return), B(ForInStep), R(7), B(Star), R(7), - B(JumpLoop), U8(-23), U8(0), + B(JumpLoop), U8(23), I8(0), B(LdaUndefined), /* 85 S> */ B(Return), ] @@ -107,7 +107,7 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 59 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(9), + /* 59 S> */ B(CreateArrayLiteral), U8(0), U8(2), U8(9), B(JumpIfUndefined), U8(46), B(JumpIfNull), U8(44), B(ToObject), R(3), @@ -116,18 +116,18 @@ bytecodes: [ B(Star), R(7), /* 54 S> */ B(ForInContinue), R(7), R(6), B(JumpIfFalse), U8(31), - B(ForInNext), R(3), R(7), R(4), U8(3), + B(ForInNext), R(3), R(7), R(4), U8(4), B(JumpIfUndefined), U8(17), B(Star), R(1), /* 45 E> */ B(StackCheck), B(Star), R(2), /* 70 S> */ B(Ldar), R(1), - /* 75 E> */ B(Add), R(0), U8(2), + /* 75 E> */ B(Add), R(0), U8(3), B(Mov), R(0), R(8), B(Star), R(0), /* 72 E> */ B(ForInStep), R(7), B(Star), R(7), - B(JumpLoop), U8(-31), U8(0), + B(JumpLoop), U8(31), I8(0), B(LdaUndefined), /* 80 S> */ B(Return), ] @@ -150,9 +150,9 @@ parameter count: 1 bytecode array length: 85 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), + /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), B(Mov), R(1), R(0), - /* 77 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(9), + /* 77 S> */ B(CreateArrayLiteral), U8(1), U8(3), U8(9), B(JumpIfUndefined), U8(70), B(JumpIfNull), U8(68), B(ToObject), R(1), @@ -161,28 +161,28 @@ bytecodes: [ B(Star), R(5), /* 68 S> */ B(ForInContinue), R(5), R(4), B(JumpIfFalse), U8(55), - B(ForInNext), R(1), R(5), R(2), U8(12), + B(ForInNext), R(1), R(5), R(2), U8(14), B(JumpIfUndefined), U8(41), B(Star), R(6), - /* 67 E> */ B(StaNamedPropertySloppy), R(0), U8(2), U8(10), + /* 67 E> */ B(StaNamedPropertySloppy), R(0), U8(2), U8(12), /* 62 E> */ B(StackCheck), /* 95 S> */ B(Nop), - /* 100 E> */ B(LdaNamedProperty), R(0), U8(2), U8(4), + /* 100 E> */ B(LdaNamedProperty), R(0), U8(2), U8(6), B(Star), R(6), - B(LdaSmi), U8(10), - /* 106 E> */ B(TestEqual), R(6), U8(6), + B(LdaSmi), I8(10), + /* 106 E> */ B(TestEqual), R(6), U8(8), B(JumpIfFalse), U8(4), /* 113 S> */ B(Jump), U8(18), /* 125 S> */ B(Nop), - /* 130 E> */ B(LdaNamedProperty), R(0), U8(2), U8(7), + /* 130 E> */ B(LdaNamedProperty), R(0), U8(2), U8(9), B(Star), R(6), - B(LdaSmi), U8(20), - /* 136 E> */ B(TestEqual), R(6), U8(9), + B(LdaSmi), I8(20), + /* 136 E> */ B(TestEqual), R(6), U8(11), B(JumpIfFalse), U8(4), /* 143 S> */ B(Jump), U8(9), B(ForInStep), R(5), B(Star), R(5), - B(JumpLoop), U8(-55), U8(0), + B(JumpLoop), U8(55), I8(0), B(LdaUndefined), /* 152 S> */ B(Return), ] @@ -204,9 +204,9 @@ parameter count: 1 bytecode array length: 62 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(9), + /* 42 S> */ B(CreateArrayLiteral), U8(0), U8(2), U8(9), B(Star), R(0), - /* 72 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(9), + /* 72 S> */ B(CreateArrayLiteral), U8(1), U8(3), U8(9), B(JumpIfUndefined), U8(49), B(JumpIfNull), U8(47), B(ToObject), R(1), @@ -215,20 +215,20 @@ bytecodes: [ B(Star), R(5), /* 65 S> */ B(ForInContinue), R(5), R(4), B(JumpIfFalse), U8(34), - B(ForInNext), R(1), R(5), R(2), U8(8), + B(ForInNext), R(1), R(5), R(2), U8(10), B(JumpIfUndefined), U8(20), B(Star), R(6), B(LdaZero), B(Star), R(8), B(Ldar), R(6), - /* 64 E> */ B(StaKeyedPropertySloppy), R(0), R(8), U8(6), + /* 64 E> */ B(StaKeyedPropertySloppy), R(0), R(8), U8(8), /* 59 E> */ B(StackCheck), - /* 83 S> */ B(LdaSmi), U8(3), - /* 91 E> */ B(LdaKeyedProperty), R(0), U8(4), + /* 83 S> */ B(LdaSmi), I8(3), + /* 91 E> */ B(LdaKeyedProperty), R(0), U8(6), /* 98 S> */ B(Return), B(ForInStep), R(5), B(Star), R(5), - B(JumpLoop), U8(-34), U8(0), + B(JumpLoop), U8(34), I8(0), B(LdaUndefined), /* 98 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden index 610b8b1a06..a5f7f6e683 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden @@ -18,50 +18,50 @@ bytecodes: [ B(Star), R(4), B(Mov), R(context), R(11), B(Mov), R(context), R(12), - /* 48 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(9), + /* 48 S> */ B(CreateArrayLiteral), U8(0), U8(2), U8(9), B(Star), R(13), - B(LdaNamedProperty), R(13), U8(1), U8(2), + B(LdaNamedProperty), R(13), U8(1), U8(3), B(Star), R(14), - B(CallProperty), R(14), R(13), U8(1), U8(4), + B(CallProperty), R(14), R(13), U8(1), U8(5), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(2), - /* 45 S> */ B(LdaNamedProperty), R(2), U8(2), U8(8), + /* 45 S> */ B(LdaNamedProperty), R(2), U8(2), U8(9), B(Star), R(13), - /* 45 E> */ B(CallProperty), R(13), R(2), U8(1), U8(6), + /* 45 E> */ B(CallProperty), R(13), R(2), U8(1), U8(7), B(Star), R(3), /* 45 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(3), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1), - B(LdaNamedProperty), R(3), U8(3), U8(10), + B(LdaNamedProperty), R(3), U8(3), U8(11), B(JumpIfToBooleanTrue), U8(25), - B(LdaNamedProperty), R(3), U8(4), U8(12), + B(LdaNamedProperty), R(3), U8(4), U8(13), B(Star), R(5), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(4), B(Mov), R(5), R(0), /* 34 E> */ B(StackCheck), B(Mov), R(0), R(1), B(LdaZero), B(Star), R(4), - B(JumpLoop), U8(-51), U8(0), + B(JumpLoop), U8(51), I8(0), B(Jump), U8(36), B(Star), R(13), B(Ldar), R(closure), B(CreateCatchContext), R(13), U8(5), U8(6), B(Star), R(12), B(PushContext), R(8), - B(LdaSmi), U8(2), - B(TestEqualStrict), R(4), U8(14), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(4), U8(15), B(JumpIfFalse), U8(6), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(4), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(13), B(CallRuntime), U16(Runtime::kReThrow), R(13), U8(1), B(PopContext), R(8), - B(LdaSmi), U8(-1), + B(LdaSmi), I8(-1), B(Star), R(9), B(Jump), U8(7), B(Star), R(10), @@ -71,24 +71,24 @@ bytecodes: [ B(SetPendingMessage), B(Star), R(11), B(LdaZero), - B(TestEqualStrict), R(4), U8(15), + B(TestEqualStrict), R(4), U8(16), B(JumpIfTrue), U8(111), - B(LdaNamedProperty), R(2), U8(7), U8(16), + B(LdaNamedProperty), R(2), U8(7), U8(17), B(Star), R(6), B(TestUndetectable), R(6), B(JumpIfFalse), U8(4), B(Jump), U8(99), - B(LdaSmi), U8(1), - B(TestEqualStrict), R(4), U8(19), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(4), U8(20), B(JumpIfFalse), U8(67), B(Ldar), R(6), B(TypeOf), B(Star), R(12), B(LdaConstant), U8(8), - B(TestEqualStrict), R(12), U8(20), + B(TestEqualStrict), R(12), U8(21), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), U16(129), + B(Wide), B(LdaSmi), I16(130), B(Star), R(12), B(LdaConstant), U8(9), B(Star), R(13), @@ -182,7 +182,7 @@ bytecodes: [ B(JumpIfToBooleanTrue), U8(27), B(LdaNamedProperty), R(4), U8(4), U8(12), B(Star), R(6), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(5), B(Mov), R(6), R(1), /* 54 E> */ B(StackCheck), @@ -197,20 +197,20 @@ bytecodes: [ B(CreateCatchContext), R(14), U8(5), U8(6), B(Star), R(13), B(PushContext), R(9), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(5), U8(14), B(JumpIfFalse), U8(6), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(5), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(14), B(CallRuntime), U16(Runtime::kReThrow), R(14), U8(1), B(PopContext), R(9), - B(LdaSmi), U8(-1), + B(LdaSmi), I8(-1), B(Star), R(10), B(Jump), U8(8), B(Star), R(11), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(10), B(LdaTheHole), B(SetPendingMessage), @@ -223,7 +223,7 @@ bytecodes: [ B(TestUndetectable), R(7), B(JumpIfFalse), U8(4), B(Jump), U8(99), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(TestEqualStrict), R(5), U8(19), B(JumpIfFalse), U8(67), B(Ldar), R(7), @@ -233,7 +233,7 @@ bytecodes: [ B(TestEqualStrict), R(13), U8(20), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), U16(129), + B(Wide), B(LdaSmi), I16(130), B(Star), R(13), B(LdaConstant), U8(9), B(Star), R(14), @@ -267,7 +267,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(10), U8(0), B(JumpIfTrue), U8(11), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(TestEqualStrict), R(10), U8(0), B(JumpIfTrue), U8(7), B(Jump), U8(8), @@ -313,58 +313,58 @@ bytecodes: [ B(Star), R(4), B(Mov), R(context), R(11), B(Mov), R(context), R(12), - /* 48 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(9), + /* 48 S> */ B(CreateArrayLiteral), U8(0), U8(2), U8(9), B(Star), R(13), - B(LdaNamedProperty), R(13), U8(1), U8(2), + B(LdaNamedProperty), R(13), U8(1), U8(3), B(Star), R(14), - B(CallProperty), R(14), R(13), U8(1), U8(4), + B(CallProperty), R(14), R(13), U8(1), U8(5), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(2), - /* 45 S> */ B(LdaNamedProperty), R(2), U8(2), U8(8), + /* 45 S> */ B(LdaNamedProperty), R(2), U8(2), U8(9), B(Star), R(13), - /* 45 E> */ B(CallProperty), R(13), R(2), U8(1), U8(6), + /* 45 E> */ B(CallProperty), R(13), R(2), U8(1), U8(7), B(Star), R(3), /* 45 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(3), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1), - B(LdaNamedProperty), R(3), U8(3), U8(10), + B(LdaNamedProperty), R(3), U8(3), U8(11), B(JumpIfToBooleanTrue), U8(43), - B(LdaNamedProperty), R(3), U8(4), U8(12), + B(LdaNamedProperty), R(3), U8(4), U8(13), B(Star), R(5), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(4), B(Mov), R(5), R(0), /* 34 E> */ B(StackCheck), B(Mov), R(0), R(1), - /* 66 S> */ B(LdaSmi), U8(10), - /* 72 E> */ B(TestEqual), R(1), U8(14), + /* 66 S> */ B(LdaSmi), I8(10), + /* 72 E> */ B(TestEqual), R(1), U8(15), B(JumpIfFalse), U8(4), /* 79 S> */ B(Jump), U8(14), - /* 91 S> */ B(LdaSmi), U8(20), - /* 97 E> */ B(TestEqual), R(1), U8(15), + /* 91 S> */ B(LdaSmi), I8(20), + /* 97 E> */ B(TestEqual), R(1), U8(16), B(JumpIfFalse), U8(4), /* 104 S> */ B(Jump), U8(8), B(LdaZero), B(Star), R(4), - B(JumpLoop), U8(-69), U8(0), + B(JumpLoop), U8(69), I8(0), B(Jump), U8(36), B(Star), R(13), B(Ldar), R(closure), B(CreateCatchContext), R(13), U8(5), U8(6), B(Star), R(12), B(PushContext), R(8), - B(LdaSmi), U8(2), - B(TestEqualStrict), R(4), U8(16), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(4), U8(17), B(JumpIfFalse), U8(6), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(4), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(13), B(CallRuntime), U16(Runtime::kReThrow), R(13), U8(1), B(PopContext), R(8), - B(LdaSmi), U8(-1), + B(LdaSmi), I8(-1), B(Star), R(9), B(Jump), U8(7), B(Star), R(10), @@ -374,24 +374,24 @@ bytecodes: [ B(SetPendingMessage), B(Star), R(11), B(LdaZero), - B(TestEqualStrict), R(4), U8(17), + B(TestEqualStrict), R(4), U8(18), B(JumpIfTrue), U8(111), - B(LdaNamedProperty), R(2), U8(7), U8(18), + B(LdaNamedProperty), R(2), U8(7), U8(19), B(Star), R(6), B(TestUndetectable), R(6), B(JumpIfFalse), U8(4), B(Jump), U8(99), - B(LdaSmi), U8(1), - B(TestEqualStrict), R(4), U8(21), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(4), U8(22), B(JumpIfFalse), U8(67), B(Ldar), R(6), B(TypeOf), B(Star), R(12), B(LdaConstant), U8(8), - B(TestEqualStrict), R(12), U8(22), + B(TestEqualStrict), R(12), U8(23), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), U16(129), + B(Wide), B(LdaSmi), I16(130), B(Star), R(12), B(LdaConstant), U8(9), B(Star), R(13), @@ -460,39 +460,39 @@ parameter count: 1 bytecode array length: 297 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(8), + /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(8), B(Mov), R(8), R(0), B(LdaZero), B(Star), R(3), B(Mov), R(context), R(10), B(Mov), R(context), R(11), - /* 77 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(9), + /* 77 S> */ B(CreateArrayLiteral), U8(1), U8(3), U8(9), B(Star), R(12), - B(LdaNamedProperty), R(12), U8(2), U8(2), + B(LdaNamedProperty), R(12), U8(2), U8(4), B(Star), R(13), - B(CallProperty), R(13), R(12), U8(1), U8(4), + B(CallProperty), R(13), R(12), U8(1), U8(6), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(1), - /* 74 S> */ B(LdaNamedProperty), R(1), U8(3), U8(8), + /* 74 S> */ B(LdaNamedProperty), R(1), U8(3), U8(10), B(Star), R(12), - /* 74 E> */ B(CallProperty), R(12), R(1), U8(1), U8(6), + /* 74 E> */ B(CallProperty), R(12), R(1), U8(1), U8(8), B(Star), R(2), /* 74 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(2), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1), - B(LdaNamedProperty), R(2), U8(4), U8(10), + B(LdaNamedProperty), R(2), U8(4), U8(12), B(JumpIfToBooleanTrue), U8(31), - /* 67 E> */ B(LdaNamedProperty), R(2), U8(5), U8(12), + /* 67 E> */ B(LdaNamedProperty), R(2), U8(5), U8(14), B(Star), R(4), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(3), B(Ldar), R(4), - B(StaNamedPropertySloppy), R(0), U8(6), U8(14), + B(StaNamedPropertySloppy), R(0), U8(6), U8(16), /* 62 E> */ B(StackCheck), /* 88 S> */ B(Nop), - /* 96 E> */ B(LdaNamedProperty), R(0), U8(6), U8(16), + /* 96 E> */ B(LdaNamedProperty), R(0), U8(6), U8(18), B(Star), R(9), B(LdaZero), B(Star), R(8), @@ -503,43 +503,43 @@ bytecodes: [ B(CreateCatchContext), R(12), U8(7), U8(8), B(Star), R(11), B(PushContext), R(7), - B(LdaSmi), U8(2), - B(TestEqualStrict), R(3), U8(18), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(3), U8(20), B(JumpIfFalse), U8(6), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(3), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(12), B(CallRuntime), U16(Runtime::kReThrow), R(12), U8(1), B(PopContext), R(7), - B(LdaSmi), U8(-1), + B(LdaSmi), I8(-1), B(Star), R(8), B(Jump), U8(8), B(Star), R(9), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(8), B(LdaTheHole), B(SetPendingMessage), B(Star), R(10), B(LdaZero), - B(TestEqualStrict), R(3), U8(19), + B(TestEqualStrict), R(3), U8(21), B(JumpIfTrue), U8(111), - B(LdaNamedProperty), R(1), U8(9), U8(20), + B(LdaNamedProperty), R(1), U8(9), U8(22), B(Star), R(5), B(TestUndetectable), R(5), B(JumpIfFalse), U8(4), B(Jump), U8(99), - B(LdaSmi), U8(1), - B(TestEqualStrict), R(3), U8(23), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(3), U8(25), B(JumpIfFalse), U8(67), B(Ldar), R(5), B(TypeOf), B(Star), R(11), B(LdaConstant), U8(10), - B(TestEqualStrict), R(11), U8(24), + B(TestEqualStrict), R(11), U8(26), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), U16(129), + B(Wide), B(LdaSmi), I16(130), B(Star), R(11), B(LdaConstant), U8(11), B(Star), R(12), @@ -573,7 +573,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(8), U8(0), B(JumpIfTrue), U8(11), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(TestEqualStrict), R(8), U8(0), B(JumpIfTrue), U8(7), B(Jump), U8(8), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/FunctionLiterals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/FunctionLiterals.golden index f897381d86..7d55ebf94c 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/FunctionLiterals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/FunctionLiterals.golden @@ -58,7 +58,7 @@ bytecodes: [ B(Star), R(1), B(CreateClosure), U8(0), U8(4), U8(2), B(Star), R(0), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(2), /* 67 E> */ B(Call), R(0), R(1), U8(2), U8(2), /* 71 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/GenerateTestUndetectable.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/GenerateTestUndetectable.golden index 1ee3738f2e..d12f5a6d05 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/GenerateTestUndetectable.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/GenerateTestUndetectable.golden @@ -17,13 +17,13 @@ parameter count: 1 bytecode array length: 24 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(2), + /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(2), B(Mov), R(2), R(0), - /* 63 S> */ B(LdaSmi), U8(10), + /* 63 S> */ B(LdaSmi), I8(10), B(Star), R(1), /* 67 S> */ B(TestUndetectable), R(0), B(JumpIfFalse), U8(6), - /* 88 S> */ B(LdaSmi), U8(20), + /* 88 S> */ B(LdaSmi), I8(20), B(Star), R(1), /* 97 S> */ B(Ldar), R(1), /* 107 S> */ B(Return), @@ -46,13 +46,13 @@ parameter count: 1 bytecode array length: 24 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(2), + /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(2), B(Mov), R(2), R(0), - /* 63 S> */ B(LdaSmi), U8(10), + /* 63 S> */ B(LdaSmi), I8(10), B(Star), R(1), /* 67 S> */ B(TestUndetectable), R(0), B(JumpIfFalse), U8(6), - /* 93 S> */ B(LdaSmi), U8(20), + /* 93 S> */ B(LdaSmi), I8(20), B(Star), R(1), /* 102 S> */ B(Ldar), R(1), /* 112 S> */ B(Return), @@ -75,13 +75,13 @@ parameter count: 1 bytecode array length: 24 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(2), + /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(2), B(Mov), R(2), R(0), - /* 63 S> */ B(LdaSmi), U8(10), + /* 63 S> */ B(LdaSmi), I8(10), B(Star), R(1), /* 67 S> */ B(TestUndetectable), R(0), B(JumpIfTrue), U8(6), - /* 88 S> */ B(LdaSmi), U8(20), + /* 88 S> */ B(LdaSmi), I8(20), B(Star), R(1), /* 97 S> */ B(Ldar), R(1), /* 107 S> */ B(Return), @@ -104,13 +104,13 @@ parameter count: 1 bytecode array length: 24 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(2), + /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(2), B(Mov), R(2), R(0), - /* 63 S> */ B(LdaSmi), U8(10), + /* 63 S> */ B(LdaSmi), I8(10), B(Star), R(1), /* 67 S> */ B(TestUndetectable), R(0), B(JumpIfTrue), U8(6), - /* 93 S> */ B(LdaSmi), U8(20), + /* 93 S> */ B(LdaSmi), I8(20), B(Star), R(1), /* 102 S> */ B(Ldar), R(1), /* 112 S> */ B(Return), @@ -133,13 +133,13 @@ parameter count: 1 bytecode array length: 24 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(2), + /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(2), B(Mov), R(2), R(0), - /* 63 S> */ B(LdaSmi), U8(10), + /* 63 S> */ B(LdaSmi), I8(10), B(Star), R(1), /* 67 S> */ B(TestNull), R(0), B(JumpIfFalse), U8(6), - /* 89 S> */ B(LdaSmi), U8(20), + /* 89 S> */ B(LdaSmi), I8(20), B(Star), R(1), /* 98 S> */ B(Ldar), R(1), /* 108 S> */ B(Return), @@ -162,13 +162,13 @@ parameter count: 1 bytecode array length: 24 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(2), + /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(2), B(Mov), R(2), R(0), - /* 63 S> */ B(LdaSmi), U8(10), + /* 63 S> */ B(LdaSmi), I8(10), B(Star), R(1), /* 67 S> */ B(TestUndefined), R(0), B(JumpIfFalse), U8(6), - /* 94 S> */ B(LdaSmi), U8(20), + /* 94 S> */ B(LdaSmi), I8(20), B(Star), R(1), /* 103 S> */ B(Ldar), R(1), /* 113 S> */ B(Return), @@ -191,13 +191,13 @@ parameter count: 1 bytecode array length: 24 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(2), + /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(2), B(Mov), R(2), R(0), - /* 63 S> */ B(LdaSmi), U8(10), + /* 63 S> */ B(LdaSmi), I8(10), B(Star), R(1), /* 67 S> */ B(TestNull), R(0), B(JumpIfTrue), U8(6), - /* 89 S> */ B(LdaSmi), U8(20), + /* 89 S> */ B(LdaSmi), I8(20), B(Star), R(1), /* 98 S> */ B(Ldar), R(1), /* 108 S> */ B(Return), @@ -220,13 +220,13 @@ parameter count: 1 bytecode array length: 24 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(2), + /* 46 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(2), B(Mov), R(2), R(0), - /* 63 S> */ B(LdaSmi), U8(10), + /* 63 S> */ B(LdaSmi), I8(10), B(Star), R(1), /* 67 S> */ B(TestUndefined), R(0), B(JumpIfTrue), U8(6), - /* 94 S> */ B(LdaSmi), U8(20), + /* 94 S> */ B(LdaSmi), I8(20), B(Star), R(1), /* 103 S> */ B(Ldar), R(1), /* 113 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden index a53f7f622f..1a542b8aec 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden @@ -24,10 +24,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(1), U8(0), B(JumpIfTrue), U8(53), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(3), B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CreateFunctionContext), U8(2), B(PushContext), R(0), @@ -35,19 +35,19 @@ bytecodes: [ B(StaCurrentContextSlot), U8(4), /* 11 E> */ B(StackCheck), B(Mov), R(context), R(5), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(7), B(Mov), R(closure), R(6), /* 11 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(6), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(6), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(7), B(LdaZero), B(SuspendGenerator), R(7), B(Ldar), R(6), /* 16 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(7), U8(1), B(Star), R(8), @@ -56,7 +56,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(9), U8(0), B(JumpIfTrue), U8(31), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(9), U8(0), B(JumpIfTrue), U8(21), B(Jump), U8(2), @@ -76,19 +76,19 @@ bytecodes: [ B(Star), R(7), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(6), U8(2), B(Star), R(4), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(3), B(Jump), U8(14), - B(LdaSmi), U8(-1), + B(LdaSmi), I8(-1), B(Star), R(3), B(Jump), U8(8), B(Star), R(4), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(3), B(LdaTheHole), B(SetPendingMessage), B(Star), R(5), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(6), B(CallRuntime), U16(Runtime::k_GeneratorClose), R(6), U8(1), B(Ldar), R(5), @@ -96,10 +96,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(3), U8(0), B(JumpIfTrue), U8(18), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(TestEqualStrict), R(3), U8(0), B(JumpIfTrue), U8(14), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(3), U8(0), B(JumpIfTrue), U8(10), B(Jump), U8(11), @@ -136,13 +136,13 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(1), U8(0), B(JumpIfTrue), U8(60), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(TestEqualStrict), R(1), U8(0), - B(JumpIfTrueConstant), U8(0), - B(LdaSmi), U8(78), + B(JumpIfTrue), U8(130), + B(LdaSmi), I8(78), B(Star), R(3), B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CreateFunctionContext), U8(2), B(PushContext), R(0), @@ -150,19 +150,19 @@ bytecodes: [ B(StaCurrentContextSlot), U8(4), /* 11 E> */ B(StackCheck), B(Mov), R(context), R(5), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(7), B(Mov), R(closure), R(6), /* 11 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(6), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(6), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(7), B(LdaZero), B(SuspendGenerator), R(7), B(Ldar), R(6), /* 25 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(7), U8(1), B(Star), R(8), @@ -171,7 +171,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(9), U8(0), B(JumpIfTrue), U8(31), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(9), U8(0), B(JumpIfTrue), U8(21), B(Jump), U8(2), @@ -185,19 +185,19 @@ bytecodes: [ B(Jump), U8(113), B(Ldar), R(8), /* 11 E> */ B(Throw), - /* 16 S> */ B(LdaSmi), U8(42), + /* 16 S> */ B(LdaSmi), I8(42), B(Star), R(6), B(LdaFalse), B(Star), R(7), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(6), U8(2), B(Star), R(6), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(7), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(SuspendGenerator), R(7), B(Ldar), R(6), /* 25 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(7), U8(1), B(Star), R(8), @@ -206,7 +206,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(9), U8(0), B(JumpIfTrue), U8(32), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(9), U8(0), B(JumpIfTrue), U8(22), B(Jump), U8(2), @@ -215,7 +215,7 @@ bytecodes: [ B(Mov), R(8), R(10), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(10), U8(2), B(Star), R(4), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(3), B(Jump), U8(35), B(Ldar), R(8), @@ -226,19 +226,19 @@ bytecodes: [ B(Star), R(7), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(6), U8(2), B(Star), R(4), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(3), B(Jump), U8(14), - B(LdaSmi), U8(-1), + B(LdaSmi), I8(-1), B(Star), R(3), B(Jump), U8(8), B(Star), R(4), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(Star), R(3), B(LdaTheHole), B(SetPendingMessage), B(Star), R(5), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(6), B(CallRuntime), U16(Runtime::k_GeneratorClose), R(6), U8(1), B(Ldar), R(5), @@ -246,13 +246,13 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(3), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(TestEqualStrict), R(3), U8(0), B(JumpIfTrue), U8(21), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(3), U8(0), B(JumpIfTrue), U8(17), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(TestEqualStrict), R(3), U8(0), B(JumpIfTrue), U8(13), B(Jump), U8(14), @@ -268,7 +268,6 @@ bytecodes: [ /* 25 S> */ B(Return), ] constant pool: [ - Smi [130], ] handlers: [ [53, 228, 234], @@ -281,7 +280,7 @@ snippet: " " frame size: 18 parameter count: 1 -bytecode array length: 778 +bytecode array length: 775 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(35), @@ -292,13 +291,13 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(3), U8(0), B(JumpIfTrue), U8(60), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(TestEqualStrict), R(3), U8(0), - B(JumpIfTrueConstant), U8(3), - B(LdaSmi), U8(78), + B(JumpIfTrue), U8(154), + B(LdaSmi), I8(78), B(Star), R(5), B(CallRuntime), U16(Runtime::kAbort), R(5), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(3), B(CreateFunctionContext), U8(9), B(PushContext), R(0), @@ -306,19 +305,19 @@ bytecodes: [ B(StaCurrentContextSlot), U8(4), /* 11 E> */ B(StackCheck), B(Mov), R(context), R(7), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(9), B(Mov), R(closure), R(8), /* 11 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(8), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(8), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(9), B(LdaZero), B(SuspendGenerator), R(9), B(Ldar), R(8), /* 44 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(3), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(9), U8(1), B(Star), R(10), @@ -327,7 +326,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(11), U8(0), B(JumpIfTrue), U8(31), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(11), U8(0), B(JumpIfTrue), U8(21), B(Jump), U8(2), @@ -338,7 +337,7 @@ bytecodes: [ B(Star), R(6), B(LdaZero), B(Star), R(5), - B(JumpConstant), U8(18), + B(JumpConstant), U8(13), B(Ldar), R(10), /* 11 E> */ B(Throw), B(Ldar), R(closure), @@ -350,28 +349,28 @@ bytecodes: [ B(StaContextSlot), R(1), U8(9), U8(0), B(Mov), R(context), R(10), B(Mov), R(context), R(11), - /* 30 S> */ B(CreateArrayLiteral), U8(1), U8(0), U8(9), + /* 30 S> */ B(CreateArrayLiteral), U8(1), U8(2), U8(9), B(Star), R(12), - B(LdaNamedProperty), R(12), U8(2), U8(2), + B(LdaNamedProperty), R(12), U8(2), U8(3), B(Star), R(13), - B(CallProperty), R(13), R(12), U8(1), U8(4), + B(CallProperty), R(13), R(12), U8(1), U8(5), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), /* 30 E> */ B(StaContextSlot), R(1), U8(7), U8(0), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(TestEqual), R(3), U8(0), B(JumpIfTrue), U8(18), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(TestEqualStrict), R(3), U8(0), - B(JumpIfTrueConstant), U8(8), - B(LdaSmi), U8(78), + B(JumpIfTrue), U8(134), + B(LdaSmi), I8(78), B(Star), R(12), B(CallRuntime), U16(Runtime::kAbort), R(12), U8(1), /* 27 S> */ B(LdaContextSlot), R(1), U8(7), U8(0), B(Star), R(13), - B(LdaNamedProperty), R(13), U8(4), U8(8), + B(LdaNamedProperty), R(13), U8(3), U8(9), B(Star), R(12), - /* 27 E> */ B(CallProperty), R(12), R(13), U8(1), U8(6), + /* 27 E> */ B(CallProperty), R(12), R(13), U8(1), U8(7), /* 27 E> */ B(StaContextSlot), R(1), U8(8), U8(0), B(Star), R(12), B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(12), U8(1), @@ -382,37 +381,37 @@ bytecodes: [ B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), B(LdaContextSlot), R(1), U8(8), U8(0), B(Star), R(12), - B(LdaNamedProperty), R(12), U8(5), U8(10), - B(JumpIfToBooleanTrueConstant), U8(9), + B(LdaNamedProperty), R(12), U8(4), U8(11), + B(JumpIfToBooleanTrue), U8(147), B(LdaContextSlot), R(1), U8(8), U8(0), B(Star), R(12), - B(LdaNamedProperty), R(12), U8(6), U8(12), + B(LdaNamedProperty), R(12), U8(5), U8(13), B(StaContextSlot), R(1), U8(10), U8(0), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(StaContextSlot), R(1), U8(9), U8(0), B(LdaContextSlot), R(1), U8(10), U8(0), B(StaContextSlot), R(1), U8(6), U8(0), /* 16 E> */ B(StackCheck), B(Ldar), R(closure), - B(CreateBlockContext), U8(7), + B(CreateBlockContext), U8(6), B(PushContext), R(2), B(LdaTheHole), B(StaCurrentContextSlot), U8(4), B(LdaContextSlot), R(1), U8(6), U8(0), B(StaCurrentContextSlot), U8(4), - /* 36 S> */ B(LdaCurrentContextSlot), U8(4), + /* 36 S> */ B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(12), B(LdaFalse), B(Star), R(13), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(12), U8(2), B(Star), R(12), - B(LdaContextSlot), R(1), U8(5), U8(0), + B(LdaImmutableContextSlot), R(1), U8(5), U8(0), B(Star), R(13), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(SuspendGenerator), R(13), B(Ldar), R(12), /* 44 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(3), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(13), U8(1), B(Star), R(14), @@ -421,7 +420,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(15), U8(0), B(JumpIfTrue), U8(43), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(15), U8(0), B(JumpIfTrue), U8(33), B(Jump), U8(2), @@ -438,35 +437,35 @@ bytecodes: [ B(Star), R(9), B(LdaZero), B(Star), R(8), - B(Jump), U8(74), + B(Jump), U8(71), B(Ldar), R(14), /* 36 E> */ B(Throw), B(PopContext), R(2), B(LdaZero), B(StaContextSlot), R(1), U8(9), U8(0), - B(Wide), B(JumpLoop), U16(-219), U16(0), + B(JumpLoop), U8(218), I8(0), B(Jump), U8(44), B(Star), R(12), B(Ldar), R(closure), - B(CreateCatchContext), R(12), U8(10), U8(11), + B(CreateCatchContext), R(12), U8(7), U8(8), B(Star), R(11), B(PushContext), R(2), B(LdaContextSlot), R(1), U8(9), U8(0), B(Star), R(12), - B(LdaSmi), U8(2), - B(TestEqualStrict), R(12), U8(14), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(12), U8(15), B(JumpIfFalse), U8(8), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(StaContextSlot), R(1), U8(9), U8(0), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(12), B(CallRuntime), U16(Runtime::kReThrow), R(12), U8(1), B(PopContext), R(2), - B(LdaSmi), U8(-1), + B(LdaSmi), I8(-1), B(Star), R(8), B(Jump), U8(8), B(Star), R(9), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(8), B(LdaTheHole), B(SetPendingMessage), @@ -474,32 +473,32 @@ bytecodes: [ B(LdaContextSlot), R(1), U8(9), U8(0), B(Star), R(11), B(LdaZero), - B(TestEqualStrict), R(11), U8(15), - B(JumpIfTrueConstant), U8(17), + B(TestEqualStrict), R(11), U8(16), + B(JumpIfTrue), U8(159), B(LdaContextSlot), R(1), U8(7), U8(0), B(Star), R(11), - B(LdaNamedProperty), R(11), U8(12), U8(16), + B(LdaNamedProperty), R(11), U8(9), U8(17), B(StaContextSlot), R(1), U8(11), U8(0), B(LdaContextSlot), R(1), U8(11), U8(0), B(Star), R(11), B(TestUndetectable), R(11), B(JumpIfFalse), U8(4), - B(JumpConstant), U8(16), + B(Jump), U8(133), B(LdaContextSlot), R(1), U8(9), U8(0), B(Star), R(11), - B(LdaSmi), U8(1), - B(TestEqualStrict), R(11), U8(19), + B(LdaSmi), I8(1), + B(TestEqualStrict), R(11), U8(20), B(JumpIfFalse), U8(75), B(LdaContextSlot), R(1), U8(11), U8(0), B(TypeOf), B(Star), R(11), - B(LdaConstant), U8(13), - B(TestEqualStrict), R(11), U8(20), + B(LdaConstant), U8(10), + B(TestEqualStrict), R(11), U8(21), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), U16(129), + B(Wide), B(LdaSmi), I16(130), B(Star), R(11), - B(LdaConstant), U8(14), + B(LdaConstant), U8(11), B(Star), R(12), B(CallRuntime), U16(Runtime::kNewTypeError), R(11), U8(2), B(Throw), @@ -512,7 +511,7 @@ bytecodes: [ B(Jump), U8(20), B(Star), R(12), B(Ldar), R(closure), - B(CreateCatchContext), R(12), U8(10), U8(15), + B(CreateCatchContext), R(12), U8(7), U8(12), B(Star), R(11), B(LdaTheHole), B(SetPendingMessage), @@ -539,19 +538,19 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(8), U8(0), B(JumpIfTrue), U8(11), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(TestEqualStrict), R(8), U8(0), B(JumpIfTrue), U8(17), B(Jump), U8(28), B(PopContext), R(1), B(PopContext), R(1), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(5), B(Mov), R(9), R(6), B(Jump), U8(47), B(PopContext), R(1), B(PopContext), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(5), B(Mov), R(9), R(6), B(Jump), U8(34), @@ -562,19 +561,19 @@ bytecodes: [ B(Star), R(9), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(8), U8(2), B(Star), R(6), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(Star), R(5), B(Jump), U8(14), - B(LdaSmi), U8(-1), + B(LdaSmi), I8(-1), B(Star), R(5), B(Jump), U8(8), B(Star), R(6), - B(LdaSmi), U8(4), + B(LdaSmi), I8(4), B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), B(Star), R(7), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(8), B(CallRuntime), U16(Runtime::k_GeneratorClose), R(8), U8(1), B(Ldar), R(7), @@ -582,16 +581,16 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(5), U8(0), B(JumpIfTrue), U8(32), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(TestEqualStrict), R(5), U8(0), B(JumpIfTrue), U8(28), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(5), U8(0), B(JumpIfTrue), U8(24), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(TestEqualStrict), R(5), U8(0), B(JumpIfTrue), U8(20), - B(LdaSmi), U8(4), + B(LdaSmi), I8(4), B(TestEqualStrict), R(5), U8(0), B(JumpIfTrue), U8(16), B(Jump), U8(17), @@ -612,27 +611,22 @@ constant pool: [ FIXED_ARRAY_TYPE, CONSTANT_ELEMENTS_PAIR_TYPE, SYMBOL_TYPE, - Smi [154], ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], FIXED_ARRAY_TYPE, - Smi [134], - Smi [150], ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"], FIXED_ARRAY_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["function"], ONE_BYTE_INTERNALIZED_STRING_TYPE [""], FIXED_ARRAY_TYPE, - Smi [133], - Smi [159], - Smi [582], + Smi [579], ] handlers: [ - [53, 697, 703], - [149, 448, 454], - [152, 404, 406], - [550, 566, 568], + [53, 694, 700], + [149, 445, 451], + [152, 401, 403], + [547, 563, 565], ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalCompoundExpressions.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalCompoundExpressions.golden index 57403bc402..4d04f6a3fa 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalCompoundExpressions.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalCompoundExpressions.golden @@ -19,7 +19,7 @@ bytecodes: [ /* 26 E> */ B(StackCheck), /* 31 S> */ B(LdaGlobal), U8(0), U8(2), B(Star), R(0), - B(BitwiseAndSmi), U8(1), R(0), U8(4), + B(BitwiseAndSmi), I8(1), R(0), U8(4), /* 45 E> */ B(StaGlobalSloppy), U8(0), U8(5), /* 51 S> */ B(Return), ] @@ -42,7 +42,7 @@ bytecodes: [ /* 27 E> */ B(StackCheck), /* 32 S> */ B(LdaGlobal), U8(0), U8(2), B(Star), R(0), - B(AddSmi), U8(1), R(0), U8(4), + B(AddSmi), I8(1), R(0), U8(4), /* 51 E> */ B(StaGlobalSloppy), U8(0), U8(5), /* 57 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalDelete.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalDelete.golden index b717c71bea..1db8a27f03 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalDelete.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalDelete.golden @@ -48,7 +48,7 @@ bytecodes: [ /* 28 E> */ B(StackCheck), /* 51 S> */ B(LdaGlobal), U8(0), U8(2), B(Star), R(0), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(DeletePropertyStrict), R(0), /* 71 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/IfConditions.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/IfConditions.golden index 17ee039b91..ce53de6b7c 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/IfConditions.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/IfConditions.golden @@ -22,7 +22,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 55 S> */ B(LdaSmi), U8(-1), + /* 55 S> */ B(LdaSmi), I8(-1), /* 70 S> */ B(Return), ] constant pool: [ @@ -46,7 +46,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 36 S> */ B(LdaSmi), U8(1), + /* 36 S> */ B(LdaSmi), I8(1), /* 76 S> */ B(Return), ] constant pool: [ @@ -70,7 +70,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 59 S> */ B(LdaSmi), U8(-1), + /* 59 S> */ B(LdaSmi), I8(-1), /* 74 S> */ B(Return), ] constant pool: [ @@ -117,14 +117,14 @@ parameter count: 1 bytecode array length: 23 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 25 S> */ B(LdaSmi), U8(1), + /* 25 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 30 S> */ B(JumpIfToBooleanFalse), U8(13), - /* 43 S> */ B(AddSmi), U8(1), R(0), U8(2), + /* 43 S> */ B(AddSmi), I8(1), R(0), U8(2), B(Mov), R(0), R(1), B(Star), R(0), B(Jump), U8(5), - /* 66 S> */ B(LdaSmi), U8(2), + /* 66 S> */ B(LdaSmi), I8(2), /* 80 S> */ B(Return), B(LdaUndefined), /* 80 S> */ B(Return), @@ -153,9 +153,9 @@ bytecodes: [ /* 18 S> */ B(LdaZero), /* 24 E> */ B(TestLessThanOrEqual), R(arg0), U8(2), B(JumpIfFalse), U8(7), - /* 36 S> */ B(Wide), B(LdaSmi), U16(200), + /* 36 S> */ B(Wide), B(LdaSmi), I16(200), /* 80 S> */ B(Return), - /* 63 S> */ B(Wide), B(LdaSmi), U16(-200), + /* 63 S> */ B(Wide), B(LdaSmi), I16(-200), /* 80 S> */ B(Return), B(LdaUndefined), /* 80 S> */ B(Return), @@ -177,7 +177,7 @@ bytecodes: [ /* 19 S> */ B(Ldar), R(arg1), /* 25 E> */ B(TestIn), R(arg0), B(JumpIfFalse), U8(7), - /* 33 S> */ B(Wide), B(LdaSmi), U16(200), + /* 33 S> */ B(Wide), B(LdaSmi), I16(200), /* 47 S> */ B(Return), B(LdaUndefined), /* 47 S> */ B(Return), @@ -396,9 +396,9 @@ bytecodes: [ /* 1057 S> */ B(Mov), R(1), R(0), /* 1066 S> */ B(Mov), R(0), R(1), /* 1073 S> */ B(Mov), R(1), R(0), - /* 1081 S> */ B(Wide), B(LdaSmi), U16(200), + /* 1081 S> */ B(Wide), B(LdaSmi), I16(200), /* 1117 S> */ B(Return), - /* 1102 S> */ B(Wide), B(LdaSmi), U16(-200), + /* 1102 S> */ B(Wide), B(LdaSmi), I16(-200), /* 1117 S> */ B(Return), B(LdaUndefined), /* 1117 S> */ B(Return), @@ -622,9 +622,9 @@ bytecodes: [ /* 1051 S> */ B(Mov), R(1), R(0), /* 1060 S> */ B(Mov), R(0), R(1), /* 1067 S> */ B(Mov), R(1), R(0), - /* 1076 S> */ B(Wide), B(LdaSmi), U16(200), + /* 1076 S> */ B(Wide), B(LdaSmi), I16(200), /* 1112 S> */ B(Return), - /* 1097 S> */ B(Wide), B(LdaSmi), U16(-200), + /* 1097 S> */ B(Wide), B(LdaSmi), I16(-200), /* 1112 S> */ B(Return), B(LdaUndefined), /* 1112 S> */ B(Return), @@ -658,42 +658,42 @@ bytecodes: [ /* 21 S> */ B(Ldar), R(arg1), /* 27 E> */ B(TestEqual), R(arg0), U8(2), B(JumpIfFalse), U8(5), - /* 35 S> */ B(LdaSmi), U8(1), + /* 35 S> */ B(LdaSmi), I8(1), /* 262 S> */ B(Return), /* 49 S> */ B(Ldar), R(arg1), /* 55 E> */ B(TestEqualStrict), R(arg0), U8(3), B(JumpIfFalse), U8(5), - /* 64 S> */ B(LdaSmi), U8(1), + /* 64 S> */ B(LdaSmi), I8(1), /* 262 S> */ B(Return), /* 78 S> */ B(Ldar), R(arg1), /* 84 E> */ B(TestLessThan), R(arg0), U8(4), B(JumpIfFalse), U8(5), - /* 91 S> */ B(LdaSmi), U8(1), + /* 91 S> */ B(LdaSmi), I8(1), /* 262 S> */ B(Return), /* 105 S> */ B(Ldar), R(arg1), /* 111 E> */ B(TestGreaterThan), R(arg0), U8(5), B(JumpIfFalse), U8(5), - /* 118 S> */ B(LdaSmi), U8(1), + /* 118 S> */ B(LdaSmi), I8(1), /* 262 S> */ B(Return), /* 132 S> */ B(Ldar), R(arg1), /* 138 E> */ B(TestLessThanOrEqual), R(arg0), U8(6), B(JumpIfFalse), U8(5), - /* 146 S> */ B(LdaSmi), U8(1), + /* 146 S> */ B(LdaSmi), I8(1), /* 262 S> */ B(Return), /* 160 S> */ B(Ldar), R(arg1), /* 166 E> */ B(TestGreaterThanOrEqual), R(arg0), U8(7), B(JumpIfFalse), U8(5), - /* 174 S> */ B(LdaSmi), U8(1), + /* 174 S> */ B(LdaSmi), I8(1), /* 262 S> */ B(Return), /* 188 S> */ B(Ldar), R(arg1), /* 194 E> */ B(TestIn), R(arg0), B(JumpIfFalse), U8(5), - /* 202 S> */ B(LdaSmi), U8(1), + /* 202 S> */ B(LdaSmi), I8(1), /* 262 S> */ B(Return), /* 216 S> */ B(Ldar), R(arg1), /* 222 E> */ B(TestInstanceOf), R(arg0), B(JumpIfFalse), U8(5), - /* 238 S> */ B(LdaSmi), U8(1), + /* 238 S> */ B(LdaSmi), I8(1), /* 262 S> */ B(Return), /* 252 S> */ B(LdaZero), /* 262 S> */ B(Return), @@ -723,9 +723,9 @@ bytecodes: [ /* 25 S> */ B(LdaZero), B(Star), R(0), /* 30 S> */ B(JumpIfToBooleanFalse), U8(5), - /* 43 S> */ B(LdaSmi), U8(20), + /* 43 S> */ B(LdaSmi), I8(20), /* 85 S> */ B(Return), - /* 69 S> */ B(LdaSmi), U8(-20), + /* 69 S> */ B(LdaSmi), I8(-20), /* 85 S> */ B(Return), B(LdaUndefined), /* 85 S> */ B(Return), @@ -759,7 +759,7 @@ bytecodes: [ B(LdaZero), /* 37 E> */ B(TestLessThan), R(arg0), U8(3), B(JumpIfFalse), U8(5), - /* 48 S> */ B(LdaSmi), U8(1), + /* 48 S> */ B(LdaSmi), I8(1), /* 133 S> */ B(Return), /* 67 S> */ B(LdaZero), /* 73 E> */ B(TestGreaterThan), R(arg0), U8(4), @@ -769,7 +769,7 @@ bytecodes: [ B(JumpIfFalse), U8(4), /* 93 S> */ B(LdaZero), /* 133 S> */ B(Return), - /* 118 S> */ B(LdaSmi), U8(-1), + /* 118 S> */ B(LdaSmi), I8(-1), /* 133 S> */ B(Return), B(LdaUndefined), /* 133 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/IntegerConstants.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/IntegerConstants.golden index f71907ba4d..1997d02233 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/IntegerConstants.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/IntegerConstants.golden @@ -14,7 +14,7 @@ parameter count: 1 bytecode array length: 8 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(ExtraWide), B(LdaSmi), U32(12345678), + /* 34 S> */ B(ExtraWide), B(LdaSmi), I32(12345678), /* 51 S> */ B(Return), ] constant pool: [ @@ -31,9 +31,9 @@ parameter count: 1 bytecode array length: 12 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(Wide), B(LdaSmi), U16(1234), + /* 42 S> */ B(Wide), B(LdaSmi), I16(1234), B(Star), R(0), - /* 48 S> */ B(Wide), B(LdaSmi), U16(5678), + /* 48 S> */ B(Wide), B(LdaSmi), I16(5678), /* 61 S> */ B(Return), ] constant pool: [ @@ -50,9 +50,9 @@ parameter count: 1 bytecode array length: 12 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(Wide), B(LdaSmi), U16(1234), + /* 42 S> */ B(Wide), B(LdaSmi), I16(1234), B(Star), R(0), - /* 48 S> */ B(Wide), B(LdaSmi), U16(1234), + /* 48 S> */ B(Wide), B(LdaSmi), I16(1234), /* 61 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/JumpsRequiringConstantWideOperands.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/JumpsRequiringConstantWideOperands.golden index 99e7eac9c2..292247b425 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/JumpsRequiringConstantWideOperands.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/JumpsRequiringConstantWideOperands.golden @@ -956,23 +956,23 @@ bytecodes: [ B(Star), R(0), /* 4103 S> */ B(LdaZero), B(Star), R(1), - /* 4108 S> */ B(LdaSmi), U8(3), + /* 4108 S> */ B(LdaSmi), I8(3), /* 4108 E> */ B(TestLessThan), R(1), U8(2), B(Wide), B(JumpIfFalse), U16(39), /* 4090 E> */ B(StackCheck), - /* 4122 S> */ B(LdaSmi), U8(1), + /* 4122 S> */ B(LdaSmi), I8(1), /* 4128 E> */ B(TestEqual), R(1), U8(4), B(Wide), B(JumpIfFalse), U16(7), /* 4134 S> */ B(Wide), B(Jump), U16(16), - /* 4146 S> */ B(LdaSmi), U8(2), + /* 4146 S> */ B(LdaSmi), I8(2), /* 4152 E> */ B(TestEqual), R(1), U8(5), B(Wide), B(JumpIfFalse), U16(7), /* 4158 S> */ B(Wide), B(Jump), U16(12), /* 4114 S> */ B(Ldar), R(1), B(Inc), U8(3), B(Star), R(1), - B(JumpLoop), U8(-42), U8(0), - /* 4167 S> */ B(LdaSmi), U8(3), + B(JumpLoop), U8(42), I8(0), + /* 4167 S> */ B(LdaSmi), I8(3), /* 4177 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/LetVariable.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/LetVariable.golden index 74709fdab9..60f236f17a 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/LetVariable.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/LetVariable.golden @@ -16,7 +16,7 @@ bytecodes: [ B(LdaTheHole), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), B(Star), R(0), B(LdaUndefined), /* 46 S> */ B(Return), @@ -37,7 +37,7 @@ bytecodes: [ B(LdaTheHole), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), B(Star), R(0), /* 46 S> */ B(Nop), /* 56 S> */ B(Return), @@ -58,7 +58,7 @@ bytecodes: [ B(LdaTheHole), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 45 S> */ B(LdaSmi), U8(20), + /* 45 S> */ B(LdaSmi), I8(20), B(Star), R(1), B(Ldar), R(0), B(JumpIfNotHole), U8(11), @@ -87,9 +87,9 @@ bytecodes: [ B(LdaTheHole), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), B(Star), R(0), - /* 46 S> */ B(LdaSmi), U8(20), + /* 46 S> */ B(LdaSmi), I8(20), B(Star), R(0), B(LdaUndefined), /* 54 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/LetVariableContextSlot.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/LetVariableContextSlot.golden index c1c979c0ac..5d10939959 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/LetVariableContextSlot.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/LetVariableContextSlot.golden @@ -20,7 +20,7 @@ bytecodes: [ B(CreateClosure), U8(0), U8(2), U8(2), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), /* 42 E> */ B(StaCurrentContextSlot), U8(4), B(LdaUndefined), /* 72 S> */ B(Return), @@ -46,9 +46,9 @@ bytecodes: [ B(CreateClosure), U8(0), U8(2), U8(2), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), /* 42 E> */ B(StaCurrentContextSlot), U8(4), - /* 72 S> */ B(LdaCurrentContextSlot), U8(4), + /* 72 S> */ B(LdaImmutableCurrentContextSlot), U8(4), /* 82 S> */ B(Return), ] constant pool: [ @@ -72,7 +72,7 @@ bytecodes: [ B(CreateClosure), U8(0), U8(2), U8(2), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 45 S> */ B(LdaSmi), U8(20), + /* 45 S> */ B(LdaSmi), I8(20), B(Star), R(2), B(LdaCurrentContextSlot), U8(4), B(JumpIfNotHole), U8(11), @@ -107,9 +107,9 @@ bytecodes: [ B(CreateClosure), U8(0), U8(2), U8(2), B(Star), R(0), /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), /* 42 E> */ B(StaCurrentContextSlot), U8(4), - /* 46 S> */ B(LdaSmi), U8(20), + /* 46 S> */ B(LdaSmi), I8(20), /* 48 E> */ B(StaCurrentContextSlot), U8(4), B(LdaUndefined), /* 80 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/LogicalExpressions.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/LogicalExpressions.golden index fae86a673d..8cfa8474f9 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/LogicalExpressions.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/LogicalExpressions.golden @@ -17,7 +17,7 @@ bytecodes: [ /* 42 S> */ B(LdaZero), B(Star), R(0), /* 45 S> */ B(JumpIfToBooleanTrue), U8(4), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 60 S> */ B(Return), ] constant pool: [ @@ -36,10 +36,10 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 45 S> */ B(LdaSmi), U8(1), + /* 45 S> */ B(LdaSmi), I8(1), /* 55 E> */ B(TestEqual), R(0), U8(2), B(JumpIfTrue), U8(4), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 67 S> */ B(Return), ] constant pool: [ @@ -59,7 +59,7 @@ bytecodes: [ /* 42 S> */ B(LdaZero), B(Star), R(0), /* 45 S> */ B(JumpIfToBooleanFalse), U8(4), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 60 S> */ B(Return), ] constant pool: [ @@ -81,7 +81,7 @@ bytecodes: [ /* 45 S> */ B(LdaZero), /* 55 E> */ B(TestEqual), R(0), U8(2), B(JumpIfFalse), U8(4), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 67 S> */ B(Return), ] constant pool: [ @@ -101,7 +101,7 @@ bytecodes: [ /* 42 S> */ B(LdaZero), B(Star), R(0), /* 45 S> */ B(JumpIfToBooleanTrue), U8(4), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 68 S> */ B(Return), ] constant pool: [ @@ -118,17 +118,17 @@ parameter count: 1 bytecode array length: 24 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(2), + /* 42 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 49 S> */ B(LdaSmi), U8(3), + /* 49 S> */ B(LdaSmi), I8(3), B(Star), R(1), - /* 56 S> */ B(LdaSmi), U8(4), + /* 56 S> */ B(LdaSmi), I8(4), B(Star), R(2), /* 59 S> */ B(Ldar), R(0), B(JumpIfToBooleanTrue), U8(8), - B(LdaSmi), U8(5), + B(LdaSmi), I8(5), B(Star), R(2), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 95 S> */ B(Return), ] constant pool: [ @@ -177,143 +177,143 @@ parameter count: 1 bytecode array length: 276 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 53 S> */ B(LdaSmi), U8(2), + /* 53 S> */ B(LdaSmi), I8(2), B(Star), R(1), - /* 60 S> */ B(LdaSmi), U8(3), + /* 60 S> */ B(LdaSmi), I8(3), B(Star), R(2), /* 63 S> */ B(Ldar), R(0), B(JumpIfToBooleanTrueConstant), U8(0), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 624 S> */ B(Return), ] constant pool: [ @@ -365,141 +365,141 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 53 S> */ B(LdaSmi), U8(2), + /* 53 S> */ B(LdaSmi), I8(2), B(Star), R(1), - /* 60 S> */ B(LdaSmi), U8(3), + /* 60 S> */ B(LdaSmi), I8(3), B(Star), R(2), /* 63 S> */ B(Ldar), R(0), B(JumpIfToBooleanFalseConstant), U8(0), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 624 S> */ B(Return), ] constant pool: [ @@ -549,144 +549,144 @@ parameter count: 1 bytecode array length: 279 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 53 S> */ B(LdaSmi), U8(2), + /* 53 S> */ B(LdaSmi), I8(2), B(Star), R(1), - /* 60 S> */ B(LdaSmi), U8(3), + /* 60 S> */ B(LdaSmi), I8(3), B(Star), R(2), - /* 63 S> */ B(LdaSmi), U8(3), + /* 63 S> */ B(LdaSmi), I8(3), /* 73 E> */ B(TestGreaterThan), R(0), U8(2), B(JumpIfTrueConstant), U8(0), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 630 S> */ B(Return), ] constant pool: [ @@ -738,142 +738,142 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 53 S> */ B(LdaSmi), U8(2), + /* 53 S> */ B(LdaSmi), I8(2), B(Star), R(1), - /* 60 S> */ B(LdaSmi), U8(3), + /* 60 S> */ B(LdaSmi), I8(3), B(Star), R(2), - /* 63 S> */ B(LdaSmi), U8(5), + /* 63 S> */ B(LdaSmi), I8(5), /* 73 E> */ B(TestLessThan), R(0), U8(2), B(JumpIfFalseConstant), U8(0), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(2), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), /* 630 S> */ B(Return), ] constant pool: [ @@ -908,7 +908,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(LdaSmi), U8(1), + /* 34 S> */ B(LdaSmi), I8(1), /* 49 S> */ B(Return), ] constant pool: [ @@ -925,13 +925,13 @@ parameter count: 1 bytecode array length: 15 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(JumpIfToBooleanFalse), U8(4), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(JumpIfToBooleanTrue), U8(3), B(LdaZero), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), /* 68 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlot.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlot.golden index 07dbbdfe19..fdfe86481c 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlot.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlot.golden @@ -31,9 +31,9 @@ bytecodes: [ B(Star), R(3), B(LdaZero), B(Star), R(7), - B(LdaSmi), U8(10), + B(LdaSmi), I8(10), B(Star), R(8), - B(LdaSmi), U8(14), + B(LdaSmi), I8(14), B(Star), R(9), B(Mov), R(1), R(4), B(Mov), R(3), R(5), @@ -77,9 +77,9 @@ bytecodes: [ B(Star), R(3), B(LdaZero), B(Star), R(7), - B(LdaSmi), U8(10), + B(LdaSmi), I8(10), B(Star), R(8), - B(LdaSmi), U8(14), + B(LdaSmi), I8(14), B(Star), R(9), B(Mov), R(1), R(4), B(Mov), R(3), R(5), @@ -116,7 +116,7 @@ bytecodes: [ B(Ldar), R(new_target), B(StaCurrentContextSlot), U8(5), /* 10 E> */ B(StackCheck), - /* 14 S> */ B(LdaSmi), U8(20), + /* 14 S> */ B(LdaSmi), I8(20), /* 16 E> */ B(StaLookupSlotSloppy), U8(0), /* 22 S> */ B(LdaUndefined), B(Star), R(2), @@ -126,9 +126,9 @@ bytecodes: [ B(Star), R(3), B(LdaZero), B(Star), R(7), - B(LdaSmi), U8(10), + B(LdaSmi), I8(10), B(Star), R(8), - B(LdaSmi), U8(29), + B(LdaSmi), I8(29), B(Star), R(9), B(Mov), R(1), R(4), B(Mov), R(3), R(5), @@ -176,9 +176,9 @@ bytecodes: [ B(Star), R(3), B(LdaZero), B(Star), R(7), - B(LdaSmi), U8(38), + B(LdaSmi), I8(38), B(Star), R(8), - B(LdaSmi), U8(44), + B(LdaSmi), I8(44), B(Star), R(9), B(Mov), R(1), R(4), B(Mov), R(3), R(5), @@ -227,9 +227,9 @@ bytecodes: [ B(Star), R(3), B(LdaZero), B(Star), R(7), - B(LdaSmi), U8(34), + B(LdaSmi), I8(34), B(Star), R(8), - B(LdaSmi), U8(40), + B(LdaSmi), I8(40), B(Star), R(9), B(Mov), R(1), R(4), B(Mov), R(3), R(5), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlotInEval.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlotInEval.golden index ce915d51c0..9a40416535 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlotInEval.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlotInEval.golden @@ -43,7 +43,7 @@ parameter count: 1 bytecode array length: 7 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 15 S> */ B(LdaSmi), U8(10), + /* 15 S> */ B(LdaSmi), I8(10), /* 17 E> */ B(StaLookupSlotSloppy), U8(0), B(LdaUndefined), /* 23 S> */ B(Return), @@ -68,7 +68,7 @@ parameter count: 1 bytecode array length: 7 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 29 S> */ B(LdaSmi), U8(10), + /* 29 S> */ B(LdaSmi), I8(10), /* 31 E> */ B(StaLookupSlotStrict), U8(0), B(LdaUndefined), /* 37 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlotWideInEval.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlotWideInEval.golden index f7e64f4864..2dcd93b231 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlotWideInEval.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/LookupSlotWideInEval.golden @@ -2895,7 +2895,7 @@ bytecodes: [ B(Star), R(0), /* 3082 S> */ B(LdaConstant), U8(255), B(Star), R(0), - /* 3086 S> */ B(LdaSmi), U8(10), + /* 3086 S> */ B(LdaSmi), I8(10), /* 3088 E> */ B(Wide), B(StaLookupSlotSloppy), U16(256), B(LdaUndefined), /* 3093 S> */ B(Return), @@ -3949,7 +3949,7 @@ bytecodes: [ B(Star), R(0), /* 3095 S> */ B(LdaConstant), U8(255), B(Star), R(0), - /* 3099 S> */ B(LdaSmi), U8(10), + /* 3099 S> */ B(LdaSmi), I8(10), /* 3101 E> */ B(Wide), B(StaLookupSlotStrict), U16(256), B(LdaUndefined), /* 3106 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Modules.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Modules.golden index db5b72c6ee..f8c4df6b30 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Modules.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Modules.golden @@ -24,10 +24,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(1), U8(0), B(JumpIfTrue), U8(63), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(3), B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(LdaConstant), U8(0), B(Star), R(5), @@ -38,19 +38,19 @@ bytecodes: [ B(Ldar), R(this), B(StaCurrentContextSlot), U8(4), /* 0 E> */ B(StackCheck), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(4), B(Mov), R(closure), R(3), /* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(3), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(4), B(LdaZero), B(SuspendGenerator), R(4), B(Ldar), R(3), /* 13 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(4), U8(1), B(Star), R(5), @@ -59,7 +59,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(15), B(Jump), U8(2), @@ -96,10 +96,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(1), U8(0), B(JumpIfTrue), U8(63), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(3), B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(LdaConstant), U8(0), B(Star), R(5), @@ -110,19 +110,19 @@ bytecodes: [ B(Ldar), R(this), B(StaCurrentContextSlot), U8(4), /* 0 E> */ B(StackCheck), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(4), B(Mov), R(closure), R(3), /* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(3), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(4), B(LdaZero), B(SuspendGenerator), R(4), B(Ldar), R(3), /* 24 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(4), U8(1), B(Star), R(5), @@ -131,7 +131,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(15), B(Jump), U8(2), @@ -170,10 +170,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(2), U8(0), B(JumpIfTrue), U8(63), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(4), B(CallRuntime), U16(Runtime::kAbort), R(4), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(2), B(LdaConstant), U8(0), B(Star), R(6), @@ -184,19 +184,19 @@ bytecodes: [ B(Ldar), R(this), B(StaCurrentContextSlot), U8(4), /* 0 E> */ B(StackCheck), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(5), B(Mov), R(closure), R(4), /* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(4), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(4), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(5), B(LdaZero), B(SuspendGenerator), R(5), B(Ldar), R(4), /* 64 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(2), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(5), U8(1), B(Star), R(6), @@ -205,7 +205,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(7), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(7), U8(0), B(JumpIfTrue), U8(15), B(Jump), U8(2), @@ -218,13 +218,13 @@ bytecodes: [ /* 0 E> */ B(Throw), /* 32 S> */ B(LdaUndefined), B(Star), R(5), - /* 32 E> */ B(LdaModuleVariable), U8(-1), U8(0), + /* 32 E> */ B(LdaModuleVariable), I8(-1), U8(0), B(JumpIfNotHole), U8(11), B(LdaConstant), U8(1), B(Star), R(6), B(CallRuntime), U16(Runtime::kThrowReferenceError), R(6), U8(1), B(Star), R(4), - B(LdaSmi), U8(42), + B(LdaSmi), I8(42), B(Star), R(6), /* 32 E> */ B(Call), R(4), R(5), U8(2), U8(2), B(Ldar), R(closure), @@ -236,13 +236,13 @@ bytecodes: [ /* 47 E> */ B(StaCurrentContextSlot), U8(4), /* 52 S> */ B(LdaUndefined), B(Star), R(5), - /* 52 E> */ B(LdaModuleVariable), U8(-1), U8(1), + /* 52 E> */ B(LdaModuleVariable), I8(-1), U8(1), B(JumpIfNotHole), U8(11), B(LdaConstant), U8(1), B(Star), R(6), B(CallRuntime), U16(Runtime::kThrowReferenceError), R(6), U8(1), B(Star), R(4), - B(LdaSmi), U8(42), + B(LdaSmi), I8(42), B(Star), R(6), /* 52 E> */ B(Call), R(4), R(5), U8(2), U8(4), B(PopContext), R(1), @@ -276,10 +276,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(2), U8(0), B(JumpIfTrue), U8(63), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(4), B(CallRuntime), U16(Runtime::kAbort), R(4), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(2), B(LdaConstant), U8(0), B(Star), R(6), @@ -290,19 +290,19 @@ bytecodes: [ B(Ldar), R(this), B(StaCurrentContextSlot), U8(4), /* 0 E> */ B(StackCheck), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(5), B(Mov), R(closure), R(4), /* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(4), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(4), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(5), B(LdaZero), B(SuspendGenerator), R(5), B(Ldar), R(4), /* 49 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(2), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(5), U8(1), B(Star), R(6), @@ -311,7 +311,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(7), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(7), U8(0), B(JumpIfTrue), U8(15), B(Jump), U8(2), @@ -322,11 +322,11 @@ bytecodes: [ /* 49 S> */ B(Return), B(Ldar), R(6), /* 0 E> */ B(Throw), - /* 17 S> */ B(LdaSmi), U8(42), - /* 17 E> */ B(StaModuleVariable), U8(1), U8(0), - /* 21 S> */ B(LdaModuleVariable), U8(1), U8(0), + /* 17 S> */ B(LdaSmi), I8(42), + /* 17 E> */ B(StaModuleVariable), I8(1), U8(0), + /* 21 S> */ B(LdaModuleVariable), I8(1), U8(0), B(Inc), U8(2), - /* 24 E> */ B(StaModuleVariable), U8(1), U8(0), + /* 24 E> */ B(StaModuleVariable), I8(1), U8(0), B(Ldar), R(closure), B(CreateBlockContext), U8(1), B(PushContext), R(1), @@ -334,9 +334,9 @@ bytecodes: [ B(StaCurrentContextSlot), U8(4), /* 34 S> */ B(LdaUndefined), /* 34 E> */ B(StaCurrentContextSlot), U8(4), - /* 39 S> */ B(LdaModuleVariable), U8(1), U8(1), + /* 39 S> */ B(LdaModuleVariable), I8(1), U8(1), B(Inc), U8(3), - /* 42 E> */ B(StaModuleVariable), U8(1), U8(1), + /* 42 E> */ B(StaModuleVariable), I8(1), U8(1), B(PopContext), R(1), B(LdaUndefined), /* 49 S> */ B(Return), @@ -367,10 +367,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(2), U8(0), B(JumpIfTrue), U8(67), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(4), B(CallRuntime), U16(Runtime::kAbort), R(4), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(2), B(LdaConstant), U8(0), B(Star), R(6), @@ -381,21 +381,21 @@ bytecodes: [ B(Ldar), R(this), B(StaCurrentContextSlot), U8(4), B(LdaTheHole), - B(StaModuleVariable), U8(1), U8(0), + B(StaModuleVariable), I8(1), U8(0), /* 0 E> */ B(StackCheck), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(5), B(Mov), R(closure), R(4), /* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(4), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(4), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(5), B(LdaZero), B(SuspendGenerator), R(5), B(Ldar), R(4), /* 49 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(2), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(5), U8(1), B(Star), R(6), @@ -404,7 +404,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(7), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(7), U8(0), B(JumpIfTrue), U8(15), B(Jump), U8(2), @@ -415,11 +415,11 @@ bytecodes: [ /* 49 S> */ B(Return), B(Ldar), R(6), /* 0 E> */ B(Throw), - /* 17 S> */ B(LdaSmi), U8(42), - /* 17 E> */ B(StaModuleVariable), U8(1), U8(0), - /* 21 S> */ B(LdaModuleVariable), U8(1), U8(0), + /* 17 S> */ B(LdaSmi), I8(42), + /* 17 E> */ B(StaModuleVariable), I8(1), U8(0), + /* 21 S> */ B(LdaModuleVariable), I8(1), U8(0), B(Inc), U8(2), - /* 24 E> */ B(StaModuleVariable), U8(1), U8(0), + /* 24 E> */ B(StaModuleVariable), I8(1), U8(0), B(Ldar), R(closure), B(CreateBlockContext), U8(1), B(PushContext), R(1), @@ -427,9 +427,9 @@ bytecodes: [ B(StaCurrentContextSlot), U8(4), /* 34 S> */ B(LdaUndefined), /* 34 E> */ B(StaCurrentContextSlot), U8(4), - /* 39 S> */ B(LdaModuleVariable), U8(1), U8(1), + /* 39 S> */ B(LdaModuleVariable), I8(1), U8(1), B(Inc), U8(3), - /* 42 E> */ B(StaModuleVariable), U8(1), U8(1), + /* 42 E> */ B(StaModuleVariable), I8(1), U8(1), B(PopContext), R(1), B(LdaUndefined), /* 49 S> */ B(Return), @@ -460,10 +460,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(2), U8(0), B(JumpIfTrue), U8(67), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(4), B(CallRuntime), U16(Runtime::kAbort), R(4), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(2), B(LdaConstant), U8(0), B(Star), R(6), @@ -474,21 +474,21 @@ bytecodes: [ B(Ldar), R(this), B(StaCurrentContextSlot), U8(4), B(LdaTheHole), - B(StaModuleVariable), U8(1), U8(0), + B(StaModuleVariable), I8(1), U8(0), /* 0 E> */ B(StackCheck), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(5), B(Mov), R(closure), R(4), /* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(4), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(4), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(5), B(LdaZero), B(SuspendGenerator), R(5), B(Ldar), R(4), /* 51 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(2), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(5), U8(1), B(Star), R(6), @@ -497,7 +497,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(7), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(7), U8(0), B(JumpIfTrue), U8(15), B(Jump), U8(2), @@ -508,9 +508,9 @@ bytecodes: [ /* 51 S> */ B(Return), B(Ldar), R(6), /* 0 E> */ B(Throw), - /* 19 S> */ B(LdaSmi), U8(42), - /* 19 E> */ B(StaModuleVariable), U8(1), U8(0), - /* 23 S> */ B(LdaModuleVariable), U8(1), U8(0), + /* 19 S> */ B(LdaSmi), I8(42), + /* 19 E> */ B(StaModuleVariable), I8(1), U8(0), + /* 23 S> */ B(LdaModuleVariable), I8(1), U8(0), B(Inc), U8(2), /* 26 E> */ B(CallRuntime), U16(Runtime::kThrowConstAssignError), R(0), U8(0), B(Ldar), R(closure), @@ -520,7 +520,7 @@ bytecodes: [ B(StaCurrentContextSlot), U8(4), /* 36 S> */ B(LdaUndefined), /* 36 E> */ B(StaCurrentContextSlot), U8(4), - /* 41 S> */ B(LdaModuleVariable), U8(1), U8(1), + /* 41 S> */ B(LdaModuleVariable), I8(1), U8(1), B(Inc), U8(3), /* 44 E> */ B(CallRuntime), U16(Runtime::kThrowConstAssignError), R(0), U8(0), B(PopContext), R(1), @@ -551,10 +551,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(1), U8(0), B(JumpIfTrue), U8(67), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(3), B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(LdaConstant), U8(0), B(Star), R(5), @@ -565,21 +565,21 @@ bytecodes: [ B(Ldar), R(this), B(StaCurrentContextSlot), U8(4), B(LdaTheHole), - B(StaModuleVariable), U8(1), U8(0), + B(StaModuleVariable), I8(1), U8(0), /* 0 E> */ B(StackCheck), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(4), B(Mov), R(closure), R(3), /* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(3), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(4), B(LdaZero), B(SuspendGenerator), R(4), B(Ldar), R(3), /* 32 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(4), U8(1), B(Star), R(5), @@ -588,7 +588,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(15), B(Jump), U8(2), @@ -600,7 +600,7 @@ bytecodes: [ B(Ldar), R(5), /* 0 E> */ B(Throw), B(CreateClosure), U8(1), U8(2), U8(0), - B(StaModuleVariable), U8(1), U8(0), + B(StaModuleVariable), I8(1), U8(0), B(LdaUndefined), /* 32 S> */ B(Return), ] @@ -628,10 +628,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(1), U8(0), B(JumpIfTrue), U8(67), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(3), B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(LdaConstant), U8(0), B(Star), R(5), @@ -642,21 +642,21 @@ bytecodes: [ B(Ldar), R(this), B(StaCurrentContextSlot), U8(4), B(LdaTheHole), - B(StaModuleVariable), U8(1), U8(0), + B(StaModuleVariable), I8(1), U8(0), /* 0 E> */ B(StackCheck), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(4), B(Mov), R(closure), R(3), /* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(3), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(4), B(LdaZero), B(SuspendGenerator), R(4), B(Ldar), R(3), /* 26 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(4), U8(1), B(Star), R(5), @@ -665,7 +665,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(15), B(Jump), U8(2), @@ -680,9 +680,9 @@ bytecodes: [ B(Star), R(3), B(LdaTheHole), B(Star), R(4), - B(LdaSmi), U8(16), + B(LdaSmi), I8(16), B(Star), R(6), - B(LdaSmi), U8(24), + B(LdaSmi), I8(24), B(Star), R(7), B(Mov), R(3), R(5), B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(4), @@ -691,7 +691,7 @@ bytecodes: [ B(CallRuntime), U16(Runtime::kToFastProperties), R(3), U8(1), B(StaCurrentContextSlot), U8(6), B(LdaCurrentContextSlot), U8(6), - /* 16 E> */ B(StaModuleVariable), U8(1), U8(0), + /* 16 E> */ B(StaModuleVariable), I8(1), U8(0), B(LdaUndefined), /* 26 S> */ B(Return), ] @@ -719,10 +719,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(1), U8(0), B(JumpIfTrue), U8(63), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(3), B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(LdaConstant), U8(0), B(Star), R(5), @@ -733,19 +733,19 @@ bytecodes: [ B(Ldar), R(this), B(StaCurrentContextSlot), U8(4), /* 0 E> */ B(StackCheck), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(4), B(Mov), R(closure), R(3), /* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(3), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(4), B(LdaZero), B(SuspendGenerator), R(4), B(Ldar), R(3), /* 30 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(4), U8(1), B(Star), R(5), @@ -754,7 +754,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(15), B(Jump), U8(2), @@ -791,10 +791,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(1), U8(0), B(JumpIfTrue), U8(63), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(3), B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(LdaConstant), U8(0), B(Star), R(5), @@ -805,19 +805,19 @@ bytecodes: [ B(Ldar), R(this), B(StaCurrentContextSlot), U8(4), /* 0 E> */ B(StackCheck), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(4), B(Mov), R(closure), R(3), /* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(3), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(4), B(LdaZero), B(SuspendGenerator), R(4), B(Ldar), R(3), /* 19 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(4), U8(1), B(Star), R(5), @@ -826,7 +826,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(15), B(Jump), U8(2), @@ -864,10 +864,10 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(1), U8(0), B(JumpIfTrue), U8(73), - B(LdaSmi), U8(78), + B(LdaSmi), I8(78), B(Star), R(3), B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(LdaConstant), U8(0), B(Star), R(5), @@ -882,19 +882,19 @@ bytecodes: [ B(CallRuntime), U16(Runtime::kGetModuleNamespace), R(3), U8(1), B(StaCurrentContextSlot), U8(6), /* 0 E> */ B(StackCheck), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(4), B(Mov), R(closure), R(3), /* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2), B(StaCurrentContextSlot), U8(5), B(Star), R(3), - B(LdaCurrentContextSlot), U8(5), + B(LdaImmutableCurrentContextSlot), U8(5), B(Star), R(4), B(LdaZero), B(SuspendGenerator), R(4), B(Ldar), R(3), /* 45 S> */ B(Return), - B(LdaSmi), U8(-2), + B(LdaSmi), I8(-2), B(Star), R(1), B(CallRuntime), U16(Runtime::k_GeneratorGetInputOrDebugPos), R(4), U8(1), B(Star), R(5), @@ -903,7 +903,7 @@ bytecodes: [ B(LdaZero), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(25), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(6), U8(0), B(JumpIfTrue), U8(15), B(Jump), U8(2), @@ -914,13 +914,13 @@ bytecodes: [ /* 45 S> */ B(Return), B(Ldar), R(5), /* 0 E> */ B(Throw), - /* 27 S> */ B(LdaCurrentContextSlot), U8(6), + /* 27 S> */ B(LdaImmutableCurrentContextSlot), U8(6), B(Star), R(4), /* 30 E> */ B(LdaNamedProperty), R(4), U8(1), U8(4), B(Star), R(3), - B(LdaCurrentContextSlot), U8(6), + B(LdaImmutableCurrentContextSlot), U8(6), B(Star), R(5), - B(LdaCurrentContextSlot), U8(6), + B(LdaImmutableCurrentContextSlot), U8(6), B(Star), R(6), /* 41 E> */ B(LdaNamedProperty), R(6), U8(2), U8(6), B(Star), R(6), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden new file mode 100644 index 0000000000..e77314533c --- /dev/null +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden @@ -0,0 +1,157 @@ +# +# Autogenerated by generate-bytecode-expectations. +# + +--- +wrap: yes + +--- +snippet: " + class A { constructor(...args) { this.args = args; } } + new A(...[1, 2, 3]); +" +frame size: 8 +parameter count: 1 +bytecode array length: 64 +bytecodes: [ + B(LdaTheHole), + B(Star), R(2), + /* 30 E> */ B(StackCheck), + B(LdaTheHole), + B(Star), R(0), + /* 34 S> */ B(CreateClosure), U8(0), U8(2), U8(2), + B(Star), R(3), + B(LdaTheHole), + B(Star), R(4), + B(LdaSmi), I8(34), + B(Star), R(6), + B(LdaSmi), I8(88), + B(Star), R(7), + B(Mov), R(3), R(5), + B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(4), + B(Star), R(4), + B(CallRuntime), U16(Runtime::kInstallClassNameAccessor), R(3), U8(1), + B(CallRuntime), U16(Runtime::kToFastProperties), R(3), U8(1), + B(Star), R(0), + B(Star), R(1), + B(Star), R(2), + /* 89 S> */ B(CreateArrayLiteral), U8(1), U8(5), U8(9), + B(Star), R(4), + B(Ldar), R(2), + /* 89 E> */ B(ConstructWithSpread), R(2), R(4), U8(1), + B(LdaUndefined), + /* 110 S> */ B(Return), +] +constant pool: [ + SHARED_FUNCTION_INFO_TYPE, + CONSTANT_ELEMENTS_PAIR_TYPE, +] +handlers: [ +] + +--- +snippet: " + class A { constructor(...args) { this.args = args; } } + new A(0, ...[1, 2, 3]); +" +frame size: 8 +parameter count: 1 +bytecode array length: 67 +bytecodes: [ + B(LdaTheHole), + B(Star), R(2), + /* 30 E> */ B(StackCheck), + B(LdaTheHole), + B(Star), R(0), + /* 34 S> */ B(CreateClosure), U8(0), U8(2), U8(2), + B(Star), R(3), + B(LdaTheHole), + B(Star), R(4), + B(LdaSmi), I8(34), + B(Star), R(6), + B(LdaSmi), I8(88), + B(Star), R(7), + B(Mov), R(3), R(5), + B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(4), + B(Star), R(4), + B(CallRuntime), U16(Runtime::kInstallClassNameAccessor), R(3), U8(1), + B(CallRuntime), U16(Runtime::kToFastProperties), R(3), U8(1), + B(Star), R(0), + B(Star), R(1), + B(Star), R(2), + /* 89 S> */ B(LdaZero), + B(Star), R(4), + B(CreateArrayLiteral), U8(1), U8(5), U8(9), + B(Star), R(5), + B(Ldar), R(2), + /* 89 E> */ B(ConstructWithSpread), R(2), R(4), U8(2), + B(LdaUndefined), + /* 113 S> */ B(Return), +] +constant pool: [ + SHARED_FUNCTION_INFO_TYPE, + CONSTANT_ELEMENTS_PAIR_TYPE, +] +handlers: [ +] + +--- +snippet: " + class A { constructor(...args) { this.args = args; } } + new A(0, ...[1, 2, 3], 4); +" +frame size: 9 +parameter count: 1 +bytecode array length: 98 +bytecodes: [ + B(LdaTheHole), + B(Star), R(2), + /* 30 E> */ B(StackCheck), + B(LdaTheHole), + B(Star), R(0), + /* 34 S> */ B(CreateClosure), U8(0), U8(2), U8(2), + B(Star), R(3), + B(LdaTheHole), + B(Star), R(4), + B(LdaSmi), I8(34), + B(Star), R(6), + B(LdaSmi), I8(88), + B(Star), R(7), + B(Mov), R(3), R(5), + B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(4), + B(Star), R(4), + B(CallRuntime), U16(Runtime::kInstallClassNameAccessor), R(3), U8(1), + B(CallRuntime), U16(Runtime::kToFastProperties), R(3), U8(1), + B(Star), R(0), + B(Star), R(1), + B(Star), R(2), + /* 89 S> */ B(LdaUndefined), + B(Star), R(3), + B(LdaUndefined), + B(Star), R(5), + /* 93 E> */ B(CreateArrayLiteral), U8(1), U8(3), U8(9), + B(Star), R(6), + B(LdaUndefined), + B(Star), R(7), + B(CreateArrayLiteral), U8(2), U8(4), U8(9), + B(Star), R(8), + B(CallJSRuntime), U8(%spread_iterable), R(7), U8(2), + B(Star), R(7), + B(CreateArrayLiteral), U8(3), U8(5), U8(9), + B(Star), R(8), + B(CallJSRuntime), U8(%spread_arguments), R(5), U8(4), + B(Star), R(5), + B(Mov), R(1), R(4), + B(CallJSRuntime), U8(%reflect_construct), R(3), U8(3), + B(LdaUndefined), + /* 116 S> */ B(Return), +] +constant pool: [ + SHARED_FUNCTION_INFO_TYPE, + CONSTANT_ELEMENTS_PAIR_TYPE, + CONSTANT_ELEMENTS_PAIR_TYPE, + CONSTANT_ELEMENTS_PAIR_TYPE, +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden index 75c6ff57be..de0db058e9 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden @@ -14,7 +14,7 @@ parameter count: 1 bytecode array length: 9 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(35), R(0), + /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(35), R(0), B(Ldar), R(0), /* 46 S> */ B(Return), ] @@ -33,7 +33,7 @@ parameter count: 1 bytecode array length: 9 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(0), + /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(0), B(Ldar), R(0), /* 71 S> */ B(Return), ] @@ -52,10 +52,10 @@ parameter count: 1 bytecode array length: 17 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), - /* 75 E> */ B(StaNamedPropertySloppy), R(1), U8(1), U8(2), + /* 45 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), + /* 75 E> */ B(StaNamedOwnProperty), R(1), U8(1), U8(3), B(Ldar), R(1), /* 80 S> */ B(Return), ] @@ -75,11 +75,11 @@ parameter count: 1 bytecode array length: 21 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), - /* 69 E> */ B(AddSmi), U8(1), R(0), U8(2), - B(StaNamedPropertySloppy), R(1), U8(1), U8(3), + /* 45 S> */ B(CreateObjectLiteral), U8(0), U8(3), U8(1), R(1), + /* 69 E> */ B(AddSmi), I8(1), R(0), U8(2), + B(StaNamedOwnProperty), R(1), U8(1), U8(4), B(Ldar), R(1), /* 76 S> */ B(Return), ] @@ -99,9 +99,9 @@ parameter count: 1 bytecode array length: 17 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(0), + /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(3), U8(1), R(0), B(CreateClosure), U8(1), U8(2), U8(2), - B(StaNamedPropertySloppy), R(0), U8(2), U8(3), + B(StaNamedOwnProperty), R(0), U8(2), U8(4), B(Ldar), R(0), /* 67 S> */ B(Return), ] @@ -122,9 +122,9 @@ parameter count: 1 bytecode array length: 17 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(0), + /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(3), U8(1), R(0), B(CreateClosure), U8(1), U8(2), U8(2), - B(StaNamedPropertySloppy), R(0), U8(2), U8(3), + B(StaNamedOwnProperty), R(0), U8(2), U8(4), B(Ldar), R(0), /* 68 S> */ B(Return), ] @@ -145,7 +145,7 @@ parameter count: 1 bytecode array length: 33 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(0), + /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(3), U8(1), R(0), B(LdaConstant), U8(1), B(Star), R(2), B(CreateClosure), U8(2), U8(2), U8(2), @@ -176,7 +176,7 @@ parameter count: 1 bytecode array length: 36 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(0), + /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(4), U8(1), R(0), B(LdaConstant), U8(1), B(Star), R(2), B(CreateClosure), U8(2), U8(2), U8(2), @@ -208,7 +208,7 @@ parameter count: 1 bytecode array length: 33 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(0), + /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(3), U8(1), R(0), B(LdaConstant), U8(1), B(Star), R(2), B(LdaNull), @@ -239,10 +239,10 @@ parameter count: 1 bytecode array length: 31 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), - B(LdaSmi), U8(1), + /* 45 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), + B(LdaSmi), I8(1), B(Star), R(3), B(LdaZero), B(Star), R(5), @@ -267,7 +267,7 @@ parameter count: 1 bytecode array length: 20 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(35), R(0), + /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(35), R(0), B(LdaNull), B(Star), R(2), B(Mov), R(0), R(1), @@ -292,11 +292,11 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaConstant), U8(0), B(Star), R(0), - /* 50 S> */ B(CreateObjectLiteral), U8(1), U8(0), U8(35), R(1), + /* 50 S> */ B(CreateObjectLiteral), U8(1), U8(2), U8(35), R(1), /* 60 E> */ B(ToName), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(3), - B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(2), + B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(3), B(Ldar), R(1), /* 69 S> */ B(Return), ] @@ -318,12 +318,12 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaConstant), U8(0), B(Star), R(0), - /* 50 S> */ B(CreateObjectLiteral), U8(1), U8(0), U8(1), R(1), - /* 64 E> */ B(StaNamedPropertySloppy), R(1), U8(2), U8(2), + /* 50 S> */ B(CreateObjectLiteral), U8(1), U8(2), U8(1), R(1), + /* 64 E> */ B(StaNamedOwnProperty), R(1), U8(2), U8(3), /* 68 E> */ B(ToName), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(3), - B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(4), + B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(5), B(Ldar), R(1), /* 77 S> */ B(Return), ] @@ -346,12 +346,12 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaConstant), U8(0), B(Star), R(0), - /* 50 S> */ B(CreateObjectLiteral), U8(1), U8(1), U8(35), R(1), + /* 50 S> */ B(CreateObjectLiteral), U8(1), U8(3), U8(35), R(1), /* 60 E> */ B(ToName), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(3), - B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(2), - B(CreateObjectLiteral), U8(1), U8(0), U8(35), R(4), + B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(4), + B(CreateObjectLiteral), U8(1), U8(2), U8(35), R(4), B(Mov), R(1), R(2), B(Mov), R(4), R(3), B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(2), U8(2), @@ -376,11 +376,11 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaConstant), U8(0), B(Star), R(0), - /* 50 S> */ B(CreateObjectLiteral), U8(1), U8(0), U8(35), R(1), + /* 50 S> */ B(CreateObjectLiteral), U8(1), U8(4), U8(35), R(1), /* 60 E> */ B(ToName), R(2), B(LdaConstant), U8(2), B(Star), R(3), - B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(4), + B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(5), B(LdaConstant), U8(3), B(ToName), R(3), B(CreateClosure), U8(4), U8(2), U8(2), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiteralsWide.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiteralsWide.golden index b281cb7336..e1f320e397 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiteralsWide.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiteralsWide.golden @@ -783,7 +783,7 @@ bytecodes: [ B(Star), R(0), /* 2591 S> */ B(LdaConstant), U8(255), B(Star), R(0), - /* 2601 S> */ B(Wide), B(CreateObjectLiteral), U16(256), U16(0), U8(1), R16(1), + /* 2601 S> */ B(Wide), B(CreateObjectLiteral), U16(256), U16(2), U8(1), R16(1), B(Ldar), R(1), /* 2638 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/OuterContextVariables.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/OuterContextVariables.golden index 52ea01f910..d72a32aef4 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/OuterContextVariables.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/OuterContextVariables.golden @@ -23,9 +23,9 @@ parameter count: 1 bytecode array length: 13 bytecodes: [ /* 97 E> */ B(StackCheck), - /* 102 S> */ B(LdaContextSlot), R(context), U8(4), U8(1), + /* 102 S> */ B(LdaImmutableContextSlot), R(context), U8(4), U8(1), B(Star), R(0), - B(LdaCurrentContextSlot), U8(4), + B(LdaImmutableCurrentContextSlot), U8(4), /* 118 E> */ B(Mul), R(0), U8(2), /* 130 S> */ B(Return), ] @@ -51,7 +51,7 @@ parameter count: 1 bytecode array length: 9 bytecodes: [ /* 97 E> */ B(StackCheck), - /* 102 S> */ B(LdaCurrentContextSlot), U8(4), + /* 102 S> */ B(LdaImmutableCurrentContextSlot), U8(4), /* 111 E> */ B(StaContextSlot), R(context), U8(4), U8(1), B(LdaUndefined), /* 123 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Parameters.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Parameters.golden index 01c3ad0694..b3c987f296 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Parameters.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Parameters.golden @@ -106,7 +106,7 @@ parameter count: 2 bytecode array length: 7 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 19 S> */ B(LdaSmi), U8(1), + /* 19 S> */ B(LdaSmi), I8(1), B(Star), R(arg0), B(LdaUndefined), /* 29 S> */ B(Return), @@ -126,7 +126,7 @@ parameter count: 5 bytecode array length: 7 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 37 S> */ B(LdaSmi), U8(1), + /* 37 S> */ B(LdaSmi), I8(1), B(Star), R(arg1), B(LdaUndefined), /* 47 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PrimitiveExpressions.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrimitiveExpressions.golden index 90fb7b9dbb..055c016e24 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/PrimitiveExpressions.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrimitiveExpressions.golden @@ -35,7 +35,7 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 45 S> */ B(LdaSmi), U8(3), + /* 45 S> */ B(LdaSmi), I8(3), /* 54 E> */ B(Add), R(0), U8(2), /* 59 S> */ B(Return), ] @@ -55,7 +55,7 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 45 S> */ B(LdaSmi), U8(3), + /* 45 S> */ B(LdaSmi), I8(3), /* 54 E> */ B(Sub), R(0), U8(2), /* 59 S> */ B(Return), ] @@ -73,9 +73,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(4), + /* 42 S> */ B(LdaSmi), I8(4), B(Star), R(0), - /* 45 S> */ B(LdaSmi), U8(3), + /* 45 S> */ B(LdaSmi), I8(3), /* 54 E> */ B(Mul), R(0), U8(2), /* 59 S> */ B(Return), ] @@ -93,9 +93,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(4), + /* 42 S> */ B(LdaSmi), I8(4), B(Star), R(0), - /* 45 S> */ B(LdaSmi), U8(3), + /* 45 S> */ B(LdaSmi), I8(3), /* 54 E> */ B(Div), R(0), U8(2), /* 59 S> */ B(Return), ] @@ -113,9 +113,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(4), + /* 42 S> */ B(LdaSmi), I8(4), B(Star), R(0), - /* 45 S> */ B(LdaSmi), U8(3), + /* 45 S> */ B(LdaSmi), I8(3), /* 54 E> */ B(Mod), R(0), U8(2), /* 59 S> */ B(Return), ] @@ -133,9 +133,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(LdaSmi), U8(2), + /* 45 S> */ B(LdaSmi), I8(2), /* 54 E> */ B(BitwiseOr), R(0), U8(2), /* 59 S> */ B(Return), ] @@ -153,9 +153,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(LdaSmi), U8(2), + /* 45 S> */ B(LdaSmi), I8(2), /* 54 E> */ B(BitwiseXor), R(0), U8(2), /* 59 S> */ B(Return), ] @@ -173,9 +173,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(LdaSmi), U8(2), + /* 45 S> */ B(LdaSmi), I8(2), /* 54 E> */ B(BitwiseAnd), R(0), U8(2), /* 59 S> */ B(Return), ] @@ -193,9 +193,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), B(Star), R(0), - /* 46 S> */ B(LdaSmi), U8(3), + /* 46 S> */ B(LdaSmi), I8(3), /* 55 E> */ B(ShiftLeft), R(0), U8(2), /* 61 S> */ B(Return), ] @@ -213,9 +213,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), B(Star), R(0), - /* 46 S> */ B(LdaSmi), U8(3), + /* 46 S> */ B(LdaSmi), I8(3), /* 55 E> */ B(ShiftRight), R(0), U8(2), /* 61 S> */ B(Return), ] @@ -233,9 +233,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(10), + /* 42 S> */ B(LdaSmi), I8(10), B(Star), R(0), - /* 46 S> */ B(LdaSmi), U8(3), + /* 46 S> */ B(LdaSmi), I8(3), /* 55 E> */ B(ShiftRightLogical), R(0), U8(2), /* 62 S> */ B(Return), ] @@ -255,7 +255,7 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 45 S> */ B(LdaSmi), U8(3), + /* 45 S> */ B(LdaSmi), I8(3), /* 60 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PrimitiveReturnStatements.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrimitiveReturnStatements.golden index 48db168d03..aae0c2d0bd 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/PrimitiveReturnStatements.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrimitiveReturnStatements.golden @@ -115,7 +115,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(LdaSmi), U8(1), + /* 34 S> */ B(LdaSmi), I8(1), /* 45 S> */ B(Return), ] constant pool: [ @@ -132,7 +132,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(LdaSmi), U8(-1), + /* 34 S> */ B(LdaSmi), I8(-1), /* 45 S> */ B(Return), ] constant pool: [ @@ -149,7 +149,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(LdaSmi), U8(127), + /* 34 S> */ B(LdaSmi), I8(127), /* 47 S> */ B(Return), ] constant pool: [ @@ -166,7 +166,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(LdaSmi), U8(-128), + /* 34 S> */ B(LdaSmi), I8(-128), /* 47 S> */ B(Return), ] constant pool: [ @@ -183,7 +183,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(LdaSmi), U8(2), + /* 34 S> */ B(LdaSmi), I8(2), /* 46 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyCall.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyCall.golden index f0a51af8bd..38ef6a3fc4 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyCall.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyCall.golden @@ -500,20 +500,20 @@ bytecodes: [ /* 16 S> */ B(Nop), /* 24 E> */ B(LdaNamedProperty), R(arg0), U8(0), U8(8), B(Star), R(2), - B(LdaSmi), U8(1), + B(LdaSmi), I8(1), B(Star), R(4), B(Mov), R(arg0), R(3), /* 25 E> */ B(CallProperty), R(2), R(3), U8(2), U8(6), B(Star), R(2), /* 32 E> */ B(LdaNamedProperty), R(2), U8(0), U8(10), B(Star), R(1), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(Star), R(3), /* 33 E> */ B(CallProperty), R(1), R(2), U8(2), U8(4), B(Star), R(1), /* 40 E> */ B(LdaNamedProperty), R(1), U8(0), U8(12), B(Star), R(0), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(Star), R(2), /* 41 E> */ B(CallProperty), R(0), R(1), U8(2), U8(2), /* 50 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoads.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoads.golden index 70e75645b2..bee525cf44 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoads.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoads.golden @@ -56,7 +56,7 @@ parameter count: 2 bytecode array length: 7 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 16 S> */ B(LdaSmi), U8(100), + /* 16 S> */ B(LdaSmi), I8(100), /* 24 E> */ B(LdaKeyedProperty), R(arg0), U8(2), /* 31 S> */ B(Return), ] @@ -97,7 +97,7 @@ bytecodes: [ /* 25 S> */ B(Nop), /* 25 E> */ B(LdaNamedProperty), R(arg0), U8(0), U8(2), B(Star), R(0), - /* 32 S> */ B(LdaSmi), U8(-124), + /* 32 S> */ B(LdaSmi), I8(-124), /* 40 E> */ B(LdaKeyedProperty), R(arg0), U8(4), /* 48 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyStores.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyStores.golden index ed71814500..7e6dd5ae78 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyStores.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyStores.golden @@ -60,7 +60,7 @@ parameter count: 2 bytecode array length: 13 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 16 S> */ B(LdaSmi), U8(100), + /* 16 S> */ B(LdaSmi), I8(100), B(Star), R(1), B(LdaConstant), U8(0), /* 23 E> */ B(StaKeyedPropertySloppy), R(arg0), R(1), U8(2), @@ -104,7 +104,7 @@ parameter count: 2 bytecode array length: 12 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 16 S> */ B(LdaSmi), U8(-124), + /* 16 S> */ B(LdaSmi), I8(-124), /* 26 E> */ B(LdaKeyedProperty), R(arg0), U8(2), /* 23 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(4), B(LdaUndefined), @@ -299,263 +299,263 @@ parameter count: 2 bytecode array length: 785 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 18 S> */ B(LdaSmi), U8(1), + /* 18 S> */ B(LdaSmi), I8(1), /* 25 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(2), - /* 32 S> */ B(LdaSmi), U8(1), + /* 32 S> */ B(LdaSmi), I8(1), /* 39 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(4), - /* 46 S> */ B(LdaSmi), U8(1), + /* 46 S> */ B(LdaSmi), I8(1), /* 53 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(6), - /* 60 S> */ B(LdaSmi), U8(1), + /* 60 S> */ B(LdaSmi), I8(1), /* 67 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(8), - /* 74 S> */ B(LdaSmi), U8(1), + /* 74 S> */ B(LdaSmi), I8(1), /* 81 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(10), - /* 88 S> */ B(LdaSmi), U8(1), + /* 88 S> */ B(LdaSmi), I8(1), /* 95 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(12), - /* 102 S> */ B(LdaSmi), U8(1), + /* 102 S> */ B(LdaSmi), I8(1), /* 109 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(14), - /* 116 S> */ B(LdaSmi), U8(1), + /* 116 S> */ B(LdaSmi), I8(1), /* 123 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(16), - /* 130 S> */ B(LdaSmi), U8(1), + /* 130 S> */ B(LdaSmi), I8(1), /* 137 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(18), - /* 144 S> */ B(LdaSmi), U8(1), + /* 144 S> */ B(LdaSmi), I8(1), /* 151 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(20), - /* 158 S> */ B(LdaSmi), U8(1), + /* 158 S> */ B(LdaSmi), I8(1), /* 165 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(22), - /* 172 S> */ B(LdaSmi), U8(1), + /* 172 S> */ B(LdaSmi), I8(1), /* 179 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(24), - /* 186 S> */ B(LdaSmi), U8(1), + /* 186 S> */ B(LdaSmi), I8(1), /* 193 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(26), - /* 200 S> */ B(LdaSmi), U8(1), + /* 200 S> */ B(LdaSmi), I8(1), /* 207 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(28), - /* 214 S> */ B(LdaSmi), U8(1), + /* 214 S> */ B(LdaSmi), I8(1), /* 221 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(30), - /* 228 S> */ B(LdaSmi), U8(1), + /* 228 S> */ B(LdaSmi), I8(1), /* 235 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(32), - /* 242 S> */ B(LdaSmi), U8(1), + /* 242 S> */ B(LdaSmi), I8(1), /* 249 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(34), - /* 256 S> */ B(LdaSmi), U8(1), + /* 256 S> */ B(LdaSmi), I8(1), /* 263 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(36), - /* 270 S> */ B(LdaSmi), U8(1), + /* 270 S> */ B(LdaSmi), I8(1), /* 277 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(38), - /* 284 S> */ B(LdaSmi), U8(1), + /* 284 S> */ B(LdaSmi), I8(1), /* 291 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(40), - /* 298 S> */ B(LdaSmi), U8(1), + /* 298 S> */ B(LdaSmi), I8(1), /* 305 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(42), - /* 312 S> */ B(LdaSmi), U8(1), + /* 312 S> */ B(LdaSmi), I8(1), /* 319 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(44), - /* 326 S> */ B(LdaSmi), U8(1), + /* 326 S> */ B(LdaSmi), I8(1), /* 333 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(46), - /* 340 S> */ B(LdaSmi), U8(1), + /* 340 S> */ B(LdaSmi), I8(1), /* 347 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(48), - /* 354 S> */ B(LdaSmi), U8(1), + /* 354 S> */ B(LdaSmi), I8(1), /* 361 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(50), - /* 368 S> */ B(LdaSmi), U8(1), + /* 368 S> */ B(LdaSmi), I8(1), /* 375 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(52), - /* 382 S> */ B(LdaSmi), U8(1), + /* 382 S> */ B(LdaSmi), I8(1), /* 389 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(54), - /* 396 S> */ B(LdaSmi), U8(1), + /* 396 S> */ B(LdaSmi), I8(1), /* 403 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(56), - /* 410 S> */ B(LdaSmi), U8(1), + /* 410 S> */ B(LdaSmi), I8(1), /* 417 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(58), - /* 424 S> */ B(LdaSmi), U8(1), + /* 424 S> */ B(LdaSmi), I8(1), /* 431 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(60), - /* 438 S> */ B(LdaSmi), U8(1), + /* 438 S> */ B(LdaSmi), I8(1), /* 445 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(62), - /* 452 S> */ B(LdaSmi), U8(1), + /* 452 S> */ B(LdaSmi), I8(1), /* 459 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(64), - /* 466 S> */ B(LdaSmi), U8(1), + /* 466 S> */ B(LdaSmi), I8(1), /* 473 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(66), - /* 480 S> */ B(LdaSmi), U8(1), + /* 480 S> */ B(LdaSmi), I8(1), /* 487 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(68), - /* 494 S> */ B(LdaSmi), U8(1), + /* 494 S> */ B(LdaSmi), I8(1), /* 501 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(70), - /* 508 S> */ B(LdaSmi), U8(1), + /* 508 S> */ B(LdaSmi), I8(1), /* 515 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(72), - /* 522 S> */ B(LdaSmi), U8(1), + /* 522 S> */ B(LdaSmi), I8(1), /* 529 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(74), - /* 536 S> */ B(LdaSmi), U8(1), + /* 536 S> */ B(LdaSmi), I8(1), /* 543 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(76), - /* 550 S> */ B(LdaSmi), U8(1), + /* 550 S> */ B(LdaSmi), I8(1), /* 557 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(78), - /* 564 S> */ B(LdaSmi), U8(1), + /* 564 S> */ B(LdaSmi), I8(1), /* 571 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(80), - /* 578 S> */ B(LdaSmi), U8(1), + /* 578 S> */ B(LdaSmi), I8(1), /* 585 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(82), - /* 592 S> */ B(LdaSmi), U8(1), + /* 592 S> */ B(LdaSmi), I8(1), /* 599 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(84), - /* 606 S> */ B(LdaSmi), U8(1), + /* 606 S> */ B(LdaSmi), I8(1), /* 613 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(86), - /* 620 S> */ B(LdaSmi), U8(1), + /* 620 S> */ B(LdaSmi), I8(1), /* 627 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(88), - /* 634 S> */ B(LdaSmi), U8(1), + /* 634 S> */ B(LdaSmi), I8(1), /* 641 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(90), - /* 648 S> */ B(LdaSmi), U8(1), + /* 648 S> */ B(LdaSmi), I8(1), /* 655 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(92), - /* 662 S> */ B(LdaSmi), U8(1), + /* 662 S> */ B(LdaSmi), I8(1), /* 669 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(94), - /* 676 S> */ B(LdaSmi), U8(1), + /* 676 S> */ B(LdaSmi), I8(1), /* 683 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(96), - /* 690 S> */ B(LdaSmi), U8(1), + /* 690 S> */ B(LdaSmi), I8(1), /* 697 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(98), - /* 704 S> */ B(LdaSmi), U8(1), + /* 704 S> */ B(LdaSmi), I8(1), /* 711 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(100), - /* 718 S> */ B(LdaSmi), U8(1), + /* 718 S> */ B(LdaSmi), I8(1), /* 725 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(102), - /* 732 S> */ B(LdaSmi), U8(1), + /* 732 S> */ B(LdaSmi), I8(1), /* 739 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(104), - /* 746 S> */ B(LdaSmi), U8(1), + /* 746 S> */ B(LdaSmi), I8(1), /* 753 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(106), - /* 760 S> */ B(LdaSmi), U8(1), + /* 760 S> */ B(LdaSmi), I8(1), /* 767 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(108), - /* 774 S> */ B(LdaSmi), U8(1), + /* 774 S> */ B(LdaSmi), I8(1), /* 781 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(110), - /* 788 S> */ B(LdaSmi), U8(1), + /* 788 S> */ B(LdaSmi), I8(1), /* 795 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(112), - /* 802 S> */ B(LdaSmi), U8(1), + /* 802 S> */ B(LdaSmi), I8(1), /* 809 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(114), - /* 816 S> */ B(LdaSmi), U8(1), + /* 816 S> */ B(LdaSmi), I8(1), /* 823 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(116), - /* 830 S> */ B(LdaSmi), U8(1), + /* 830 S> */ B(LdaSmi), I8(1), /* 837 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(118), - /* 844 S> */ B(LdaSmi), U8(1), + /* 844 S> */ B(LdaSmi), I8(1), /* 851 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(120), - /* 858 S> */ B(LdaSmi), U8(1), + /* 858 S> */ B(LdaSmi), I8(1), /* 865 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(122), - /* 872 S> */ B(LdaSmi), U8(1), + /* 872 S> */ B(LdaSmi), I8(1), /* 879 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(124), - /* 886 S> */ B(LdaSmi), U8(1), + /* 886 S> */ B(LdaSmi), I8(1), /* 893 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(126), - /* 900 S> */ B(LdaSmi), U8(1), + /* 900 S> */ B(LdaSmi), I8(1), /* 907 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(128), - /* 914 S> */ B(LdaSmi), U8(1), + /* 914 S> */ B(LdaSmi), I8(1), /* 921 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(130), - /* 928 S> */ B(LdaSmi), U8(1), + /* 928 S> */ B(LdaSmi), I8(1), /* 935 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(132), - /* 942 S> */ B(LdaSmi), U8(1), + /* 942 S> */ B(LdaSmi), I8(1), /* 949 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(134), - /* 956 S> */ B(LdaSmi), U8(1), + /* 956 S> */ B(LdaSmi), I8(1), /* 963 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(136), - /* 970 S> */ B(LdaSmi), U8(1), + /* 970 S> */ B(LdaSmi), I8(1), /* 977 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(138), - /* 984 S> */ B(LdaSmi), U8(1), + /* 984 S> */ B(LdaSmi), I8(1), /* 991 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(140), - /* 998 S> */ B(LdaSmi), U8(1), + /* 998 S> */ B(LdaSmi), I8(1), /* 1005 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(142), - /* 1012 S> */ B(LdaSmi), U8(1), + /* 1012 S> */ B(LdaSmi), I8(1), /* 1019 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(144), - /* 1026 S> */ B(LdaSmi), U8(1), + /* 1026 S> */ B(LdaSmi), I8(1), /* 1033 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(146), - /* 1040 S> */ B(LdaSmi), U8(1), + /* 1040 S> */ B(LdaSmi), I8(1), /* 1047 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(148), - /* 1054 S> */ B(LdaSmi), U8(1), + /* 1054 S> */ B(LdaSmi), I8(1), /* 1061 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(150), - /* 1068 S> */ B(LdaSmi), U8(1), + /* 1068 S> */ B(LdaSmi), I8(1), /* 1075 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(152), - /* 1082 S> */ B(LdaSmi), U8(1), + /* 1082 S> */ B(LdaSmi), I8(1), /* 1089 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(154), - /* 1096 S> */ B(LdaSmi), U8(1), + /* 1096 S> */ B(LdaSmi), I8(1), /* 1103 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(156), - /* 1110 S> */ B(LdaSmi), U8(1), + /* 1110 S> */ B(LdaSmi), I8(1), /* 1117 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(158), - /* 1124 S> */ B(LdaSmi), U8(1), + /* 1124 S> */ B(LdaSmi), I8(1), /* 1131 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(160), - /* 1138 S> */ B(LdaSmi), U8(1), + /* 1138 S> */ B(LdaSmi), I8(1), /* 1145 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(162), - /* 1152 S> */ B(LdaSmi), U8(1), + /* 1152 S> */ B(LdaSmi), I8(1), /* 1159 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(164), - /* 1166 S> */ B(LdaSmi), U8(1), + /* 1166 S> */ B(LdaSmi), I8(1), /* 1173 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(166), - /* 1180 S> */ B(LdaSmi), U8(1), + /* 1180 S> */ B(LdaSmi), I8(1), /* 1187 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(168), - /* 1194 S> */ B(LdaSmi), U8(1), + /* 1194 S> */ B(LdaSmi), I8(1), /* 1201 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(170), - /* 1208 S> */ B(LdaSmi), U8(1), + /* 1208 S> */ B(LdaSmi), I8(1), /* 1215 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(172), - /* 1222 S> */ B(LdaSmi), U8(1), + /* 1222 S> */ B(LdaSmi), I8(1), /* 1229 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(174), - /* 1236 S> */ B(LdaSmi), U8(1), + /* 1236 S> */ B(LdaSmi), I8(1), /* 1243 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(176), - /* 1250 S> */ B(LdaSmi), U8(1), + /* 1250 S> */ B(LdaSmi), I8(1), /* 1257 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(178), - /* 1264 S> */ B(LdaSmi), U8(1), + /* 1264 S> */ B(LdaSmi), I8(1), /* 1271 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(180), - /* 1278 S> */ B(LdaSmi), U8(1), + /* 1278 S> */ B(LdaSmi), I8(1), /* 1285 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(182), - /* 1292 S> */ B(LdaSmi), U8(1), + /* 1292 S> */ B(LdaSmi), I8(1), /* 1299 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(184), - /* 1306 S> */ B(LdaSmi), U8(1), + /* 1306 S> */ B(LdaSmi), I8(1), /* 1313 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(186), - /* 1320 S> */ B(LdaSmi), U8(1), + /* 1320 S> */ B(LdaSmi), I8(1), /* 1327 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(188), - /* 1334 S> */ B(LdaSmi), U8(1), + /* 1334 S> */ B(LdaSmi), I8(1), /* 1341 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(190), - /* 1348 S> */ B(LdaSmi), U8(1), + /* 1348 S> */ B(LdaSmi), I8(1), /* 1355 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(192), - /* 1362 S> */ B(LdaSmi), U8(1), + /* 1362 S> */ B(LdaSmi), I8(1), /* 1369 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(194), - /* 1376 S> */ B(LdaSmi), U8(1), + /* 1376 S> */ B(LdaSmi), I8(1), /* 1383 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(196), - /* 1390 S> */ B(LdaSmi), U8(1), + /* 1390 S> */ B(LdaSmi), I8(1), /* 1397 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(198), - /* 1404 S> */ B(LdaSmi), U8(1), + /* 1404 S> */ B(LdaSmi), I8(1), /* 1411 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(200), - /* 1418 S> */ B(LdaSmi), U8(1), + /* 1418 S> */ B(LdaSmi), I8(1), /* 1425 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(202), - /* 1432 S> */ B(LdaSmi), U8(1), + /* 1432 S> */ B(LdaSmi), I8(1), /* 1439 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(204), - /* 1446 S> */ B(LdaSmi), U8(1), + /* 1446 S> */ B(LdaSmi), I8(1), /* 1453 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(206), - /* 1460 S> */ B(LdaSmi), U8(1), + /* 1460 S> */ B(LdaSmi), I8(1), /* 1467 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(208), - /* 1474 S> */ B(LdaSmi), U8(1), + /* 1474 S> */ B(LdaSmi), I8(1), /* 1481 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(210), - /* 1488 S> */ B(LdaSmi), U8(1), + /* 1488 S> */ B(LdaSmi), I8(1), /* 1495 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(212), - /* 1502 S> */ B(LdaSmi), U8(1), + /* 1502 S> */ B(LdaSmi), I8(1), /* 1509 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(214), - /* 1516 S> */ B(LdaSmi), U8(1), + /* 1516 S> */ B(LdaSmi), I8(1), /* 1523 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(216), - /* 1530 S> */ B(LdaSmi), U8(1), + /* 1530 S> */ B(LdaSmi), I8(1), /* 1537 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(218), - /* 1544 S> */ B(LdaSmi), U8(1), + /* 1544 S> */ B(LdaSmi), I8(1), /* 1551 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(220), - /* 1558 S> */ B(LdaSmi), U8(1), + /* 1558 S> */ B(LdaSmi), I8(1), /* 1565 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(222), - /* 1572 S> */ B(LdaSmi), U8(1), + /* 1572 S> */ B(LdaSmi), I8(1), /* 1579 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(224), - /* 1586 S> */ B(LdaSmi), U8(1), + /* 1586 S> */ B(LdaSmi), I8(1), /* 1593 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(226), - /* 1600 S> */ B(LdaSmi), U8(1), + /* 1600 S> */ B(LdaSmi), I8(1), /* 1607 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(228), - /* 1614 S> */ B(LdaSmi), U8(1), + /* 1614 S> */ B(LdaSmi), I8(1), /* 1621 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(230), - /* 1628 S> */ B(LdaSmi), U8(1), + /* 1628 S> */ B(LdaSmi), I8(1), /* 1635 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(232), - /* 1642 S> */ B(LdaSmi), U8(1), + /* 1642 S> */ B(LdaSmi), I8(1), /* 1649 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(234), - /* 1656 S> */ B(LdaSmi), U8(1), + /* 1656 S> */ B(LdaSmi), I8(1), /* 1663 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(236), - /* 1670 S> */ B(LdaSmi), U8(1), + /* 1670 S> */ B(LdaSmi), I8(1), /* 1677 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(238), - /* 1684 S> */ B(LdaSmi), U8(1), + /* 1684 S> */ B(LdaSmi), I8(1), /* 1691 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(240), - /* 1698 S> */ B(LdaSmi), U8(1), + /* 1698 S> */ B(LdaSmi), I8(1), /* 1705 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(242), - /* 1712 S> */ B(LdaSmi), U8(1), + /* 1712 S> */ B(LdaSmi), I8(1), /* 1719 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(244), - /* 1726 S> */ B(LdaSmi), U8(1), + /* 1726 S> */ B(LdaSmi), I8(1), /* 1733 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(246), - /* 1740 S> */ B(LdaSmi), U8(1), + /* 1740 S> */ B(LdaSmi), I8(1), /* 1747 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(248), - /* 1754 S> */ B(LdaSmi), U8(1), + /* 1754 S> */ B(LdaSmi), I8(1), /* 1761 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(250), - /* 1768 S> */ B(LdaSmi), U8(1), + /* 1768 S> */ B(LdaSmi), I8(1), /* 1775 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(252), - /* 1782 S> */ B(LdaSmi), U8(1), + /* 1782 S> */ B(LdaSmi), I8(1), /* 1789 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(254), - /* 1796 S> */ B(LdaSmi), U8(1), + /* 1796 S> */ B(LdaSmi), I8(1), /* 1803 E> */ B(Wide), B(StaNamedPropertySloppy), R16(arg0), U16(0), U16(256), - /* 1810 S> */ B(LdaSmi), U8(2), + /* 1810 S> */ B(LdaSmi), I8(2), /* 1817 E> */ B(Wide), B(StaNamedPropertySloppy), R16(arg0), U16(0), U16(258), B(LdaUndefined), /* 1822 S> */ B(Return), @@ -707,263 +707,263 @@ parameter count: 2 bytecode array length: 785 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 33 S> */ B(LdaSmi), U8(1), + /* 33 S> */ B(LdaSmi), I8(1), /* 40 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(2), - /* 47 S> */ B(LdaSmi), U8(1), + /* 47 S> */ B(LdaSmi), I8(1), /* 54 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(4), - /* 61 S> */ B(LdaSmi), U8(1), + /* 61 S> */ B(LdaSmi), I8(1), /* 68 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(6), - /* 75 S> */ B(LdaSmi), U8(1), + /* 75 S> */ B(LdaSmi), I8(1), /* 82 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(8), - /* 89 S> */ B(LdaSmi), U8(1), + /* 89 S> */ B(LdaSmi), I8(1), /* 96 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(10), - /* 103 S> */ B(LdaSmi), U8(1), + /* 103 S> */ B(LdaSmi), I8(1), /* 110 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(12), - /* 117 S> */ B(LdaSmi), U8(1), + /* 117 S> */ B(LdaSmi), I8(1), /* 124 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(14), - /* 131 S> */ B(LdaSmi), U8(1), + /* 131 S> */ B(LdaSmi), I8(1), /* 138 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(16), - /* 145 S> */ B(LdaSmi), U8(1), + /* 145 S> */ B(LdaSmi), I8(1), /* 152 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(18), - /* 159 S> */ B(LdaSmi), U8(1), + /* 159 S> */ B(LdaSmi), I8(1), /* 166 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(20), - /* 173 S> */ B(LdaSmi), U8(1), + /* 173 S> */ B(LdaSmi), I8(1), /* 180 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(22), - /* 187 S> */ B(LdaSmi), U8(1), + /* 187 S> */ B(LdaSmi), I8(1), /* 194 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(24), - /* 201 S> */ B(LdaSmi), U8(1), + /* 201 S> */ B(LdaSmi), I8(1), /* 208 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(26), - /* 215 S> */ B(LdaSmi), U8(1), + /* 215 S> */ B(LdaSmi), I8(1), /* 222 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(28), - /* 229 S> */ B(LdaSmi), U8(1), + /* 229 S> */ B(LdaSmi), I8(1), /* 236 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(30), - /* 243 S> */ B(LdaSmi), U8(1), + /* 243 S> */ B(LdaSmi), I8(1), /* 250 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(32), - /* 257 S> */ B(LdaSmi), U8(1), + /* 257 S> */ B(LdaSmi), I8(1), /* 264 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(34), - /* 271 S> */ B(LdaSmi), U8(1), + /* 271 S> */ B(LdaSmi), I8(1), /* 278 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(36), - /* 285 S> */ B(LdaSmi), U8(1), + /* 285 S> */ B(LdaSmi), I8(1), /* 292 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(38), - /* 299 S> */ B(LdaSmi), U8(1), + /* 299 S> */ B(LdaSmi), I8(1), /* 306 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(40), - /* 313 S> */ B(LdaSmi), U8(1), + /* 313 S> */ B(LdaSmi), I8(1), /* 320 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(42), - /* 327 S> */ B(LdaSmi), U8(1), + /* 327 S> */ B(LdaSmi), I8(1), /* 334 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(44), - /* 341 S> */ B(LdaSmi), U8(1), + /* 341 S> */ B(LdaSmi), I8(1), /* 348 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(46), - /* 355 S> */ B(LdaSmi), U8(1), + /* 355 S> */ B(LdaSmi), I8(1), /* 362 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(48), - /* 369 S> */ B(LdaSmi), U8(1), + /* 369 S> */ B(LdaSmi), I8(1), /* 376 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(50), - /* 383 S> */ B(LdaSmi), U8(1), + /* 383 S> */ B(LdaSmi), I8(1), /* 390 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(52), - /* 397 S> */ B(LdaSmi), U8(1), + /* 397 S> */ B(LdaSmi), I8(1), /* 404 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(54), - /* 411 S> */ B(LdaSmi), U8(1), + /* 411 S> */ B(LdaSmi), I8(1), /* 418 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(56), - /* 425 S> */ B(LdaSmi), U8(1), + /* 425 S> */ B(LdaSmi), I8(1), /* 432 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(58), - /* 439 S> */ B(LdaSmi), U8(1), + /* 439 S> */ B(LdaSmi), I8(1), /* 446 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(60), - /* 453 S> */ B(LdaSmi), U8(1), + /* 453 S> */ B(LdaSmi), I8(1), /* 460 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(62), - /* 467 S> */ B(LdaSmi), U8(1), + /* 467 S> */ B(LdaSmi), I8(1), /* 474 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(64), - /* 481 S> */ B(LdaSmi), U8(1), + /* 481 S> */ B(LdaSmi), I8(1), /* 488 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(66), - /* 495 S> */ B(LdaSmi), U8(1), + /* 495 S> */ B(LdaSmi), I8(1), /* 502 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(68), - /* 509 S> */ B(LdaSmi), U8(1), + /* 509 S> */ B(LdaSmi), I8(1), /* 516 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(70), - /* 523 S> */ B(LdaSmi), U8(1), + /* 523 S> */ B(LdaSmi), I8(1), /* 530 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(72), - /* 537 S> */ B(LdaSmi), U8(1), + /* 537 S> */ B(LdaSmi), I8(1), /* 544 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(74), - /* 551 S> */ B(LdaSmi), U8(1), + /* 551 S> */ B(LdaSmi), I8(1), /* 558 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(76), - /* 565 S> */ B(LdaSmi), U8(1), + /* 565 S> */ B(LdaSmi), I8(1), /* 572 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(78), - /* 579 S> */ B(LdaSmi), U8(1), + /* 579 S> */ B(LdaSmi), I8(1), /* 586 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(80), - /* 593 S> */ B(LdaSmi), U8(1), + /* 593 S> */ B(LdaSmi), I8(1), /* 600 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(82), - /* 607 S> */ B(LdaSmi), U8(1), + /* 607 S> */ B(LdaSmi), I8(1), /* 614 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(84), - /* 621 S> */ B(LdaSmi), U8(1), + /* 621 S> */ B(LdaSmi), I8(1), /* 628 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(86), - /* 635 S> */ B(LdaSmi), U8(1), + /* 635 S> */ B(LdaSmi), I8(1), /* 642 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(88), - /* 649 S> */ B(LdaSmi), U8(1), + /* 649 S> */ B(LdaSmi), I8(1), /* 656 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(90), - /* 663 S> */ B(LdaSmi), U8(1), + /* 663 S> */ B(LdaSmi), I8(1), /* 670 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(92), - /* 677 S> */ B(LdaSmi), U8(1), + /* 677 S> */ B(LdaSmi), I8(1), /* 684 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(94), - /* 691 S> */ B(LdaSmi), U8(1), + /* 691 S> */ B(LdaSmi), I8(1), /* 698 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(96), - /* 705 S> */ B(LdaSmi), U8(1), + /* 705 S> */ B(LdaSmi), I8(1), /* 712 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(98), - /* 719 S> */ B(LdaSmi), U8(1), + /* 719 S> */ B(LdaSmi), I8(1), /* 726 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(100), - /* 733 S> */ B(LdaSmi), U8(1), + /* 733 S> */ B(LdaSmi), I8(1), /* 740 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(102), - /* 747 S> */ B(LdaSmi), U8(1), + /* 747 S> */ B(LdaSmi), I8(1), /* 754 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(104), - /* 761 S> */ B(LdaSmi), U8(1), + /* 761 S> */ B(LdaSmi), I8(1), /* 768 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(106), - /* 775 S> */ B(LdaSmi), U8(1), + /* 775 S> */ B(LdaSmi), I8(1), /* 782 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(108), - /* 789 S> */ B(LdaSmi), U8(1), + /* 789 S> */ B(LdaSmi), I8(1), /* 796 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(110), - /* 803 S> */ B(LdaSmi), U8(1), + /* 803 S> */ B(LdaSmi), I8(1), /* 810 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(112), - /* 817 S> */ B(LdaSmi), U8(1), + /* 817 S> */ B(LdaSmi), I8(1), /* 824 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(114), - /* 831 S> */ B(LdaSmi), U8(1), + /* 831 S> */ B(LdaSmi), I8(1), /* 838 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(116), - /* 845 S> */ B(LdaSmi), U8(1), + /* 845 S> */ B(LdaSmi), I8(1), /* 852 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(118), - /* 859 S> */ B(LdaSmi), U8(1), + /* 859 S> */ B(LdaSmi), I8(1), /* 866 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(120), - /* 873 S> */ B(LdaSmi), U8(1), + /* 873 S> */ B(LdaSmi), I8(1), /* 880 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(122), - /* 887 S> */ B(LdaSmi), U8(1), + /* 887 S> */ B(LdaSmi), I8(1), /* 894 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(124), - /* 901 S> */ B(LdaSmi), U8(1), + /* 901 S> */ B(LdaSmi), I8(1), /* 908 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(126), - /* 915 S> */ B(LdaSmi), U8(1), + /* 915 S> */ B(LdaSmi), I8(1), /* 922 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(128), - /* 929 S> */ B(LdaSmi), U8(1), + /* 929 S> */ B(LdaSmi), I8(1), /* 936 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(130), - /* 943 S> */ B(LdaSmi), U8(1), + /* 943 S> */ B(LdaSmi), I8(1), /* 950 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(132), - /* 957 S> */ B(LdaSmi), U8(1), + /* 957 S> */ B(LdaSmi), I8(1), /* 964 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(134), - /* 971 S> */ B(LdaSmi), U8(1), + /* 971 S> */ B(LdaSmi), I8(1), /* 978 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(136), - /* 985 S> */ B(LdaSmi), U8(1), + /* 985 S> */ B(LdaSmi), I8(1), /* 992 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(138), - /* 999 S> */ B(LdaSmi), U8(1), + /* 999 S> */ B(LdaSmi), I8(1), /* 1006 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(140), - /* 1013 S> */ B(LdaSmi), U8(1), + /* 1013 S> */ B(LdaSmi), I8(1), /* 1020 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(142), - /* 1027 S> */ B(LdaSmi), U8(1), + /* 1027 S> */ B(LdaSmi), I8(1), /* 1034 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(144), - /* 1041 S> */ B(LdaSmi), U8(1), + /* 1041 S> */ B(LdaSmi), I8(1), /* 1048 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(146), - /* 1055 S> */ B(LdaSmi), U8(1), + /* 1055 S> */ B(LdaSmi), I8(1), /* 1062 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(148), - /* 1069 S> */ B(LdaSmi), U8(1), + /* 1069 S> */ B(LdaSmi), I8(1), /* 1076 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(150), - /* 1083 S> */ B(LdaSmi), U8(1), + /* 1083 S> */ B(LdaSmi), I8(1), /* 1090 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(152), - /* 1097 S> */ B(LdaSmi), U8(1), + /* 1097 S> */ B(LdaSmi), I8(1), /* 1104 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(154), - /* 1111 S> */ B(LdaSmi), U8(1), + /* 1111 S> */ B(LdaSmi), I8(1), /* 1118 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(156), - /* 1125 S> */ B(LdaSmi), U8(1), + /* 1125 S> */ B(LdaSmi), I8(1), /* 1132 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(158), - /* 1139 S> */ B(LdaSmi), U8(1), + /* 1139 S> */ B(LdaSmi), I8(1), /* 1146 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(160), - /* 1153 S> */ B(LdaSmi), U8(1), + /* 1153 S> */ B(LdaSmi), I8(1), /* 1160 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(162), - /* 1167 S> */ B(LdaSmi), U8(1), + /* 1167 S> */ B(LdaSmi), I8(1), /* 1174 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(164), - /* 1181 S> */ B(LdaSmi), U8(1), + /* 1181 S> */ B(LdaSmi), I8(1), /* 1188 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(166), - /* 1195 S> */ B(LdaSmi), U8(1), + /* 1195 S> */ B(LdaSmi), I8(1), /* 1202 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(168), - /* 1209 S> */ B(LdaSmi), U8(1), + /* 1209 S> */ B(LdaSmi), I8(1), /* 1216 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(170), - /* 1223 S> */ B(LdaSmi), U8(1), + /* 1223 S> */ B(LdaSmi), I8(1), /* 1230 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(172), - /* 1237 S> */ B(LdaSmi), U8(1), + /* 1237 S> */ B(LdaSmi), I8(1), /* 1244 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(174), - /* 1251 S> */ B(LdaSmi), U8(1), + /* 1251 S> */ B(LdaSmi), I8(1), /* 1258 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(176), - /* 1265 S> */ B(LdaSmi), U8(1), + /* 1265 S> */ B(LdaSmi), I8(1), /* 1272 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(178), - /* 1279 S> */ B(LdaSmi), U8(1), + /* 1279 S> */ B(LdaSmi), I8(1), /* 1286 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(180), - /* 1293 S> */ B(LdaSmi), U8(1), + /* 1293 S> */ B(LdaSmi), I8(1), /* 1300 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(182), - /* 1307 S> */ B(LdaSmi), U8(1), + /* 1307 S> */ B(LdaSmi), I8(1), /* 1314 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(184), - /* 1321 S> */ B(LdaSmi), U8(1), + /* 1321 S> */ B(LdaSmi), I8(1), /* 1328 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(186), - /* 1335 S> */ B(LdaSmi), U8(1), + /* 1335 S> */ B(LdaSmi), I8(1), /* 1342 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(188), - /* 1349 S> */ B(LdaSmi), U8(1), + /* 1349 S> */ B(LdaSmi), I8(1), /* 1356 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(190), - /* 1363 S> */ B(LdaSmi), U8(1), + /* 1363 S> */ B(LdaSmi), I8(1), /* 1370 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(192), - /* 1377 S> */ B(LdaSmi), U8(1), + /* 1377 S> */ B(LdaSmi), I8(1), /* 1384 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(194), - /* 1391 S> */ B(LdaSmi), U8(1), + /* 1391 S> */ B(LdaSmi), I8(1), /* 1398 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(196), - /* 1405 S> */ B(LdaSmi), U8(1), + /* 1405 S> */ B(LdaSmi), I8(1), /* 1412 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(198), - /* 1419 S> */ B(LdaSmi), U8(1), + /* 1419 S> */ B(LdaSmi), I8(1), /* 1426 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(200), - /* 1433 S> */ B(LdaSmi), U8(1), + /* 1433 S> */ B(LdaSmi), I8(1), /* 1440 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(202), - /* 1447 S> */ B(LdaSmi), U8(1), + /* 1447 S> */ B(LdaSmi), I8(1), /* 1454 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(204), - /* 1461 S> */ B(LdaSmi), U8(1), + /* 1461 S> */ B(LdaSmi), I8(1), /* 1468 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(206), - /* 1475 S> */ B(LdaSmi), U8(1), + /* 1475 S> */ B(LdaSmi), I8(1), /* 1482 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(208), - /* 1489 S> */ B(LdaSmi), U8(1), + /* 1489 S> */ B(LdaSmi), I8(1), /* 1496 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(210), - /* 1503 S> */ B(LdaSmi), U8(1), + /* 1503 S> */ B(LdaSmi), I8(1), /* 1510 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(212), - /* 1517 S> */ B(LdaSmi), U8(1), + /* 1517 S> */ B(LdaSmi), I8(1), /* 1524 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(214), - /* 1531 S> */ B(LdaSmi), U8(1), + /* 1531 S> */ B(LdaSmi), I8(1), /* 1538 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(216), - /* 1545 S> */ B(LdaSmi), U8(1), + /* 1545 S> */ B(LdaSmi), I8(1), /* 1552 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(218), - /* 1559 S> */ B(LdaSmi), U8(1), + /* 1559 S> */ B(LdaSmi), I8(1), /* 1566 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(220), - /* 1573 S> */ B(LdaSmi), U8(1), + /* 1573 S> */ B(LdaSmi), I8(1), /* 1580 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(222), - /* 1587 S> */ B(LdaSmi), U8(1), + /* 1587 S> */ B(LdaSmi), I8(1), /* 1594 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(224), - /* 1601 S> */ B(LdaSmi), U8(1), + /* 1601 S> */ B(LdaSmi), I8(1), /* 1608 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(226), - /* 1615 S> */ B(LdaSmi), U8(1), + /* 1615 S> */ B(LdaSmi), I8(1), /* 1622 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(228), - /* 1629 S> */ B(LdaSmi), U8(1), + /* 1629 S> */ B(LdaSmi), I8(1), /* 1636 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(230), - /* 1643 S> */ B(LdaSmi), U8(1), + /* 1643 S> */ B(LdaSmi), I8(1), /* 1650 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(232), - /* 1657 S> */ B(LdaSmi), U8(1), + /* 1657 S> */ B(LdaSmi), I8(1), /* 1664 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(234), - /* 1671 S> */ B(LdaSmi), U8(1), + /* 1671 S> */ B(LdaSmi), I8(1), /* 1678 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(236), - /* 1685 S> */ B(LdaSmi), U8(1), + /* 1685 S> */ B(LdaSmi), I8(1), /* 1692 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(238), - /* 1699 S> */ B(LdaSmi), U8(1), + /* 1699 S> */ B(LdaSmi), I8(1), /* 1706 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(240), - /* 1713 S> */ B(LdaSmi), U8(1), + /* 1713 S> */ B(LdaSmi), I8(1), /* 1720 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(242), - /* 1727 S> */ B(LdaSmi), U8(1), + /* 1727 S> */ B(LdaSmi), I8(1), /* 1734 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(244), - /* 1741 S> */ B(LdaSmi), U8(1), + /* 1741 S> */ B(LdaSmi), I8(1), /* 1748 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(246), - /* 1755 S> */ B(LdaSmi), U8(1), + /* 1755 S> */ B(LdaSmi), I8(1), /* 1762 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(248), - /* 1769 S> */ B(LdaSmi), U8(1), + /* 1769 S> */ B(LdaSmi), I8(1), /* 1776 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(250), - /* 1783 S> */ B(LdaSmi), U8(1), + /* 1783 S> */ B(LdaSmi), I8(1), /* 1790 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(252), - /* 1797 S> */ B(LdaSmi), U8(1), + /* 1797 S> */ B(LdaSmi), I8(1), /* 1804 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(254), - /* 1811 S> */ B(LdaSmi), U8(1), + /* 1811 S> */ B(LdaSmi), I8(1), /* 1818 E> */ B(Wide), B(StaNamedPropertyStrict), R16(arg0), U16(0), U16(256), - /* 1825 S> */ B(LdaSmi), U8(2), + /* 1825 S> */ B(LdaSmi), I8(2), /* 1832 E> */ B(Wide), B(StaNamedPropertyStrict), R16(arg0), U16(0), U16(258), B(LdaUndefined), /* 1837 S> */ B(Return), @@ -1114,263 +1114,263 @@ parameter count: 3 bytecode array length: 785 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 21 S> */ B(LdaSmi), U8(1), + /* 21 S> */ B(LdaSmi), I8(1), /* 26 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(2), - /* 33 S> */ B(LdaSmi), U8(1), + /* 33 S> */ B(LdaSmi), I8(1), /* 38 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(4), - /* 45 S> */ B(LdaSmi), U8(1), + /* 45 S> */ B(LdaSmi), I8(1), /* 50 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(6), - /* 57 S> */ B(LdaSmi), U8(1), + /* 57 S> */ B(LdaSmi), I8(1), /* 62 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(8), - /* 69 S> */ B(LdaSmi), U8(1), + /* 69 S> */ B(LdaSmi), I8(1), /* 74 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(10), - /* 81 S> */ B(LdaSmi), U8(1), + /* 81 S> */ B(LdaSmi), I8(1), /* 86 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(12), - /* 93 S> */ B(LdaSmi), U8(1), + /* 93 S> */ B(LdaSmi), I8(1), /* 98 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(14), - /* 105 S> */ B(LdaSmi), U8(1), + /* 105 S> */ B(LdaSmi), I8(1), /* 110 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(16), - /* 117 S> */ B(LdaSmi), U8(1), + /* 117 S> */ B(LdaSmi), I8(1), /* 122 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(18), - /* 129 S> */ B(LdaSmi), U8(1), + /* 129 S> */ B(LdaSmi), I8(1), /* 134 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(20), - /* 141 S> */ B(LdaSmi), U8(1), + /* 141 S> */ B(LdaSmi), I8(1), /* 146 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(22), - /* 153 S> */ B(LdaSmi), U8(1), + /* 153 S> */ B(LdaSmi), I8(1), /* 158 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(24), - /* 165 S> */ B(LdaSmi), U8(1), + /* 165 S> */ B(LdaSmi), I8(1), /* 170 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(26), - /* 177 S> */ B(LdaSmi), U8(1), + /* 177 S> */ B(LdaSmi), I8(1), /* 182 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(28), - /* 189 S> */ B(LdaSmi), U8(1), + /* 189 S> */ B(LdaSmi), I8(1), /* 194 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(30), - /* 201 S> */ B(LdaSmi), U8(1), + /* 201 S> */ B(LdaSmi), I8(1), /* 206 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(32), - /* 213 S> */ B(LdaSmi), U8(1), + /* 213 S> */ B(LdaSmi), I8(1), /* 218 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(34), - /* 225 S> */ B(LdaSmi), U8(1), + /* 225 S> */ B(LdaSmi), I8(1), /* 230 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(36), - /* 237 S> */ B(LdaSmi), U8(1), + /* 237 S> */ B(LdaSmi), I8(1), /* 242 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(38), - /* 249 S> */ B(LdaSmi), U8(1), + /* 249 S> */ B(LdaSmi), I8(1), /* 254 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(40), - /* 261 S> */ B(LdaSmi), U8(1), + /* 261 S> */ B(LdaSmi), I8(1), /* 266 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(42), - /* 273 S> */ B(LdaSmi), U8(1), + /* 273 S> */ B(LdaSmi), I8(1), /* 278 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(44), - /* 285 S> */ B(LdaSmi), U8(1), + /* 285 S> */ B(LdaSmi), I8(1), /* 290 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(46), - /* 297 S> */ B(LdaSmi), U8(1), + /* 297 S> */ B(LdaSmi), I8(1), /* 302 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(48), - /* 309 S> */ B(LdaSmi), U8(1), + /* 309 S> */ B(LdaSmi), I8(1), /* 314 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(50), - /* 321 S> */ B(LdaSmi), U8(1), + /* 321 S> */ B(LdaSmi), I8(1), /* 326 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(52), - /* 333 S> */ B(LdaSmi), U8(1), + /* 333 S> */ B(LdaSmi), I8(1), /* 338 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(54), - /* 345 S> */ B(LdaSmi), U8(1), + /* 345 S> */ B(LdaSmi), I8(1), /* 350 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(56), - /* 357 S> */ B(LdaSmi), U8(1), + /* 357 S> */ B(LdaSmi), I8(1), /* 362 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(58), - /* 369 S> */ B(LdaSmi), U8(1), + /* 369 S> */ B(LdaSmi), I8(1), /* 374 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(60), - /* 381 S> */ B(LdaSmi), U8(1), + /* 381 S> */ B(LdaSmi), I8(1), /* 386 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(62), - /* 393 S> */ B(LdaSmi), U8(1), + /* 393 S> */ B(LdaSmi), I8(1), /* 398 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(64), - /* 405 S> */ B(LdaSmi), U8(1), + /* 405 S> */ B(LdaSmi), I8(1), /* 410 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(66), - /* 417 S> */ B(LdaSmi), U8(1), + /* 417 S> */ B(LdaSmi), I8(1), /* 422 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(68), - /* 429 S> */ B(LdaSmi), U8(1), + /* 429 S> */ B(LdaSmi), I8(1), /* 434 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(70), - /* 441 S> */ B(LdaSmi), U8(1), + /* 441 S> */ B(LdaSmi), I8(1), /* 446 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(72), - /* 453 S> */ B(LdaSmi), U8(1), + /* 453 S> */ B(LdaSmi), I8(1), /* 458 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(74), - /* 465 S> */ B(LdaSmi), U8(1), + /* 465 S> */ B(LdaSmi), I8(1), /* 470 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(76), - /* 477 S> */ B(LdaSmi), U8(1), + /* 477 S> */ B(LdaSmi), I8(1), /* 482 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(78), - /* 489 S> */ B(LdaSmi), U8(1), + /* 489 S> */ B(LdaSmi), I8(1), /* 494 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(80), - /* 501 S> */ B(LdaSmi), U8(1), + /* 501 S> */ B(LdaSmi), I8(1), /* 506 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(82), - /* 513 S> */ B(LdaSmi), U8(1), + /* 513 S> */ B(LdaSmi), I8(1), /* 518 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(84), - /* 525 S> */ B(LdaSmi), U8(1), + /* 525 S> */ B(LdaSmi), I8(1), /* 530 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(86), - /* 537 S> */ B(LdaSmi), U8(1), + /* 537 S> */ B(LdaSmi), I8(1), /* 542 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(88), - /* 549 S> */ B(LdaSmi), U8(1), + /* 549 S> */ B(LdaSmi), I8(1), /* 554 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(90), - /* 561 S> */ B(LdaSmi), U8(1), + /* 561 S> */ B(LdaSmi), I8(1), /* 566 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(92), - /* 573 S> */ B(LdaSmi), U8(1), + /* 573 S> */ B(LdaSmi), I8(1), /* 578 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(94), - /* 585 S> */ B(LdaSmi), U8(1), + /* 585 S> */ B(LdaSmi), I8(1), /* 590 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(96), - /* 597 S> */ B(LdaSmi), U8(1), + /* 597 S> */ B(LdaSmi), I8(1), /* 602 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(98), - /* 609 S> */ B(LdaSmi), U8(1), + /* 609 S> */ B(LdaSmi), I8(1), /* 614 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(100), - /* 621 S> */ B(LdaSmi), U8(1), + /* 621 S> */ B(LdaSmi), I8(1), /* 626 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(102), - /* 633 S> */ B(LdaSmi), U8(1), + /* 633 S> */ B(LdaSmi), I8(1), /* 638 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(104), - /* 645 S> */ B(LdaSmi), U8(1), + /* 645 S> */ B(LdaSmi), I8(1), /* 650 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(106), - /* 657 S> */ B(LdaSmi), U8(1), + /* 657 S> */ B(LdaSmi), I8(1), /* 662 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(108), - /* 669 S> */ B(LdaSmi), U8(1), + /* 669 S> */ B(LdaSmi), I8(1), /* 674 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(110), - /* 681 S> */ B(LdaSmi), U8(1), + /* 681 S> */ B(LdaSmi), I8(1), /* 686 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(112), - /* 693 S> */ B(LdaSmi), U8(1), + /* 693 S> */ B(LdaSmi), I8(1), /* 698 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(114), - /* 705 S> */ B(LdaSmi), U8(1), + /* 705 S> */ B(LdaSmi), I8(1), /* 710 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(116), - /* 717 S> */ B(LdaSmi), U8(1), + /* 717 S> */ B(LdaSmi), I8(1), /* 722 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(118), - /* 729 S> */ B(LdaSmi), U8(1), + /* 729 S> */ B(LdaSmi), I8(1), /* 734 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(120), - /* 741 S> */ B(LdaSmi), U8(1), + /* 741 S> */ B(LdaSmi), I8(1), /* 746 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(122), - /* 753 S> */ B(LdaSmi), U8(1), + /* 753 S> */ B(LdaSmi), I8(1), /* 758 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(124), - /* 765 S> */ B(LdaSmi), U8(1), + /* 765 S> */ B(LdaSmi), I8(1), /* 770 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(126), - /* 777 S> */ B(LdaSmi), U8(1), + /* 777 S> */ B(LdaSmi), I8(1), /* 782 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(128), - /* 789 S> */ B(LdaSmi), U8(1), + /* 789 S> */ B(LdaSmi), I8(1), /* 794 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(130), - /* 801 S> */ B(LdaSmi), U8(1), + /* 801 S> */ B(LdaSmi), I8(1), /* 806 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(132), - /* 813 S> */ B(LdaSmi), U8(1), + /* 813 S> */ B(LdaSmi), I8(1), /* 818 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(134), - /* 825 S> */ B(LdaSmi), U8(1), + /* 825 S> */ B(LdaSmi), I8(1), /* 830 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(136), - /* 837 S> */ B(LdaSmi), U8(1), + /* 837 S> */ B(LdaSmi), I8(1), /* 842 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(138), - /* 849 S> */ B(LdaSmi), U8(1), + /* 849 S> */ B(LdaSmi), I8(1), /* 854 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(140), - /* 861 S> */ B(LdaSmi), U8(1), + /* 861 S> */ B(LdaSmi), I8(1), /* 866 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(142), - /* 873 S> */ B(LdaSmi), U8(1), + /* 873 S> */ B(LdaSmi), I8(1), /* 878 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(144), - /* 885 S> */ B(LdaSmi), U8(1), + /* 885 S> */ B(LdaSmi), I8(1), /* 890 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(146), - /* 897 S> */ B(LdaSmi), U8(1), + /* 897 S> */ B(LdaSmi), I8(1), /* 902 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(148), - /* 909 S> */ B(LdaSmi), U8(1), + /* 909 S> */ B(LdaSmi), I8(1), /* 914 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(150), - /* 921 S> */ B(LdaSmi), U8(1), + /* 921 S> */ B(LdaSmi), I8(1), /* 926 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(152), - /* 933 S> */ B(LdaSmi), U8(1), + /* 933 S> */ B(LdaSmi), I8(1), /* 938 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(154), - /* 945 S> */ B(LdaSmi), U8(1), + /* 945 S> */ B(LdaSmi), I8(1), /* 950 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(156), - /* 957 S> */ B(LdaSmi), U8(1), + /* 957 S> */ B(LdaSmi), I8(1), /* 962 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(158), - /* 969 S> */ B(LdaSmi), U8(1), + /* 969 S> */ B(LdaSmi), I8(1), /* 974 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(160), - /* 981 S> */ B(LdaSmi), U8(1), + /* 981 S> */ B(LdaSmi), I8(1), /* 986 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(162), - /* 993 S> */ B(LdaSmi), U8(1), + /* 993 S> */ B(LdaSmi), I8(1), /* 998 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(164), - /* 1005 S> */ B(LdaSmi), U8(1), + /* 1005 S> */ B(LdaSmi), I8(1), /* 1010 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(166), - /* 1017 S> */ B(LdaSmi), U8(1), + /* 1017 S> */ B(LdaSmi), I8(1), /* 1022 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(168), - /* 1029 S> */ B(LdaSmi), U8(1), + /* 1029 S> */ B(LdaSmi), I8(1), /* 1034 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(170), - /* 1041 S> */ B(LdaSmi), U8(1), + /* 1041 S> */ B(LdaSmi), I8(1), /* 1046 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(172), - /* 1053 S> */ B(LdaSmi), U8(1), + /* 1053 S> */ B(LdaSmi), I8(1), /* 1058 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(174), - /* 1065 S> */ B(LdaSmi), U8(1), + /* 1065 S> */ B(LdaSmi), I8(1), /* 1070 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(176), - /* 1077 S> */ B(LdaSmi), U8(1), + /* 1077 S> */ B(LdaSmi), I8(1), /* 1082 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(178), - /* 1089 S> */ B(LdaSmi), U8(1), + /* 1089 S> */ B(LdaSmi), I8(1), /* 1094 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(180), - /* 1101 S> */ B(LdaSmi), U8(1), + /* 1101 S> */ B(LdaSmi), I8(1), /* 1106 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(182), - /* 1113 S> */ B(LdaSmi), U8(1), + /* 1113 S> */ B(LdaSmi), I8(1), /* 1118 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(184), - /* 1125 S> */ B(LdaSmi), U8(1), + /* 1125 S> */ B(LdaSmi), I8(1), /* 1130 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(186), - /* 1137 S> */ B(LdaSmi), U8(1), + /* 1137 S> */ B(LdaSmi), I8(1), /* 1142 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(188), - /* 1149 S> */ B(LdaSmi), U8(1), + /* 1149 S> */ B(LdaSmi), I8(1), /* 1154 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(190), - /* 1161 S> */ B(LdaSmi), U8(1), + /* 1161 S> */ B(LdaSmi), I8(1), /* 1166 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(192), - /* 1173 S> */ B(LdaSmi), U8(1), + /* 1173 S> */ B(LdaSmi), I8(1), /* 1178 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(194), - /* 1185 S> */ B(LdaSmi), U8(1), + /* 1185 S> */ B(LdaSmi), I8(1), /* 1190 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(196), - /* 1197 S> */ B(LdaSmi), U8(1), + /* 1197 S> */ B(LdaSmi), I8(1), /* 1202 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(198), - /* 1209 S> */ B(LdaSmi), U8(1), + /* 1209 S> */ B(LdaSmi), I8(1), /* 1214 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(200), - /* 1221 S> */ B(LdaSmi), U8(1), + /* 1221 S> */ B(LdaSmi), I8(1), /* 1226 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(202), - /* 1233 S> */ B(LdaSmi), U8(1), + /* 1233 S> */ B(LdaSmi), I8(1), /* 1238 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(204), - /* 1245 S> */ B(LdaSmi), U8(1), + /* 1245 S> */ B(LdaSmi), I8(1), /* 1250 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(206), - /* 1257 S> */ B(LdaSmi), U8(1), + /* 1257 S> */ B(LdaSmi), I8(1), /* 1262 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(208), - /* 1269 S> */ B(LdaSmi), U8(1), + /* 1269 S> */ B(LdaSmi), I8(1), /* 1274 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(210), - /* 1281 S> */ B(LdaSmi), U8(1), + /* 1281 S> */ B(LdaSmi), I8(1), /* 1286 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(212), - /* 1293 S> */ B(LdaSmi), U8(1), + /* 1293 S> */ B(LdaSmi), I8(1), /* 1298 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(214), - /* 1305 S> */ B(LdaSmi), U8(1), + /* 1305 S> */ B(LdaSmi), I8(1), /* 1310 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(216), - /* 1317 S> */ B(LdaSmi), U8(1), + /* 1317 S> */ B(LdaSmi), I8(1), /* 1322 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(218), - /* 1329 S> */ B(LdaSmi), U8(1), + /* 1329 S> */ B(LdaSmi), I8(1), /* 1334 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(220), - /* 1341 S> */ B(LdaSmi), U8(1), + /* 1341 S> */ B(LdaSmi), I8(1), /* 1346 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(222), - /* 1353 S> */ B(LdaSmi), U8(1), + /* 1353 S> */ B(LdaSmi), I8(1), /* 1358 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(224), - /* 1365 S> */ B(LdaSmi), U8(1), + /* 1365 S> */ B(LdaSmi), I8(1), /* 1370 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(226), - /* 1377 S> */ B(LdaSmi), U8(1), + /* 1377 S> */ B(LdaSmi), I8(1), /* 1382 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(228), - /* 1389 S> */ B(LdaSmi), U8(1), + /* 1389 S> */ B(LdaSmi), I8(1), /* 1394 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(230), - /* 1401 S> */ B(LdaSmi), U8(1), + /* 1401 S> */ B(LdaSmi), I8(1), /* 1406 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(232), - /* 1413 S> */ B(LdaSmi), U8(1), + /* 1413 S> */ B(LdaSmi), I8(1), /* 1418 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(234), - /* 1425 S> */ B(LdaSmi), U8(1), + /* 1425 S> */ B(LdaSmi), I8(1), /* 1430 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(236), - /* 1437 S> */ B(LdaSmi), U8(1), + /* 1437 S> */ B(LdaSmi), I8(1), /* 1442 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(238), - /* 1449 S> */ B(LdaSmi), U8(1), + /* 1449 S> */ B(LdaSmi), I8(1), /* 1454 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(240), - /* 1461 S> */ B(LdaSmi), U8(1), + /* 1461 S> */ B(LdaSmi), I8(1), /* 1466 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(242), - /* 1473 S> */ B(LdaSmi), U8(1), + /* 1473 S> */ B(LdaSmi), I8(1), /* 1478 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(244), - /* 1485 S> */ B(LdaSmi), U8(1), + /* 1485 S> */ B(LdaSmi), I8(1), /* 1490 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(246), - /* 1497 S> */ B(LdaSmi), U8(1), + /* 1497 S> */ B(LdaSmi), I8(1), /* 1502 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(248), - /* 1509 S> */ B(LdaSmi), U8(1), + /* 1509 S> */ B(LdaSmi), I8(1), /* 1514 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(250), - /* 1521 S> */ B(LdaSmi), U8(1), + /* 1521 S> */ B(LdaSmi), I8(1), /* 1526 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(252), - /* 1533 S> */ B(LdaSmi), U8(1), + /* 1533 S> */ B(LdaSmi), I8(1), /* 1538 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(254), - /* 1545 S> */ B(LdaSmi), U8(1), + /* 1545 S> */ B(LdaSmi), I8(1), /* 1550 E> */ B(Wide), B(StaKeyedPropertySloppy), R16(arg0), R16(arg1), U16(256), - /* 1557 S> */ B(LdaSmi), U8(2), + /* 1557 S> */ B(LdaSmi), I8(2), /* 1562 E> */ B(Wide), B(StaKeyedPropertySloppy), R16(arg0), R16(arg1), U16(258), B(LdaUndefined), /* 1567 S> */ B(Return), @@ -1521,263 +1521,263 @@ parameter count: 3 bytecode array length: 785 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 37 S> */ B(LdaSmi), U8(1), + /* 37 S> */ B(LdaSmi), I8(1), /* 42 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(2), - /* 49 S> */ B(LdaSmi), U8(1), + /* 49 S> */ B(LdaSmi), I8(1), /* 54 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(4), - /* 61 S> */ B(LdaSmi), U8(1), + /* 61 S> */ B(LdaSmi), I8(1), /* 66 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(6), - /* 73 S> */ B(LdaSmi), U8(1), + /* 73 S> */ B(LdaSmi), I8(1), /* 78 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(8), - /* 85 S> */ B(LdaSmi), U8(1), + /* 85 S> */ B(LdaSmi), I8(1), /* 90 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(10), - /* 97 S> */ B(LdaSmi), U8(1), + /* 97 S> */ B(LdaSmi), I8(1), /* 102 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(12), - /* 109 S> */ B(LdaSmi), U8(1), + /* 109 S> */ B(LdaSmi), I8(1), /* 114 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(14), - /* 121 S> */ B(LdaSmi), U8(1), + /* 121 S> */ B(LdaSmi), I8(1), /* 126 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(16), - /* 133 S> */ B(LdaSmi), U8(1), + /* 133 S> */ B(LdaSmi), I8(1), /* 138 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(18), - /* 145 S> */ B(LdaSmi), U8(1), + /* 145 S> */ B(LdaSmi), I8(1), /* 150 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(20), - /* 157 S> */ B(LdaSmi), U8(1), + /* 157 S> */ B(LdaSmi), I8(1), /* 162 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(22), - /* 169 S> */ B(LdaSmi), U8(1), + /* 169 S> */ B(LdaSmi), I8(1), /* 174 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(24), - /* 181 S> */ B(LdaSmi), U8(1), + /* 181 S> */ B(LdaSmi), I8(1), /* 186 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(26), - /* 193 S> */ B(LdaSmi), U8(1), + /* 193 S> */ B(LdaSmi), I8(1), /* 198 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(28), - /* 205 S> */ B(LdaSmi), U8(1), + /* 205 S> */ B(LdaSmi), I8(1), /* 210 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(30), - /* 217 S> */ B(LdaSmi), U8(1), + /* 217 S> */ B(LdaSmi), I8(1), /* 222 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(32), - /* 229 S> */ B(LdaSmi), U8(1), + /* 229 S> */ B(LdaSmi), I8(1), /* 234 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(34), - /* 241 S> */ B(LdaSmi), U8(1), + /* 241 S> */ B(LdaSmi), I8(1), /* 246 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(36), - /* 253 S> */ B(LdaSmi), U8(1), + /* 253 S> */ B(LdaSmi), I8(1), /* 258 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(38), - /* 265 S> */ B(LdaSmi), U8(1), + /* 265 S> */ B(LdaSmi), I8(1), /* 270 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(40), - /* 277 S> */ B(LdaSmi), U8(1), + /* 277 S> */ B(LdaSmi), I8(1), /* 282 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(42), - /* 289 S> */ B(LdaSmi), U8(1), + /* 289 S> */ B(LdaSmi), I8(1), /* 294 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(44), - /* 301 S> */ B(LdaSmi), U8(1), + /* 301 S> */ B(LdaSmi), I8(1), /* 306 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(46), - /* 313 S> */ B(LdaSmi), U8(1), + /* 313 S> */ B(LdaSmi), I8(1), /* 318 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(48), - /* 325 S> */ B(LdaSmi), U8(1), + /* 325 S> */ B(LdaSmi), I8(1), /* 330 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(50), - /* 337 S> */ B(LdaSmi), U8(1), + /* 337 S> */ B(LdaSmi), I8(1), /* 342 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(52), - /* 349 S> */ B(LdaSmi), U8(1), + /* 349 S> */ B(LdaSmi), I8(1), /* 354 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(54), - /* 361 S> */ B(LdaSmi), U8(1), + /* 361 S> */ B(LdaSmi), I8(1), /* 366 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(56), - /* 373 S> */ B(LdaSmi), U8(1), + /* 373 S> */ B(LdaSmi), I8(1), /* 378 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(58), - /* 385 S> */ B(LdaSmi), U8(1), + /* 385 S> */ B(LdaSmi), I8(1), /* 390 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(60), - /* 397 S> */ B(LdaSmi), U8(1), + /* 397 S> */ B(LdaSmi), I8(1), /* 402 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(62), - /* 409 S> */ B(LdaSmi), U8(1), + /* 409 S> */ B(LdaSmi), I8(1), /* 414 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(64), - /* 421 S> */ B(LdaSmi), U8(1), + /* 421 S> */ B(LdaSmi), I8(1), /* 426 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(66), - /* 433 S> */ B(LdaSmi), U8(1), + /* 433 S> */ B(LdaSmi), I8(1), /* 438 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(68), - /* 445 S> */ B(LdaSmi), U8(1), + /* 445 S> */ B(LdaSmi), I8(1), /* 450 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(70), - /* 457 S> */ B(LdaSmi), U8(1), + /* 457 S> */ B(LdaSmi), I8(1), /* 462 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(72), - /* 469 S> */ B(LdaSmi), U8(1), + /* 469 S> */ B(LdaSmi), I8(1), /* 474 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(74), - /* 481 S> */ B(LdaSmi), U8(1), + /* 481 S> */ B(LdaSmi), I8(1), /* 486 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(76), - /* 493 S> */ B(LdaSmi), U8(1), + /* 493 S> */ B(LdaSmi), I8(1), /* 498 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(78), - /* 505 S> */ B(LdaSmi), U8(1), + /* 505 S> */ B(LdaSmi), I8(1), /* 510 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(80), - /* 517 S> */ B(LdaSmi), U8(1), + /* 517 S> */ B(LdaSmi), I8(1), /* 522 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(82), - /* 529 S> */ B(LdaSmi), U8(1), + /* 529 S> */ B(LdaSmi), I8(1), /* 534 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(84), - /* 541 S> */ B(LdaSmi), U8(1), + /* 541 S> */ B(LdaSmi), I8(1), /* 546 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(86), - /* 553 S> */ B(LdaSmi), U8(1), + /* 553 S> */ B(LdaSmi), I8(1), /* 558 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(88), - /* 565 S> */ B(LdaSmi), U8(1), + /* 565 S> */ B(LdaSmi), I8(1), /* 570 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(90), - /* 577 S> */ B(LdaSmi), U8(1), + /* 577 S> */ B(LdaSmi), I8(1), /* 582 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(92), - /* 589 S> */ B(LdaSmi), U8(1), + /* 589 S> */ B(LdaSmi), I8(1), /* 594 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(94), - /* 601 S> */ B(LdaSmi), U8(1), + /* 601 S> */ B(LdaSmi), I8(1), /* 606 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(96), - /* 613 S> */ B(LdaSmi), U8(1), + /* 613 S> */ B(LdaSmi), I8(1), /* 618 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(98), - /* 625 S> */ B(LdaSmi), U8(1), + /* 625 S> */ B(LdaSmi), I8(1), /* 630 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(100), - /* 637 S> */ B(LdaSmi), U8(1), + /* 637 S> */ B(LdaSmi), I8(1), /* 642 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(102), - /* 649 S> */ B(LdaSmi), U8(1), + /* 649 S> */ B(LdaSmi), I8(1), /* 654 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(104), - /* 661 S> */ B(LdaSmi), U8(1), + /* 661 S> */ B(LdaSmi), I8(1), /* 666 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(106), - /* 673 S> */ B(LdaSmi), U8(1), + /* 673 S> */ B(LdaSmi), I8(1), /* 678 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(108), - /* 685 S> */ B(LdaSmi), U8(1), + /* 685 S> */ B(LdaSmi), I8(1), /* 690 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(110), - /* 697 S> */ B(LdaSmi), U8(1), + /* 697 S> */ B(LdaSmi), I8(1), /* 702 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(112), - /* 709 S> */ B(LdaSmi), U8(1), + /* 709 S> */ B(LdaSmi), I8(1), /* 714 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(114), - /* 721 S> */ B(LdaSmi), U8(1), + /* 721 S> */ B(LdaSmi), I8(1), /* 726 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(116), - /* 733 S> */ B(LdaSmi), U8(1), + /* 733 S> */ B(LdaSmi), I8(1), /* 738 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(118), - /* 745 S> */ B(LdaSmi), U8(1), + /* 745 S> */ B(LdaSmi), I8(1), /* 750 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(120), - /* 757 S> */ B(LdaSmi), U8(1), + /* 757 S> */ B(LdaSmi), I8(1), /* 762 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(122), - /* 769 S> */ B(LdaSmi), U8(1), + /* 769 S> */ B(LdaSmi), I8(1), /* 774 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(124), - /* 781 S> */ B(LdaSmi), U8(1), + /* 781 S> */ B(LdaSmi), I8(1), /* 786 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(126), - /* 793 S> */ B(LdaSmi), U8(1), + /* 793 S> */ B(LdaSmi), I8(1), /* 798 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(128), - /* 805 S> */ B(LdaSmi), U8(1), + /* 805 S> */ B(LdaSmi), I8(1), /* 810 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(130), - /* 817 S> */ B(LdaSmi), U8(1), + /* 817 S> */ B(LdaSmi), I8(1), /* 822 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(132), - /* 829 S> */ B(LdaSmi), U8(1), + /* 829 S> */ B(LdaSmi), I8(1), /* 834 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(134), - /* 841 S> */ B(LdaSmi), U8(1), + /* 841 S> */ B(LdaSmi), I8(1), /* 846 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(136), - /* 853 S> */ B(LdaSmi), U8(1), + /* 853 S> */ B(LdaSmi), I8(1), /* 858 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(138), - /* 865 S> */ B(LdaSmi), U8(1), + /* 865 S> */ B(LdaSmi), I8(1), /* 870 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(140), - /* 877 S> */ B(LdaSmi), U8(1), + /* 877 S> */ B(LdaSmi), I8(1), /* 882 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(142), - /* 889 S> */ B(LdaSmi), U8(1), + /* 889 S> */ B(LdaSmi), I8(1), /* 894 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(144), - /* 901 S> */ B(LdaSmi), U8(1), + /* 901 S> */ B(LdaSmi), I8(1), /* 906 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(146), - /* 913 S> */ B(LdaSmi), U8(1), + /* 913 S> */ B(LdaSmi), I8(1), /* 918 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(148), - /* 925 S> */ B(LdaSmi), U8(1), + /* 925 S> */ B(LdaSmi), I8(1), /* 930 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(150), - /* 937 S> */ B(LdaSmi), U8(1), + /* 937 S> */ B(LdaSmi), I8(1), /* 942 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(152), - /* 949 S> */ B(LdaSmi), U8(1), + /* 949 S> */ B(LdaSmi), I8(1), /* 954 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(154), - /* 961 S> */ B(LdaSmi), U8(1), + /* 961 S> */ B(LdaSmi), I8(1), /* 966 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(156), - /* 973 S> */ B(LdaSmi), U8(1), + /* 973 S> */ B(LdaSmi), I8(1), /* 978 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(158), - /* 985 S> */ B(LdaSmi), U8(1), + /* 985 S> */ B(LdaSmi), I8(1), /* 990 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(160), - /* 997 S> */ B(LdaSmi), U8(1), + /* 997 S> */ B(LdaSmi), I8(1), /* 1002 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(162), - /* 1009 S> */ B(LdaSmi), U8(1), + /* 1009 S> */ B(LdaSmi), I8(1), /* 1014 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(164), - /* 1021 S> */ B(LdaSmi), U8(1), + /* 1021 S> */ B(LdaSmi), I8(1), /* 1026 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(166), - /* 1033 S> */ B(LdaSmi), U8(1), + /* 1033 S> */ B(LdaSmi), I8(1), /* 1038 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(168), - /* 1045 S> */ B(LdaSmi), U8(1), + /* 1045 S> */ B(LdaSmi), I8(1), /* 1050 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(170), - /* 1057 S> */ B(LdaSmi), U8(1), + /* 1057 S> */ B(LdaSmi), I8(1), /* 1062 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(172), - /* 1069 S> */ B(LdaSmi), U8(1), + /* 1069 S> */ B(LdaSmi), I8(1), /* 1074 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(174), - /* 1081 S> */ B(LdaSmi), U8(1), + /* 1081 S> */ B(LdaSmi), I8(1), /* 1086 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(176), - /* 1093 S> */ B(LdaSmi), U8(1), + /* 1093 S> */ B(LdaSmi), I8(1), /* 1098 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(178), - /* 1105 S> */ B(LdaSmi), U8(1), + /* 1105 S> */ B(LdaSmi), I8(1), /* 1110 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(180), - /* 1117 S> */ B(LdaSmi), U8(1), + /* 1117 S> */ B(LdaSmi), I8(1), /* 1122 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(182), - /* 1129 S> */ B(LdaSmi), U8(1), + /* 1129 S> */ B(LdaSmi), I8(1), /* 1134 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(184), - /* 1141 S> */ B(LdaSmi), U8(1), + /* 1141 S> */ B(LdaSmi), I8(1), /* 1146 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(186), - /* 1153 S> */ B(LdaSmi), U8(1), + /* 1153 S> */ B(LdaSmi), I8(1), /* 1158 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(188), - /* 1165 S> */ B(LdaSmi), U8(1), + /* 1165 S> */ B(LdaSmi), I8(1), /* 1170 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(190), - /* 1177 S> */ B(LdaSmi), U8(1), + /* 1177 S> */ B(LdaSmi), I8(1), /* 1182 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(192), - /* 1189 S> */ B(LdaSmi), U8(1), + /* 1189 S> */ B(LdaSmi), I8(1), /* 1194 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(194), - /* 1201 S> */ B(LdaSmi), U8(1), + /* 1201 S> */ B(LdaSmi), I8(1), /* 1206 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(196), - /* 1213 S> */ B(LdaSmi), U8(1), + /* 1213 S> */ B(LdaSmi), I8(1), /* 1218 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(198), - /* 1225 S> */ B(LdaSmi), U8(1), + /* 1225 S> */ B(LdaSmi), I8(1), /* 1230 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(200), - /* 1237 S> */ B(LdaSmi), U8(1), + /* 1237 S> */ B(LdaSmi), I8(1), /* 1242 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(202), - /* 1249 S> */ B(LdaSmi), U8(1), + /* 1249 S> */ B(LdaSmi), I8(1), /* 1254 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(204), - /* 1261 S> */ B(LdaSmi), U8(1), + /* 1261 S> */ B(LdaSmi), I8(1), /* 1266 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(206), - /* 1273 S> */ B(LdaSmi), U8(1), + /* 1273 S> */ B(LdaSmi), I8(1), /* 1278 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(208), - /* 1285 S> */ B(LdaSmi), U8(1), + /* 1285 S> */ B(LdaSmi), I8(1), /* 1290 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(210), - /* 1297 S> */ B(LdaSmi), U8(1), + /* 1297 S> */ B(LdaSmi), I8(1), /* 1302 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(212), - /* 1309 S> */ B(LdaSmi), U8(1), + /* 1309 S> */ B(LdaSmi), I8(1), /* 1314 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(214), - /* 1321 S> */ B(LdaSmi), U8(1), + /* 1321 S> */ B(LdaSmi), I8(1), /* 1326 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(216), - /* 1333 S> */ B(LdaSmi), U8(1), + /* 1333 S> */ B(LdaSmi), I8(1), /* 1338 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(218), - /* 1345 S> */ B(LdaSmi), U8(1), + /* 1345 S> */ B(LdaSmi), I8(1), /* 1350 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(220), - /* 1357 S> */ B(LdaSmi), U8(1), + /* 1357 S> */ B(LdaSmi), I8(1), /* 1362 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(222), - /* 1369 S> */ B(LdaSmi), U8(1), + /* 1369 S> */ B(LdaSmi), I8(1), /* 1374 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(224), - /* 1381 S> */ B(LdaSmi), U8(1), + /* 1381 S> */ B(LdaSmi), I8(1), /* 1386 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(226), - /* 1393 S> */ B(LdaSmi), U8(1), + /* 1393 S> */ B(LdaSmi), I8(1), /* 1398 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(228), - /* 1405 S> */ B(LdaSmi), U8(1), + /* 1405 S> */ B(LdaSmi), I8(1), /* 1410 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(230), - /* 1417 S> */ B(LdaSmi), U8(1), + /* 1417 S> */ B(LdaSmi), I8(1), /* 1422 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(232), - /* 1429 S> */ B(LdaSmi), U8(1), + /* 1429 S> */ B(LdaSmi), I8(1), /* 1434 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(234), - /* 1441 S> */ B(LdaSmi), U8(1), + /* 1441 S> */ B(LdaSmi), I8(1), /* 1446 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(236), - /* 1453 S> */ B(LdaSmi), U8(1), + /* 1453 S> */ B(LdaSmi), I8(1), /* 1458 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(238), - /* 1465 S> */ B(LdaSmi), U8(1), + /* 1465 S> */ B(LdaSmi), I8(1), /* 1470 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(240), - /* 1477 S> */ B(LdaSmi), U8(1), + /* 1477 S> */ B(LdaSmi), I8(1), /* 1482 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(242), - /* 1489 S> */ B(LdaSmi), U8(1), + /* 1489 S> */ B(LdaSmi), I8(1), /* 1494 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(244), - /* 1501 S> */ B(LdaSmi), U8(1), + /* 1501 S> */ B(LdaSmi), I8(1), /* 1506 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(246), - /* 1513 S> */ B(LdaSmi), U8(1), + /* 1513 S> */ B(LdaSmi), I8(1), /* 1518 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(248), - /* 1525 S> */ B(LdaSmi), U8(1), + /* 1525 S> */ B(LdaSmi), I8(1), /* 1530 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(250), - /* 1537 S> */ B(LdaSmi), U8(1), + /* 1537 S> */ B(LdaSmi), I8(1), /* 1542 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(252), - /* 1549 S> */ B(LdaSmi), U8(1), + /* 1549 S> */ B(LdaSmi), I8(1), /* 1554 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(254), - /* 1561 S> */ B(LdaSmi), U8(1), + /* 1561 S> */ B(LdaSmi), I8(1), /* 1566 E> */ B(Wide), B(StaKeyedPropertyStrict), R16(arg0), R16(arg1), U16(256), - /* 1573 S> */ B(LdaSmi), U8(2), + /* 1573 S> */ B(LdaSmi), I8(2), /* 1578 E> */ B(Wide), B(StaKeyedPropertyStrict), R16(arg0), R16(arg1), U16(258), B(LdaUndefined), /* 1583 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/RegExpLiterals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/RegExpLiterals.golden index cdb00db659..61b3b242b7 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/RegExpLiterals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/RegExpLiterals.golden @@ -14,7 +14,7 @@ parameter count: 1 bytecode array length: 6 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateRegExpLiteral), U8(0), U8(0), U8(0), + /* 34 S> */ B(CreateRegExpLiteral), U8(0), U8(2), U8(0), /* 49 S> */ B(Return), ] constant pool: [ @@ -32,7 +32,7 @@ parameter count: 1 bytecode array length: 6 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateRegExpLiteral), U8(0), U8(0), U8(2), + /* 34 S> */ B(CreateRegExpLiteral), U8(0), U8(2), U8(2), /* 58 S> */ B(Return), ] constant pool: [ @@ -50,9 +50,9 @@ parameter count: 1 bytecode array length: 23 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateRegExpLiteral), U8(0), U8(0), U8(0), + /* 34 S> */ B(CreateRegExpLiteral), U8(0), U8(4), U8(0), B(Star), R(1), - /* 47 E> */ B(LdaNamedProperty), R(1), U8(1), U8(4), + /* 47 E> */ B(LdaNamedProperty), R(1), U8(1), U8(5), B(Star), R(0), B(LdaConstant), U8(2), B(Star), R(2), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/RegExpLiteralsWide.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/RegExpLiteralsWide.golden index 3eb79ba725..2fcd4b1188 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/RegExpLiteralsWide.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/RegExpLiteralsWide.golden @@ -783,7 +783,7 @@ bytecodes: [ B(Star), R(0), /* 2591 S> */ B(LdaConstant), U8(255), B(Star), R(0), - /* 2601 S> */ B(Wide), B(CreateRegExpLiteral), U16(256), U16(0), U8(0), + /* 2601 S> */ B(Wide), B(CreateRegExpLiteral), U16(256), U16(2), U8(0), /* 2616 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/RemoveRedundantLdar.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/RemoveRedundantLdar.golden index 1c806b7f46..4fb7fbe420 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/RemoveRedundantLdar.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/RemoveRedundantLdar.golden @@ -19,17 +19,17 @@ parameter count: 1 bytecode array length: 28 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 45 S> */ B(LdaSmi), U8(1), + /* 45 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 48 E> */ B(StackCheck), /* 64 S> */ B(Ldar), R(0), /* 76 E> */ B(Add), R(0), U8(2), B(Star), R(0), - /* 86 S> */ B(LdaSmi), U8(10), + /* 86 S> */ B(LdaSmi), I8(10), /* 95 E> */ B(TestGreaterThan), R(0), U8(3), B(JumpIfFalse), U8(4), /* 101 S> */ B(Jump), U8(5), - B(JumpLoop), U8(-17), U8(0), + B(JumpLoop), U8(17), I8(0), /* 110 S> */ B(Ldar), R(0), /* 123 S> */ B(Return), ] @@ -52,13 +52,13 @@ parameter count: 1 bytecode array length: 24 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 45 S> */ B(LdaSmi), U8(1), + /* 45 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 48 E> */ B(StackCheck), /* 55 S> */ B(Nop), /* 67 E> */ B(Add), R(0), U8(2), B(Star), R(0), - /* 77 S> */ B(LdaSmi), U8(10), + /* 77 S> */ B(LdaSmi), I8(10), /* 86 E> */ B(TestGreaterThan), R(0), U8(3), B(JumpIfFalse), U8(4), /* 92 S> */ B(Jump), U8(2), @@ -81,7 +81,7 @@ parameter count: 1 bytecode array length: 13 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 45 S> */ B(LdaSmi), U8(1), + /* 45 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 50 S> */ B(Nop), /* 62 E> */ B(Add), R(0), U8(2), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/StoreGlobal.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/StoreGlobal.golden index 422fa12cb1..4e0330ede3 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/StoreGlobal.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/StoreGlobal.golden @@ -17,7 +17,7 @@ parameter count: 1 bytecode array length: 8 bytecodes: [ /* 21 E> */ B(StackCheck), - /* 26 S> */ B(LdaSmi), U8(2), + /* 26 S> */ B(LdaSmi), I8(2), /* 28 E> */ B(StaGlobalSloppy), U8(0), U8(2), B(LdaUndefined), /* 33 S> */ B(Return), @@ -60,7 +60,7 @@ parameter count: 1 bytecode array length: 8 bytecodes: [ /* 35 E> */ B(StackCheck), - /* 40 S> */ B(LdaSmi), U8(2), + /* 40 S> */ B(LdaSmi), I8(2), /* 42 E> */ B(StaGlobalStrict), U8(0), U8(2), B(LdaUndefined), /* 47 S> */ B(Return), @@ -82,7 +82,7 @@ parameter count: 1 bytecode array length: 8 bytecodes: [ /* 17 E> */ B(StackCheck), - /* 22 S> */ B(LdaSmi), U8(2), + /* 22 S> */ B(LdaSmi), I8(2), /* 24 E> */ B(StaGlobalSloppy), U8(0), U8(2), B(LdaUndefined), /* 29 S> */ B(Return), @@ -490,7 +490,7 @@ bytecodes: [ /* 1286 E> */ B(LdaNamedProperty), R(arg0), U8(0), U8(254), /* 1295 S> */ B(Nop), /* 1296 E> */ B(Wide), B(LdaNamedProperty), R16(arg0), U16(0), U16(256), - /* 1305 S> */ B(LdaSmi), U8(2), + /* 1305 S> */ B(LdaSmi), I8(2), /* 1307 E> */ B(Wide), B(StaGlobalSloppy), U16(1), U16(258), B(LdaUndefined), /* 1312 S> */ B(Return), @@ -900,7 +900,7 @@ bytecodes: [ /* 1302 E> */ B(LdaNamedProperty), R(arg0), U8(0), U8(254), /* 1311 S> */ B(Nop), /* 1312 E> */ B(Wide), B(LdaNamedProperty), R16(arg0), U16(0), U16(256), - /* 1321 S> */ B(LdaSmi), U8(2), + /* 1321 S> */ B(LdaSmi), I8(2), /* 1323 E> */ B(Wide), B(StaGlobalStrict), U16(1), U16(258), B(LdaUndefined), /* 1328 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden index 2dd9ec5383..8446beb7bf 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden @@ -17,9 +17,9 @@ snippet: " test = new B(1, 2, 3).constructor; })(); " -frame size: 7 +frame size: 4 parameter count: 1 -bytecode array length: 29 +bytecode array length: 23 bytecodes: [ B(CreateRestParameter), B(Star), R(2), @@ -29,10 +29,8 @@ bytecodes: [ /* 93 E> */ B(StackCheck), /* 93 S> */ B(Ldar), R(1), B(GetSuperConstructor), R(3), - B(Mov), R(3), R(4), - B(Mov), R(0), R(5), - B(Mov), R(2), R(6), - /* 93 E> */ B(NewWithSpread), R(4), U8(3), + B(Ldar), R(0), + /* 93 E> */ B(ConstructWithSpread), R(3), R(2), U8(1), /* 93 S> */ B(Return), ] constant pool: [ @@ -53,9 +51,9 @@ snippet: " test = new B(1, 2, 3).constructor; })(); " -frame size: 8 +frame size: 6 parameter count: 1 -bytecode array length: 62 +bytecode array length: 59 bytecodes: [ B(CreateRestParameter), B(Star), R(2), @@ -65,12 +63,11 @@ bytecodes: [ /* 128 E> */ B(StackCheck), /* 140 S> */ B(Ldar), R(1), B(GetSuperConstructor), R(3), - B(LdaSmi), U8(1), - B(Star), R(6), - B(Mov), R(3), R(4), - B(Mov), R(0), R(5), - B(Mov), R(2), R(7), - /* 140 E> */ B(NewWithSpread), R(4), U8(4), + B(LdaSmi), I8(1), + B(Star), R(4), + B(Ldar), R(0), + B(Mov), R(2), R(5), + /* 140 E> */ B(ConstructWithSpread), R(3), R(4), U8(2), B(Star), R(3), B(Ldar), R(this), B(JumpIfNotHole), U8(4), @@ -119,14 +116,14 @@ bytecodes: [ B(Star), R(4), B(LdaUndefined), B(Star), R(5), - B(CreateArrayLiteral), U8(0), U8(0), U8(9), + B(CreateArrayLiteral), U8(0), U8(2), U8(9), B(Star), R(6), B(LdaUndefined), B(Star), R(7), B(Mov), R(2), R(8), /* 152 E> */ B(CallJSRuntime), U8(%spread_iterable), R(7), U8(2), B(Star), R(7), - B(CreateArrayLiteral), U8(1), U8(1), U8(9), + B(CreateArrayLiteral), U8(1), U8(3), U8(9), B(Star), R(8), B(CallJSRuntime), U8(%spread_arguments), R(5), U8(4), B(Star), R(5), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Switch.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Switch.golden index 77bee13e14..a1025e5ba4 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Switch.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Switch.golden @@ -18,20 +18,20 @@ parameter count: 1 bytecode array length: 34 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(Star), R(1), - /* 45 S> */ B(LdaSmi), U8(1), + /* 45 S> */ B(LdaSmi), I8(1), B(TestEqualStrict), R(1), U8(2), B(Mov), R(0), R(2), B(JumpIfToBooleanTrue), U8(11), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(2), U8(3), B(JumpIfTrue), U8(7), B(Jump), U8(8), - /* 66 S> */ B(LdaSmi), U8(2), + /* 66 S> */ B(LdaSmi), I8(2), /* 97 S> */ B(Return), - /* 85 S> */ B(LdaSmi), U8(3), + /* 85 S> */ B(LdaSmi), I8(3), /* 97 S> */ B(Return), B(LdaUndefined), /* 97 S> */ B(Return), @@ -54,21 +54,21 @@ parameter count: 1 bytecode array length: 40 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(Star), R(1), - /* 45 S> */ B(LdaSmi), U8(1), + /* 45 S> */ B(LdaSmi), I8(1), B(TestEqualStrict), R(1), U8(2), B(Mov), R(0), R(2), B(JumpIfToBooleanTrue), U8(11), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(2), U8(3), B(JumpIfTrue), U8(10), B(Jump), U8(14), - /* 66 S> */ B(LdaSmi), U8(2), + /* 66 S> */ B(LdaSmi), I8(2), B(Star), R(0), /* 73 S> */ B(Jump), U8(8), - /* 89 S> */ B(LdaSmi), U8(3), + /* 89 S> */ B(LdaSmi), I8(3), B(Star), R(0), /* 96 S> */ B(Jump), U8(2), B(LdaUndefined), @@ -92,20 +92,20 @@ parameter count: 1 bytecode array length: 38 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(Star), R(1), - /* 45 S> */ B(LdaSmi), U8(1), + /* 45 S> */ B(LdaSmi), I8(1), B(TestEqualStrict), R(1), U8(2), B(Mov), R(0), R(2), B(JumpIfToBooleanTrue), U8(11), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(2), U8(3), B(JumpIfTrue), U8(8), B(Jump), U8(12), - /* 66 S> */ B(LdaSmi), U8(2), + /* 66 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 98 S> */ B(LdaSmi), U8(3), + /* 98 S> */ B(LdaSmi), I8(3), B(Star), R(0), /* 105 S> */ B(Jump), U8(2), B(LdaUndefined), @@ -130,20 +130,20 @@ parameter count: 1 bytecode array length: 38 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(Star), R(1), - /* 45 S> */ B(LdaSmi), U8(2), + /* 45 S> */ B(LdaSmi), I8(2), B(TestEqualStrict), R(1), U8(2), B(Mov), R(0), R(2), B(JumpIfToBooleanTrue), U8(11), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(TestEqualStrict), R(2), U8(3), B(JumpIfTrue), U8(6), B(Jump), U8(6), /* 66 S> */ B(Jump), U8(10), /* 82 S> */ B(Jump), U8(8), - /* 99 S> */ B(LdaSmi), U8(1), + /* 99 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 106 S> */ B(Jump), U8(2), B(LdaUndefined), @@ -168,25 +168,25 @@ parameter count: 1 bytecode array length: 47 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 42 E> */ B(TypeOf), B(Star), R(1), - /* 45 S> */ B(LdaSmi), U8(2), + /* 45 S> */ B(LdaSmi), I8(2), B(TestEqualStrict), R(1), U8(2), B(Mov), R(1), R(2), B(JumpIfToBooleanTrue), U8(11), - B(LdaSmi), U8(3), + B(LdaSmi), I8(3), B(TestEqualStrict), R(2), U8(3), B(JumpIfTrue), U8(10), B(Jump), U8(14), - /* 74 S> */ B(LdaSmi), U8(1), + /* 74 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 81 S> */ B(Jump), U8(14), - /* 97 S> */ B(LdaSmi), U8(2), + /* 97 S> */ B(LdaSmi), I8(2), B(Star), R(0), /* 104 S> */ B(Jump), U8(8), - /* 121 S> */ B(LdaSmi), U8(3), + /* 121 S> */ B(LdaSmi), I8(3), B(Star), R(0), /* 128 S> */ B(Jump), U8(2), B(LdaUndefined), @@ -210,7 +210,7 @@ parameter count: 1 bytecode array length: 32 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(Star), R(1), /* 45 S> */ B(TypeOf), @@ -218,10 +218,10 @@ bytecodes: [ B(Mov), R(0), R(2), B(JumpIfToBooleanTrue), U8(4), B(Jump), U8(8), - /* 74 S> */ B(LdaSmi), U8(1), + /* 74 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 81 S> */ B(Jump), U8(8), - /* 98 S> */ B(LdaSmi), U8(2), + /* 98 S> */ B(LdaSmi), I8(2), B(Star), R(0), /* 105 S> */ B(Jump), U8(2), B(LdaUndefined), @@ -312,147 +312,147 @@ parameter count: 1 bytecode array length: 292 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(Star), R(1), - /* 45 S> */ B(LdaSmi), U8(1), + /* 45 S> */ B(LdaSmi), I8(1), B(TestEqualStrict), R(1), U8(2), B(Mov), R(0), R(2), B(JumpIfToBooleanTrue), U8(11), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(2), U8(3), B(JumpIfTrueConstant), U8(0), B(JumpConstant), U8(1), - /* 68 S> */ B(LdaSmi), U8(2), + /* 68 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 77 S> */ B(LdaSmi), U8(2), + /* 77 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 86 S> */ B(LdaSmi), U8(2), + /* 86 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 95 S> */ B(LdaSmi), U8(2), + /* 95 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 104 S> */ B(LdaSmi), U8(2), + /* 104 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 113 S> */ B(LdaSmi), U8(2), + /* 113 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 122 S> */ B(LdaSmi), U8(2), + /* 122 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 131 S> */ B(LdaSmi), U8(2), + /* 131 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 140 S> */ B(LdaSmi), U8(2), + /* 140 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 149 S> */ B(LdaSmi), U8(2), + /* 149 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 158 S> */ B(LdaSmi), U8(2), + /* 158 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 167 S> */ B(LdaSmi), U8(2), + /* 167 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 176 S> */ B(LdaSmi), U8(2), + /* 176 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 185 S> */ B(LdaSmi), U8(2), + /* 185 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 194 S> */ B(LdaSmi), U8(2), + /* 194 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 203 S> */ B(LdaSmi), U8(2), + /* 203 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 212 S> */ B(LdaSmi), U8(2), + /* 212 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 221 S> */ B(LdaSmi), U8(2), + /* 221 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 230 S> */ B(LdaSmi), U8(2), + /* 230 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 239 S> */ B(LdaSmi), U8(2), + /* 239 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 248 S> */ B(LdaSmi), U8(2), + /* 248 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 257 S> */ B(LdaSmi), U8(2), + /* 257 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 266 S> */ B(LdaSmi), U8(2), + /* 266 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 275 S> */ B(LdaSmi), U8(2), + /* 275 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 284 S> */ B(LdaSmi), U8(2), + /* 284 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 293 S> */ B(LdaSmi), U8(2), + /* 293 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 302 S> */ B(LdaSmi), U8(2), + /* 302 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 311 S> */ B(LdaSmi), U8(2), + /* 311 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 320 S> */ B(LdaSmi), U8(2), + /* 320 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 329 S> */ B(LdaSmi), U8(2), + /* 329 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 338 S> */ B(LdaSmi), U8(2), + /* 338 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 347 S> */ B(LdaSmi), U8(2), + /* 347 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 356 S> */ B(LdaSmi), U8(2), + /* 356 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 365 S> */ B(LdaSmi), U8(2), + /* 365 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 374 S> */ B(LdaSmi), U8(2), + /* 374 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 383 S> */ B(LdaSmi), U8(2), + /* 383 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 392 S> */ B(LdaSmi), U8(2), + /* 392 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 401 S> */ B(LdaSmi), U8(2), + /* 401 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 410 S> */ B(LdaSmi), U8(2), + /* 410 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 419 S> */ B(LdaSmi), U8(2), + /* 419 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 428 S> */ B(LdaSmi), U8(2), + /* 428 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 437 S> */ B(LdaSmi), U8(2), + /* 437 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 446 S> */ B(LdaSmi), U8(2), + /* 446 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 455 S> */ B(LdaSmi), U8(2), + /* 455 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 464 S> */ B(LdaSmi), U8(2), + /* 464 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 473 S> */ B(LdaSmi), U8(2), + /* 473 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 482 S> */ B(LdaSmi), U8(2), + /* 482 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 491 S> */ B(LdaSmi), U8(2), + /* 491 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 500 S> */ B(LdaSmi), U8(2), + /* 500 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 509 S> */ B(LdaSmi), U8(2), + /* 509 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 518 S> */ B(LdaSmi), U8(2), + /* 518 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 527 S> */ B(LdaSmi), U8(2), + /* 527 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 536 S> */ B(LdaSmi), U8(2), + /* 536 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 545 S> */ B(LdaSmi), U8(2), + /* 545 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 554 S> */ B(LdaSmi), U8(2), + /* 554 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 563 S> */ B(LdaSmi), U8(2), + /* 563 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 572 S> */ B(LdaSmi), U8(2), + /* 572 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 581 S> */ B(LdaSmi), U8(2), + /* 581 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 590 S> */ B(LdaSmi), U8(2), + /* 590 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 599 S> */ B(LdaSmi), U8(2), + /* 599 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 608 S> */ B(LdaSmi), U8(2), + /* 608 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 617 S> */ B(LdaSmi), U8(2), + /* 617 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 626 S> */ B(LdaSmi), U8(2), + /* 626 S> */ B(LdaSmi), I8(2), B(Star), R(0), - /* 635 S> */ B(LdaSmi), U8(2), + /* 635 S> */ B(LdaSmi), I8(2), B(Star), R(0), /* 644 S> */ B(Jump), U8(8), - /* 662 S> */ B(LdaSmi), U8(3), + /* 662 S> */ B(LdaSmi), I8(3), B(Star), R(0), /* 671 S> */ B(Jump), U8(2), B(LdaUndefined), @@ -482,31 +482,31 @@ parameter count: 1 bytecode array length: 62 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(Star), R(2), - /* 45 S> */ B(LdaSmi), U8(1), + /* 45 S> */ B(LdaSmi), I8(1), B(TestEqualStrict), R(2), U8(5), B(Mov), R(0), R(3), B(JumpIfToBooleanTrue), U8(11), - B(LdaSmi), U8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(3), U8(6), B(JumpIfTrue), U8(34), B(Jump), U8(36), - /* 79 E> */ B(AddSmi), U8(1), R(0), U8(2), + /* 79 E> */ B(AddSmi), I8(1), R(0), U8(2), B(Star), R(1), - /* 70 S> */ B(LdaSmi), U8(2), + /* 70 S> */ B(LdaSmi), I8(2), B(TestEqualStrict), R(1), U8(3), B(Mov), R(1), R(4), B(JumpIfToBooleanTrue), U8(4), B(Jump), U8(8), - /* 101 S> */ B(LdaSmi), U8(1), + /* 101 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 108 S> */ B(Jump), U8(8), - /* 131 S> */ B(LdaSmi), U8(2), + /* 131 S> */ B(LdaSmi), I8(2), B(Star), R(0), /* 138 S> */ B(Jump), U8(2), - /* 176 S> */ B(LdaSmi), U8(3), + /* 176 S> */ B(LdaSmi), I8(3), B(Star), R(0), B(LdaUndefined), /* 185 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Throw.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Throw.golden index 15afe2f4eb..73e203a60b 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Throw.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Throw.golden @@ -14,7 +14,7 @@ parameter count: 1 bytecode array length: 4 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(LdaSmi), U8(1), + /* 34 S> */ B(LdaSmi), I8(1), /* 34 E> */ B(Throw), ] constant pool: [ @@ -49,7 +49,7 @@ parameter count: 1 bytecode array length: 12 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(JumpIfToBooleanFalse), U8(5), /* 54 S> */ B(LdaConstant), U8(0), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/TopLevelObjectLiterals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/TopLevelObjectLiterals.golden index 1594422e49..275bdf5491 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/TopLevelObjectLiterals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/TopLevelObjectLiterals.golden @@ -24,10 +24,10 @@ bytecodes: [ /* 8 S> */ B(LdaConstant), U8(1), B(Star), R(1), B(LdaZero), - B(CreateObjectLiteral), U8(2), U8(0), U8(1), R(3), + B(CreateObjectLiteral), U8(2), U8(5), U8(1), R(3), B(Star), R(2), B(CreateClosure), U8(3), U8(4), U8(0), - B(StaNamedPropertySloppy), R(3), U8(4), U8(5), + B(StaNamedOwnProperty), R(3), U8(4), U8(6), B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), B(LdaUndefined), /* 33 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/TryCatch.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/TryCatch.golden index b687ed24ca..93f906c287 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/TryCatch.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/TryCatch.golden @@ -15,7 +15,7 @@ bytecode array length: 32 bytecodes: [ /* 30 E> */ B(StackCheck), B(Mov), R(context), R(1), - /* 40 S> */ B(LdaSmi), U8(1), + /* 40 S> */ B(LdaSmi), I8(1), /* 75 S> */ B(Return), B(Jump), U8(23), B(Star), R(2), @@ -26,7 +26,7 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(1), B(PushContext), R(0), - /* 63 S> */ B(LdaSmi), U8(2), + /* 63 S> */ B(LdaSmi), I8(2), B(PopContext), R(0), /* 75 S> */ B(Return), B(LdaUndefined), @@ -52,7 +52,7 @@ bytecode array length: 61 bytecodes: [ /* 30 E> */ B(StackCheck), B(Mov), R(context), R(2), - /* 47 S> */ B(LdaSmi), U8(1), + /* 47 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(Jump), U8(20), B(Star), R(3), @@ -65,7 +65,7 @@ bytecodes: [ B(PushContext), R(1), B(PopContext), R(1), B(Mov), R(context), R(2), - /* 75 S> */ B(LdaSmi), U8(2), + /* 75 S> */ B(LdaSmi), I8(2), B(Star), R(0), B(Jump), U8(24), B(Star), R(3), @@ -76,7 +76,7 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(2), B(PushContext), R(1), - /* 95 S> */ B(LdaSmi), U8(3), + /* 95 S> */ B(LdaSmi), I8(3), B(Star), R(0), B(PopContext), R(1), B(LdaUndefined), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/TryFinally.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/TryFinally.golden index b85ae8c51a..eaad3bb8bb 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/TryFinally.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/TryFinally.golden @@ -15,12 +15,12 @@ parameter count: 1 bytecode array length: 47 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(Mov), R(context), R(3), - /* 51 S> */ B(LdaSmi), U8(2), + /* 51 S> */ B(LdaSmi), I8(2), B(Star), R(0), - B(LdaSmi), U8(-1), + B(LdaSmi), I8(-1), B(Star), R(1), B(Jump), U8(7), B(Star), R(2), @@ -29,7 +29,7 @@ bytecodes: [ B(LdaTheHole), /* 53 E> */ B(SetPendingMessage), B(Star), R(3), - /* 70 S> */ B(LdaSmi), U8(3), + /* 70 S> */ B(LdaSmi), I8(3), B(Star), R(0), B(Ldar), R(3), /* 72 E> */ B(SetPendingMessage), @@ -58,11 +58,11 @@ parameter count: 1 bytecode array length: 74 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(1), + /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(Mov), R(context), R(4), B(Mov), R(context), R(5), - /* 51 S> */ B(LdaSmi), U8(2), + /* 51 S> */ B(LdaSmi), I8(2), B(Star), R(0), B(Jump), U8(24), B(Star), R(6), @@ -73,10 +73,10 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(5), B(PushContext), R(1), - /* 71 S> */ B(LdaSmi), U8(20), + /* 71 S> */ B(LdaSmi), I8(20), B(Star), R(0), B(PopContext), R(1), - B(LdaSmi), U8(-1), + B(LdaSmi), I8(-1), B(Star), R(2), B(Jump), U8(7), B(Star), R(3), @@ -85,7 +85,7 @@ bytecodes: [ B(LdaTheHole), /* 73 E> */ B(SetPendingMessage), B(Star), R(4), - /* 90 S> */ B(LdaSmi), U8(3), + /* 90 S> */ B(LdaSmi), I8(3), B(Star), R(0), B(Ldar), R(4), /* 92 E> */ B(SetPendingMessage), @@ -121,7 +121,7 @@ bytecodes: [ B(Mov), R(context), R(4), B(Mov), R(context), R(5), B(Mov), R(context), R(6), - /* 55 S> */ B(LdaSmi), U8(1), + /* 55 S> */ B(LdaSmi), I8(1), B(Star), R(0), B(Jump), U8(24), B(Star), R(7), @@ -132,7 +132,7 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(6), B(PushContext), R(1), - /* 74 S> */ B(LdaSmi), U8(2), + /* 74 S> */ B(LdaSmi), I8(2), B(Star), R(0), B(PopContext), R(1), B(Jump), U8(24), @@ -144,10 +144,10 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(5), B(PushContext), R(1), - /* 95 S> */ B(LdaSmi), U8(20), + /* 95 S> */ B(LdaSmi), I8(20), B(Star), R(0), B(PopContext), R(1), - B(LdaSmi), U8(-1), + B(LdaSmi), I8(-1), B(Star), R(2), B(Jump), U8(7), B(Star), R(3), @@ -156,7 +156,7 @@ bytecodes: [ B(LdaTheHole), /* 97 E> */ B(SetPendingMessage), B(Star), R(4), - /* 114 S> */ B(LdaSmi), U8(3), + /* 114 S> */ B(LdaSmi), I8(3), B(Star), R(0), B(Ldar), R(4), /* 116 E> */ B(SetPendingMessage), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Typeof.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Typeof.golden index d5ab090594..ecf9ed6d64 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Typeof.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Typeof.golden @@ -19,7 +19,7 @@ parameter count: 1 bytecode array length: 7 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 24 S> */ B(LdaSmi), U8(13), + /* 24 S> */ B(LdaSmi), I8(13), B(Star), R(0), /* 29 S> */ B(TypeOf), /* 47 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/UnaryOperators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/UnaryOperators.golden index 1620f93f5e..b94144d76b 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/UnaryOperators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/UnaryOperators.golden @@ -20,14 +20,14 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), - /* 54 S> */ B(LdaSmi), U8(10), + /* 54 S> */ B(LdaSmi), I8(10), /* 54 E> */ B(TestEqual), R(0), U8(2), B(JumpIfTrue), U8(13), /* 45 E> */ B(StackCheck), - /* 65 S> */ B(LdaSmi), U8(10), + /* 65 S> */ B(LdaSmi), I8(10), /* 71 E> */ B(Add), R(0), U8(3), B(Star), R(0), - B(JumpLoop), U8(-15), U8(0), + B(JumpLoop), U8(15), I8(0), /* 79 S> */ B(Ldar), R(0), /* 89 S> */ B(Return), ] @@ -58,7 +58,7 @@ bytecodes: [ /* 74 S> */ B(LdaFalse), /* 74 E> */ B(TestEqual), R(0), U8(2), B(JumpIfFalse), U8(5), - B(JumpLoop), U8(-12), U8(0), + B(JumpLoop), U8(12), I8(0), /* 85 S> */ B(Ldar), R(0), /* 95 S> */ B(Return), ] @@ -77,9 +77,9 @@ parameter count: 1 bytecode array length: 12 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(101), + /* 42 S> */ B(LdaSmi), I8(101), B(Star), R(0), - /* 47 S> */ B(LdaSmi), U8(3), + /* 47 S> */ B(LdaSmi), I8(3), /* 61 E> */ B(Mul), R(0), U8(2), B(LdaUndefined), /* 67 S> */ B(Return), @@ -100,12 +100,12 @@ parameter count: 1 bytecode array length: 22 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(Wide), B(LdaSmi), U16(1234), + /* 42 S> */ B(Wide), B(LdaSmi), I16(1234), B(Star), R(0), /* 56 S> */ B(Nop), /* 64 E> */ B(Mul), R(0), U8(2), B(Star), R(2), - /* 68 E> */ B(SubSmi), U8(1), R(2), U8(3), + /* 68 E> */ B(SubSmi), I8(1), R(2), U8(3), B(LdaUndefined), B(Star), R(1), /* 74 S> */ B(Nop), @@ -126,9 +126,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(13), + /* 42 S> */ B(LdaSmi), I8(13), B(Star), R(0), - /* 46 S> */ B(LdaSmi), U8(-1), + /* 46 S> */ B(LdaSmi), I8(-1), /* 53 E> */ B(BitwiseXor), R(0), U8(2), /* 57 S> */ B(Return), ] @@ -147,9 +147,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(13), + /* 42 S> */ B(LdaSmi), I8(13), B(Star), R(0), - /* 46 S> */ B(LdaSmi), U8(1), + /* 46 S> */ B(LdaSmi), I8(1), /* 53 E> */ B(Mul), R(0), U8(2), /* 57 S> */ B(Return), ] @@ -168,9 +168,9 @@ parameter count: 1 bytecode array length: 11 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 42 S> */ B(LdaSmi), U8(13), + /* 42 S> */ B(LdaSmi), I8(13), B(Star), R(0), - /* 46 S> */ B(LdaSmi), U8(-1), + /* 46 S> */ B(LdaSmi), I8(-1), /* 53 E> */ B(Mul), R(0), U8(2), /* 57 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden index fc7d322e60..402b9aea80 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden @@ -524,7 +524,7 @@ parameter count: 1 bytecode array length: 18 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 1494 S> */ B(LdaSmi), U8(3), + /* 1494 S> */ B(LdaSmi), I8(3), /* 1501 E> */ B(TestGreaterThan), R(2), U8(2), B(JumpIfFalse), U8(7), /* 1508 S> */ B(Wide), B(Ldar), R16(129), @@ -708,12 +708,12 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 1503 S> */ B(LdaZero), B(Star), R(0), - /* 1506 S> */ B(LdaSmi), U8(3), + /* 1506 S> */ B(LdaSmi), I8(3), /* 1515 E> */ B(Wide), B(TestEqual), R16(129), U16(2), B(JumpIfFalse), U8(10), /* 1534 S> */ B(Wide), B(Mov), R16(0), R16(129), B(Ldar), R(0), - /* 1540 S> */ B(LdaSmi), U8(3), + /* 1540 S> */ B(LdaSmi), I8(3), /* 1547 E> */ B(TestGreaterThan), R(2), U8(3), B(JumpIfFalse), U8(5), /* 1554 S> */ B(Ldar), R(0), @@ -900,7 +900,7 @@ bytecodes: [ B(Star), R(1), /* 1523 S> */ B(LdaZero), B(Wide), B(Star), R16(128), - /* 1538 S> */ B(LdaSmi), U8(64), + /* 1538 S> */ B(LdaSmi), I8(64), /* 1538 E> */ B(Wide), B(TestLessThan), R16(128), U16(2), B(JumpIfFalse), U8(31), /* 1518 E> */ B(StackCheck), @@ -911,7 +911,7 @@ bytecodes: [ /* 1548 S> */ B(Wide), B(Ldar), R16(128), B(Inc), U8(3), B(Wide), B(Star), R16(128), - B(JumpLoop), U8(-36), U8(0), + B(JumpLoop), U8(36), I8(0), /* 1567 S> */ B(Wide), B(Ldar), R16(128), /* 1580 S> */ B(Return), ] @@ -1088,7 +1088,7 @@ parameter count: 1 bytecode array length: 85 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 1503 S> */ B(Wide), B(LdaSmi), U16(1234), + /* 1503 S> */ B(Wide), B(LdaSmi), I16(1234), B(Star), R(0), /* 1518 S> */ B(LdaZero), B(Star), R(1), @@ -1111,7 +1111,7 @@ bytecodes: [ B(Star), R(1), /* 1544 E> */ B(Wide), B(ForInStep), R16(161), B(Wide), B(Star), R16(161), - B(JumpLoop), U8(-48), U8(0), + B(JumpLoop), U8(48), I8(0), /* 1553 S> */ B(Ldar), R(1), /* 1564 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/WithStatement.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/WithStatement.golden index 963c71f184..93467600ef 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/WithStatement.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/WithStatement.golden @@ -14,7 +14,7 @@ parameter count: 1 bytecode array length: 22 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1), + /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1), B(Ldar), R(1), B(ToObject), R(1), B(Ldar), R(closure), diff --git a/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc b/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc index e5dca853a5..172a3e9b8f 100644 --- a/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc +++ b/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc @@ -43,6 +43,7 @@ class ProgramOptions final { module_(false), top_level_(false), do_expressions_(false), + async_iteration_(false), verbose_(false) {} bool Validate() const; @@ -61,6 +62,7 @@ class ProgramOptions final { bool module() const { return module_; } bool top_level() const { return top_level_; } bool do_expressions() const { return do_expressions_; } + bool async_iteration() const { return async_iteration_; } bool verbose() const { return verbose_; } bool suppress_runtime_errors() const { return rebaseline_ && !verbose_; } std::vector<std::string> input_filenames() const { return input_filenames_; } @@ -77,6 +79,7 @@ class ProgramOptions final { bool module_; bool top_level_; bool do_expressions_; + bool async_iteration_; bool verbose_; std::vector<std::string> input_filenames_; std::string output_filename_; @@ -165,6 +168,8 @@ ProgramOptions ProgramOptions::FromCommandLine(int argc, char** argv) { options.top_level_ = true; } else if (strcmp(argv[i], "--do-expressions") == 0) { options.do_expressions_ = true; + } else if (strcmp(argv[i], "--async-iteration") == 0) { + options.async_iteration_ = true; } else if (strcmp(argv[i], "--verbose") == 0) { options.verbose_ = true; } else if (strncmp(argv[i], "--output=", 9) == 0) { @@ -267,6 +272,8 @@ void ProgramOptions::UpdateFromHeader(std::istream& stream) { top_level_ = ParseBoolean(line.c_str() + 11); } else if (line.compare(0, 16, "do expressions: ") == 0) { do_expressions_ = ParseBoolean(line.c_str() + 16); + } else if (line.compare(0, 17, "async iteration: ") == 0) { + async_iteration_ = ParseBoolean(line.c_str() + 17); } else if (line == "---") { break; } else if (line.empty()) { @@ -289,6 +296,7 @@ void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT if (module_) stream << "\nmodule: yes"; if (top_level_) stream << "\ntop level: yes"; if (do_expressions_) stream << "\ndo expressions: yes"; + if (async_iteration_) stream << "\nasync iteration: yes"; stream << "\n\n"; } @@ -393,6 +401,7 @@ void GenerateExpectationsFile(std::ostream& stream, // NOLINT } if (options.do_expressions()) i::FLAG_harmony_do_expressions = true; + if (options.async_iteration()) i::FLAG_harmony_async_iteration = true; stream << "#\n# Autogenerated by generate-bytecode-expectations.\n#\n\n"; options.PrintHeader(stream); @@ -401,6 +410,7 @@ void GenerateExpectationsFile(std::ostream& stream, // NOLINT } i::FLAG_harmony_do_expressions = false; + i::FLAG_harmony_async_iteration = false; } bool WriteExpectationsFile(const std::vector<std::string>& snippet_list, @@ -445,6 +455,7 @@ void PrintUsage(const char* exec_path) { "Specify the name of the test function.\n" " --top-level Process top level code, not the top-level function.\n" " --do-expressions Enable harmony_do_expressions flag.\n" + " --async-iteration Enable harmony_async_iteration flag.\n" " --output=file.name\n" " Specify the output file. If not specified, output goes to " "stdout.\n" diff --git a/deps/v8/test/cctest/interpreter/interpreter-tester.cc b/deps/v8/test/cctest/interpreter/interpreter-tester.cc index 23a1d2d45e..815c54233c 100644 --- a/deps/v8/test/cctest/interpreter/interpreter-tester.cc +++ b/deps/v8/test/cctest/interpreter/interpreter-tester.cc @@ -18,24 +18,25 @@ MaybeHandle<Object> CallInterpreter(Isolate* isolate, InterpreterTester::InterpreterTester( Isolate* isolate, const char* source, MaybeHandle<BytecodeArray> bytecode, - MaybeHandle<FeedbackVector> feedback_vector, const char* filter) + MaybeHandle<FeedbackMetadata> feedback_metadata, const char* filter) : isolate_(isolate), source_(source), bytecode_(bytecode), - feedback_vector_(feedback_vector) { + feedback_metadata_(feedback_metadata) { i::FLAG_ignition = true; i::FLAG_always_opt = false; } InterpreterTester::InterpreterTester( Isolate* isolate, Handle<BytecodeArray> bytecode, - MaybeHandle<FeedbackVector> feedback_vector, const char* filter) - : InterpreterTester(isolate, nullptr, bytecode, feedback_vector, filter) {} + MaybeHandle<FeedbackMetadata> feedback_metadata, const char* filter) + : InterpreterTester(isolate, nullptr, bytecode, feedback_metadata, filter) { +} InterpreterTester::InterpreterTester(Isolate* isolate, const char* source, const char* filter) : InterpreterTester(isolate, source, MaybeHandle<BytecodeArray>(), - MaybeHandle<FeedbackVector>(), filter) {} + MaybeHandle<FeedbackMetadata>(), filter) {} InterpreterTester::~InterpreterTester() {} diff --git a/deps/v8/test/cctest/interpreter/interpreter-tester.h b/deps/v8/test/cctest/interpreter/interpreter-tester.h index ce103fe6d1..f0a0aef6e3 100644 --- a/deps/v8/test/cctest/interpreter/interpreter-tester.h +++ b/deps/v8/test/cctest/interpreter/interpreter-tester.h @@ -4,6 +4,7 @@ #include "src/v8.h" +#include "src/api.h" #include "src/execution.h" #include "src/handles.h" #include "src/interpreter/bytecode-array-builder.h" @@ -53,12 +54,12 @@ class InterpreterTester { public: InterpreterTester(Isolate* isolate, const char* source, MaybeHandle<BytecodeArray> bytecode, - MaybeHandle<FeedbackVector> feedback_vector, + MaybeHandle<FeedbackMetadata> feedback_metadata, const char* filter); InterpreterTester(Isolate* isolate, Handle<BytecodeArray> bytecode, - MaybeHandle<FeedbackVector> feedback_vector = - MaybeHandle<FeedbackVector>(), + MaybeHandle<FeedbackMetadata> feedback_metadata = + MaybeHandle<FeedbackMetadata>(), const char* filter = kFunctionName); InterpreterTester(Isolate* isolate, const char* source, @@ -85,7 +86,7 @@ class InterpreterTester { Isolate* isolate_; const char* source_; MaybeHandle<BytecodeArray> bytecode_; - MaybeHandle<FeedbackVector> feedback_vector_; + MaybeHandle<FeedbackMetadata> feedback_metadata_; template <class... A> Handle<JSFunction> GetBytecodeFunction() { @@ -115,9 +116,11 @@ class InterpreterTester { if (!bytecode_.is_null()) { function->shared()->set_function_data(*bytecode_.ToHandleChecked()); } - if (!feedback_vector_.is_null()) { - function->literals()->set_feedback_vector( - *feedback_vector_.ToHandleChecked()); + if (!feedback_metadata_.is_null()) { + function->set_feedback_vector_cell(isolate_->heap()->undefined_cell()); + function->shared()->set_feedback_metadata( + *feedback_metadata_.ToHandleChecked()); + JSFunction::EnsureLiterals(function); } return function; } diff --git a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc index b43384e946..5ee0a6fc3c 100644 --- a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc +++ b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc @@ -2343,6 +2343,73 @@ TEST(SuperCallAndSpread) { LoadGolden("SuperCallAndSpread.golden"))); } +TEST(CallAndSpread) { + InitializedIgnitionHandleScope scope; + BytecodeExpectationsPrinter printer(CcTest::isolate()); + const char* snippets[] = {"Math.max(...[1, 2, 3]);\n", + "Math.max(0, ...[1, 2, 3]);\n", + "Math.max(0, ...[1, 2, 3], 4);\n"}; + + CHECK(CompareTexts(BuildActual(printer, snippets), + LoadGolden("CallAndSpread.golden"))); +} + +TEST(NewAndSpread) { + InitializedIgnitionHandleScope scope; + BytecodeExpectationsPrinter printer(CcTest::isolate()); + const char* snippets[] = { + "class A { constructor(...args) { this.args = args; } }\n" + "new A(...[1, 2, 3]);\n", + + "class A { constructor(...args) { this.args = args; } }\n" + "new A(0, ...[1, 2, 3]);\n", + + "class A { constructor(...args) { this.args = args; } }\n" + "new A(0, ...[1, 2, 3], 4);\n"}; + + CHECK(CompareTexts(BuildActual(printer, snippets), + LoadGolden("NewAndSpread.golden"))); +} + +TEST(ForAwaitOf) { + bool old_flag = i::FLAG_harmony_async_iteration; + i::FLAG_harmony_async_iteration = true; + InitializedIgnitionHandleScope scope; + BytecodeExpectationsPrinter printer(CcTest::isolate()); + printer.set_wrap(false); + printer.set_test_function_name("f"); + + const char* snippets[] = { + "async function f() {\n" + " for await (let x of [1, 2, 3]) {}\n" + "}\n" + "f();\n", + + "async function f() {\n" + " for await (let x of [1, 2, 3]) { return x; }\n" + "}\n" + "f();\n", + + "async function f() {\n" + " for await (let x of [10, 20, 30]) {\n" + " if (x == 10) continue;\n" + " if (x == 20) break;\n" + " }\n" + "}\n" + "f();\n", + + "async function f() {\n" + " var x = { 'a': 1, 'b': 2 };\n" + " for (x['a'] of [1,2,3]) { return x['a']; }\n" + "}\n" + "f();\n"}; + + CHECK(CompareTexts(BuildActual(printer, snippets), + LoadGolden("ForAwaitOf.golden"))); + + i::FLAG_harmony_async_iteration = old_flag; +} + } // namespace interpreter } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc b/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc index 70051253cc..cad46547b4 100644 --- a/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc +++ b/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc @@ -5,6 +5,7 @@ #include "src/v8.h" #include "src/interpreter/interpreter-intrinsics.h" +#include "src/objects-inl.h" #include "test/cctest/interpreter/interpreter-tester.h" namespace v8 { @@ -225,27 +226,6 @@ TEST(IntrinsicAsStubCall) { ->SameValue(*sub_string_helper.NewObject("'bar'"))); } -TEST(ValueOf) { - HandleAndZoneScope handles; - Isolate* isolate = handles.main_isolate(); - Factory* factory = isolate->factory(); - InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(), - Runtime::kInlineValueOf); - - CHECK_EQ(Smi::FromInt(1234), *helper.Invoke(helper.NewObject("1234"))); - CHECK_EQ(Smi::FromInt(5678), - *helper.Invoke(helper.NewObject("new Object(5678)"))); - - CHECK_EQ(*factory->true_value(), *helper.Invoke(helper.NewObject("true"))); - CHECK_EQ(*factory->false_value(), - *helper.Invoke(helper.NewObject("new Object(false)"))); - - CHECK(helper.Invoke(helper.NewObject("'foobar'")) - ->SameValue(*helper.NewObject("'foobar'"))); - CHECK(helper.Invoke(helper.NewObject("new Object('foobar')")) - ->SameValue(*helper.NewObject("'foobar'"))); -} - TEST(ClassOf) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); diff --git a/deps/v8/test/cctest/interpreter/test-interpreter.cc b/deps/v8/test/cctest/interpreter/test-interpreter.cc index 70af275c8b..ae5ab33eb6 100644 --- a/deps/v8/test/cctest/interpreter/test-interpreter.cc +++ b/deps/v8/test/cctest/interpreter/test-interpreter.cc @@ -22,16 +22,17 @@ namespace v8 { namespace internal { namespace interpreter { -static int GetIndex(FeedbackVectorSlot slot) { +static int GetIndex(FeedbackSlot slot) { return FeedbackVector::GetIndex(slot); } TEST(InterpreterReturn) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Handle<Object> undefined_value = isolate->factory()->undefined_value(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); @@ -45,9 +46,10 @@ TEST(InterpreterReturn) { TEST(InterpreterLoadUndefined) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Handle<Object> undefined_value = isolate->factory()->undefined_value(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.LoadUndefined().Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); @@ -61,9 +63,10 @@ TEST(InterpreterLoadUndefined) { TEST(InterpreterLoadNull) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Handle<Object> null_value = isolate->factory()->null_value(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.LoadNull().Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); @@ -77,9 +80,10 @@ TEST(InterpreterLoadNull) { TEST(InterpreterLoadTheHole) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Handle<Object> the_hole_value = isolate->factory()->the_hole_value(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.LoadTheHole().Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); @@ -93,9 +97,10 @@ TEST(InterpreterLoadTheHole) { TEST(InterpreterLoadTrue) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Handle<Object> true_value = isolate->factory()->true_value(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.LoadTrue().Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); @@ -109,9 +114,10 @@ TEST(InterpreterLoadTrue) { TEST(InterpreterLoadFalse) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Handle<Object> false_value = isolate->factory()->false_value(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.LoadFalse().Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); @@ -125,11 +131,11 @@ TEST(InterpreterLoadFalse) { TEST(InterpreterLoadLiteral) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Factory* factory = isolate->factory(); + Zone* zone = handles.main_zone(); // Small Smis. for (int i = -128; i < 128; i++) { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.LoadLiteral(Smi::FromInt(i)).Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); @@ -141,7 +147,7 @@ TEST(InterpreterLoadLiteral) { // Large Smis. { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.LoadLiteral(Smi::FromInt(0x12345678)).Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); @@ -154,9 +160,14 @@ TEST(InterpreterLoadLiteral) { // Heap numbers. { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); + + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); + + builder.LoadLiteral(ast_factory.NewNumber(-2.1e19)).Return(); - builder.LoadLiteral(factory->NewHeapNumber(-2.1e19)).Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); InterpreterTester tester(isolate, bytecode_array); @@ -167,16 +178,21 @@ TEST(InterpreterLoadLiteral) { // Strings. { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); - Handle<i::String> string = factory->NewStringFromAsciiChecked("String"); - builder.LoadLiteral(string).Return(); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); + + const AstRawString* raw_string = ast_factory.GetOneByteString("String"); + builder.LoadLiteral(raw_string).Return(); + + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); InterpreterTester tester(isolate, bytecode_array); auto callable = tester.GetCallable<>(); Handle<Object> return_val = callable().ToHandleChecked(); - CHECK(i::String::cast(*return_val)->Equals(*string)); + CHECK(i::String::cast(*return_val)->Equals(*raw_string->string())); } } @@ -184,9 +200,10 @@ TEST(InterpreterLoadLiteral) { TEST(InterpreterLoadStoreRegisters) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Handle<Object> true_value = isolate->factory()->true_value(); for (int i = 0; i <= kMaxInt8; i++) { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, i + 1); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, i + 1); Register reg(i); builder.LoadTrue() @@ -269,14 +286,14 @@ TEST(InterpreterShiftOpsSmi) { for (size_t o = 0; o < arraysize(kShiftOperators); o++) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 1); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); Register reg(0); int lhs = lhs_inputs[l]; @@ -288,7 +305,7 @@ TEST(InterpreterShiftOpsSmi) { .Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); Handle<Object> expected_value = @@ -308,14 +325,14 @@ TEST(InterpreterBinaryOpsSmi) { for (size_t o = 0; o < arraysize(kArithmeticOperators); o++) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 1); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); Register reg(0); int lhs = lhs_inputs[l]; @@ -323,12 +340,11 @@ TEST(InterpreterBinaryOpsSmi) { builder.LoadLiteral(Smi::FromInt(lhs)) .StoreAccumulatorInRegister(reg) .LoadLiteral(Smi::FromInt(rhs)) - .BinaryOperation(kArithmeticOperators[o], reg, - GetIndex(slot)) + .BinaryOperation(kArithmeticOperators[o], reg, GetIndex(slot)) .Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); Handle<Object> expected_value = @@ -349,26 +365,29 @@ TEST(InterpreterBinaryOpsHeapNumber) { for (size_t o = 0; o < arraysize(kArithmeticOperators); o++) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 1); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); Register reg(0); double lhs = lhs_inputs[l]; double rhs = rhs_inputs[r]; - builder.LoadLiteral(factory->NewNumber(lhs)) + builder.LoadLiteral(ast_factory.NewNumber(lhs)) .StoreAccumulatorInRegister(reg) - .LoadLiteral(factory->NewNumber(rhs)) + .LoadLiteral(ast_factory.NewNumber(rhs)) .BinaryOperation(kArithmeticOperators[o], reg, GetIndex(slot)) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); Handle<Object> expected_value = @@ -383,51 +402,53 @@ TEST(InterpreterBinaryOpsHeapNumber) { TEST(InterpreterStringAdd) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); struct TestCase { - Handle<Object> lhs; - Handle<Object> rhs; + const AstRawString* lhs; + const AstValue* rhs; Handle<Object> expected_value; int32_t expected_feedback; } test_cases[] = { - {factory->NewStringFromStaticChars("a"), - factory->NewStringFromStaticChars("b"), + {ast_factory.GetOneByteString("a"), + ast_factory.NewString(ast_factory.GetOneByteString("b")), factory->NewStringFromStaticChars("ab"), BinaryOperationFeedback::kString}, - {factory->NewStringFromStaticChars("aaaaaa"), - factory->NewStringFromStaticChars("b"), + {ast_factory.GetOneByteString("aaaaaa"), + ast_factory.NewString(ast_factory.GetOneByteString("b")), factory->NewStringFromStaticChars("aaaaaab"), BinaryOperationFeedback::kString}, - {factory->NewStringFromStaticChars("aaa"), - factory->NewStringFromStaticChars("bbbbb"), + {ast_factory.GetOneByteString("aaa"), + ast_factory.NewString(ast_factory.GetOneByteString("bbbbb")), factory->NewStringFromStaticChars("aaabbbbb"), BinaryOperationFeedback::kString}, - {factory->NewStringFromStaticChars(""), - factory->NewStringFromStaticChars("b"), + {ast_factory.GetOneByteString(""), + ast_factory.NewString(ast_factory.GetOneByteString("b")), factory->NewStringFromStaticChars("b"), BinaryOperationFeedback::kString}, - {factory->NewStringFromStaticChars("a"), - factory->NewStringFromStaticChars(""), + {ast_factory.GetOneByteString("a"), + ast_factory.NewString(ast_factory.GetOneByteString("")), factory->NewStringFromStaticChars("a"), BinaryOperationFeedback::kString}, - {factory->NewStringFromStaticChars("1.11"), factory->NewHeapNumber(2.5), + {ast_factory.GetOneByteString("1.11"), ast_factory.NewNumber(2.5), factory->NewStringFromStaticChars("1.112.5"), BinaryOperationFeedback::kAny}, - {factory->NewStringFromStaticChars("-1.11"), factory->NewHeapNumber(2.56), + {ast_factory.GetOneByteString("-1.11"), ast_factory.NewNumber(2.56), factory->NewStringFromStaticChars("-1.112.56"), BinaryOperationFeedback::kAny}, - {factory->NewStringFromStaticChars(""), factory->NewHeapNumber(2.5), + {ast_factory.GetOneByteString(""), ast_factory.NewNumber(2.5), factory->NewStringFromStaticChars("2.5"), BinaryOperationFeedback::kAny}, }; for (size_t i = 0; i < arraysize(test_cases); i++) { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 1); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); Register reg(0); builder.LoadLiteral(test_cases[i].lhs) @@ -435,14 +456,15 @@ TEST(InterpreterStringAdd) { .LoadLiteral(test_cases[i].rhs) .BinaryOperation(Token::Value::ADD, reg, GetIndex(slot)) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->SameValue(*test_cases[i].expected_value)); - Object* feedback = vector->Get(slot); + Object* feedback = callable.vector()->Get(slot); CHECK(feedback->IsSmi()); CHECK_EQ(test_cases[i].expected_feedback, static_cast<Smi*>(feedback)->value()); @@ -453,7 +475,8 @@ TEST(InterpreterStringAdd) { TEST(InterpreterParameter1) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + Zone* zone = handles.main_zone(); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.LoadAccumulatorWithRegister(builder.Parameter(0)).Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); @@ -476,20 +499,22 @@ TEST(InterpreterParameter1) { TEST(InterpreterParameter8) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Zone zone(isolate->allocator(), ZONE_NAME); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 8, 0, 0); - - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot4 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot5 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot6 = feedback_spec.AddInterpreterBinaryOpICSlot(); - - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); + BytecodeArrayBuilder builder(isolate, zone, 8, 0, 0); + + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot4 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot5 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot6 = feedback_spec.AddInterpreterBinaryOpICSlot(); + + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); builder.LoadAccumulatorWithRegister(builder.Parameter(0)) .BinaryOperation(Token::Value::ADD, builder.Parameter(1), GetIndex(slot)) @@ -500,9 +525,10 @@ TEST(InterpreterParameter8) { .BinaryOperation(Token::Value::ADD, builder.Parameter(6), GetIndex(slot5)) .BinaryOperation(Token::Value::ADD, builder.Parameter(7), GetIndex(slot6)) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); typedef Handle<Object> H; auto callable = tester.GetCallable<H, H, H, H, H, H, H, H>(); @@ -524,132 +550,122 @@ TEST(InterpreterParameter8) { TEST(InterpreterBinaryOpTypeFeedback) { HandleAndZoneScope handles; i::Isolate* isolate = handles.main_isolate(); - i::Zone zone(isolate->allocator(), ZONE_NAME); + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); struct BinaryOpExpectation { Token::Value op; - Handle<Object> arg1; - Handle<Object> arg2; + const AstValue* arg1; + const AstValue* arg2; Handle<Object> result; int32_t feedback; }; BinaryOpExpectation const kTestCases[] = { // ADD - {Token::Value::ADD, Handle<Smi>(Smi::FromInt(2), isolate), - Handle<Smi>(Smi::FromInt(3), isolate), + {Token::Value::ADD, ast_factory.NewSmi(2), ast_factory.NewSmi(3), Handle<Smi>(Smi::FromInt(5), isolate), BinaryOperationFeedback::kSignedSmall}, - {Token::Value::ADD, Handle<Smi>(Smi::FromInt(Smi::kMaxValue), isolate), - Handle<Smi>(Smi::FromInt(1), isolate), + {Token::Value::ADD, ast_factory.NewSmi(Smi::kMaxValue), + ast_factory.NewSmi(1), isolate->factory()->NewHeapNumber(Smi::kMaxValue + 1.0), BinaryOperationFeedback::kNumber}, - {Token::Value::ADD, isolate->factory()->NewHeapNumber(3.1415), - Handle<Smi>(Smi::FromInt(3), isolate), + {Token::Value::ADD, ast_factory.NewNumber(3.1415), ast_factory.NewSmi(3), isolate->factory()->NewHeapNumber(3.1415 + 3), BinaryOperationFeedback::kNumber}, - {Token::Value::ADD, isolate->factory()->NewHeapNumber(3.1415), - isolate->factory()->NewHeapNumber(1.4142), + {Token::Value::ADD, ast_factory.NewNumber(3.1415), + ast_factory.NewNumber(1.4142), isolate->factory()->NewHeapNumber(3.1415 + 1.4142), BinaryOperationFeedback::kNumber}, - {Token::Value::ADD, isolate->factory()->NewStringFromAsciiChecked("foo"), - isolate->factory()->NewStringFromAsciiChecked("bar"), + {Token::Value::ADD, + ast_factory.NewString(ast_factory.GetOneByteString("foo")), + ast_factory.NewString(ast_factory.GetOneByteString("bar")), isolate->factory()->NewStringFromAsciiChecked("foobar"), BinaryOperationFeedback::kString}, - {Token::Value::ADD, Handle<Smi>(Smi::FromInt(2), isolate), - isolate->factory()->NewStringFromAsciiChecked("2"), + {Token::Value::ADD, ast_factory.NewSmi(2), + ast_factory.NewString(ast_factory.GetOneByteString("2")), isolate->factory()->NewStringFromAsciiChecked("22"), BinaryOperationFeedback::kAny}, // SUB - {Token::Value::SUB, Handle<Smi>(Smi::FromInt(2), isolate), - Handle<Smi>(Smi::FromInt(3), isolate), + {Token::Value::SUB, ast_factory.NewSmi(2), ast_factory.NewSmi(3), Handle<Smi>(Smi::FromInt(-1), isolate), BinaryOperationFeedback::kSignedSmall}, - {Token::Value::SUB, Handle<Smi>(Smi::FromInt(Smi::kMinValue), isolate), - Handle<Smi>(Smi::FromInt(1), isolate), + {Token::Value::SUB, ast_factory.NewSmi(Smi::kMinValue), + ast_factory.NewSmi(1), isolate->factory()->NewHeapNumber(Smi::kMinValue - 1.0), BinaryOperationFeedback::kNumber}, - {Token::Value::SUB, isolate->factory()->NewHeapNumber(3.1415), - Handle<Smi>(Smi::FromInt(3), isolate), + {Token::Value::SUB, ast_factory.NewNumber(3.1415), ast_factory.NewSmi(3), isolate->factory()->NewHeapNumber(3.1415 - 3), BinaryOperationFeedback::kNumber}, - {Token::Value::SUB, isolate->factory()->NewHeapNumber(3.1415), - isolate->factory()->NewHeapNumber(1.4142), + {Token::Value::SUB, ast_factory.NewNumber(3.1415), + ast_factory.NewNumber(1.4142), isolate->factory()->NewHeapNumber(3.1415 - 1.4142), BinaryOperationFeedback::kNumber}, - {Token::Value::SUB, Handle<Smi>(Smi::FromInt(2), isolate), - isolate->factory()->NewStringFromAsciiChecked("1"), + {Token::Value::SUB, ast_factory.NewSmi(2), + ast_factory.NewString(ast_factory.GetOneByteString("1")), Handle<Smi>(Smi::FromInt(1), isolate), BinaryOperationFeedback::kAny}, // MUL - {Token::Value::MUL, Handle<Smi>(Smi::FromInt(2), isolate), - Handle<Smi>(Smi::FromInt(3), isolate), + {Token::Value::MUL, ast_factory.NewSmi(2), ast_factory.NewSmi(3), Handle<Smi>(Smi::FromInt(6), isolate), BinaryOperationFeedback::kSignedSmall}, - {Token::Value::MUL, Handle<Smi>(Smi::FromInt(Smi::kMinValue), isolate), - Handle<Smi>(Smi::FromInt(2), isolate), + {Token::Value::MUL, ast_factory.NewSmi(Smi::kMinValue), + ast_factory.NewSmi(2), isolate->factory()->NewHeapNumber(Smi::kMinValue * 2.0), BinaryOperationFeedback::kNumber}, - {Token::Value::MUL, isolate->factory()->NewHeapNumber(3.1415), - Handle<Smi>(Smi::FromInt(3), isolate), + {Token::Value::MUL, ast_factory.NewNumber(3.1415), ast_factory.NewSmi(3), isolate->factory()->NewHeapNumber(3 * 3.1415), BinaryOperationFeedback::kNumber}, - {Token::Value::MUL, isolate->factory()->NewHeapNumber(3.1415), - isolate->factory()->NewHeapNumber(1.4142), + {Token::Value::MUL, ast_factory.NewNumber(3.1415), + ast_factory.NewNumber(1.4142), isolate->factory()->NewHeapNumber(3.1415 * 1.4142), BinaryOperationFeedback::kNumber}, - {Token::Value::MUL, Handle<Smi>(Smi::FromInt(2), isolate), - isolate->factory()->NewStringFromAsciiChecked("1"), + {Token::Value::MUL, ast_factory.NewSmi(2), + ast_factory.NewString(ast_factory.GetOneByteString("1")), Handle<Smi>(Smi::FromInt(2), isolate), BinaryOperationFeedback::kAny}, // DIV - {Token::Value::DIV, Handle<Smi>(Smi::FromInt(6), isolate), - Handle<Smi>(Smi::FromInt(3), isolate), + {Token::Value::DIV, ast_factory.NewSmi(6), ast_factory.NewSmi(3), Handle<Smi>(Smi::FromInt(2), isolate), BinaryOperationFeedback::kSignedSmall}, - {Token::Value::DIV, Handle<Smi>(Smi::FromInt(3), isolate), - Handle<Smi>(Smi::FromInt(2), isolate), + {Token::Value::DIV, ast_factory.NewSmi(3), ast_factory.NewSmi(2), isolate->factory()->NewHeapNumber(3.0 / 2.0), BinaryOperationFeedback::kNumber}, - {Token::Value::DIV, isolate->factory()->NewHeapNumber(3.1415), - Handle<Smi>(Smi::FromInt(3), isolate), + {Token::Value::DIV, ast_factory.NewNumber(3.1415), ast_factory.NewSmi(3), isolate->factory()->NewHeapNumber(3.1415 / 3), BinaryOperationFeedback::kNumber}, - {Token::Value::DIV, isolate->factory()->NewHeapNumber(3.1415), - isolate->factory()->NewHeapNumber( - -std::numeric_limits<double>::infinity()), + {Token::Value::DIV, ast_factory.NewNumber(3.1415), + ast_factory.NewNumber(-std::numeric_limits<double>::infinity()), isolate->factory()->NewHeapNumber(-0.0), BinaryOperationFeedback::kNumber}, - {Token::Value::DIV, Handle<Smi>(Smi::FromInt(2), isolate), - isolate->factory()->NewStringFromAsciiChecked("1"), + {Token::Value::DIV, ast_factory.NewSmi(2), + ast_factory.NewString(ast_factory.GetOneByteString("1")), Handle<Smi>(Smi::FromInt(2), isolate), BinaryOperationFeedback::kAny}, // MOD - {Token::Value::MOD, Handle<Smi>(Smi::FromInt(5), isolate), - Handle<Smi>(Smi::FromInt(3), isolate), + {Token::Value::MOD, ast_factory.NewSmi(5), ast_factory.NewSmi(3), Handle<Smi>(Smi::FromInt(2), isolate), BinaryOperationFeedback::kSignedSmall}, - {Token::Value::MOD, Handle<Smi>(Smi::FromInt(-4), isolate), - Handle<Smi>(Smi::FromInt(2), isolate), + {Token::Value::MOD, ast_factory.NewSmi(-4), ast_factory.NewSmi(2), isolate->factory()->NewHeapNumber(-0.0), BinaryOperationFeedback::kNumber}, - {Token::Value::MOD, isolate->factory()->NewHeapNumber(3.1415), - Handle<Smi>(Smi::FromInt(3), isolate), + {Token::Value::MOD, ast_factory.NewNumber(3.1415), ast_factory.NewSmi(3), isolate->factory()->NewHeapNumber(fmod(3.1415, 3.0)), BinaryOperationFeedback::kNumber}, - {Token::Value::MOD, isolate->factory()->NewHeapNumber(-3.1415), - isolate->factory()->NewHeapNumber(-1.4142), + {Token::Value::MOD, ast_factory.NewNumber(-3.1415), + ast_factory.NewNumber(-1.4142), isolate->factory()->NewHeapNumber(fmod(-3.1415, -1.4142)), BinaryOperationFeedback::kNumber}, - {Token::Value::MOD, Handle<Smi>(Smi::FromInt(3), isolate), - isolate->factory()->NewStringFromAsciiChecked("-2"), + {Token::Value::MOD, ast_factory.NewSmi(3), + ast_factory.NewString(ast_factory.GetOneByteString("-2")), Handle<Smi>(Smi::FromInt(1), isolate), BinaryOperationFeedback::kAny}}; for (const BinaryOpExpectation& test_case : kTestCases) { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 1); - i::FeedbackVectorSpec feedback_spec(&zone); - i::FeedbackVectorSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot(); + i::FeedbackVectorSpec feedback_spec(zone); + i::FeedbackSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - i::NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + i::NewFeedbackMetadata(isolate, &feedback_spec); Register reg(0); builder.LoadLiteral(test_case.arg1) @@ -658,13 +674,14 @@ TEST(InterpreterBinaryOpTypeFeedback) { .BinaryOperation(test_case.op, reg, GetIndex(slot0)) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_val = callable().ToHandleChecked(); - Object* feedback0 = vector->Get(slot0); + Object* feedback0 = callable.vector()->Get(slot0); CHECK(feedback0->IsSmi()); CHECK_EQ(test_case.feedback, static_cast<Smi*>(feedback0)->value()); CHECK(Object::Equals(test_case.result, return_val).ToChecked()); @@ -674,11 +691,13 @@ TEST(InterpreterBinaryOpTypeFeedback) { TEST(InterpreterBinaryOpSmiTypeFeedback) { HandleAndZoneScope handles; i::Isolate* isolate = handles.main_isolate(); - i::Zone zone(isolate->allocator(), ZONE_NAME); + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); struct BinaryOpExpectation { Token::Value op; - Handle<Object> arg1; + const AstValue* arg1; int32_t arg2; Handle<Object> result; int32_t feedback; @@ -686,74 +705,79 @@ TEST(InterpreterBinaryOpSmiTypeFeedback) { BinaryOpExpectation const kTestCases[] = { // ADD - {Token::Value::ADD, Handle<Smi>(Smi::FromInt(2), isolate), 42, + {Token::Value::ADD, ast_factory.NewSmi(2), 42, Handle<Smi>(Smi::FromInt(44), isolate), BinaryOperationFeedback::kSignedSmall}, - {Token::Value::ADD, Handle<Smi>(Smi::FromInt(2), isolate), Smi::kMaxValue, + {Token::Value::ADD, ast_factory.NewSmi(2), Smi::kMaxValue, isolate->factory()->NewHeapNumber(Smi::kMaxValue + 2.0), BinaryOperationFeedback::kNumber}, - {Token::Value::ADD, isolate->factory()->NewHeapNumber(3.1415), 2, + {Token::Value::ADD, ast_factory.NewNumber(3.1415), 2, isolate->factory()->NewHeapNumber(3.1415 + 2.0), BinaryOperationFeedback::kNumber}, - {Token::Value::ADD, isolate->factory()->NewStringFromAsciiChecked("2"), 2, + {Token::Value::ADD, + ast_factory.NewString(ast_factory.GetOneByteString("2")), 2, isolate->factory()->NewStringFromAsciiChecked("22"), BinaryOperationFeedback::kAny}, // SUB - {Token::Value::SUB, Handle<Smi>(Smi::FromInt(2), isolate), 42, + {Token::Value::SUB, ast_factory.NewSmi(2), 42, Handle<Smi>(Smi::FromInt(-40), isolate), BinaryOperationFeedback::kSignedSmall}, - {Token::Value::SUB, Handle<Smi>(Smi::FromInt(Smi::kMinValue), isolate), 1, + {Token::Value::SUB, ast_factory.NewSmi(Smi::kMinValue), 1, isolate->factory()->NewHeapNumber(Smi::kMinValue - 1.0), BinaryOperationFeedback::kNumber}, - {Token::Value::SUB, isolate->factory()->NewHeapNumber(3.1415), 2, + {Token::Value::SUB, ast_factory.NewNumber(3.1415), 2, isolate->factory()->NewHeapNumber(3.1415 - 2.0), BinaryOperationFeedback::kNumber}, - {Token::Value::SUB, isolate->factory()->NewStringFromAsciiChecked("2"), 2, + {Token::Value::SUB, + ast_factory.NewString(ast_factory.GetOneByteString("2")), 2, Handle<Smi>(Smi::kZero, isolate), BinaryOperationFeedback::kAny}, // BIT_OR - {Token::Value::BIT_OR, Handle<Smi>(Smi::FromInt(4), isolate), 1, + {Token::Value::BIT_OR, ast_factory.NewSmi(4), 1, Handle<Smi>(Smi::FromInt(5), isolate), BinaryOperationFeedback::kSignedSmall}, - {Token::Value::BIT_OR, isolate->factory()->NewHeapNumber(3.1415), 8, + {Token::Value::BIT_OR, ast_factory.NewNumber(3.1415), 8, Handle<Smi>(Smi::FromInt(11), isolate), BinaryOperationFeedback::kNumber}, - {Token::Value::BIT_OR, isolate->factory()->NewStringFromAsciiChecked("2"), - 1, Handle<Smi>(Smi::FromInt(3), isolate), BinaryOperationFeedback::kAny}, + {Token::Value::BIT_OR, + ast_factory.NewString(ast_factory.GetOneByteString("2")), 1, + Handle<Smi>(Smi::FromInt(3), isolate), BinaryOperationFeedback::kAny}, // BIT_AND - {Token::Value::BIT_AND, Handle<Smi>(Smi::FromInt(3), isolate), 1, + {Token::Value::BIT_AND, ast_factory.NewSmi(3), 1, Handle<Smi>(Smi::FromInt(1), isolate), BinaryOperationFeedback::kSignedSmall}, - {Token::Value::BIT_AND, isolate->factory()->NewHeapNumber(3.1415), 2, + {Token::Value::BIT_AND, ast_factory.NewNumber(3.1415), 2, Handle<Smi>(Smi::FromInt(2), isolate), BinaryOperationFeedback::kNumber}, {Token::Value::BIT_AND, - isolate->factory()->NewStringFromAsciiChecked("2"), 1, + ast_factory.NewString(ast_factory.GetOneByteString("2")), 1, Handle<Smi>(Smi::kZero, isolate), BinaryOperationFeedback::kAny}, // SHL - {Token::Value::SHL, Handle<Smi>(Smi::FromInt(3), isolate), 1, + {Token::Value::SHL, ast_factory.NewSmi(3), 1, Handle<Smi>(Smi::FromInt(6), isolate), BinaryOperationFeedback::kSignedSmall}, - {Token::Value::SHL, isolate->factory()->NewHeapNumber(3.1415), 2, + {Token::Value::SHL, ast_factory.NewNumber(3.1415), 2, Handle<Smi>(Smi::FromInt(12), isolate), BinaryOperationFeedback::kNumber}, - {Token::Value::SHL, isolate->factory()->NewStringFromAsciiChecked("2"), 1, + {Token::Value::SHL, + ast_factory.NewString(ast_factory.GetOneByteString("2")), 1, Handle<Smi>(Smi::FromInt(4), isolate), BinaryOperationFeedback::kAny}, // SAR - {Token::Value::SAR, Handle<Smi>(Smi::FromInt(3), isolate), 1, + {Token::Value::SAR, ast_factory.NewSmi(3), 1, Handle<Smi>(Smi::FromInt(1), isolate), BinaryOperationFeedback::kSignedSmall}, - {Token::Value::SAR, isolate->factory()->NewHeapNumber(3.1415), 2, + {Token::Value::SAR, ast_factory.NewNumber(3.1415), 2, Handle<Smi>(Smi::kZero, isolate), BinaryOperationFeedback::kNumber}, - {Token::Value::SAR, isolate->factory()->NewStringFromAsciiChecked("2"), 1, + {Token::Value::SAR, + ast_factory.NewString(ast_factory.GetOneByteString("2")), 1, Handle<Smi>(Smi::FromInt(1), isolate), BinaryOperationFeedback::kAny}}; for (const BinaryOpExpectation& test_case : kTestCases) { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 1); - i::FeedbackVectorSpec feedback_spec(&zone); - i::FeedbackVectorSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot(); + i::FeedbackVectorSpec feedback_spec(zone); + i::FeedbackSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - i::NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + i::NewFeedbackMetadata(isolate, &feedback_spec); Register reg(0); builder.LoadLiteral(test_case.arg1) @@ -762,13 +786,14 @@ TEST(InterpreterBinaryOpSmiTypeFeedback) { .BinaryOperation(test_case.op, reg, GetIndex(slot0)) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_val = callable().ToHandleChecked(); - Object* feedback0 = vector->Get(slot0); + Object* feedback0 = callable.vector()->Get(slot0); CHECK(feedback0->IsSmi()); CHECK_EQ(test_case.feedback, static_cast<Smi*>(feedback0)->value()); CHECK(Object::Equals(test_case.result, return_val).ToChecked()); @@ -778,7 +803,7 @@ TEST(InterpreterBinaryOpSmiTypeFeedback) { TEST(InterpreterUnaryOpFeedback) { HandleAndZoneScope handles; i::Isolate* isolate = handles.main_isolate(); - i::Zone zone(isolate->allocator(), ZONE_NAME); + Zone* zone = handles.main_zone(); Handle<Smi> smi_one = Handle<Smi>(Smi::FromInt(1), isolate); Handle<Smi> smi_max = Handle<Smi>(Smi::FromInt(Smi::kMaxValue), isolate); @@ -797,16 +822,16 @@ TEST(InterpreterUnaryOpFeedback) { {Token::Value::ADD, smi_one, smi_max, number, str}, {Token::Value::SUB, smi_one, smi_min, number, str}}; for (TestCase const& test_case : kTestCases) { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 4, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 4, 0, 0); - i::FeedbackVectorSpec feedback_spec(&zone); - i::FeedbackVectorSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot(); - i::FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); - i::FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); - i::FeedbackVectorSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot(); + i::FeedbackVectorSpec feedback_spec(zone); + i::FeedbackSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot(); + i::FeedbackSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); + i::FeedbackSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); + i::FeedbackSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - i::NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + i::NewFeedbackMetadata(isolate, &feedback_spec); builder.LoadAccumulatorWithRegister(builder.Parameter(0)) .CountOperation(test_case.op, GetIndex(slot0)) @@ -820,7 +845,7 @@ TEST(InterpreterUnaryOpFeedback) { Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); typedef Handle<Object> H; auto callable = tester.GetCallable<H, H, H, H>(); @@ -830,22 +855,22 @@ TEST(InterpreterUnaryOpFeedback) { test_case.number_feedback_value, test_case.any_feedback_value) .ToHandleChecked(); USE(return_val); - Object* feedback0 = vector->Get(slot0); + Object* feedback0 = callable.vector()->Get(slot0); CHECK(feedback0->IsSmi()); CHECK_EQ(BinaryOperationFeedback::kSignedSmall, static_cast<Smi*>(feedback0)->value()); - Object* feedback1 = vector->Get(slot1); + Object* feedback1 = callable.vector()->Get(slot1); CHECK(feedback1->IsSmi()); CHECK_EQ(BinaryOperationFeedback::kNumber, static_cast<Smi*>(feedback1)->value()); - Object* feedback2 = vector->Get(slot2); + Object* feedback2 = callable.vector()->Get(slot2); CHECK(feedback2->IsSmi()); CHECK_EQ(BinaryOperationFeedback::kNumber, static_cast<Smi*>(feedback2)->value()); - Object* feedback3 = vector->Get(slot3); + Object* feedback3 = callable.vector()->Get(slot3); CHECK(feedback3->IsSmi()); CHECK_EQ(BinaryOperationFeedback::kAny, static_cast<Smi*>(feedback3)->value()); @@ -855,21 +880,21 @@ TEST(InterpreterUnaryOpFeedback) { TEST(InterpreterBitwiseTypeFeedback) { HandleAndZoneScope handles; i::Isolate* isolate = handles.main_isolate(); - i::Zone zone(isolate->allocator(), ZONE_NAME); + Zone* zone = handles.main_zone(); const Token::Value kBitwiseBinaryOperators[] = { Token::Value::BIT_OR, Token::Value::BIT_XOR, Token::Value::BIT_AND, Token::Value::SHL, Token::Value::SHR, Token::Value::SAR}; for (Token::Value op : kBitwiseBinaryOperators) { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 4, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 4, 0, 0); - i::FeedbackVectorSpec feedback_spec(&zone); - i::FeedbackVectorSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot(); - i::FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); - i::FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); + i::FeedbackVectorSpec feedback_spec(zone); + i::FeedbackSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot(); + i::FeedbackSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); + i::FeedbackSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - i::NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + i::NewFeedbackMetadata(isolate, &feedback_spec); builder.LoadAccumulatorWithRegister(builder.Parameter(0)) .BinaryOperation(op, builder.Parameter(1), GetIndex(slot0)) @@ -879,7 +904,7 @@ TEST(InterpreterBitwiseTypeFeedback) { Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); typedef Handle<Object> H; auto callable = tester.GetCallable<H, H, H, H>(); @@ -891,17 +916,17 @@ TEST(InterpreterBitwiseTypeFeedback) { Handle<Object> return_val = callable(arg1, arg2, arg3, arg4).ToHandleChecked(); USE(return_val); - Object* feedback0 = vector->Get(slot0); + Object* feedback0 = callable.vector()->Get(slot0); CHECK(feedback0->IsSmi()); CHECK_EQ(BinaryOperationFeedback::kSignedSmall, static_cast<Smi*>(feedback0)->value()); - Object* feedback1 = vector->Get(slot1); + Object* feedback1 = callable.vector()->Get(slot1); CHECK(feedback1->IsSmi()); CHECK_EQ(BinaryOperationFeedback::kNumber, static_cast<Smi*>(feedback1)->value()); - Object* feedback2 = vector->Get(slot2); + Object* feedback2 = callable.vector()->Get(slot2); CHECK(feedback2->IsSmi()); CHECK_EQ(BinaryOperationFeedback::kAny, static_cast<Smi*>(feedback2)->value()); @@ -911,7 +936,8 @@ TEST(InterpreterBitwiseTypeFeedback) { TEST(InterpreterParameter1Assign) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + Zone* zone = handles.main_zone(); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.LoadLiteral(Smi::FromInt(5)) .StoreAccumulatorInRegister(builder.Parameter(0)) @@ -1030,25 +1056,26 @@ TEST(InterpreterStoreUnallocated) { TEST(InterpreterLoadNamedProperty) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot(); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddLoadICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); - Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); - name = factory->string_table()->LookupString(isolate, name); + const AstRawString* name = ast_factory.GetOneByteString("val"); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.LoadNamedProperty(builder.Parameter(0), name, GetIndex(slot)) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); @@ -1083,26 +1110,27 @@ TEST(InterpreterLoadNamedProperty) { TEST(InterpreterLoadKeyedProperty) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot(); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddKeyedLoadICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); - Handle<i::String> key = factory->NewStringFromAsciiChecked("key"); - key = factory->string_table()->LookupString(isolate, key); + const AstRawString* key = ast_factory.GetOneByteString("key"); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 1); builder.LoadLiteral(key) .LoadKeyedProperty(builder.Parameter(0), GetIndex(slot)) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> object = InterpreterTester::NewObject("({ key : 123 })"); @@ -1125,44 +1153,48 @@ TEST(InterpreterLoadKeyedProperty) { TEST(InterpreterStoreNamedProperty) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddStoreICSlot(); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddStoreICSlot(SLOPPY); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); - Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); - name = factory->string_table()->LookupString(isolate, name); + const AstRawString* name = ast_factory.GetOneByteString("val"); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 0); builder.LoadLiteral(Smi::FromInt(999)) .StoreNamedProperty(builder.Parameter(0), name, GetIndex(slot), STRICT) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); // Test IC miss. Handle<Object> result; callable(object).ToHandleChecked(); - CHECK(Runtime::GetObjectProperty(isolate, object, name).ToHandle(&result)); + CHECK(Runtime::GetObjectProperty(isolate, object, name->string()) + .ToHandle(&result)); CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); // Test transition to monomorphic IC. callable(object).ToHandleChecked(); - CHECK(Runtime::GetObjectProperty(isolate, object, name).ToHandle(&result)); + CHECK(Runtime::GetObjectProperty(isolate, object, name->string()) + .ToHandle(&result)); CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); // Test transition to polymorphic IC. Handle<Object> object2 = InterpreterTester::NewObject("({ val : 456, other : 123 })"); callable(object2).ToHandleChecked(); - CHECK(Runtime::GetObjectProperty(isolate, object2, name).ToHandle(&result)); + CHECK(Runtime::GetObjectProperty(isolate, object2, name->string()) + .ToHandle(&result)); CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); // Test transition to megamorphic IC. @@ -1175,7 +1207,8 @@ TEST(InterpreterStoreNamedProperty) { Handle<Object> object5 = InterpreterTester::NewObject("({ val : 789, val4 : 123 })"); callable(object5).ToHandleChecked(); - CHECK(Runtime::GetObjectProperty(isolate, object5, name).ToHandle(&result)); + CHECK(Runtime::GetObjectProperty(isolate, object5, name->string()) + .ToHandle(&result)); CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); } @@ -1183,19 +1216,19 @@ TEST(InterpreterStoreNamedProperty) { TEST(InterpreterStoreKeyedProperty) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddKeyedStoreICSlot(); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddKeyedStoreICSlot(SLOPPY); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); - Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); - name = factory->string_table()->LookupString(isolate, name); + const AstRawString* name = ast_factory.GetOneByteString("val"); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 1); builder.LoadLiteral(name) .StoreAccumulatorInRegister(Register(0)) @@ -1203,52 +1236,57 @@ TEST(InterpreterStoreKeyedProperty) { .StoreKeyedProperty(builder.Parameter(0), Register(0), GetIndex(slot), i::SLOPPY) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); // Test IC miss. Handle<Object> result; callable(object).ToHandleChecked(); - CHECK(Runtime::GetObjectProperty(isolate, object, name).ToHandle(&result)); + CHECK(Runtime::GetObjectProperty(isolate, object, name->string()) + .ToHandle(&result)); CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); // Test transition to monomorphic IC. callable(object).ToHandleChecked(); - CHECK(Runtime::GetObjectProperty(isolate, object, name).ToHandle(&result)); + CHECK(Runtime::GetObjectProperty(isolate, object, name->string()) + .ToHandle(&result)); CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); // Test transition to megamorphic IC. Handle<Object> object2 = InterpreterTester::NewObject("({ val : 456, other : 123 })"); callable(object2).ToHandleChecked(); - CHECK(Runtime::GetObjectProperty(isolate, object2, name).ToHandle(&result)); + CHECK(Runtime::GetObjectProperty(isolate, object2, name->string()) + .ToHandle(&result)); CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); } static void TestInterpreterCall(TailCallMode tail_call_mode) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot(); - FeedbackVectorSlot call_slot = feedback_spec.AddCallICSlot(); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddLoadICSlot(); + FeedbackSlot call_slot = feedback_spec.AddCallICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); int slot_index = GetIndex(slot); int call_slot_index = -1; call_slot_index = GetIndex(call_slot); - Handle<i::String> name = factory->NewStringFromAsciiChecked("func"); - name = factory->string_table()->LookupString(isolate, name); + const AstRawString* name = ast_factory.GetOneByteString("func"); // Check with no args. { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 1); Register reg = builder.register_allocator()->NewRegister(); RegisterList args = builder.register_allocator()->NewRegisterList(1); builder.LoadNamedProperty(builder.Parameter(0), name, slot_index) @@ -1258,9 +1296,10 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) { builder.Call(reg, args, call_slot_index, Call::GLOBAL_CALL, tail_call_mode); builder.Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> object = InterpreterTester::NewObject( @@ -1271,7 +1310,7 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) { // Check that receiver is passed properly. { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 1); Register reg = builder.register_allocator()->NewRegister(); RegisterList args = builder.register_allocator()->NewRegisterList(1); builder.LoadNamedProperty(builder.Parameter(0), name, slot_index) @@ -1279,9 +1318,10 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) { .MoveRegister(builder.Parameter(0), args[0]); builder.Call(reg, args, call_slot_index, Call::GLOBAL_CALL, tail_call_mode); builder.Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> object = InterpreterTester::NewObject( @@ -1295,7 +1335,7 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) { // Check with two parameters (+ receiver). { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 4); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 4); Register reg = builder.register_allocator()->NewRegister(); RegisterList args = builder.register_allocator()->NewRegisterList(3); @@ -1312,9 +1352,10 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) { builder.Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> object = InterpreterTester::NewObject( @@ -1327,7 +1368,7 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) { // Check with 10 parameters (+ receiver). { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 12); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 12); Register reg = builder.register_allocator()->NewRegister(); RegisterList args = builder.register_allocator()->NewRegisterList(11); @@ -1335,34 +1376,35 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) { .StoreAccumulatorInRegister(reg) .LoadAccumulatorWithRegister(builder.Parameter(0)) .StoreAccumulatorInRegister(args[0]) - .LoadLiteral(factory->NewStringFromAsciiChecked("a")) + .LoadLiteral(ast_factory.NewString(ast_factory.GetOneByteString("a"))) .StoreAccumulatorInRegister(args[1]) - .LoadLiteral(factory->NewStringFromAsciiChecked("b")) + .LoadLiteral(ast_factory.NewString(ast_factory.GetOneByteString("b"))) .StoreAccumulatorInRegister(args[2]) - .LoadLiteral(factory->NewStringFromAsciiChecked("c")) + .LoadLiteral(ast_factory.NewString(ast_factory.GetOneByteString("c"))) .StoreAccumulatorInRegister(args[3]) - .LoadLiteral(factory->NewStringFromAsciiChecked("d")) + .LoadLiteral(ast_factory.NewString(ast_factory.GetOneByteString("d"))) .StoreAccumulatorInRegister(args[4]) - .LoadLiteral(factory->NewStringFromAsciiChecked("e")) + .LoadLiteral(ast_factory.NewString(ast_factory.GetOneByteString("e"))) .StoreAccumulatorInRegister(args[5]) - .LoadLiteral(factory->NewStringFromAsciiChecked("f")) + .LoadLiteral(ast_factory.NewString(ast_factory.GetOneByteString("f"))) .StoreAccumulatorInRegister(args[6]) - .LoadLiteral(factory->NewStringFromAsciiChecked("g")) + .LoadLiteral(ast_factory.NewString(ast_factory.GetOneByteString("g"))) .StoreAccumulatorInRegister(args[7]) - .LoadLiteral(factory->NewStringFromAsciiChecked("h")) + .LoadLiteral(ast_factory.NewString(ast_factory.GetOneByteString("h"))) .StoreAccumulatorInRegister(args[8]) - .LoadLiteral(factory->NewStringFromAsciiChecked("i")) + .LoadLiteral(ast_factory.NewString(ast_factory.GetOneByteString("i"))) .StoreAccumulatorInRegister(args[9]) - .LoadLiteral(factory->NewStringFromAsciiChecked("j")) + .LoadLiteral(ast_factory.NewString(ast_factory.GetOneByteString("j"))) .StoreAccumulatorInRegister(args[10]); builder.Call(reg, args, call_slot_index, Call::GLOBAL_CALL, tail_call_mode); builder.Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<Handle<Object>>(); Handle<Object> object = InterpreterTester::NewObject( @@ -1407,16 +1449,16 @@ static BytecodeArrayBuilder& IncrementRegister(BytecodeArrayBuilder& builder, TEST(InterpreterJumps) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Zone zone(isolate->allocator(), ZONE_NAME); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 2); + Zone* zone = handles.main_zone(); + BytecodeArrayBuilder builder(isolate, zone, 0, 0, 2); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); Register reg(0), scratch(1); BytecodeLabel label[3]; @@ -1435,7 +1477,7 @@ TEST(InterpreterJumps) { .Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK_EQ(Smi::cast(*return_value)->value(), 7); @@ -1445,18 +1487,18 @@ TEST(InterpreterJumps) { TEST(InterpreterConditionalJumps) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Zone zone(isolate->allocator(), ZONE_NAME); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 2); + Zone* zone = handles.main_zone(); + BytecodeArrayBuilder builder(isolate, zone, 0, 0, 2); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot4 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot4 = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); Register reg(0), scratch(1); BytecodeLabel label[2]; @@ -1485,7 +1527,7 @@ TEST(InterpreterConditionalJumps) { .Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK_EQ(Smi::cast(*return_value)->value(), 7); @@ -1495,18 +1537,18 @@ TEST(InterpreterConditionalJumps2) { // TODO(oth): Add tests for all conditional jumps near and far. HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Zone zone(isolate->allocator(), ZONE_NAME); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 2); + Zone* zone = handles.main_zone(); + BytecodeArrayBuilder builder(isolate, zone, 0, 0, 2); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot(); - FeedbackVectorSlot slot4 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot4 = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); Register reg(0), scratch(1); BytecodeLabel label[2]; @@ -1535,7 +1577,7 @@ TEST(InterpreterConditionalJumps2) { .Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK_EQ(Smi::cast(*return_value)->value(), 7); @@ -1544,14 +1586,15 @@ TEST(InterpreterConditionalJumps2) { TEST(InterpreterJumpConstantWith16BitOperand) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 257); + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 257); - Zone zone(isolate->allocator(), ZONE_NAME); - - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); Register reg(0), scratch(256); BytecodeLabel done, fake; @@ -1560,7 +1603,7 @@ TEST(InterpreterJumpConstantWith16BitOperand) { builder.StoreAccumulatorInRegister(reg); // Consume all 8-bit operands for (int i = 1; i <= 256; i++) { - builder.LoadLiteral(isolate->factory()->NewNumber(i)); + builder.LoadLiteral(ast_factory.NewNumber(i + 0.5)); builder.BinaryOperation(Token::Value::ADD, reg, GetIndex(slot)); builder.StoreAccumulatorInRegister(reg); } @@ -1579,6 +1622,7 @@ TEST(InterpreterJumpConstantWith16BitOperand) { builder.LoadAccumulatorWithRegister(reg); builder.Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); BytecodeArrayIterator iterator(bytecode_array); @@ -1593,31 +1637,38 @@ TEST(InterpreterJumpConstantWith16BitOperand) { } CHECK(found_16bit_constant_jump); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); - CHECK_EQ(Smi::cast(*return_value)->value(), 256.0 / 2 * (1 + 256)); + CHECK_EQ(Handle<HeapNumber>::cast(return_value)->value(), + 256.0 / 2 * (1.5 + 256.5)); } TEST(InterpreterJumpWith32BitOperand) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 1); Register reg(0); BytecodeLabel done; builder.LoadLiteral(Smi::kZero); builder.StoreAccumulatorInRegister(reg); - // Consume all 16-bit constant pool entries + // Consume all 16-bit constant pool entries. Make sure to use doubles so that + // the jump can't re-use an integer. for (int i = 1; i <= 65536; i++) { - builder.LoadLiteral(isolate->factory()->NewNumber(i)); + builder.LoadLiteral(ast_factory.NewNumber(i + 0.5)); } builder.Jump(&done); builder.LoadLiteral(Smi::kZero); builder.Bind(&done); builder.Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); + BytecodeArrayIterator iterator(bytecode_array); bool found_32bit_jump = false; @@ -1634,7 +1685,7 @@ TEST(InterpreterJumpWith32BitOperand) { InterpreterTester tester(isolate, bytecode_array); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); - CHECK_EQ(Smi::cast(*return_value)->value(), 65536.0); + CHECK_EQ(Handle<HeapNumber>::cast(return_value)->value(), 65536.5); } static const Token::Value kComparisonTypes[] = { @@ -1691,13 +1742,13 @@ TEST(InterpreterSmiComparisons) { for (size_t j = 0; j < arraysize(inputs); j++) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Zone zone(isolate->allocator(), ZONE_NAME); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1); + Zone* zone = handles.main_zone(); + BytecodeArrayBuilder builder(isolate, zone, 0, 0, 1); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterCompareICSlot(); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); Register r0(0); builder.LoadLiteral(Smi::FromInt(inputs[i])) @@ -1707,13 +1758,13 @@ TEST(InterpreterSmiComparisons) { .Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->IsBoolean()); CHECK_EQ(return_value->BooleanValue(), CompareC(comparison, inputs[i], inputs[j])); - Object* feedback = vector->Get(slot); + Object* feedback = callable.vector()->Get(slot); CHECK(feedback->IsSmi()); CHECK_EQ(CompareOperationFeedback::kSignedSmall, static_cast<Smi*>(feedback)->value()); @@ -1737,30 +1788,33 @@ TEST(InterpreterHeapNumberComparisons) { for (size_t j = 0; j < arraysize(inputs); j++) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1); + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); + + BytecodeArrayBuilder builder(isolate, zone, 0, 0, 1); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterCompareICSlot(); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); Register r0(0); - builder.LoadLiteral(factory->NewHeapNumber(inputs[i])) + builder.LoadLiteral(ast_factory.NewNumber(inputs[i])) .StoreAccumulatorInRegister(r0) - .LoadLiteral(factory->NewHeapNumber(inputs[j])) + .LoadLiteral(ast_factory.NewNumber(inputs[j])) .CompareOperation(comparison, r0, GetIndex(slot)) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->IsBoolean()); CHECK_EQ(return_value->BooleanValue(), CompareC(comparison, inputs[i], inputs[j])); - Object* feedback = vector->Get(slot); + Object* feedback = callable.vector()->Get(slot); CHECK(feedback->IsSmi()); CHECK_EQ(CompareOperationFeedback::kNumber, static_cast<Smi*>(feedback)->value()); @@ -1773,8 +1827,7 @@ TEST(InterpreterHeapNumberComparisons) { TEST(InterpreterStringComparisons) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); + Zone* zone = handles.main_zone(); std::string inputs[] = {"A", "abc", "z", "", "Foo!", "Foo"}; @@ -1782,31 +1835,35 @@ TEST(InterpreterStringComparisons) { Token::Value comparison = kComparisonTypes[c]; for (size_t i = 0; i < arraysize(inputs); i++) { for (size_t j = 0; j < arraysize(inputs); j++) { + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); + CanonicalHandleScope canonical(isolate); const char* lhs = inputs[i].c_str(); const char* rhs = inputs[j].c_str(); - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot slot = feedback_spec.AddInterpreterCompareICSlot(); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1); + BytecodeArrayBuilder builder(isolate, zone, 0, 0, 1); Register r0(0); - builder.LoadLiteral(factory->InternalizeUtf8String(lhs)) + builder.LoadLiteral(ast_factory.GetOneByteString(lhs)) .StoreAccumulatorInRegister(r0) - .LoadLiteral(factory->InternalizeUtf8String(rhs)) + .LoadLiteral(ast_factory.GetOneByteString(rhs)) .CompareOperation(comparison, r0, GetIndex(slot)) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); + InterpreterTester tester(isolate, bytecode_array, metadata); auto callable = tester.GetCallable<>(); Handle<Object> return_value = callable().ToHandleChecked(); CHECK(return_value->IsBoolean()); CHECK_EQ(return_value->BooleanValue(), CompareC(comparison, inputs[i], inputs[j])); - Object* feedback = vector->Get(slot); + Object* feedback = callable.vector()->Get(slot); CHECK(feedback->IsSmi()); int const expected_feedback = Token::IsOrderedRelationalCompareOp(comparison) @@ -1818,6 +1875,19 @@ TEST(InterpreterStringComparisons) { } } +static void LoadStringAndAddSpace(BytecodeArrayBuilder* builder, + AstValueFactory* ast_factory, + const char* cstr, + FeedbackSlot string_add_slot) { + Register string_reg = builder->register_allocator()->NewRegister(); + + (*builder) + .LoadLiteral(ast_factory->NewString(ast_factory->GetOneByteString(cstr))) + .StoreAccumulatorInRegister(string_reg) + .LoadLiteral(ast_factory->NewString(ast_factory->GetOneByteString(" "))) + .BinaryOperation(Token::Value::ADD, string_reg, + GetIndex(string_add_slot)); +} TEST(InterpreterMixedComparisons) { // This test compares a HeapNumber with a String. The latter is @@ -1828,59 +1898,104 @@ TEST(InterpreterMixedComparisons) { UnicodeCache unicode_cache; + enum WhichSideString { kLhsIsString, kRhsIsString }; + + enum StringType { kInternalizedStringConstant, kComputedString }; + for (size_t c = 0; c < arraysize(kComparisonTypes); c++) { Token::Value comparison = kComparisonTypes[c]; for (size_t i = 0; i < arraysize(inputs); i++) { for (size_t j = 0; j < arraysize(inputs); j++) { - for (int pass = 0; pass < 2; pass++) { - const char* lhs_cstr = inputs[i]; - const char* rhs_cstr = inputs[j]; - double lhs = StringToDouble(&unicode_cache, lhs_cstr, - ConversionFlags::NO_FLAGS); - double rhs = StringToDouble(&unicode_cache, rhs_cstr, - ConversionFlags::NO_FLAGS); - HandleAndZoneScope handles; - Isolate* isolate = handles.main_isolate(); - Factory* factory = isolate->factory(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1); - Zone zone(isolate->allocator(), ZONE_NAME); - - FeedbackVectorSpec feedback_spec(&zone); - FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot(); - Handle<i::FeedbackVector> vector = - NewFeedbackVector(isolate, &feedback_spec); - - Register r0(0); - if (pass == 0) { - // Comparison with HeapNumber on the lhs and String on the rhs - builder.LoadLiteral(factory->NewNumber(lhs)) - .StoreAccumulatorInRegister(r0) - .LoadLiteral(factory->NewStringFromAsciiChecked(rhs_cstr)) - .CompareOperation(comparison, r0, GetIndex(slot)) - .Return(); - } else { - // Comparison with HeapNumber on the rhs and String on the lhs - builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs_cstr)) - .StoreAccumulatorInRegister(r0) - .LoadLiteral(factory->NewNumber(rhs)) - .CompareOperation(comparison, r0, GetIndex(slot)) + // We test the case where either the lhs or the rhs is a string... + for (WhichSideString which_side : {kLhsIsString, kRhsIsString}) { + // ... and the case when the string is internalized or computed. + for (StringType string_type : + {kInternalizedStringConstant, kComputedString}) { + const char* lhs_cstr = inputs[i]; + const char* rhs_cstr = inputs[j]; + double lhs = StringToDouble(&unicode_cache, lhs_cstr, + ConversionFlags::NO_FLAGS); + double rhs = StringToDouble(&unicode_cache, rhs_cstr, + ConversionFlags::NO_FLAGS); + HandleAndZoneScope handles; + Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); + BytecodeArrayBuilder builder(isolate, zone, 0, 0, 0); + + FeedbackVectorSpec feedback_spec(zone); + FeedbackSlot string_add_slot = + feedback_spec.AddInterpreterBinaryOpICSlot(); + FeedbackSlot slot = feedback_spec.AddInterpreterCompareICSlot(); + Handle<i::FeedbackMetadata> metadata = + NewFeedbackMetadata(isolate, &feedback_spec); + + // lhs is in a register, rhs is in the accumulator. + Register lhs_reg = builder.register_allocator()->NewRegister(); + + if (which_side == kRhsIsString) { + // Comparison with HeapNumber on the lhs and String on the rhs. + + builder.LoadLiteral(ast_factory.NewNumber(lhs)) + .StoreAccumulatorInRegister(lhs_reg); + + if (string_type == kInternalizedStringConstant) { + // rhs string is internalized. + builder.LoadLiteral(ast_factory.NewString( + ast_factory.GetOneByteString(rhs_cstr))); + } else { + CHECK_EQ(string_type, kComputedString); + // rhs string is not internalized (append a space to the end). + LoadStringAndAddSpace(&builder, &ast_factory, rhs_cstr, + string_add_slot); + } + break; + } else { + CHECK_EQ(which_side, kLhsIsString); + // Comparison with String on the lhs and HeapNumber on the rhs. + + if (string_type == kInternalizedStringConstant) { + // lhs string is internalized + builder.LoadLiteral(ast_factory.NewString( + ast_factory.GetOneByteString(lhs_cstr))); + } else { + CHECK_EQ(string_type, kComputedString); + // lhs string is not internalized (append a space to the end). + LoadStringAndAddSpace(&builder, &ast_factory, lhs_cstr, + string_add_slot); + } + builder.StoreAccumulatorInRegister(lhs_reg); + + builder.LoadLiteral(ast_factory.NewNumber(rhs)); + } + + builder.CompareOperation(comparison, lhs_reg, GetIndex(slot)) .Return(); - } - Handle<BytecodeArray> bytecode_array = - builder.ToBytecodeArray(isolate); - InterpreterTester tester(isolate, bytecode_array, vector); - auto callable = tester.GetCallable<>(); - Handle<Object> return_value = callable().ToHandleChecked(); - CHECK(return_value->IsBoolean()); - CHECK_EQ(return_value->BooleanValue(), - CompareC(comparison, lhs, rhs, true)); - Object* feedback = vector->Get(slot); - CHECK(feedback->IsSmi()); - // kNumber | kString gets converted to CompareOperationHint::kAny. - int expected_feedback = CompareOperationFeedback::kNumber | - CompareOperationFeedback::kString; - CHECK_EQ(expected_feedback, static_cast<Smi*>(feedback)->value()); + ast_factory.Internalize(isolate); + Handle<BytecodeArray> bytecode_array = + builder.ToBytecodeArray(isolate); + InterpreterTester tester(isolate, bytecode_array, metadata); + auto callable = tester.GetCallable<>(); + Handle<Object> return_value = callable().ToHandleChecked(); + CHECK(return_value->IsBoolean()); + CHECK_EQ(return_value->BooleanValue(), + CompareC(comparison, lhs, rhs, true)); + Object* feedback = callable.vector()->Get(slot); + CHECK(feedback->IsSmi()); + int expected_feedback = CompareOperationFeedback::kNumber; + if (string_type == kInternalizedStringConstant && + !Token::IsOrderedRelationalCompareOp(comparison)) { + // Non-ordering compares (i.e. equality/strict equality) have + // special type feedback specifically for internalized strings. + expected_feedback |= + CompareOperationFeedback::kInternalizedString; + } else { + expected_feedback |= CompareOperationFeedback::kString; + } + CHECK_EQ(expected_feedback, static_cast<Smi*>(feedback)->value()); + } } } } @@ -1962,6 +2077,7 @@ TEST(InterpreterStrictNotEqual) { TEST(InterpreterInstanceOf) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Factory* factory = isolate->factory(); Handle<i::String> name = factory->NewStringFromAsciiChecked("cons"); Handle<i::JSFunction> func = factory->NewFunction(name); @@ -1970,12 +2086,16 @@ TEST(InterpreterInstanceOf) { Handle<i::Object> cases[] = {Handle<i::Object>::cast(instance), other}; for (size_t i = 0; i < arraysize(cases); i++) { bool expected_value = (i == 0); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1); + BytecodeArrayBuilder builder(isolate, zone, 0, 0, 1); Register r0(0); - builder.LoadLiteral(cases[i]); - builder.StoreAccumulatorInRegister(r0) - .LoadLiteral(func) + size_t case_entry = builder.AllocateDeferredConstantPoolEntry(); + builder.SetDeferredConstantPoolEntry(case_entry, cases[i]); + builder.LoadConstantPoolEntry(case_entry).StoreAccumulatorInRegister(r0); + + size_t func_entry = builder.AllocateDeferredConstantPoolEntry(); + builder.SetDeferredConstantPoolEntry(func_entry, func); + builder.LoadConstantPoolEntry(func_entry) .CompareOperation(Token::Value::INSTANCEOF, r0, 0) .Return(); @@ -1992,7 +2112,10 @@ TEST(InterpreterInstanceOf) { TEST(InterpreterTestIn) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); Factory* factory = isolate->factory(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); // Allocate an array Handle<i::JSArray> array = factory->NewJSArray(0, i::ElementsKind::FAST_SMI_ELEMENTS); @@ -2000,15 +2123,19 @@ TEST(InterpreterTestIn) { const char* properties[] = {"length", "fuzzle", "x", "0"}; for (size_t i = 0; i < arraysize(properties); i++) { bool expected_value = (i == 0); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1); + BytecodeArrayBuilder builder(isolate, zone, 0, 0, 1); Register r0(0); - builder.LoadLiteral(factory->NewStringFromAsciiChecked(properties[i])) - .StoreAccumulatorInRegister(r0) - .LoadLiteral(Handle<Object>::cast(array)) + builder.LoadLiteral(ast_factory.GetOneByteString(properties[i])) + .StoreAccumulatorInRegister(r0); + + size_t array_entry = builder.AllocateDeferredConstantPoolEntry(); + builder.SetDeferredConstantPoolEntry(array_entry, array); + builder.LoadConstantPoolEntry(array_entry) .CompareOperation(Token::Value::IN, r0, 0) .Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); InterpreterTester tester(isolate, bytecode_array); auto callable = tester.GetCallable<>(); @@ -2022,9 +2149,10 @@ TEST(InterpreterTestIn) { TEST(InterpreterUnaryNot) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); for (size_t i = 1; i < 10; i++) { bool expected_value = ((i & 1) == 1); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 0, 0, 0); Register r0(0); builder.LoadFalse(); @@ -2042,56 +2170,34 @@ TEST(InterpreterUnaryNot) { } -static void LoadAny(BytecodeArrayBuilder* builder, - v8::internal::Factory* factory, Handle<Object> obj) { - if (obj->IsOddball()) { - if (obj->SameValue(*factory->true_value())) { - builder->LoadTrue(); - } else if (obj->SameValue(*factory->false_value())) { - builder->LoadFalse(); - } else if (obj->SameValue(*factory->the_hole_value())) { - builder->LoadTheHole(); - } else if (obj->SameValue(*factory->null_value())) { - builder->LoadNull(); - } else if (obj->SameValue(*factory->undefined_value())) { - builder->LoadUndefined(); - } else { - UNREACHABLE(); - } - } else if (obj->IsSmi()) { - builder->LoadLiteral(*Handle<Smi>::cast(obj)); - } else { - builder->LoadLiteral(obj); - } -} - - TEST(InterpreterUnaryNotNonBoolean) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); - Factory* factory = isolate->factory(); - - std::pair<Handle<Object>, bool> object_type_tuples[] = { - std::make_pair(factory->undefined_value(), true), - std::make_pair(factory->null_value(), true), - std::make_pair(factory->false_value(), true), - std::make_pair(factory->true_value(), false), - std::make_pair(factory->NewNumber(9.1), false), - std::make_pair(factory->NewNumberFromInt(0), true), - std::make_pair( - Handle<Object>::cast(factory->NewStringFromStaticChars("hello")), - false), + Zone* zone = handles.main_zone(); + AstValueFactory ast_factory(zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); + + std::pair<const AstValue*, bool> object_type_tuples[] = { + std::make_pair(ast_factory.NewUndefined(), true), + std::make_pair(ast_factory.NewNull(), true), + std::make_pair(ast_factory.NewBoolean(false), true), + std::make_pair(ast_factory.NewBoolean(true), false), + std::make_pair(ast_factory.NewNumber(9.1), false), + std::make_pair(ast_factory.NewNumber(0), true), std::make_pair( - Handle<Object>::cast(factory->NewStringFromStaticChars("")), true), + ast_factory.NewString(ast_factory.GetOneByteString("hello")), false), + std::make_pair(ast_factory.NewString(ast_factory.GetOneByteString("")), + true), }; for (size_t i = 0; i < arraysize(object_type_tuples); i++) { - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 0); + BytecodeArrayBuilder builder(isolate, zone, 0, 0, 0); Register r0(0); - LoadAny(&builder, factory, object_type_tuples[i].first); + builder.LoadLiteral(object_type_tuples[i].first); builder.LogicalNot(); builder.Return(); + ast_factory.Internalize(isolate); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); InterpreterTester tester(isolate, bytecode_array); auto callable = tester.GetCallable<>(); @@ -2133,8 +2239,9 @@ TEST(InterpreterTypeof) { TEST(InterpreterCallRuntime) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 2); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 2); RegisterList args = builder.register_allocator()->NewRegisterList(2); builder.LoadLiteral(Smi::FromInt(15)) @@ -2155,8 +2262,9 @@ TEST(InterpreterCallRuntime) { TEST(InterpreterInvokeIntrinsic) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); + Zone* zone = handles.main_zone(); - BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 2); + BytecodeArrayBuilder builder(isolate, zone, 1, 0, 2); builder.LoadLiteral(Smi::FromInt(15)) .StoreAccumulatorInRegister(Register(0)) diff --git a/deps/v8/test/cctest/parsing/test-preparser.cc b/deps/v8/test/cctest/parsing/test-preparser.cc new file mode 100644 index 0000000000..cb86d4f900 --- /dev/null +++ b/deps/v8/test/cctest/parsing/test-preparser.cc @@ -0,0 +1,567 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/ast/ast.h" +#include "src/compiler.h" +#include "src/objects-inl.h" +#include "src/parsing/parse-info.h" +#include "src/parsing/parsing.h" + +#include "test/cctest/cctest.h" +#include "test/cctest/scope-test-helper.h" +#include "test/cctest/unicode-helpers.h" + +namespace { + +enum SkipStrict { + DONT_SKIP = 0, + // Skip if the test function declares itself strict, otherwise don't skip. + SKIP_STRICT_FUNCTION = 1, + // Skip if there's a "use strict" directive above the test. + SKIP_STRICT_OUTER = 1 << 1, + SKIP_STRICT = SKIP_STRICT_FUNCTION | SKIP_STRICT_OUTER +}; + +} // namespace + +TEST(PreParserScopeAnalysis) { + i::FLAG_lazy_inner_functions = true; + i::FLAG_preparser_scope_analysis = true; + i::Isolate* isolate = CcTest::i_isolate(); + i::Factory* factory = isolate->factory(); + i::HandleScope scope(isolate); + LocalContext env; + + /* Test the following cases: + 1) + (function outer() { + function test() { ... } + })(); + against: + (function outer() { + (function test() { ... })(); + })(); + + 2) + (function outer() { + function inner() { function test() { ... } } + })(); + against: + (function outer() { + (function inner() { function test() { ... } })(); + })(); + (Modified function is deeper inside the laziness boundary.) + + 3) + (function outer() { + function inner() { () => { ... } } + })(); + against: + (function outer() { + (function inner() { () => { ... } })(); + })(); + + Inner arrow functions are never lazy, so the corresponding case is missing. + */ + + struct { + const char* prefix; + const char* suffix; + const char* lazy_inner; + const char* eager_inner; + bool strict_outer; + bool strict_test_function; + } outers[] = { + // The scope start positions must match; note the extra space in + // lazy_inner. + {"(function outer() { ", "})();", " function test(%s) { %s }", + "(function test(%s) { %s })()", false, false}, + {"(function outer() { ", "})();", + " function inner() { function test(%s) { %s } }", + "(function inner() { function test(%s) { %s } })()", false, false}, + // FIXME(marja): enable test for arrow functions once it passes. + // {"(function outer() { ", "})();", + // " function inner() { (%s) => { %s } }", + // "(function inner() { (%s) => { %s } })()", false}, + {"(function outer() { 'use strict'; ", "})();", + " function test(%s) { %s }", "(function test(%s) { %s })()", true, + false}, + {"(function outer() { 'use strict'; ", "})();", + " function inner() { function test(%s) { %s } }", + "(function inner() { function test(%s) { %s } })()", true, false}, + {"(function outer() { ", "})();", + " function test(%s) { 'use strict'; %s }", + "(function test(%s) { 'use strict'; %s })()", false, true}, + {"(function outer() { ", "})();", + " function inner() { function test(%s) { 'use strict'; %s } }", + "(function inner() { function test(%s) { 'use strict'; %s } })()", false, + true}, + }; + + struct Inner { + Inner(const char* s) : source(s) {} // NOLINT + Inner(const char* s, SkipStrict skip) + : source(s), skip_in_strict_mode(skip) {} + Inner(const char* s, SkipStrict skip, bool precise) + : source(s), + skip_in_strict_mode(skip), + precise_maybe_assigned(precise) {} + + Inner(const char* p, const char* s) : params(p), source(s) {} + Inner(const char* p, const char* s, SkipStrict skip) + : params(p), source(s), skip_in_strict_mode(skip) {} + Inner(const char* p, const char* s, SkipStrict skip, bool precise) + : params(p), + source(s), + skip_in_strict_mode(skip), + precise_maybe_assigned(precise) {} + + const char* params = ""; + const char* source; + SkipStrict skip_in_strict_mode = DONT_SKIP; + bool precise_maybe_assigned = true; + } inners[] = { + // Simple cases + {"var1;"}, + {"var1 = 5;"}, + {"if (true) {}"}, + {"function f1() {}"}, + + // Var declarations and assignments. + {"var var1;"}, + {"var var1; var1 = 5;"}, + {"if (true) { var var1; }", DONT_SKIP, false}, + {"if (true) { var var1; var1 = 5; }"}, + {"var var1; function f() { var1; }"}, + {"var var1; var1 = 5; function f() { var1; }"}, + {"var var1; function f() { var1 = 5; }"}, + + // Let declarations and assignments. + {"let var1;"}, + {"let var1; var1 = 5;"}, + {"if (true) { let var1; }"}, + {"if (true) { let var1; var1 = 5; }"}, + {"let var1; function f() { var1; }"}, + {"let var1; var1 = 5; function f() { var1; }"}, + {"let var1; function f() { var1 = 5; }"}, + + // Const declarations. + {"const var1 = 5;"}, + {"if (true) { const var1 = 5; }"}, + {"const var1 = 5; function f() { var1; }"}, + + // Redeclarations. + {"var var1; var var1;"}, + {"var var1; var var1; var1 = 5;"}, + {"var var1; if (true) { var var1; }"}, + {"if (true) { var var1; var var1; }"}, + {"var var1; if (true) { var var1; var1 = 5; }"}, + {"if (true) { var var1; var var1; var1 = 5; }"}, + {"var var1; var var1; function f() { var1; }"}, + {"var var1; var var1; function f() { var1 = 5; }"}, + + // Shadowing declarations. + {"var var1; if (true) { var var1; }"}, + {"var var1; if (true) { let var1; }"}, + {"let var1; if (true) { let var1; }"}, + + {"var var1; if (true) { const var1 = 0; }"}, + {"const var1 = 0; if (true) { const var1 = 0; }"}, + + // Variables deeper in the subscopes (scopes without variables inbetween). + {"if (true) { if (true) { function f() { var var1 = 5; } } }"}, + + // Arguments and this. + {"arguments;"}, + {"arguments = 5;", SKIP_STRICT}, + {"if (true) { arguments; }"}, + {"if (true) { arguments = 5; }", SKIP_STRICT}, + + {"this;"}, + {"if (true) { this; }"}, + + // Variable called "arguments" + {"var arguments;", SKIP_STRICT}, + {"var arguments; arguments = 5;", SKIP_STRICT}, + {"if (true) { var arguments; }", SKIP_STRICT, false}, + {"if (true) { var arguments; arguments = 5; }", SKIP_STRICT}, + {"var arguments; function f() { arguments; }", SKIP_STRICT}, + {"var arguments; arguments = 5; function f() { arguments; }", + SKIP_STRICT}, + {"var arguments; function f() { arguments = 5; }", SKIP_STRICT}, + + {"let arguments;", SKIP_STRICT}, + {"let arguments; arguments = 5;", SKIP_STRICT}, + {"if (true) { let arguments; }", SKIP_STRICT}, + {"if (true) { let arguments; arguments = 5; }", SKIP_STRICT}, + {"let arguments; function f() { arguments; }", SKIP_STRICT}, + {"let arguments; arguments = 5; function f() { arguments; }", + SKIP_STRICT}, + {"let arguments; function f() { arguments = 5; }", SKIP_STRICT}, + + {"const arguments = 5;", SKIP_STRICT}, + {"if (true) { const arguments = 5; }", SKIP_STRICT}, + {"const arguments = 5; function f() { arguments; }", SKIP_STRICT}, + + // Destructuring declarations. + {"var [var1, var2] = [1, 2];"}, + {"var [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"}, + {"var [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"}, + {"var [var1, ...var2] = [1, 2, 3];"}, + + {"var {var1: var2, var3: var4} = {var1: 1, var3: 2};"}, + {"var {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"}, + {"var {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"}, + + {"let [var1, var2] = [1, 2];"}, + {"let [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"}, + {"let [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"}, + {"let [var1, ...var2] = [1, 2, 3];"}, + + {"let {var1: var2, var3: var4} = {var1: 1, var3: 2};"}, + {"let {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"}, + {"let {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"}, + + {"const [var1, var2] = [1, 2];"}, + {"const [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"}, + {"const [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"}, + {"const [var1, ...var2] = [1, 2, 3];"}, + + {"const {var1: var2, var3: var4} = {var1: 1, var3: 2};"}, + {"const {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"}, + {"const {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"}, + + // Referencing the function variable. + {"test;"}, + {"function f1() { f1; }"}, + {"function f1() { function f2() { f1; } }"}, + {"function arguments() {}", SKIP_STRICT}, + {"function f1() {} function f1() {}", SKIP_STRICT}, + {"var f1; function f1() {}"}, + + // Assigning to the function variable. + {"test = 3;"}, + {"function f1() { f1 = 3; }"}, + {"function f1() { f1; } f1 = 3;"}, + {"function arguments() {} arguments = 8;", SKIP_STRICT}, + {"function f1() {} f1 = 3; function f1() {}", SKIP_STRICT}, + + // Evals. + {"var var1; eval('');"}, + {"var var1; function f1() { eval(''); }"}, + {"let var1; eval('');"}, + {"let var1; function f1() { eval(''); }"}, + {"const var1 = 10; eval('');"}, + {"const var1 = 10; function f1() { eval(''); }"}, + + // Standard for loops. + {"for (var var1 = 0; var1 < 10; ++var1) { }"}, + {"for (let var1 = 0; var1 < 10; ++var1) { }"}, + {"for (const var1 = 0; var1 < 10; ++var1) { }"}, + + {"for (var var1 = 0; var1 < 10; ++var1) { function foo() { var1; } }"}, + {"for (let var1 = 0; var1 < 10; ++var1) { function foo() { var1; } }"}, + {"for (const var1 = 0; var1 < 10; ++var1) { function foo() { var1; } }"}, + + // For of loops + {"for (var1 of [1, 2]) { }"}, + {"for (var var1 of [1, 2]) { }"}, + {"for (let var1 of [1, 2]) { }"}, + {"for (const var1 of [1, 2]) { }"}, + + {"for (var1 of [1, 2]) { var1; }"}, + {"for (var var1 of [1, 2]) { var1; }"}, + {"for (let var1 of [1, 2]) { var1; }"}, + {"for (const var1 of [1, 2]) { var1; }"}, + + {"for (var1 of [1, 2]) { var1 = 0; }"}, + {"for (var var1 of [1, 2]) { var1 = 0; }"}, + {"for (let var1 of [1, 2]) { var1 = 0; }"}, + {"for (const var1 of [1, 2]) { var1 = 0; }"}, + + {"for (var1 of [1, 2]) { function foo() { var1; } }"}, + {"for (var var1 of [1, 2]) { function foo() { var1; } }"}, + {"for (let var1 of [1, 2]) { function foo() { var1; } }"}, + {"for (const var1 of [1, 2]) { function foo() { var1; } }"}, + + {"for (var1 of [1, 2]) { function foo() { var1 = 0; } }"}, + {"for (var var1 of [1, 2]) { function foo() { var1 = 0; } }"}, + {"for (let var1 of [1, 2]) { function foo() { var1 = 0; } }"}, + {"for (const var1 of [1, 2]) { function foo() { var1 = 0; } }"}, + + // For in loops + {"for (var1 in {a: 6}) { }"}, + {"for (var var1 in {a: 6}) { }"}, + {"for (let var1 in {a: 6}) { }"}, + {"for (const var1 in {a: 6}) { }"}, + + {"for (var1 in {a: 6}) { var1; }"}, + {"for (var var1 in {a: 6}) { var1; }"}, + {"for (let var1 in {a: 6}) { var1; }"}, + {"for (const var1 in {a: 6}) { var1; }"}, + + {"for (var1 in {a: 6}) { var1 = 0; }"}, + {"for (var var1 in {a: 6}) { var1 = 0; }"}, + {"for (let var1 in {a: 6}) { var1 = 0; }"}, + {"for (const var1 in {a: 6}) { var1 = 0; }"}, + + {"for (var1 in {a: 6}) { function foo() { var1; } }"}, + {"for (var var1 in {a: 6}) { function foo() { var1; } }"}, + {"for (let var1 in {a: 6}) { function foo() { var1; } }"}, + {"for (const var1 in {a: 6}) { function foo() { var1; } }"}, + + {"for (var1 in {a: 6}) { function foo() { var1 = 0; } }"}, + {"for (var var1 in {a: 6}) { function foo() { var1 = 0; } }"}, + {"for (let var1 in {a: 6}) { function foo() { var1 = 0; } }"}, + {"for (const var1 in {a: 6}) { function foo() { var1 = 0; } }"}, + + {"for (var1 in {a: 6}) { function foo() { var1 = 0; } }"}, + {"for (var var1 in {a: 6}) { function foo() { var1 = 0; } }"}, + {"for (let var1 in {a: 6}) { function foo() { var1 = 0; } }"}, + {"for (const var1 in {a: 6}) { function foo() { var1 = 0; } }"}, + + // Loops without declarations + {"var var1 = 0; for ( ; var1 < 2; ++var1) { }"}, + {"var var1 = 0; for ( ; var1 < 2; ++var1) { function foo() { var1; } }"}, + {"var var1 = 0; for ( ; var1 > 2; ) { }"}, + {"var var1 = 0; for ( ; var1 > 2; ) { function foo() { var1; } }"}, + {"var var1 = 0; for ( ; var1 > 2; ) { function foo() { var1 = 6; } }"}, + + {"var var1 = 0; for(var1; var1 < 2; ++var1) { }"}, + {"var var1 = 0; for (var1; var1 < 2; ++var1) { function foo() { var1; } " + "}"}, + {"var var1 = 0; for (var1; var1 > 2; ) { }"}, + {"var var1 = 0; for (var1; var1 > 2; ) { function foo() { var1; } }"}, + {"var var1 = 0; for (var1; var1 > 2; ) { function foo() { var1 = 6; } }"}, + + // Block functions (potentially sloppy). + {"if (true) { function f1() {} }"}, + {"if (true) { function f1() {} function f1() {} }", SKIP_STRICT}, + {"if (true) { if (true) { function f1() {} } }"}, + {"if (true) { if (true) { function f1() {} function f1() {} } }", + SKIP_STRICT}, + {"if (true) { function f1() {} f1 = 3; }"}, + + {"if (true) { function f1() {} function foo() { f1; } }"}, + {"if (true) { function f1() {} } function foo() { f1; }"}, + {"if (true) { function f1() {} function f1() {} function foo() { f1; } " + "}", + SKIP_STRICT}, + {"if (true) { function f1() {} function f1() {} } function foo() { f1; " + "}", + SKIP_STRICT}, + {"if (true) { if (true) { function f1() {} } function foo() { f1; } }"}, + {"if (true) { if (true) { function f1() {} function f1() {} } function " + "foo() { f1; } }", + SKIP_STRICT}, + {"if (true) { function f1() {} f1 = 3; function foo() { f1; } }"}, + {"if (true) { function f1() {} f1 = 3; } function foo() { f1; }"}, + + {"var f1 = 1; if (true) { function f1() {} }"}, + {"var f1 = 1; if (true) { function f1() {} } function foo() { f1; }"}, + + // Simple parameters. + {"var1", ""}, + {"var1", "var1;"}, + {"var1", "var1 = 9;"}, + {"var1", "function f1() { var1; }"}, + {"var1", "function f1() { var1 = 9; }"}, + + {"var1, var2", ""}, + {"var1, var2", "var2;"}, + {"var1, var2", "var2 = 9;"}, + {"var1, var2", "function f1() { var2; }"}, + {"var1, var2", "function f1() { var2 = 9; }"}, + {"var1, var2", "var1;"}, + {"var1, var2", "var1 = 9;"}, + {"var1, var2", "function f1() { var1; }"}, + {"var1, var2", "function f1() { var1 = 9; }"}, + + // Duplicate parameters. + {"var1, var1", "", SKIP_STRICT}, + {"var1, var1", "var1;", SKIP_STRICT}, + {"var1, var1", "var1 = 9;", SKIP_STRICT}, + {"var1, var1", "function f1() { var1; }", SKIP_STRICT}, + {"var1, var1", "function f1() { var1 = 9; }", SKIP_STRICT}, + + // If the function declares itself strict, non-simple parameters aren't + // allowed. + + // Rest parameter. + {"...var2", "", SKIP_STRICT_FUNCTION}, + {"...var2", "var2;", SKIP_STRICT_FUNCTION}, + {"...var2", "var2 = 9;", SKIP_STRICT_FUNCTION}, + {"...var2", "function f1() { var2; }", SKIP_STRICT_FUNCTION}, + {"...var2", "function f1() { var2 = 9; }", SKIP_STRICT_FUNCTION}, + + {"var1, ...var2", "", SKIP_STRICT_FUNCTION}, + {"var1, ...var2", "var2;", SKIP_STRICT_FUNCTION}, + {"var1, ...var2", "var2 = 9;", SKIP_STRICT_FUNCTION}, + {"var1, ...var2", "function f1() { var2; }", SKIP_STRICT_FUNCTION}, + {"var1, ...var2", "function f1() { var2 = 9; }", SKIP_STRICT_FUNCTION}, + + // Default parameters. + {"var1 = 3", "", SKIP_STRICT_FUNCTION}, + {"var1, var2 = var1", "", SKIP_STRICT_FUNCTION}, + {"var1, var2 = 4, ...var3", "", SKIP_STRICT_FUNCTION}, + + // Destructuring parameters. Because of the search space explosion, we + // cannot test all interesting cases. Let's try to test a relevant subset. + {"[]", "", SKIP_STRICT_FUNCTION}, + {"{}", "", SKIP_STRICT_FUNCTION}, + + {"[var1]", "", SKIP_STRICT_FUNCTION}, + {"{name1: var1}", "", SKIP_STRICT_FUNCTION}, + {"{var1}", "", SKIP_STRICT_FUNCTION}, + + {"[var1]", "var1;", SKIP_STRICT_FUNCTION}, + {"{name1: var1}", "var1;", SKIP_STRICT_FUNCTION}, + {"{name1: var1}", "name1;", SKIP_STRICT_FUNCTION}, + {"{var1}", "var1;", SKIP_STRICT_FUNCTION}, + + {"[var1]", "var1 = 16;", SKIP_STRICT_FUNCTION}, + {"{name1: var1}", "var1 = 16;", SKIP_STRICT_FUNCTION}, + {"{name1: var1}", "name1 = 16;", SKIP_STRICT_FUNCTION}, + {"{var1}", "var1 = 16;", SKIP_STRICT_FUNCTION}, + + {"[var1]", "() => { var1; }", SKIP_STRICT_FUNCTION}, + {"{name1: var1}", "() => { var1; }", SKIP_STRICT_FUNCTION}, + {"{name1: var1}", "() => { name1; }", SKIP_STRICT_FUNCTION}, + {"{var1}", "() => { var1; }", SKIP_STRICT_FUNCTION}, + + {"[var1, var2, var3]", "", SKIP_STRICT_FUNCTION}, + {"{name1: var1, name2: var2, name3: var3}", "", SKIP_STRICT_FUNCTION}, + {"{var1, var2, var3}", "", SKIP_STRICT_FUNCTION}, + + {"[var1, var2, var3]", "() => { var2 = 16;}", SKIP_STRICT_FUNCTION}, + {"{name1: var1, name2: var2, name3: var3}", "() => { var2 = 16;}", + SKIP_STRICT_FUNCTION}, + {"{name1: var1, name2: var2, name3: var3}", "() => { name2 = 16;}", + SKIP_STRICT_FUNCTION}, + {"{var1, var2, var3}", "() => { var2 = 16;}", SKIP_STRICT_FUNCTION}, + + // Nesting destructuring. + {"[var1, [var2, var3], {var4, name5: [var5, var6]}]", "", + SKIP_STRICT_FUNCTION}, + + // Complicated params. + {"var1, [var2], var3, [var4, var5], var6, {var7}, var8, {name9: var9, " + "name10: var10}, ...var11", + "", SKIP_STRICT_FUNCTION}, + + // Destructuring rest. Because we can. + {"var1, ...[var2]", "() => { }", SKIP_STRICT_FUNCTION}, + {"var1, ...[var2]", "() => { var2; }", SKIP_STRICT_FUNCTION}, + + // Default parameters for destruring parameters. + {"[var1 = 4, var2 = var1]", "", SKIP_STRICT_FUNCTION, false}, + {"{var1 = 4, var2 = var1}", "", SKIP_STRICT_FUNCTION, false}, + + // Locals shadowing parameters. + {"var1, var2", "var var1 = 16; () => { var1 = 17; }"}, + + // Locals shadowing destructuring parameters and the rest parameter. + {"[var1, var2]", "var var1 = 16; () => { var1 = 17; }", + SKIP_STRICT_FUNCTION}, + {"{var1, var2}", "var var1 = 16; () => { var1 = 17; }", + SKIP_STRICT_FUNCTION}, + {"var1, var2, ...var3", "var var3 = 16; () => { var3 = 17; }", + SKIP_STRICT_FUNCTION}, + {"var1, var2 = var1", "var var1 = 16; () => { var1 = 17; }", + SKIP_STRICT_FUNCTION}, + + // Hoisted sloppy block function shadowing a parameter. + {"var1, var2", "for (;;) { function var1() { } }"}, + + // Eval in default parameter. + {"var1, var2 = eval(''), var3", "let var4 = 0;", SKIP_STRICT_FUNCTION}, + {"var1, var2 = eval(''), var3 = eval('')", "let var4 = 0;", + SKIP_STRICT_FUNCTION}, + + // FIXME(marja): arguments parameter + }; + + for (unsigned outer_ix = 0; outer_ix < arraysize(outers); ++outer_ix) { + for (unsigned inner_ix = 0; inner_ix < arraysize(inners); ++inner_ix) { + if (outers[outer_ix].strict_outer && + (inners[inner_ix].skip_in_strict_mode & SKIP_STRICT_OUTER)) { + continue; + } + if (outers[outer_ix].strict_test_function && + (inners[inner_ix].skip_in_strict_mode & SKIP_STRICT_FUNCTION)) { + continue; + } + + const char* prefix = outers[outer_ix].prefix; + const char* suffix = outers[outer_ix].suffix; + int prefix_len = Utf8LengthHelper(prefix); + int suffix_len = Utf8LengthHelper(suffix); + + // First compile with the lazy inner function and extract the scope data. + const char* inner_function = outers[outer_ix].lazy_inner; + int inner_function_len = Utf8LengthHelper(inner_function) - 4; + + int params_len = Utf8LengthHelper(inners[inner_ix].params); + int source_len = Utf8LengthHelper(inners[inner_ix].source); + int len = prefix_len + inner_function_len + params_len + source_len + + suffix_len; + + i::ScopedVector<char> lazy_program(len + 1); + i::SNPrintF(lazy_program, "%s", prefix); + i::SNPrintF(lazy_program + prefix_len, inner_function, + inners[inner_ix].params, inners[inner_ix].source); + i::SNPrintF(lazy_program + prefix_len + inner_function_len + params_len + + source_len, + "%s", suffix); + + i::Handle<i::String> source = + factory->InternalizeUtf8String(lazy_program.start()); + source->PrintOn(stdout); + printf("\n"); + + i::Handle<i::Script> script = factory->NewScript(source); + i::ParseInfo lazy_info(script); + + // No need to run scope analysis; preparser scope data is produced when + // parsing. + CHECK(i::parsing::ParseProgram(&lazy_info)); + + // Then parse eagerly and check against the scope data. + inner_function = outers[outer_ix].eager_inner; + inner_function_len = Utf8LengthHelper(inner_function) - 4; + len = prefix_len + inner_function_len + params_len + source_len + + suffix_len; + + i::ScopedVector<char> eager_program(len + 1); + i::SNPrintF(eager_program, "%s", prefix); + i::SNPrintF(eager_program + prefix_len, inner_function, + inners[inner_ix].params, inners[inner_ix].source); + i::SNPrintF(eager_program + prefix_len + inner_function_len + params_len + + source_len, + "%s", suffix); + + source = factory->InternalizeUtf8String(eager_program.start()); + source->PrintOn(stdout); + printf("\n"); + + script = factory->NewScript(source); + i::ParseInfo eager_info(script); + eager_info.set_allow_lazy_parsing(false); + + CHECK(i::parsing::ParseProgram(&eager_info)); + CHECK(i::Compiler::Analyze(&eager_info)); + + i::Scope* scope = + eager_info.literal()->scope()->inner_scope()->inner_scope(); + DCHECK_NOT_NULL(scope); + DCHECK_NULL(scope->sibling()); + DCHECK(scope->is_function_scope()); + + size_t index = 0; + i::ScopeTestHelper::CompareScopeToData( + scope, lazy_info.preparsed_scope_data(), index, + inners[inner_ix].precise_maybe_assigned); + } + } +} diff --git a/deps/v8/test/cctest/scope-test-helper.h b/deps/v8/test/cctest/scope-test-helper.h new file mode 100644 index 0000000000..65d5c3f059 --- /dev/null +++ b/deps/v8/test/cctest/scope-test-helper.h @@ -0,0 +1,79 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_CCTEST_SCOPE_TEST_HELPER_H_ +#define V8_CCTEST_SCOPE_TEST_HELPER_H_ + +#include "src/ast/scopes.h" +#include "src/ast/variables.h" + +namespace v8 { +namespace internal { + +class ScopeTestHelper { + public: + static bool MustAllocateInContext(Variable* var) { + return var->scope()->MustAllocateInContext(var); + } + + static void CompareScopeToData(Scope* scope, const PreParsedScopeData* data, + size_t& index, bool precise_maybe_assigned) { + CHECK(PreParsedScopeData::HasVariablesWhichNeedAllocationData(scope)); + CHECK_GT(data->backing_store_.size(), index + 4); + CHECK_EQ(data->backing_store_[index++], scope->scope_type()); + CHECK_EQ(data->backing_store_[index++], scope->start_position()); + CHECK_EQ(data->backing_store_[index++], scope->end_position()); + + int inner_scope_count = 0; + for (Scope* inner = scope->inner_scope(); inner != nullptr; + inner = inner->sibling()) { + if (PreParsedScopeData::HasVariablesWhichNeedAllocationData(inner)) { + ++inner_scope_count; + } + } + CHECK_EQ(data->backing_store_[index++], inner_scope_count); + + int variable_count = 0; + for (Variable* local : scope->locals_) { + if (local->mode() == VAR || local->mode() == LET || + local->mode() == CONST) { + ++variable_count; + } + } + + CHECK_EQ(data->backing_store_[index++], variable_count); + + for (Variable* local : scope->locals_) { + if (local->mode() == VAR || local->mode() == LET || + local->mode() == CONST) { +#ifdef DEBUG + const AstRawString* local_name = local->raw_name(); + int name_length = data->backing_store_[index++]; + CHECK_EQ(name_length, local_name->length()); + for (int i = 0; i < name_length; ++i) { + CHECK_EQ(data->backing_store_[index++], local_name->raw_data()[i]); + } +#endif + CHECK_EQ(data->backing_store_[index++], local->location()); + if (precise_maybe_assigned) { + CHECK_EQ(data->backing_store_[index++], local->maybe_assigned()); + } else { + STATIC_ASSERT(kMaybeAssigned > kNotAssigned); + CHECK_GE(data->backing_store_[index++], local->maybe_assigned()); + } + } + } + + for (Scope* inner = scope->inner_scope(); inner != nullptr; + inner = inner->sibling()) { + if (PreParsedScopeData::HasVariablesWhichNeedAllocationData(inner)) { + CompareScopeToData(inner, data, index, precise_maybe_assigned); + } + } + } +}; +} // namespace internal +} // namespace v8 + +#endif // V8_CCTEST_SCOPE_TEST_HELPER_H_ diff --git a/deps/v8/test/cctest/test-access-checks.cc b/deps/v8/test/cctest/test-access-checks.cc index 727444b532..f260a15c6e 100644 --- a/deps/v8/test/cctest/test-access-checks.cc +++ b/deps/v8/test/cctest/test-access-checks.cc @@ -102,6 +102,23 @@ void IndexedEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { info.GetReturnValue().Set(names); } +void MethodGetter(v8::Local<v8::Name> property, + const v8::PropertyCallbackInfo<v8::Value>& info) { + v8::Isolate* isolate = info.GetIsolate(); + v8::Local<v8::Context> context = isolate->GetCurrentContext(); + + v8::Local<v8::External> data = info.Data().As<v8::External>(); + v8::Local<v8::FunctionTemplate>& function_template = + *reinterpret_cast<v8::Local<v8::FunctionTemplate>*>(data->Value()); + + info.GetReturnValue().Set( + function_template->GetFunction(context).ToLocalChecked()); +} + +void MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { + info.GetReturnValue().Set(8); +} + void NamedGetterThrowsException( v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) { @@ -288,6 +305,44 @@ TEST(AccessCheckWithInterceptor) { CheckCrossContextAccess(isolate, context1, context0->Global()); } +TEST(CallFunctionWithRemoteContextReceiver) { + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + v8::Local<v8::FunctionTemplate> global_template = + v8::FunctionTemplate::New(isolate); + + v8::Local<v8::Signature> signature = + v8::Signature::New(isolate, global_template); + v8::Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New( + isolate, MethodCallback, v8::External::New(isolate, &function_template), + signature); + + global_template->InstanceTemplate()->SetAccessCheckCallbackAndHandler( + AccessCheck, v8::NamedPropertyHandlerConfiguration( + MethodGetter, nullptr, nullptr, nullptr, nullptr, + v8::External::New(isolate, &function_template)), + v8::IndexedPropertyHandlerConfiguration()); + + v8::Local<v8::Object> accessed_object = + v8::Context::NewRemoteContext(isolate, + global_template->InstanceTemplate()) + .ToLocalChecked(); + v8::Local<v8::Context> accessing_context = + v8::Context::New(isolate, nullptr, global_template->InstanceTemplate()); + + v8::HandleScope handle_scope(isolate); + accessing_context->Global() + ->Set(accessing_context, v8_str("other"), accessed_object) + .FromJust(); + v8::Context::Scope context_scope(accessing_context); + + { + v8::TryCatch try_catch(isolate); + ExpectInt32("this.other.method()", 8); + CHECK(!try_catch.HasCaught()); + } +} + TEST(AccessCheckWithExceptionThrowingInterceptor) { v8::Isolate* isolate = CcTest::isolate(); isolate->SetFailedAccessCheckCallbackFunction([](v8::Local<v8::Object> target, diff --git a/deps/v8/test/cctest/test-accessor-assembler.cc b/deps/v8/test/cctest/test-accessor-assembler.cc index c129bbaf13..273cdd4ff0 100644 --- a/deps/v8/test/cctest/test-accessor-assembler.cc +++ b/deps/v8/test/cctest/test-accessor-assembler.cc @@ -5,8 +5,9 @@ #include "test/cctest/cctest.h" #include "src/base/utils/random-number-generator.h" -#include "src/ic/accessor-assembler-impl.h" +#include "src/ic/accessor-assembler.h" #include "src/ic/stub-cache.h" +#include "src/objects-inl.h" #include "test/cctest/compiler/code-assembler-tester.h" #include "test/cctest/compiler/function-tester.h" @@ -23,7 +24,7 @@ void TestStubCacheOffsetCalculation(StubCache::Table table) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 2; CodeAssemblerTester data(isolate, kNumParams); - AccessorAssemblerImpl m(data.state()); + AccessorAssembler m(data.state()); { Node* name = m.Parameter(0); @@ -121,7 +122,7 @@ TEST(TryProbeStubCache) { Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 3; CodeAssemblerTester data(isolate, kNumParams); - AccessorAssemblerImpl m(data.state()); + AccessorAssembler m(data.state()); Code::Kind ic_kind = Code::LOAD_IC; StubCache stub_cache(isolate, ic_kind); diff --git a/deps/v8/test/cctest/test-accessors.cc b/deps/v8/test/cctest/test-accessors.cc index 63c25c5b8c..c38d77bd21 100644 --- a/deps/v8/test/cctest/test-accessors.cc +++ b/deps/v8/test/cctest/test-accessors.cc @@ -154,8 +154,8 @@ THREADED_TEST(GlobalVariableAccess) { v8::External::New(isolate, &baz)); LocalContext env(0, templ->InstanceTemplate()); v8_compile("foo = (++bar) + baz")->Run(env.local()).ToLocalChecked(); - CHECK_EQ(bar, -3); - CHECK_EQ(foo, 7); + CHECK_EQ(-3, bar); + CHECK_EQ(7, foo); } diff --git a/deps/v8/test/cctest/test-api-accessors.cc b/deps/v8/test/cctest/test-api-accessors.cc index cc0c7efb5f..921f54d466 100644 --- a/deps/v8/test/cctest/test-api-accessors.cc +++ b/deps/v8/test/cctest/test-api-accessors.cc @@ -249,6 +249,89 @@ TEST(CachedAccessorCrankshaft) { ExpectInt32("g()", 789); } +TEST(CachedAccessorOnGlobalObject) { + i::FLAG_allow_natives_syntax = true; + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + + v8::Local<v8::FunctionTemplate> templ = + v8::FunctionTemplate::New(CcTest::isolate()); + v8::Local<v8::ObjectTemplate> object_template = templ->InstanceTemplate(); + v8::Local<v8::Private> priv = + v8::Private::ForApi(isolate, v8_str("Foo#draft")); + + object_template->SetAccessorProperty( + v8_str("draft"), + v8::FunctionTemplate::NewWithCache(isolate, UnreachableCallback, priv, + v8::Local<v8::Value>())); + + v8::Local<v8::Context> ctx = + v8::Context::New(CcTest::isolate(), nullptr, object_template); + v8::Local<v8::Object> obj = ctx->Global(); + + // Install the private property on the instance. + CHECK(obj->SetPrivate(isolate->GetCurrentContext(), priv, + v8::Undefined(isolate)) + .FromJust()); + + { + v8::Context::Scope context_scope(ctx); + + // Access surrogate accessor. + ExpectUndefined("draft"); + + // Set hidden property. + CHECK(obj->SetPrivate(env.local(), priv, v8::Integer::New(isolate, 123)) + .FromJust()); + + // Test ICs. + CompileRun( + "function f() {" + " var x;" + " for (var i = 0; i < 100; i++) {" + " x = draft;" + " }" + " return x;" + "}"); + + ExpectInt32("f()", 123); + + // Reset hidden property. + CHECK(obj->SetPrivate(env.local(), priv, v8::Integer::New(isolate, 456)) + .FromJust()); + + // Test Crankshaft. + CompileRun("%OptimizeFunctionOnNextCall(f);"); + + ExpectInt32("f()", 456); + + CHECK(obj->SetPrivate(env.local(), priv, v8::Integer::New(isolate, 456)) + .FromJust()); + // Test non-global ICs. + CompileRun( + "var x = this;" + "function g() {" + " var r = 0;" + " for (var i = 0; i < 100; i++) {" + " r = x.draft;" + " }" + " return r;" + "}"); + + ExpectInt32("g()", 456); + + // Reset hidden property. + CHECK(obj->SetPrivate(env.local(), priv, v8::Integer::New(isolate, 789)) + .FromJust()); + + // Test non-global access in Crankshaft. + CompileRun("%OptimizeFunctionOnNextCall(g);"); + + ExpectInt32("g()", 789); + } +} + namespace { static void Setter(v8::Local<v8::String> name, v8::Local<v8::Value> value, diff --git a/deps/v8/test/cctest/test-api-interceptors.cc b/deps/v8/test/cctest/test-api-interceptors.cc index 66f0a0b0eb..955b8f4df5 100644 --- a/deps/v8/test/cctest/test-api-interceptors.cc +++ b/deps/v8/test/cctest/test-api-interceptors.cc @@ -12,7 +12,9 @@ #include "src/base/platform/platform.h" #include "src/compilation-cache.h" #include "src/execution.h" +#include "src/objects-inl.h" #include "src/objects.h" +#include "src/runtime/runtime.h" #include "src/unicode-inl.h" #include "src/utils.h" @@ -403,12 +405,12 @@ THREADED_TEST(QueryInterceptor) { ->NewInstance(env.local()) .ToLocalChecked()) .FromJust(); - CHECK_EQ(query_counter_int, 0); + CHECK_EQ(0, query_counter_int); v8::Local<Value> result = v8_compile("Object.getOwnPropertyDescriptor(obj, 'x');") ->Run(env.local()) .ToLocalChecked(); - CHECK_EQ(query_counter_int, 1); + CHECK_EQ(1, query_counter_int); CHECK_EQ(v8::PropertyAttribute::None, static_cast<v8::PropertyAttribute>( result->Int32Value(env.local()).FromJust())); @@ -416,64 +418,64 @@ THREADED_TEST(QueryInterceptor) { v8_compile("Object.defineProperty(obj, 'not_enum', {value: 17});") ->Run(env.local()) .ToLocalChecked(); - CHECK_EQ(query_counter_int, 2); + CHECK_EQ(2, query_counter_int); v8_compile( "Object.defineProperty(obj, 'enum', {value: 17, enumerable: true, " "writable: true});") ->Run(env.local()) .ToLocalChecked(); - CHECK_EQ(query_counter_int, 3); + CHECK_EQ(3, query_counter_int); CHECK(v8_compile("obj.propertyIsEnumerable('enum');") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()); - CHECK_EQ(query_counter_int, 4); + CHECK_EQ(4, query_counter_int); CHECK(!v8_compile("obj.propertyIsEnumerable('not_enum');") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()); - CHECK_EQ(query_counter_int, 5); + CHECK_EQ(5, query_counter_int); CHECK(v8_compile("obj.hasOwnProperty('enum');") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()); - CHECK_EQ(query_counter_int, 5); + CHECK_EQ(5, query_counter_int); CHECK(v8_compile("obj.hasOwnProperty('not_enum');") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()); - CHECK_EQ(query_counter_int, 5); + CHECK_EQ(5, query_counter_int); CHECK(!v8_compile("obj.hasOwnProperty('x');") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()); - CHECK_EQ(query_counter_int, 6); + CHECK_EQ(6, query_counter_int); CHECK(!v8_compile("obj.propertyIsEnumerable('undef');") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()); - CHECK_EQ(query_counter_int, 7); + CHECK_EQ(7, query_counter_int); v8_compile("Object.defineProperty(obj, 'enum', {value: 42});") ->Run(env.local()) .ToLocalChecked(); - CHECK_EQ(query_counter_int, 8); + CHECK_EQ(8, query_counter_int); v8_compile("Object.isFrozen('obj.x');")->Run(env.local()).ToLocalChecked(); - CHECK_EQ(query_counter_int, 8); + CHECK_EQ(8, query_counter_int); } namespace { @@ -494,6 +496,12 @@ void SetterCallback(Local<Name> property, Local<Value> value, set_was_called_counter++; } +void InterceptingSetterCallback( + Local<Name> property, Local<Value> value, + const v8::PropertyCallbackInfo<v8::Value>& info) { + info.GetReturnValue().Set(value); +} + } // namespace // Check that get callback is called in defineProperty with accessor descriptor. @@ -517,8 +525,8 @@ THREADED_TEST(DefinerCallbackAccessorInterceptor) { v8_compile("Object.defineProperty(obj, 'x', {set: function() {return 17;}});") ->Run(env.local()) .ToLocalChecked(); - CHECK_EQ(get_was_called, true); - CHECK_EQ(set_was_called, false); + CHECK(get_was_called); + CHECK(!set_was_called); } // Check that set callback is called for function declarations. @@ -544,7 +552,7 @@ THREADED_TEST(SetterCallbackFunctionDeclarationInterceptor) { .ToLocalChecked() ->Int32Value(ctx) .FromJust()); - CHECK_EQ(set_was_called_counter, 1); + CHECK_EQ(1, set_was_called_counter); // Redeclare function. code = v8_str("function x() {return 43;}; x();"); @@ -554,7 +562,7 @@ THREADED_TEST(SetterCallbackFunctionDeclarationInterceptor) { .ToLocalChecked() ->Int32Value(ctx) .FromJust()); - CHECK_EQ(set_was_called_counter, 2); + CHECK_EQ(2, set_was_called_counter); // Redefine function. code = v8_str("x = function() {return 44;}; x();"); @@ -564,7 +572,99 @@ THREADED_TEST(SetterCallbackFunctionDeclarationInterceptor) { .ToLocalChecked() ->Int32Value(ctx) .FromJust()); - CHECK_EQ(set_was_called_counter, 3); + CHECK_EQ(3, set_was_called_counter); +} + +namespace { +int descriptor_was_called; + +void PropertyDescriptorCallback( + Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + // Intercept the callback by setting a different descriptor. + descriptor_was_called++; + const char* code = + "var desc = {value: 5};" + "desc;"; + Local<Value> descriptor = v8_compile(code) + ->Run(info.GetIsolate()->GetCurrentContext()) + .ToLocalChecked(); + info.GetReturnValue().Set(descriptor); +} +} // namespace + +// Check that the descriptor callback is called on the global object. +THREADED_TEST(DescriptorCallbackOnGlobalObject) { + v8::HandleScope scope(CcTest::isolate()); + LocalContext env; + v8::Local<v8::FunctionTemplate> templ = + v8::FunctionTemplate::New(CcTest::isolate()); + + v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate(); + object_template->SetHandler(v8::NamedPropertyHandlerConfiguration( + nullptr, nullptr, PropertyDescriptorCallback, nullptr, nullptr, nullptr)); + v8::Local<v8::Context> ctx = + v8::Context::New(CcTest::isolate(), nullptr, object_template); + + descriptor_was_called = 0; + + // Declare function. + v8::Local<v8::String> code = v8_str( + "var x = 42; var desc = Object.getOwnPropertyDescriptor(this, 'x'); " + "desc.value;"); + CHECK_EQ(5, v8::Script::Compile(ctx, code) + .ToLocalChecked() + ->Run(ctx) + .ToLocalChecked() + ->Int32Value(ctx) + .FromJust()); + CHECK_EQ(1, descriptor_was_called); +} + +namespace { +void QueryCallbackSetDontDelete( + Local<Name> property, const v8::PropertyCallbackInfo<v8::Integer>& info) { + info.GetReturnValue().Set(v8::PropertyAttribute::DontDelete); +} + +} // namespace + +// Regression for a Node.js test that fails in debug mode. +THREADED_TEST(InterceptorFunctionRedeclareWithQueryCallback) { + v8::HandleScope scope(CcTest::isolate()); + LocalContext env; + v8::Local<v8::FunctionTemplate> templ = + v8::FunctionTemplate::New(CcTest::isolate()); + + v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate(); + object_template->SetHandler(v8::NamedPropertyHandlerConfiguration( + nullptr, nullptr, QueryCallbackSetDontDelete)); + v8::Local<v8::Context> ctx = + v8::Context::New(CcTest::isolate(), nullptr, object_template); + + // Declare and redeclare function. + v8::Local<v8::String> code = v8_str( + "function x() {return 42;};" + "function x() {return 43;};"); + v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).ToLocalChecked(); +} + +// Regression test for chromium bug 656648. +// Do not crash on non-masking, intercepting setter callbacks. +THREADED_TEST(NonMaskingInterceptor) { + v8::HandleScope scope(CcTest::isolate()); + LocalContext env; + v8::Local<v8::FunctionTemplate> templ = + v8::FunctionTemplate::New(CcTest::isolate()); + + v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate(); + object_template->SetHandler(v8::NamedPropertyHandlerConfiguration( + nullptr, InterceptingSetterCallback, nullptr, nullptr, nullptr, + Local<Value>(), v8::PropertyHandlerFlags::kNonMasking)); + v8::Local<v8::Context> ctx = + v8::Context::New(CcTest::isolate(), nullptr, object_template); + + v8::Local<v8::String> code = v8_str("function x() {return 43;};"); + v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).ToLocalChecked(); } // Check that function re-declarations throw if they are read-only. @@ -595,7 +695,7 @@ THREADED_TEST(SetterCallbackFunctionDeclarationInterceptorThrow) { ->Int32Value(ctx) .FromJust()); - CHECK_EQ(set_was_called, true); + CHECK(set_was_called); v8::TryCatch try_catch(CcTest::isolate()); set_was_called = false; @@ -605,51 +705,7 @@ THREADED_TEST(SetterCallbackFunctionDeclarationInterceptorThrow) { CHECK(v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).IsEmpty()); CHECK(try_catch.HasCaught()); - CHECK_EQ(set_was_called, false); -} -namespace { -int descriptor_was_called; - -void PropertyDescriptorCallback( - Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - // Intercept the callback by setting a different descriptor. - descriptor_was_called++; - const char* code = - "var desc = {value: 5};" - "desc;"; - Local<Value> descriptor = v8_compile(code) - ->Run(info.GetIsolate()->GetCurrentContext()) - .ToLocalChecked(); - info.GetReturnValue().Set(descriptor); -} -} // namespace - -// Check that the descriptor callback is called on the global object. -THREADED_TEST(DescriptorCallbackOnGlobalObject) { - v8::HandleScope scope(CcTest::isolate()); - LocalContext env; - v8::Local<v8::FunctionTemplate> templ = - v8::FunctionTemplate::New(CcTest::isolate()); - - v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate(); - object_template->SetHandler(v8::NamedPropertyHandlerConfiguration( - nullptr, nullptr, PropertyDescriptorCallback, nullptr, nullptr, nullptr)); - v8::Local<v8::Context> ctx = - v8::Context::New(CcTest::isolate(), nullptr, object_template); - - descriptor_was_called = 0; - - // Declare function. - v8::Local<v8::String> code = v8_str( - "var x = 42; var desc = Object.getOwnPropertyDescriptor(this, 'x'); " - "desc.value;"); - CHECK_EQ(5, v8::Script::Compile(ctx, code) - .ToLocalChecked() - ->Run(ctx) - .ToLocalChecked() - ->Int32Value(ctx) - .FromJust()); - CHECK_EQ(1, descriptor_was_called); + CHECK(!set_was_called); } @@ -661,14 +717,14 @@ bool define_was_called_in_order = false; void GetterCallbackOrder(Local<Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) { get_was_called_in_order = true; - CHECK_EQ(define_was_called_in_order, true); + CHECK(define_was_called_in_order); info.GetReturnValue().Set(property); } void DefinerCallbackOrder(Local<Name> property, const v8::PropertyDescriptor& desc, const v8::PropertyCallbackInfo<v8::Value>& info) { - CHECK_EQ(get_was_called_in_order, false); // Define called before get. + CHECK(!get_was_called_in_order); // Define called before get. define_was_called_in_order = true; } @@ -689,14 +745,14 @@ THREADED_TEST(DefinerCallbackGetAndDefine) { .ToLocalChecked()) .FromJust(); - CHECK_EQ(get_was_called_in_order, false); - CHECK_EQ(define_was_called_in_order, false); + CHECK(!get_was_called_in_order); + CHECK(!define_was_called_in_order); v8_compile("Object.defineProperty(obj, 'x', {set: function() {return 17;}});") ->Run(env.local()) .ToLocalChecked(); - CHECK_EQ(get_was_called_in_order, true); - CHECK_EQ(define_was_called_in_order, true); + CHECK(get_was_called_in_order); + CHECK(define_was_called_in_order); } namespace { // namespace for InObjectLiteralDefinitionWithInterceptor @@ -777,15 +833,15 @@ THREADED_TEST(InterceptorHasOwnProperty) { v8::Local<Value> value = CompileRun( "var o = new constructor();" "o.hasOwnProperty('ostehaps');"); - CHECK_EQ(false, value->BooleanValue(context.local()).FromJust()); + CHECK(!value->BooleanValue(context.local()).FromJust()); value = CompileRun( "o.ostehaps = 42;" "o.hasOwnProperty('ostehaps');"); - CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(context.local()).FromJust()); value = CompileRun( "var p = new constructor();" "p.hasOwnProperty('ostehaps');"); - CHECK_EQ(false, value->BooleanValue(context.local()).FromJust()); + CHECK(!value->BooleanValue(context.local()).FromJust()); } @@ -819,7 +875,7 @@ THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { "var o = new constructor();" "o.__proto__ = new String(x);" "o.hasOwnProperty('ostehaps');"); - CHECK_EQ(false, value->BooleanValue(context.local()).FromJust()); + CHECK(!value->BooleanValue(context.local()).FromJust()); } @@ -1295,7 +1351,7 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) { " f();" "};" "f();"); - CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(context.local()).FromJust()); value = CompileRun( "var f = function() { " @@ -1310,7 +1366,7 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) { " f();" "};" "f();"); - CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(context.local()).FromJust()); value = CompileRun( "var f = function() { " @@ -1325,7 +1381,7 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) { " f();" "};" "f();"); - CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(context.local()).FromJust()); } static void InterceptorLoadICGetter0( @@ -1492,9 +1548,9 @@ THREADED_TEST(NamedPropertyHandlerGetter) { ->NewInstance(env.local()) .ToLocalChecked()) .FromJust(); - CHECK_EQ(echo_named_call_count, 0); + CHECK_EQ(0, echo_named_call_count); v8_compile("obj.x")->Run(env.local()).ToLocalChecked(); - CHECK_EQ(echo_named_call_count, 1); + CHECK_EQ(1, echo_named_call_count); const char* code = "var str = 'oddle'; obj[str] + obj.poddle;"; v8::Local<Value> str = CompileRun(code); String::Utf8Value value(str); @@ -2044,11 +2100,10 @@ THREADED_TEST(IndexedPropertyHandlerGetter) { .ToLocalChecked()) .FromJust(); Local<Script> script = v8_compile("obj[900]"); - CHECK_EQ(script->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust(), - 900); + CHECK_EQ(900, script->Run(env.local()) + .ToLocalChecked() + ->Int32Value(env.local()) + .FromJust()); } @@ -2674,7 +2729,7 @@ THREADED_TEST(NamedInterceptorMapTransitionRead) { CompileRun("var o = new F(); o.x = 23;"); // Create an instance of F and invoke the getter. The result should be 23. Local<Value> result = CompileRun("o = new F(); o.x"); - CHECK_EQ(result->Int32Value(context.local()).FromJust(), 23); + CHECK_EQ(23, result->Int32Value(context.local()).FromJust()); } @@ -3978,7 +4033,7 @@ THREADED_TEST(InterceptorICReferenceErrors) { " return false;" "};" "f();"); - CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(context.local()).FromJust()); interceptor_call_count = 0; value = CompileRun( "function g() {" @@ -3988,7 +4043,7 @@ THREADED_TEST(InterceptorICReferenceErrors) { " return false;" "};" "g();"); - CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(context.local()).FromJust()); } @@ -4034,7 +4089,7 @@ THREADED_TEST(InterceptorICGetterExceptions) { " return false;" "};" "f();"); - CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(context.local()).FromJust()); interceptor_ic_exception_get_count = 0; value = CompileRun( "function f() {" @@ -4044,7 +4099,7 @@ THREADED_TEST(InterceptorICGetterExceptions) { " return false;" "};" "f();"); - CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(context.local()).FromJust()); } @@ -4078,7 +4133,7 @@ THREADED_TEST(InterceptorICSetterExceptions) { " return false;" "};" "f();"); - CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(context.local()).FromJust()); } @@ -4137,6 +4192,7 @@ THREADED_TEST(NamedPropertyHandlerGetterAttributes) { THREADED_TEST(Regress256330) { + if (!i::FLAG_crankshaft) return; i::FLAG_allow_natives_syntax = true; LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -4152,7 +4208,10 @@ THREADED_TEST(Regress256330) { "f(o); f(o); f(o);" "%OptimizeFunctionOnNextCall(f);" "f(o);"); - ExpectBoolean("%GetOptimizationStatus(f) != 2", true); + int status = v8_run_int32value(v8_compile("%GetOptimizationStatus(f)")); + int mask = static_cast<int>(i::OptimizationStatus::kIsFunction) | + static_cast<int>(i::OptimizationStatus::kOptimized); + CHECK_EQ(mask, status & mask); } diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 24cbafbab1..2787e21d77 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -46,7 +46,9 @@ #include "src/debug/debug.h" #include "src/execution.h" #include "src/futex-emulation.h" -#include "src/objects.h" +#include "src/heap/incremental-marking.h" +#include "src/lookup.h" +#include "src/objects-inl.h" #include "src/parsing/preparse-data.h" #include "src/profiler/cpu-profiler.h" #include "src/unicode-inl.h" @@ -508,8 +510,8 @@ THREADED_TEST(ScriptMakingExternalString) { // Trigger GCs so that the newly allocated string moves to old gen. CcTest::CollectGarbage(i::NEW_SPACE); // in survivor space now CcTest::CollectGarbage(i::NEW_SPACE); // in old gen now - CHECK_EQ(source->IsExternal(), false); - CHECK_EQ(source->IsExternalOneByte(), false); + CHECK(!source->IsExternal()); + CHECK(!source->IsExternalOneByte()); String::Encoding encoding = String::UNKNOWN_ENCODING; CHECK(!source->GetExternalStringResourceBase(&encoding)); CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); @@ -1722,7 +1724,7 @@ THREADED_TEST(BooleanObject) { v8::Local<v8::BooleanObject> as_boxed = boxed_boolean.As<v8::BooleanObject>(); CHECK(!as_boxed.IsEmpty()); bool the_boolean = as_boxed->ValueOf(); - CHECK_EQ(true, the_boolean); + CHECK(the_boolean); v8::Local<v8::Value> boxed_true = v8::BooleanObject::New(env->GetIsolate(), true); v8::Local<v8::Value> boxed_false = @@ -1730,9 +1732,9 @@ THREADED_TEST(BooleanObject) { CHECK(boxed_true->IsBooleanObject()); CHECK(boxed_false->IsBooleanObject()); as_boxed = boxed_true.As<v8::BooleanObject>(); - CHECK_EQ(true, as_boxed->ValueOf()); + CHECK(as_boxed->ValueOf()); as_boxed = boxed_false.As<v8::BooleanObject>(); - CHECK_EQ(false, as_boxed->ValueOf()); + CHECK(!as_boxed->ValueOf()); } @@ -2481,7 +2483,7 @@ THREADED_TEST(AccessorIsPreservedOnAttributeChange) { CHECK(a->map()->instance_descriptors()->IsFixedArray()); CHECK_GT(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0); CompileRun("Object.defineProperty(a, 'length', { writable: false });"); - CHECK_EQ(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0); + CHECK_EQ(0, i::FixedArray::cast(a->map()->instance_descriptors())->length()); // But we should still have an AccessorInfo. i::Handle<i::String> name(v8::Utils::OpenHandle(*v8_str("length"))); i::LookupIterator it(a, name, i::LookupIterator::OWN_SKIP_INTERCEPTOR); @@ -3931,7 +3933,7 @@ THREADED_TEST(External) { Local<Value> reext_obj = CompileRun("this.ext"); v8::Local<v8::External> reext = reext_obj.As<v8::External>(); int* ptr = static_cast<int*>(reext->Value()); - CHECK_EQ(x, 3); + CHECK_EQ(3, x); *ptr = 10; CHECK_EQ(x, 10); @@ -3963,7 +3965,7 @@ THREADED_TEST(GlobalHandle) { } { v8::HandleScope scope(isolate); - CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); + CHECK_EQ(3, v8::Local<String>::New(isolate, global)->Length()); } global.Reset(); { @@ -3972,7 +3974,7 @@ THREADED_TEST(GlobalHandle) { } { v8::HandleScope scope(isolate); - CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); + CHECK_EQ(3, v8::Local<String>::New(isolate, global)->Length()); } global.Reset(); } @@ -3990,7 +3992,7 @@ THREADED_TEST(ResettingGlobalHandle) { int initial_handle_count = global_handles->global_handles_count(); { v8::HandleScope scope(isolate); - CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); + CHECK_EQ(3, v8::Local<String>::New(isolate, global)->Length()); } { v8::HandleScope scope(isolate); @@ -3999,7 +4001,7 @@ THREADED_TEST(ResettingGlobalHandle) { CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); { v8::HandleScope scope(isolate); - CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 6); + CHECK_EQ(6, v8::Local<String>::New(isolate, global)->Length()); } global.Reset(); CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); @@ -4018,7 +4020,7 @@ THREADED_TEST(ResettingGlobalHandleToEmpty) { int initial_handle_count = global_handles->global_handles_count(); { v8::HandleScope scope(isolate); - CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); + CHECK_EQ(3, v8::Local<String>::New(isolate, global)->Length()); } { v8::HandleScope scope(isolate); @@ -4416,29 +4418,29 @@ THREADED_TEST(HandleEquality) { global1.Reset(isolate, v8_str("str")); global2.Reset(isolate, v8_str("str2")); } - CHECK_EQ(global1 == global1, true); - CHECK_EQ(global1 != global1, false); + CHECK(global1 == global1); + CHECK(!(global1 != global1)); { v8::HandleScope scope(isolate); Local<String> local1 = Local<String>::New(isolate, global1); Local<String> local2 = Local<String>::New(isolate, global2); - CHECK_EQ(global1 == local1, true); - CHECK_EQ(global1 != local1, false); - CHECK_EQ(local1 == global1, true); - CHECK_EQ(local1 != global1, false); + CHECK(global1 == local1); + CHECK(!(global1 != local1)); + CHECK(local1 == global1); + CHECK(!(local1 != global1)); - CHECK_EQ(global1 == local2, false); - CHECK_EQ(global1 != local2, true); - CHECK_EQ(local2 == global1, false); - CHECK_EQ(local2 != global1, true); + CHECK(!(global1 == local2)); + CHECK(global1 != local2); + CHECK(!(local2 == global1)); + CHECK(local2 != global1); - CHECK_EQ(local1 == local2, false); - CHECK_EQ(local1 != local2, true); + CHECK(!(local1 == local2)); + CHECK(local1 != local2); Local<String> anotherLocal1 = Local<String>::New(isolate, global1); - CHECK_EQ(local1 == anotherLocal1, true); - CHECK_EQ(local1 != anotherLocal1, false); + CHECK(local1 == anotherLocal1); + CHECK(!(local1 != anotherLocal1)); } global1.Reset(); global2.Reset(); @@ -4449,7 +4451,7 @@ THREADED_TEST(LocalHandle) { v8::HandleScope scope(CcTest::isolate()); v8::Local<String> local = v8::Local<String>::New(CcTest::isolate(), v8_str("str")); - CHECK_EQ(local->Length(), 3); + CHECK_EQ(3, local->Length()); } @@ -6284,7 +6286,7 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) { "obj, 'x');" "prop.configurable;"); Local<Value> result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true); + CHECK(result->BooleanValue(context.local()).FromJust()); // Redefine get - but still configurable Local<Script> script_define = v8_compile( @@ -6297,7 +6299,7 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) { // Check that the accessor is still configurable result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true); + CHECK(result->BooleanValue(context.local()).FromJust()); // Redefine to a non-configurable script_define = v8_compile( @@ -6308,7 +6310,7 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) { result = script_define->Run(context.local()).ToLocalChecked(); CHECK(result->Equals(context.local(), v8_num(43)).FromJust()); result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK_EQ(result->BooleanValue(context.local()).FromJust(), false); + CHECK(!result->BooleanValue(context.local()).FromJust()); // Make sure that it is not possible to redefine again v8::TryCatch try_catch(isolate); @@ -6337,7 +6339,7 @@ THREADED_TEST(DefinePropertyOnDefineGetterSetter) { "obj, 'x');" "prop.configurable;"); Local<Value> result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true); + CHECK(result->BooleanValue(context.local()).FromJust()); Local<Script> script_define = v8_compile( "var desc = {get: function(){return 42; }," @@ -6348,7 +6350,7 @@ THREADED_TEST(DefinePropertyOnDefineGetterSetter) { CHECK(result->Equals(context.local(), v8_num(42)).FromJust()); result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true); + CHECK(result->BooleanValue(context.local()).FromJust()); script_define = v8_compile( "var desc = {get: function(){return 43; }," @@ -6359,7 +6361,7 @@ THREADED_TEST(DefinePropertyOnDefineGetterSetter) { CHECK(result->Equals(context.local(), v8_num(43)).FromJust()); result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK_EQ(result->BooleanValue(context.local()).FromJust(), false); + CHECK(!result->BooleanValue(context.local()).FromJust()); v8::TryCatch try_catch(isolate); CHECK(script_define->Run(context.local()).IsEmpty()); @@ -6459,14 +6461,14 @@ THREADED_TEST(DefineAPIAccessorOnObject) { ExpectString("obj1.x", "z"); ExpectString("obj2.x", "z"); - CHECK(GetGlobalProperty(&context, "obj1") + CHECK(!GetGlobalProperty(&context, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL, v8_str("donut")) - .IsNothing()); - CHECK(GetGlobalProperty(&context, "obj2") + .FromJust()); + CHECK(!GetGlobalProperty(&context, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL, v8_str("donut")) - .IsNothing()); + .FromJust()); ExpectString("obj1.x", "z"); ExpectString("obj2.x", "z"); @@ -6500,14 +6502,14 @@ THREADED_TEST(DontDeleteAPIAccessorsCannotBeOverriden) { ExpectTrue("!Object.getOwnPropertyDescriptor(obj1, 'x').configurable"); ExpectTrue("!Object.getOwnPropertyDescriptor(obj2, 'x').configurable"); - CHECK(GetGlobalProperty(&context, "obj1") + CHECK(!GetGlobalProperty(&context, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL, v8_str("donut")) - .IsNothing()); - CHECK(GetGlobalProperty(&context, "obj2") + .FromJust()); + CHECK(!GetGlobalProperty(&context, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL, v8_str("donut")) - .IsNothing()); + .FromJust()); { v8::TryCatch try_catch(isolate); @@ -7459,7 +7461,8 @@ static void IndependentWeakHandle(bool global_gc, bool interlinked) { FlagAndPersistent object_a, object_b; - size_t big_heap_size; + size_t big_heap_size = 0; + size_t big_array_size = 0; { v8::HandleScope handle_scope(iso); @@ -7476,9 +7479,13 @@ static void IndependentWeakHandle(bool global_gc, bool interlinked) { } else { CcTest::CollectGarbage(i::NEW_SPACE); } - // We are relying on this creating a big flag array and reserving the space - // up front. - v8::Local<Value> big_array = CompileRun("new Array(5000)"); + v8::Local<Value> big_array = v8::Array::New(CcTest::isolate(), 5000); + // Verify that we created an array where the space was reserved up front. + big_array_size = + v8::internal::JSArray::cast(*v8::Utils::OpenHandle(*big_array)) + ->elements() + ->Size(); + CHECK_LE(20000, big_array_size); a->Set(context, v8_str("y"), big_array).FromJust(); big_heap_size = CcTest::heap()->SizeOfObjects(); } @@ -7500,8 +7507,7 @@ static void IndependentWeakHandle(bool global_gc, bool interlinked) { } // A single GC should be enough to reclaim the memory, since we are using // phantom handles. - // BUG(5865): --expose-wasm with no snapshot builds requires a limit change. - CHECK_LT(CcTest::heap()->SizeOfObjects(), big_heap_size - 19000); + CHECK_GT(big_heap_size - big_array_size, CcTest::heap()->SizeOfObjects()); CHECK(object_a.flag); CHECK(object_b.flag); } @@ -7566,13 +7572,14 @@ void InternalFieldCallback(bool global_gc) { Trivial* t1; Trivial2* t2; instance_templ->SetInternalFieldCount(2); + v8::Persistent<v8::Object> handle; { v8::HandleScope scope(isolate); Local<v8::Object> obj = templ->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked(); - v8::Persistent<v8::Object> handle(isolate, obj); + handle.Reset(isolate, obj); CHECK_EQ(2, obj->InternalFieldCount()); CHECK(obj->GetInternalField(0)->IsUndefined()); t1 = new Trivial(42); @@ -11085,7 +11092,7 @@ THREADED_TEST(ConstructorForObject) { value = CompileRun("(function() { var o = new obj(true); return o.a; })()"); CHECK(!try_catch.HasCaught()); CHECK(value->IsBoolean()); - CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(context.local()).FromJust()); Local<Value> args3[] = {v8::True(isolate)}; Local<Value> value_obj3 = @@ -11095,7 +11102,7 @@ THREADED_TEST(ConstructorForObject) { value = object3->Get(context.local(), v8_str("a")).ToLocalChecked(); CHECK(!try_catch.HasCaught()); CHECK(value->IsBoolean()); - CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(context.local()).FromJust()); // Call the Object's constructor with undefined. Local<Value> args4[] = {v8::Undefined(isolate)}; @@ -13696,9 +13703,6 @@ static void CheckSurvivingGlobalObjectsCount(int expected) { CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); CcTest::CollectAllGarbage(i::Heap::kMakeHeapIterableMask); int count = GetGlobalObjectsCount(); -#ifdef DEBUG - if (count != expected) CcTest::heap()->TracePathToGlobal(); -#endif CHECK_EQ(expected, count); } @@ -16156,7 +16160,7 @@ static void ObjectWithExternalArrayTestHelper(Local<Context> context, "caught_exception;", element_count); result = CompileRun(test_buf.start()); - CHECK_EQ(false, result->BooleanValue(context).FromJust()); + CHECK(!result->BooleanValue(context).FromJust()); // Make sure out-of-range stores do not throw. i::SNPrintF(test_buf, @@ -16169,7 +16173,7 @@ static void ObjectWithExternalArrayTestHelper(Local<Context> context, "caught_exception;", element_count); result = CompileRun(test_buf.start()); - CHECK_EQ(false, result->BooleanValue(context).FromJust()); + CHECK(!result->BooleanValue(context).FromJust()); // Check other boundary conditions, values and operations. result = CompileRun("for (var i = 0; i < 8; i++) {" @@ -16261,7 +16265,7 @@ static void ObjectWithExternalArrayTestHelper(Local<Context> context, unsigned_data : (is_pixel_data ? pixel_data : signed_data))); result = CompileRun(test_buf.start()); - CHECK_EQ(true, result->BooleanValue(context).FromJust()); + CHECK(result->BooleanValue(context).FromJust()); } i::Handle<ExternalArrayClass> array(ExternalArrayClass::cast( @@ -17907,7 +17911,7 @@ TEST(PromiseHook) { CHECK(GetPromise("p")->Equals(env.local(), init_promise).FromJust()); auto init_promise_obj = v8::Local<v8::Promise>::Cast(init_promise); CHECK(init_promise_obj->State() == v8::Promise::PromiseState::kPending); - CHECK_EQ(false, init_promise_obj->HasHandler()); + CHECK(!init_promise_obj->HasHandler()); promise_hook_data->Reset(); promise_hook_data->promise_hook_value = "fulfilled"; @@ -18985,7 +18989,7 @@ THREADED_TEST(FunctionGetDebugName) { .ToLocalChecked(); v8::Local<v8::Value> error = env->Global()->Get(env.local(), v8_str("error")).ToLocalChecked(); - CHECK_EQ(false, error->BooleanValue(env.local()).FromJust()); + CHECK(!error->BooleanValue(env.local()).FromJust()); const char* functions[] = {"a", "display_a", "b", "display_b", "c", "c", @@ -19068,7 +19072,7 @@ THREADED_TEST(FunctionGetDisplayName) { env->Global()->Get(env.local(), v8_str("f")).ToLocalChecked()); v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( env->Global()->Get(env.local(), v8_str("g")).ToLocalChecked()); - CHECK_EQ(false, error->BooleanValue(env.local()).FromJust()); + CHECK(!error->BooleanValue(env.local()).FromJust()); CHECK_EQ(0, strcmp("display_a", *v8::String::Utf8Value(a->GetDisplayName()))); CHECK_EQ(0, strcmp("display_b", *v8::String::Utf8Value(b->GetDisplayName()))); CHECK(c->GetDisplayName()->IsUndefined()); @@ -19915,10 +19919,10 @@ static void BreakArrayGuarantees(const char* script) { v8::Context::Scope context_scope(context); v8::internal::Isolate* i_isolate = reinterpret_cast<v8::internal::Isolate*>(isolate1); - CHECK_EQ(true, i_isolate->IsFastArrayConstructorPrototypeChainIntact()); + CHECK(i_isolate->IsFastArrayConstructorPrototypeChainIntact()); // Run something in new isolate. CompileRun(script); - CHECK_EQ(false, i_isolate->IsFastArrayConstructorPrototypeChainIntact()); + CHECK(!i_isolate->IsFastArrayConstructorPrototypeChainIntact()); } isolate1->Exit(); isolate1->Dispose(); @@ -20224,7 +20228,7 @@ static void InitializeTestHelper(InitDefaultIsolateThread::TestCase testCase) { InitDefaultIsolateThread thread(testCase); thread.Start(); thread.Join(); - CHECK_EQ(thread.result(), true); + CHECK(thread.result()); } @@ -21861,7 +21865,9 @@ namespace { const char* kMegamorphicTestProgram = "function CreateClass(name) {\n" " var src = \n" - " ` function ${name}() { this.a = 0; };` +\n" + // Disable constant tracking of "a" field by assigning different Smi values + // twice to ease megamorphic probes counting. + " ` function ${name}() { this.a = 0; this.a = 1; };` +\n" " ` ${name}.prototype.foo = function() {};` +\n" " ` ${name};\\n`;\n" " return (0, eval)(src);\n" @@ -22115,10 +22121,11 @@ static void CheckInstanceCheckedAccessors(bool expects_callbacks) { CheckInstanceCheckedResult(5, 5, expects_callbacks, &try_catch); // Cleanup so that closures start out fresh in next check. - CompileRun("%DeoptimizeFunction(test_get);" - "%ClearFunctionTypeFeedback(test_get);" - "%DeoptimizeFunction(test_set);" - "%ClearFunctionTypeFeedback(test_set);"); + CompileRun( + "%DeoptimizeFunction(test_get);" + "%ClearFunctionFeedback(test_get);" + "%DeoptimizeFunction(test_set);" + "%ClearFunctionFeedback(test_set);"); } @@ -24535,7 +24542,7 @@ void RunStreamingTest(const char** chunks, delete task; // Possible errors are only produced while compiling. - CHECK_EQ(false, try_catch.HasCaught()); + CHECK(!try_catch.HasCaught()); v8::ScriptOrigin origin(v8_str("http://foo.com")); char* full_source = TestSourceStream::FullSourceString(chunks); @@ -24943,7 +24950,7 @@ TEST(StreamingWithHarmonyScopes) { // Parsing should succeed (the script will be parsed and compiled in a context // independent way, so the error is not detected). - CHECK_EQ(false, try_catch.HasCaught()); + CHECK(!try_catch.HasCaught()); v8::ScriptOrigin origin(v8_str("http://foo.com")); char* full_source = TestSourceStream::FullSourceString(chunks); @@ -24952,7 +24959,7 @@ TEST(StreamingWithHarmonyScopes) { origin) .ToLocalChecked(); CHECK(!script.IsEmpty()); - CHECK_EQ(false, try_catch.HasCaught()); + CHECK(!try_catch.HasCaught()); // Running the script exposes the error. CHECK(script->Run(env.local()).IsEmpty()); @@ -25456,7 +25463,7 @@ TEST(ExtrasUtilsObject) { .ToLocalChecked() .As<v8::Symbol>(); i::Handle<i::Symbol> ips = v8::Utils::OpenHandle(*private_symbol); - CHECK_EQ(true, ips->IsPrivate()); + CHECK(ips->IsPrivate()); CompileRun("var result = 0; function store(x) { result = x; }"); auto store = CompileRun("store").As<v8::Function>(); @@ -25487,7 +25494,7 @@ TEST(ExtrasUtilsObject) { result->Get(env.local(), v8_str("rejectedButHandledPromise")) .ToLocalChecked() .As<v8::Promise>(); - CHECK_EQ(true, rejected_but_handled_promise->HasHandler()); + CHECK(rejected_but_handled_promise->HasHandler()); } @@ -25894,8 +25901,62 @@ TEST(AccessCheckedToStringTag) { CHECK_EQ(0, strcmp(*result_denied, "[object Object]")); } +TEST(ObjectTemplateArrayProtoIntrinsics) { + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + LocalContext env; + + Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate); + object_template->SetIntrinsicDataProperty(v8_str("prop_entries"), + v8::kArrayProto_entries); + object_template->SetIntrinsicDataProperty(v8_str("prop_forEach"), + v8::kArrayProto_forEach); + object_template->SetIntrinsicDataProperty(v8_str("prop_keys"), + v8::kArrayProto_keys); + object_template->SetIntrinsicDataProperty(v8_str("prop_values"), + v8::kArrayProto_values); + Local<Object> object = + object_template->NewInstance(env.local()).ToLocalChecked(); + CHECK(env->Global()->Set(env.local(), v8_str("obj1"), object).FromJust()); + + const struct { + const char* const object_property_name; + const char* const array_property_name; + } intrinsics_comparisons[] = { + {"prop_entries", "Array.prototype.entries"}, + {"prop_forEach", "Array.prototype.forEach"}, + {"prop_keys", "Array.prototype.keys"}, + {"prop_values", "Array.prototype[Symbol.iterator]"}, + }; + + for (unsigned i = 0; i < arraysize(intrinsics_comparisons); i++) { + i::ScopedVector<char> test_string(64); + + i::SNPrintF(test_string, "typeof obj1.%s", + intrinsics_comparisons[i].object_property_name); + ExpectString(test_string.start(), "function"); + + i::SNPrintF(test_string, "obj1.%s === %s", + intrinsics_comparisons[i].object_property_name, + intrinsics_comparisons[i].array_property_name); + ExpectTrue(test_string.start()); + + i::SNPrintF(test_string, "obj1.%s = 42", + intrinsics_comparisons[i].object_property_name); + CompileRun(test_string.start()); + + i::SNPrintF(test_string, "obj1.%s === %s", + intrinsics_comparisons[i].object_property_name, + intrinsics_comparisons[i].array_property_name); + ExpectFalse(test_string.start()); + + i::SNPrintF(test_string, "typeof obj1.%s", + intrinsics_comparisons[i].object_property_name); + ExpectString(test_string.start(), "number"); + } +} -TEST(ObjectTemplateIntrinsics) { +TEST(ObjectTemplatePerContextIntrinsics) { v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope scope(isolate); LocalContext env; @@ -25913,7 +25974,7 @@ TEST(ObjectTemplateIntrinsics) { object->Get(env.local(), v8_str("values")).ToLocalChecked()); auto fn = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values)); auto ctx = v8::Utils::OpenHandle(*env.local()); - CHECK_EQ(fn->GetCreationContext(), *ctx); + CHECK_EQ(*fn->GetCreationContext(), *ctx); { LocalContext env2; @@ -25929,7 +25990,7 @@ TEST(ObjectTemplateIntrinsics) { object2->Get(env2.local(), v8_str("values")).ToLocalChecked()); auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); auto ctx2 = v8::Utils::OpenHandle(*env2.local()); - CHECK_EQ(fn2->GetCreationContext(), *ctx2); + CHECK_EQ(*fn2->GetCreationContext(), *ctx2); } } diff --git a/deps/v8/test/cctest/test-assembler-arm.cc b/deps/v8/test/cctest/test-assembler-arm.cc index 680b1233f7..ff268560f1 100644 --- a/deps/v8/test/cctest/test-assembler-arm.cc +++ b/deps/v8/test/cctest/test-assembler-arm.cc @@ -1299,8 +1299,12 @@ TEST(15) { uint32_t vmin_s8[4], vmin_u16[4], vmin_s32[4]; uint32_t vmax_s8[4], vmax_u16[4], vmax_s32[4]; uint32_t vadd8[4], vadd16[4], vadd32[4]; + uint32_t vqadd_s8[4], vqadd_u16[4], vqadd_s32[4]; uint32_t vsub8[4], vsub16[4], vsub32[4]; + uint32_t vqsub_u8[4], vqsub_s16[4], vqsub_u32[4]; uint32_t vmul8[4], vmul16[4], vmul32[4]; + uint32_t vshl8[4], vshl16[4], vshl32[5]; + uint32_t vshr_s8[4], vshr_u16[4], vshr_s32[5]; uint32_t vceq[4], vceqf[4], vcgef[4], vcgtf[4]; uint32_t vcge_s8[4], vcge_u16[4], vcge_s32[4]; uint32_t vcgt_s8[4], vcgt_u16[4], vcgt_s32[4]; @@ -1631,6 +1635,28 @@ TEST(15) { __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vadd32)))); __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + // vqadd. + __ mov(r4, Operand(0x81)); + __ vdup(Neon8, q0, r4); + __ mov(r4, Operand(0x82)); + __ vdup(Neon8, q1, r4); + __ vqadd(NeonS8, q1, q1, q0); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vqadd_s8)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + __ mov(r4, Operand(0x8000)); + __ vdup(Neon16, q0, r4); + __ vdup(Neon16, q1, r4); + __ vqadd(NeonU16, q1, q1, q0); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vqadd_u16)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + __ mov(r4, Operand(0x80000001)); + __ vdup(Neon32, q0, r4); + __ mov(r4, Operand(0x80000002)); + __ vdup(Neon32, q1, r4); + __ vqadd(NeonS32, q1, q1, q0); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vqadd_s32)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + // vsub (integer). __ mov(r4, Operand(0x01)); __ vdup(Neon8, q0, r4); @@ -1654,6 +1680,29 @@ TEST(15) { __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vsub32)))); __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + // vqsub. + __ mov(r4, Operand(0x7f)); + __ vdup(Neon8, q0, r4); + __ mov(r4, Operand(0x3f)); + __ vdup(Neon8, q1, r4); + __ vqsub(NeonU8, q1, q1, q0); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vqsub_u8)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + __ mov(r4, Operand(0x8000)); + __ vdup(Neon16, q0, r4); + __ mov(r4, Operand(0x7fff)); + __ vdup(Neon16, q1, r4); + __ vqsub(NeonS16, q1, q1, q0); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vqsub_s16)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + __ mov(r4, Operand(0x80000001)); + __ vdup(Neon32, q0, r4); + __ mov(r4, Operand(0x80000000)); + __ vdup(Neon32, q1, r4); + __ vqsub(NeonU32, q1, q1, q0); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vqsub_u32)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + // vmul (integer). __ mov(r4, Operand(0x02)); __ vdup(Neon8, q0, r4); @@ -1671,6 +1720,32 @@ TEST(15) { __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vmul32)))); __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + // vshl. + __ mov(r4, Operand(0x55)); + __ vdup(Neon8, q0, r4); + __ vshl(NeonS8, q1, q0, 1); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vshl8)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + __ vshl(NeonU16, q1, q0, 9); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vshl16)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + __ vshl(NeonS32, q1, q0, 17); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vshl32)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + + // vshr.s, vshr.u. + __ mov(r4, Operand(0x80)); + __ vdup(Neon8, q0, r4); + __ vshr(NeonS8, q1, q0, 1); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vshr_s8)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + __ vshr(NeonU16, q1, q0, 9); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vshr_u16)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + __ vshr(NeonS32, q1, q0, 17); + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, vshr_s32)))); + __ vst1(Neon8, NeonListOperand(q1), NeonMemOperand(r4)); + // vceq. __ mov(r4, Operand(0x03)); __ vdup(Neon8, q0, r4); @@ -1920,12 +1995,24 @@ TEST(15) { CHECK_EQ_SPLAT(vadd8, 0x03030303u); CHECK_EQ_SPLAT(vadd16, 0x00030003u); CHECK_EQ_SPLAT(vadd32, 0x00000003u); + CHECK_EQ_SPLAT(vqadd_s8, 0x80808080u); + CHECK_EQ_SPLAT(vqadd_u16, 0xffffffffu); + CHECK_EQ_SPLAT(vqadd_s32, 0x80000000u); + CHECK_EQ_SPLAT(vqsub_u8, 0x00000000u); + CHECK_EQ_SPLAT(vqsub_s16, 0x7fff7fffu); + CHECK_EQ_SPLAT(vqsub_u32, 0x00000000u); CHECK_EQ_SPLAT(vsub8, 0xfefefefeu); CHECK_EQ_SPLAT(vsub16, 0xfffefffeu); CHECK_EQ_SPLAT(vsub32, 0xfffffffeu); CHECK_EQ_SPLAT(vmul8, 0x04040404u); CHECK_EQ_SPLAT(vmul16, 0x00040004u); CHECK_EQ_SPLAT(vmul32, 0x00000004u); + CHECK_EQ_SPLAT(vshl8, 0xaaaaaaaau); + CHECK_EQ_SPLAT(vshl16, 0xaa00aa00u); + CHECK_EQ_SPLAT(vshl32, 0xaaaa0000u); + CHECK_EQ_SPLAT(vshr_s8, 0xc0c0c0c0u); + CHECK_EQ_SPLAT(vshr_u16, 0x00400040u); + CHECK_EQ_SPLAT(vshr_s32, 0xffffc040u); CHECK_EQ_SPLAT(vceq, 0x00ff00ffu); // [0, 3, 0, 3, ...] >= [3, 3, 3, 3, ...] CHECK_EQ_SPLAT(vcge_s8, 0x00ff00ffu); diff --git a/deps/v8/test/cctest/test-assembler-ia32.cc b/deps/v8/test/cctest/test-assembler-ia32.cc index e4cac56c15..36889b2443 100644 --- a/deps/v8/test/cctest/test-assembler-ia32.cc +++ b/deps/v8/test/cctest/test-assembler-ia32.cc @@ -1535,7 +1535,7 @@ TEST(Regress621926) { #endif F0 f = FUNCTION_CAST<F0>(code->entry()); - CHECK_EQ(f(), 1); + CHECK_EQ(1, f()); } #undef __ diff --git a/deps/v8/test/cctest/test-assembler-mips.cc b/deps/v8/test/cctest/test-assembler-mips.cc index 191589a73a..7bfd1e767e 100644 --- a/deps/v8/test/cctest/test-assembler-mips.cc +++ b/deps/v8/test/cctest/test-assembler-mips.cc @@ -1406,10 +1406,10 @@ TEST(seleqz_selnez) { (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(test.a, 1); - CHECK_EQ(test.b, 0); - CHECK_EQ(test.c, 0); - CHECK_EQ(test.d, 1); + CHECK_EQ(1, test.a); + CHECK_EQ(0, test.b); + CHECK_EQ(0, test.c); + CHECK_EQ(1, test.d); const int test_size = 3; const int input_size = 5; @@ -1433,18 +1433,18 @@ TEST(seleqz_selnez) { test.i = inputs_S[i]; test.j = tests_S[j]; (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(test.g, outputs_D[i]); - CHECK_EQ(test.h, 0); - CHECK_EQ(test.k, outputs_S[i]); - CHECK_EQ(test.l, 0); + CHECK_EQ(outputs_D[i], test.g); + CHECK_EQ(0, test.h); + CHECK_EQ(outputs_S[i], test.k); + CHECK_EQ(0, test.l); test.f = tests_D[j+1]; test.j = tests_S[j+1]; (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(test.g, 0); - CHECK_EQ(test.h, outputs_D[i]); - CHECK_EQ(test.k, 0); - CHECK_EQ(test.l, outputs_S[i]); + CHECK_EQ(0, test.g); + CHECK_EQ(outputs_D[i], test.h); + CHECK_EQ(0, test.k); + CHECK_EQ(outputs_S[i], test.l); } } } @@ -3191,7 +3191,7 @@ TEST(jump_tables1) { __ jr(ra); __ nop(); - CHECK_EQ(assm.UnboundLabelsCount(), 0); + CHECK_EQ(0, assm.UnboundLabelsCount()); CodeDesc desc; assm.GetCode(&desc); @@ -3670,14 +3670,14 @@ TEST(ABS) { test.a = std::numeric_limits<double>::quiet_NaN(); test.b = std::numeric_limits<float>::quiet_NaN(); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(std::isnan(test.a), true); - CHECK_EQ(std::isnan(test.b), true); + CHECK(std::isnan(test.a)); + CHECK(std::isnan(test.b)); test.a = std::numeric_limits<double>::signaling_NaN(); test.b = std::numeric_limits<float>::signaling_NaN(); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(std::isnan(test.a), true); - CHECK_EQ(std::isnan(test.b), true); + CHECK(std::isnan(test.a)); + CHECK(std::isnan(test.b)); } @@ -3737,16 +3737,16 @@ TEST(ADD_FMT) { test.fa = std::numeric_limits<float>::max(); test.fb = std::numeric_limits<float>::max(); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(std::isfinite(test.c), false); - CHECK_EQ(std::isfinite(test.fc), false); + CHECK(!std::isfinite(test.c)); + CHECK(!std::isfinite(test.fc)); test.a = 5.0; test.b = std::numeric_limits<double>::signaling_NaN(); test.fa = 5.0; test.fb = std::numeric_limits<float>::signaling_NaN(); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(std::isnan(test.c), true); - CHECK_EQ(std::isnan(test.fc), true); + CHECK(std::isnan(test.c)); + CHECK(std::isnan(test.fc)); } @@ -4278,8 +4278,8 @@ TEST(CVT) { CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in)); } if (IsFp64Mode()) { - CHECK_EQ(test.cvt_l_s_out, -1); - CHECK_EQ(test.cvt_l_d_out, -1); + CHECK_EQ(-1, test.cvt_l_s_out); + CHECK_EQ(-1, test.cvt_l_d_out); } CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in)); CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in)); @@ -4287,9 +4287,8 @@ TEST(CVT) { IsFp64Mode()) { CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in)); } - CHECK_EQ(test.cvt_w_s_out, -1); - CHECK_EQ(test.cvt_w_d_out, -1); - + CHECK_EQ(-1, test.cvt_w_s_out); + CHECK_EQ(-1, test.cvt_w_d_out); test.cvt_d_s_in = 0.49; test.cvt_d_w_in = 1; @@ -4310,8 +4309,8 @@ TEST(CVT) { CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in)); } if (IsFp64Mode()) { - CHECK_EQ(test.cvt_l_s_out, 0); - CHECK_EQ(test.cvt_l_d_out, 0); + CHECK_EQ(0, test.cvt_l_s_out); + CHECK_EQ(0, test.cvt_l_d_out); } CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in)); CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in)); @@ -4319,8 +4318,8 @@ TEST(CVT) { IsFp64Mode()) { CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in)); } - CHECK_EQ(test.cvt_w_s_out, 0); - CHECK_EQ(test.cvt_w_d_out, 0); + CHECK_EQ(0, test.cvt_w_s_out); + CHECK_EQ(0, test.cvt_w_d_out); test.cvt_d_s_in = std::numeric_limits<float>::max(); test.cvt_d_w_in = std::numeric_limits<int32_t>::max(); @@ -4412,8 +4411,8 @@ TEST(CVT) { CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in)); } if (IsFp64Mode()) { - CHECK_EQ(test.cvt_l_s_out, 0); - CHECK_EQ(test.cvt_l_d_out, 0); + CHECK_EQ(0, test.cvt_l_s_out); + CHECK_EQ(0, test.cvt_l_d_out); } CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in)); CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in)); @@ -4421,8 +4420,8 @@ TEST(CVT) { IsFp64Mode()) { CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in)); } - CHECK_EQ(test.cvt_w_s_out, 0); - CHECK_EQ(test.cvt_w_d_out, 0); + CHECK_EQ(0, test.cvt_w_s_out); + CHECK_EQ(0, test.cvt_w_d_out); } @@ -4525,8 +4524,8 @@ TEST(DIV_FMT) { test.fOp2 = -0.0; (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(false, std::isfinite(test.dRes)); - CHECK_EQ(false, std::isfinite(test.fRes)); + CHECK(!std::isfinite(test.dRes)); + CHECK(!std::isfinite(test.fRes)); test.dOp1 = 0.0; test.dOp2 = -0.0; @@ -4534,8 +4533,8 @@ TEST(DIV_FMT) { test.fOp2 = -0.0; (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(true, std::isnan(test.dRes)); - CHECK_EQ(true, std::isnan(test.fRes)); + CHECK(std::isnan(test.dRes)); + CHECK(std::isnan(test.fRes)); test.dOp1 = std::numeric_limits<double>::quiet_NaN(); test.dOp2 = -5.0; @@ -4543,8 +4542,8 @@ TEST(DIV_FMT) { test.fOp2 = -5.0; (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(true, std::isnan(test.dRes)); - CHECK_EQ(true, std::isnan(test.fRes)); + CHECK(std::isnan(test.dRes)); + CHECK(std::isnan(test.fRes)); } @@ -5383,7 +5382,7 @@ TEST(Trampoline) { int32_t res = reinterpret_cast<int32_t>( CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); - CHECK_EQ(res, 0); + CHECK_EQ(0, res); } template <class T> diff --git a/deps/v8/test/cctest/test-assembler-mips64.cc b/deps/v8/test/cctest/test-assembler-mips64.cc index 0ec51723e9..5875f1e79d 100644 --- a/deps/v8/test/cctest/test-assembler-mips64.cc +++ b/deps/v8/test/cctest/test-assembler-mips64.cc @@ -1589,10 +1589,10 @@ TEST(seleqz_selnez) { (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(test.a, 1); - CHECK_EQ(test.b, 0); - CHECK_EQ(test.c, 0); - CHECK_EQ(test.d, 1); + CHECK_EQ(1, test.a); + CHECK_EQ(0, test.b); + CHECK_EQ(0, test.c); + CHECK_EQ(1, test.d); const int test_size = 3; const int input_size = 5; @@ -1616,18 +1616,18 @@ TEST(seleqz_selnez) { test.i = inputs_S[i]; test.j = tests_S[j]; (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(test.g, outputs_D[i]); - CHECK_EQ(test.h, 0); - CHECK_EQ(test.k, outputs_S[i]); - CHECK_EQ(test.l, 0); + CHECK_EQ(outputs_D[i], test.g); + CHECK_EQ(0, test.h); + CHECK_EQ(outputs_S[i], test.k); + CHECK_EQ(0, test.l); test.f = tests_D[j+1]; test.j = tests_S[j+1]; (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(test.g, 0); - CHECK_EQ(test.h, outputs_D[i]); - CHECK_EQ(test.k, 0); - CHECK_EQ(test.l, outputs_S[i]); + CHECK_EQ(0, test.g); + CHECK_EQ(outputs_D[i], test.h); + CHECK_EQ(0, test.k); + CHECK_EQ(outputs_S[i], test.l); } } } @@ -3315,7 +3315,7 @@ TEST(jump_tables1) { __ jr(ra); __ nop(); - CHECK_EQ(assm.UnboundLabelsCount(), 0); + CHECK_EQ(0, assm.UnboundLabelsCount()); CodeDesc desc; assm.GetCode(&desc); @@ -3829,14 +3829,14 @@ TEST(ABS) { test.a = std::numeric_limits<double>::quiet_NaN(); test.b = std::numeric_limits<float>::quiet_NaN(); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(std::isnan(test.a), true); - CHECK_EQ(std::isnan(test.b), true); + CHECK(std::isnan(test.a)); + CHECK(std::isnan(test.b)); test.a = std::numeric_limits<double>::signaling_NaN(); test.b = std::numeric_limits<float>::signaling_NaN(); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(std::isnan(test.a), true); - CHECK_EQ(std::isnan(test.b), true); + CHECK(std::isnan(test.a)); + CHECK(std::isnan(test.b)); } @@ -3896,16 +3896,16 @@ TEST(ADD_FMT) { test.fa = std::numeric_limits<float>::max(); test.fb = std::numeric_limits<float>::max(); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(std::isfinite(test.c), false); - CHECK_EQ(std::isfinite(test.fc), false); + CHECK(!std::isfinite(test.c)); + CHECK(!std::isfinite(test.fc)); test.a = 5.0; test.b = std::numeric_limits<double>::signaling_NaN(); test.fa = 5.0; test.fb = std::numeric_limits<float>::signaling_NaN(); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(std::isnan(test.c), true); - CHECK_EQ(std::isnan(test.fc), true); + CHECK(std::isnan(test.c)); + CHECK(std::isnan(test.fc)); } @@ -4425,14 +4425,13 @@ TEST(CVT) { CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in)); CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in)); CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in)); - CHECK_EQ(test.cvt_l_s_out, -1); - CHECK_EQ(test.cvt_l_d_out, -1); + CHECK_EQ(-1, test.cvt_l_s_out); + CHECK_EQ(-1, test.cvt_l_d_out); CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in)); CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in)); CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in)); - CHECK_EQ(test.cvt_w_s_out, -1); - CHECK_EQ(test.cvt_w_d_out, -1); - + CHECK_EQ(-1, test.cvt_w_s_out); + CHECK_EQ(-1, test.cvt_w_d_out); test.cvt_d_s_in = 0.49; test.cvt_d_w_in = 1; @@ -4449,13 +4448,13 @@ TEST(CVT) { CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in)); CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in)); CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in)); - CHECK_EQ(test.cvt_l_s_out, 0); - CHECK_EQ(test.cvt_l_d_out, 0); + CHECK_EQ(0, test.cvt_l_s_out); + CHECK_EQ(0, test.cvt_l_d_out); CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in)); CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in)); CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in)); - CHECK_EQ(test.cvt_w_s_out, 0); - CHECK_EQ(test.cvt_w_d_out, 0); + CHECK_EQ(0, test.cvt_w_s_out); + CHECK_EQ(0, test.cvt_w_d_out); test.cvt_d_s_in = std::numeric_limits<float>::max(); test.cvt_d_w_in = std::numeric_limits<int32_t>::max(); @@ -4527,13 +4526,13 @@ TEST(CVT) { CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in)); CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in)); CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in)); - CHECK_EQ(test.cvt_l_s_out, 0); - CHECK_EQ(test.cvt_l_d_out, 0); + CHECK_EQ(0, test.cvt_l_s_out); + CHECK_EQ(0, test.cvt_l_d_out); CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in)); CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in)); CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in)); - CHECK_EQ(test.cvt_w_s_out, 0); - CHECK_EQ(test.cvt_w_d_out, 0); + CHECK_EQ(0, test.cvt_w_s_out); + CHECK_EQ(0, test.cvt_w_d_out); } @@ -4634,8 +4633,8 @@ TEST(DIV_FMT) { test.fOp2 = -0.0; (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(false, std::isfinite(test.dRes)); - CHECK_EQ(false, std::isfinite(test.fRes)); + CHECK(!std::isfinite(test.dRes)); + CHECK(!std::isfinite(test.fRes)); test.dOp1 = 0.0; test.dOp2 = -0.0; @@ -4643,8 +4642,8 @@ TEST(DIV_FMT) { test.fOp2 = -0.0; (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(true, std::isnan(test.dRes)); - CHECK_EQ(true, std::isnan(test.fRes)); + CHECK(std::isnan(test.dRes)); + CHECK(std::isnan(test.fRes)); test.dOp1 = std::numeric_limits<double>::quiet_NaN(); test.dOp2 = -5.0; @@ -4652,8 +4651,8 @@ TEST(DIV_FMT) { test.fOp2 = -5.0; (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); - CHECK_EQ(true, std::isnan(test.dRes)); - CHECK_EQ(true, std::isnan(test.fRes)); + CHECK(std::isnan(test.dRes)); + CHECK(std::isnan(test.fRes)); } @@ -5931,7 +5930,7 @@ TEST(Trampoline) { int64_t res = reinterpret_cast<int64_t>( CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); - CHECK_EQ(res, 0); + CHECK_EQ(0, res); } template <class T> diff --git a/deps/v8/test/cctest/test-assembler-x64.cc b/deps/v8/test/cctest/test-assembler-x64.cc index 0ea854d7fe..1653851953 100644 --- a/deps/v8/test/cctest/test-assembler-x64.cc +++ b/deps/v8/test/cctest/test-assembler-x64.cc @@ -32,8 +32,10 @@ #include "src/base/platform/platform.h" #include "src/base/utils/random-number-generator.h" +#include "src/double.h" #include "src/factory.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" #include "src/ostreams.h" #include "test/cctest/cctest.h" diff --git a/deps/v8/test/cctest/test-assembler-x87.cc b/deps/v8/test/cctest/test-assembler-x87.cc index 3649b5bf88..d8285290fa 100644 --- a/deps/v8/test/cctest/test-assembler-x87.cc +++ b/deps/v8/test/cctest/test-assembler-x87.cc @@ -445,7 +445,7 @@ TEST(Regress621926) { #endif F0 f = FUNCTION_CAST<F0>(code->entry()); - CHECK_EQ(f(), 1); + CHECK_EQ(1, f()); } #undef __ diff --git a/deps/v8/test/cctest/test-code-layout.cc b/deps/v8/test/cctest/test-code-layout.cc index fb72554df4..e061dbd26d 100644 --- a/deps/v8/test/cctest/test-code-layout.cc +++ b/deps/v8/test/cctest/test-code-layout.cc @@ -42,7 +42,7 @@ TEST(CodeLayoutWithoutUnwindingInfo) { CHECK(!code->has_unwinding_info()); CHECK_EQ(code->instruction_size(), buffer_size); - CHECK_EQ(memcmp(code->instruction_start(), buffer, buffer_size), 0); + CHECK_EQ(0, memcmp(code->instruction_start(), buffer, buffer_size)); CHECK_EQ(code->instruction_end() - reinterpret_cast<byte*>(*code), Code::kHeaderSize + buffer_size - kHeapObjectTag); } @@ -79,7 +79,7 @@ TEST(CodeLayoutWithUnwindingInfo) { CHECK(code->has_unwinding_info()); CHECK_EQ(code->instruction_size(), buffer_size); - CHECK_EQ(memcmp(code->instruction_start(), buffer, buffer_size), 0); + CHECK_EQ(0, memcmp(code->instruction_start(), buffer, buffer_size)); CHECK(IsAligned(code->GetUnwindingInfoSizeOffset(), 8)); CHECK_EQ(code->unwinding_info_size(), unwinding_info_size); CHECK( diff --git a/deps/v8/test/cctest/test-code-stub-assembler.cc b/deps/v8/test/cctest/test-code-stub-assembler.cc index 068ef9c3d1..afe34b62c6 100644 --- a/deps/v8/test/cctest/test-code-stub-assembler.cc +++ b/deps/v8/test/cctest/test-code-stub-assembler.cc @@ -2,12 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/api.h" #include "src/base/utils/random-number-generator.h" #include "src/builtins/builtins-promise.h" #include "src/code-factory.h" #include "src/code-stub-assembler.h" #include "src/compiler/node.h" +#include "src/debug/debug.h" #include "src/isolate.h" +#include "src/objects-inl.h" #include "test/cctest/compiler/code-assembler-tester.h" #include "test/cctest/compiler/function-tester.h" @@ -180,47 +183,6 @@ TEST(ToString) { } } -TEST(FlattenString) { - Isolate* isolate(CcTest::InitIsolateOnce()); - const int kNumParams = 1; - CodeAssemblerTester data(isolate, kNumParams); - CodeStubAssembler m(data.state()); - m.Return(m.FlattenString(m.Parameter(0))); - - Handle<Code> code = data.GenerateCode(); - FunctionTester ft(code, kNumParams); - - Handle<FixedArray> test_cases(isolate->factory()->NewFixedArray(4)); - Handle<String> expected( - isolate->factory()->InternalizeUtf8String("hello, world!")); - test_cases->set(0, *expected); - - Handle<String> string( - isolate->factory()->InternalizeUtf8String("filler hello, world! filler")); - Handle<String> sub_string( - isolate->factory()->NewProperSubString(string, 7, 20)); - test_cases->set(1, *sub_string); - - Handle<String> hello(isolate->factory()->InternalizeUtf8String("hello,")); - Handle<String> world(isolate->factory()->InternalizeUtf8String(" world!")); - Handle<String> cons_str( - isolate->factory()->NewConsString(hello, world).ToHandleChecked()); - test_cases->set(2, *cons_str); - - Handle<String> empty(isolate->factory()->InternalizeUtf8String("")); - Handle<String> fake_cons_str( - isolate->factory()->NewConsString(expected, empty).ToHandleChecked()); - test_cases->set(3, *fake_cons_str); - - for (int i = 0; i < 4; ++i) { - Handle<String> test = handle(String::cast(test_cases->get(i))); - Handle<Object> result = ft.Call(test).ToHandleChecked(); - CHECK(result->IsString()); - CHECK(Handle<String>::cast(result)->IsFlat()); - CHECK(String::Equals(Handle<String>::cast(result), expected)); - } -} - TEST(TryToName) { typedef CodeAssemblerLabel Label; typedef CodeAssemblerVariable Variable; @@ -238,22 +200,26 @@ TEST(TryToName) { Label passed(&m), failed(&m); Label if_keyisindex(&m), if_keyisunique(&m), if_bailout(&m); - Variable var_index(&m, MachineType::PointerRepresentation()); - - m.TryToName(key, &if_keyisindex, &var_index, &if_keyisunique, &if_bailout); - - m.Bind(&if_keyisindex); - m.GotoUnless( - m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kKeyIsIndex))), - &failed); - m.Branch(m.WordEqual(m.SmiUntag(expected_arg), var_index.value()), &passed, - &failed); - - m.Bind(&if_keyisunique); - m.GotoUnless( - m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kKeyIsUnique))), - &failed); - m.Branch(m.WordEqual(expected_arg, key), &passed, &failed); + { + Variable var_index(&m, MachineType::PointerRepresentation()); + Variable var_unique(&m, MachineRepresentation::kTagged); + + m.TryToName(key, &if_keyisindex, &var_index, &if_keyisunique, &var_unique, + &if_bailout); + + m.Bind(&if_keyisindex); + m.GotoIfNot(m.WordEqual(expected_result, + m.SmiConstant(Smi::FromInt(kKeyIsIndex))), + &failed); + m.Branch(m.WordEqual(m.SmiUntag(expected_arg), var_index.value()), + &passed, &failed); + + m.Bind(&if_keyisunique); + m.GotoIfNot(m.WordEqual(expected_result, + m.SmiConstant(Smi::FromInt(kKeyIsUnique))), + &failed); + m.Branch(m.WordEqual(expected_arg, var_unique.value()), &passed, &failed); + } m.Bind(&if_bailout); m.Branch( @@ -349,6 +315,23 @@ TEST(TryToName) { Handle<Object> key = isolate->factory()->NewStringFromAsciiChecked("test"); ft.CheckTrue(key, expect_bailout); } + + if (FLAG_thin_strings) { + // TryToName(<thin string>) => internalized version. + Handle<String> s = isolate->factory()->NewStringFromAsciiChecked("foo"); + Handle<String> internalized = isolate->factory()->InternalizeString(s); + ft.CheckTrue(s, expect_unique, internalized); + } + + if (FLAG_thin_strings) { + // TryToName(<thin two-byte string>) => internalized version. + uc16 array1[] = {2001, 2002, 2003}; + Vector<const uc16> str1(array1); + Handle<String> s = + isolate->factory()->NewStringFromTwoByte(str1).ToHandleChecked(); + Handle<String> internalized = isolate->factory()->InternalizeString(s); + ft.CheckTrue(s, expect_unique, internalized); + } } namespace { @@ -409,7 +392,7 @@ void TestNameDictionaryLookup() { m.NameDictionaryLookup<Dictionary>(dictionary, unique_name, &if_found, &var_name_index, &if_not_found); m.Bind(&if_found); - m.GotoUnless( + m.GotoIfNot( m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), &failed); m.Branch(m.WordEqual(m.SmiUntag(expected_arg), var_name_index.value()), @@ -516,7 +499,7 @@ void TestNumberDictionaryLookup() { m.NumberDictionaryLookup<Dictionary>(dictionary, key, &if_found, &var_entry, &if_not_found); m.Bind(&if_found); - m.GotoUnless( + m.GotoIfNot( m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), &failed); m.Branch(m.WordEqual(m.SmiUntag(expected_arg), var_entry.value()), &passed, @@ -1526,7 +1509,7 @@ TEST(Arguments) { CodeAssemblerTester data(isolate, kNumParams); CodeStubAssembler m(data.state()); - CodeStubArguments arguments(&m, m.Int32Constant(3)); + CodeStubArguments arguments(&m, m.IntPtrConstant(3)); CSA_ASSERT( &m, m.WordEqual(arguments.AtIndex(0), m.SmiConstant(Smi::FromInt(12)))); @@ -1556,7 +1539,7 @@ TEST(ArgumentsForEach) { CodeAssemblerTester data(isolate, kNumParams); CodeStubAssembler m(data.state()); - CodeStubArguments arguments(&m, m.Int32Constant(3)); + CodeStubArguments arguments(&m, m.IntPtrConstant(3)); CodeAssemblerVariable sum(&m, MachineRepresentation::kTagged); CodeAssemblerVariableList list({&sum}, m.zone()); @@ -1599,7 +1582,7 @@ TEST(IsDebugActive) { CHECK(!code.is_null()); FunctionTester ft(code, kNumParams); - CHECK_EQ(false, isolate->debug()->is_active()); + CHECK(!isolate->debug()->is_active()); Handle<Object> result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK_EQ(isolate->heap()->false_value(), *result); @@ -1636,7 +1619,7 @@ class AppendJSArrayCodeStubAssembler : public CodeStubAssembler { JSObject::SetElement(isolate, array, 1, Handle<Smi>(Smi::FromInt(2), isolate), SLOPPY) .Check(); - CodeStubArguments args(this, Int32Constant(kNumParams)); + CodeStubArguments args(this, IntPtrConstant(kNumParams)); Variable arg_index(this, MachineType::PointerRepresentation()); Label bailout(this); arg_index.Bind(IntPtrConstant(0)); @@ -1769,7 +1752,7 @@ TEST(IsPromiseHookEnabled) { CodeAssemblerTester data(isolate, kNumParams); CodeStubAssembler m(data.state()); - m.Return(m.SelectBooleanConstant(m.IsPromiseHookEnabled())); + m.Return(m.SelectBooleanConstant(m.IsPromiseHookEnabledOrDebugIsActive())); Handle<Code> code = data.GenerateCode(); CHECK(!code.is_null()); @@ -1867,7 +1850,6 @@ TEST(AllocatePromiseReactionJobInfo) { CHECK(promise_info->deferred_on_resolve()->IsUndefined(isolate)); CHECK(promise_info->deferred_on_reject()->IsUndefined(isolate)); CHECK(promise_info->context()->IsContext()); - CHECK_EQ(kDebugPromiseNoID, promise_info->debug_id()); } TEST(AllocatePromiseResolveThenableJobInfo) { @@ -1906,7 +1888,6 @@ TEST(AllocatePromiseResolveThenableJobInfo) { CHECK(promise_info->then()->IsJSFunction()); CHECK(promise_info->resolve()->IsJSFunction()); CHECK(promise_info->reject()->IsJSFunction()); - CHECK_EQ(kDebugPromiseNoID, promise_info->debug_id()); CHECK(promise_info->context()->IsContext()); } @@ -2138,7 +2119,7 @@ TEST(AllocateFunctionWithMapAndContext) { Handle<JSFunction> fun = Handle<JSFunction>::cast(result_obj); CHECK_EQ(isolate->heap()->empty_fixed_array(), fun->properties()); CHECK_EQ(isolate->heap()->empty_fixed_array(), fun->elements()); - CHECK_EQ(isolate->heap()->empty_literals_array(), fun->literals()); + CHECK_EQ(isolate->heap()->undefined_cell(), fun->feedback_vector_cell()); CHECK_EQ(isolate->heap()->the_hole_value(), fun->prototype_or_initial_map()); CHECK_EQ(*isolate->promise_resolve_shared_fun(), fun->shared()); CHECK_EQ(isolate->promise_resolve_shared_fun()->code(), fun->code()); diff --git a/deps/v8/test/cctest/test-code-stubs-x64.cc b/deps/v8/test/cctest/test-code-stubs-x64.cc index b9eddd6c57..62ef533ad8 100644 --- a/deps/v8/test/cctest/test-code-stubs-x64.cc +++ b/deps/v8/test/cctest/test-code-stubs-x64.cc @@ -33,6 +33,7 @@ #include "src/code-stubs.h" #include "src/factory.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" #include "src/register-configuration.h" #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" diff --git a/deps/v8/test/cctest/test-code-stubs.cc b/deps/v8/test/cctest/test-code-stubs.cc index 273f57ef0e..0a8b24e4d3 100644 --- a/deps/v8/test/cctest/test-code-stubs.cc +++ b/deps/v8/test/cctest/test-code-stubs.cc @@ -33,8 +33,10 @@ #include "src/base/platform/platform.h" #include "src/code-stubs.h" +#include "src/double.h" #include "src/factory.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" diff --git a/deps/v8/test/cctest/test-compiler.cc b/deps/v8/test/cctest/test-compiler.cc index 95db65bdee..57686d0ee5 100644 --- a/deps/v8/test/cctest/test-compiler.cc +++ b/deps/v8/test/cctest/test-compiler.cc @@ -65,7 +65,7 @@ static Handle<JSFunction> Compile(const char* source) { Handle<SharedFunctionInfo> shared = Compiler::GetSharedFunctionInfoForScript( source_code, Handle<String>(), 0, 0, v8::ScriptOriginOptions(), Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, NULL, - v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false); + v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE); return isolate->factory()->NewFunctionFromSharedFunctionInfo( shared, isolate->native_context()); } @@ -312,7 +312,7 @@ TEST(FeedbackVectorPreservedAcrossRecompiles) { // Verify that we gathered feedback. CHECK(!feedback_vector->is_empty()); - FeedbackVectorSlot slot_for_a(0); + FeedbackSlot slot_for_a(0); Object* object = feedback_vector->Get(slot_for_a); CHECK(object->IsWeakCell() && WeakCell::cast(object)->value()->IsJSFunction()); @@ -361,7 +361,6 @@ TEST(FeedbackVectorUnaffectedByScopeChanges) { // If we are compiling lazily then it should not be compiled, and so no // feedback vector allocated yet. CHECK(!f->shared()->is_compiled()); - CHECK(f->feedback_vector()->is_empty()); CompileRun("morphing_call();"); @@ -386,10 +385,12 @@ TEST(OptimizedCodeSharing1) { " return function() { return x; };" "}" "var closure0 = MakeClosure();" + "var closure1 = MakeClosure();" // We only share optimized code + // if there are at least two closures. "%DebugPrint(closure0());" "%OptimizeFunctionOnNextCall(closure0);" "%DebugPrint(closure0());" - "var closure1 = MakeClosure(); closure1();" + "closure1();" "var closure2 = MakeClosure(); closure2();"); Handle<JSFunction> fun1 = Handle<JSFunction>::cast( v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( diff --git a/deps/v8/test/cctest/test-cpu-profiler.cc b/deps/v8/test/cctest/test-cpu-profiler.cc index 6ec71a2ab3..08f262d0e7 100644 --- a/deps/v8/test/cctest/test-cpu-profiler.cc +++ b/deps/v8/test/cctest/test-cpu-profiler.cc @@ -30,8 +30,10 @@ #include "src/v8.h" #include "include/v8-profiler.h" +#include "src/api.h" #include "src/base/platform/platform.h" #include "src/deoptimizer.h" +#include "src/objects-inl.h" #include "src/profiler/cpu-profiler-inl.h" #include "src/profiler/profiler-listener.h" #include "src/utils.h" @@ -78,7 +80,7 @@ static const char* reason(const i::DeoptimizeReason reason) { TEST(StartStop) { i::Isolate* isolate = CcTest::i_isolate(); CpuProfilesCollection profiles(isolate); - ProfileGenerator generator(isolate, &profiles); + ProfileGenerator generator(&profiles); std::unique_ptr<ProfilerEventsProcessor> processor( new ProfilerEventsProcessor(isolate, &generator, v8::base::TimeDelta::FromMicroseconds(100))); @@ -163,7 +165,7 @@ TEST(CodeEvents) { i::AbstractCode* args4_code = CreateCode(&env); CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); - ProfileGenerator* generator = new ProfileGenerator(isolate, profiles); + ProfileGenerator* generator = new ProfileGenerator(profiles); ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( isolate, generator, v8::base::TimeDelta::FromMicroseconds(100)); CpuProfiler profiler(isolate, profiles, generator, processor); @@ -231,7 +233,7 @@ TEST(TickEvents) { i::AbstractCode* frame3_code = CreateCode(&env); CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); - ProfileGenerator* generator = new ProfileGenerator(isolate, profiles); + ProfileGenerator* generator = new ProfileGenerator(profiles); ProfilerEventsProcessor* processor = new ProfilerEventsProcessor(CcTest::i_isolate(), generator, v8::base::TimeDelta::FromMicroseconds(100)); @@ -304,7 +306,7 @@ TEST(Issue1398) { i::AbstractCode* code = CreateCode(&env); CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); - ProfileGenerator* generator = new ProfileGenerator(isolate, profiles); + ProfileGenerator* generator = new ProfileGenerator(profiles); ProfilerEventsProcessor* processor = new ProfilerEventsProcessor(CcTest::i_isolate(), generator, v8::base::TimeDelta::FromMicroseconds(100)); @@ -1077,7 +1079,7 @@ static void TickLines(bool optimize) { CHECK(code_address); CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); - ProfileGenerator* generator = new ProfileGenerator(isolate, profiles); + ProfileGenerator* generator = new ProfileGenerator(profiles); ProfilerEventsProcessor* processor = new ProfilerEventsProcessor(CcTest::i_isolate(), generator, v8::base::TimeDelta::FromMicroseconds(100)); diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc index 54904f9b84..8d06b1b66e 100644 --- a/deps/v8/test/cctest/test-debug.cc +++ b/deps/v8/test/cctest/test-debug.cc @@ -35,6 +35,7 @@ #include "src/debug/debug.h" #include "src/deoptimizer.h" #include "src/frames.h" +#include "src/objects-inl.h" #include "src/utils.h" #include "test/cctest/cctest.h" @@ -3756,43 +3757,6 @@ TEST(TryFinallyOriginalMessage) { } -TEST(EvalJSInDebugEventListenerOnNativeReThrownException) { - DebugLocalContext env; - v8::HandleScope scope(env->GetIsolate()); - env.ExposeDebug(); - - // Create functions for testing break on exception. - v8::Local<v8::Function> noThrowJS = CompileFunction( - &env, "function noThrowJS(){var a=[1]; a.push(2); return a.length;}", - "noThrowJS"); - - debug_event_listener_callback = noThrowJS; - debug_event_listener_callback_result = 2; - - env->GetIsolate()->AddMessageListener(MessageCallbackCount); - v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter); - // Break on uncaught exception - ChangeBreakOnException(false, true); - DebugEventCounterClear(); - MessageCallbackCountClear(); - - // ReThrow native error - { - v8::TryCatch tryCatch(env->GetIsolate()); - env->GetIsolate()->ThrowException( - v8::Exception::TypeError(v8_str(env->GetIsolate(), "Type error"))); - CHECK(tryCatch.HasCaught()); - tryCatch.ReThrow(); - } - CHECK_EQ(1, exception_hit_count); - CHECK_EQ(1, uncaught_exception_hit_count); - CHECK_EQ(0, message_callback_count); // FIXME: Should it be 1 ? - CHECK(!debug_event_listener_callback.IsEmpty()); - - debug_event_listener_callback.Clear(); -} - - // Test break on exception from compiler errors. When compiling using // v8::Script::Compile there is no JavaScript stack whereas when compiling using // eval there are JavaScript frames. @@ -3822,16 +3786,18 @@ TEST(BreakOnCompileException) { // Throws SyntaxError: Unexpected end of input CHECK( v8::Script::Compile(context, v8_str(env->GetIsolate(), "+++")).IsEmpty()); - CHECK_EQ(1, exception_hit_count); - CHECK_EQ(1, uncaught_exception_hit_count); + // Exceptions with no stack are skipped. + CHECK_EQ(0, exception_hit_count); + CHECK_EQ(0, uncaught_exception_hit_count); CHECK_EQ(1, message_callback_count); CHECK_EQ(0, last_js_stack_height); // No JavaScript stack. // Throws SyntaxError: Unexpected identifier CHECK( v8::Script::Compile(context, v8_str(env->GetIsolate(), "x x")).IsEmpty()); - CHECK_EQ(2, exception_hit_count); - CHECK_EQ(2, uncaught_exception_hit_count); + // Exceptions with no stack are skipped. + CHECK_EQ(0, exception_hit_count); + CHECK_EQ(0, uncaught_exception_hit_count); CHECK_EQ(2, message_callback_count); CHECK_EQ(0, last_js_stack_height); // No JavaScript stack. @@ -3840,8 +3806,8 @@ TEST(BreakOnCompileException) { .ToLocalChecked() ->Run(context) .IsEmpty()); - CHECK_EQ(3, exception_hit_count); - CHECK_EQ(3, uncaught_exception_hit_count); + CHECK_EQ(1, exception_hit_count); + CHECK_EQ(1, uncaught_exception_hit_count); CHECK_EQ(3, message_callback_count); CHECK_EQ(1, last_js_stack_height); @@ -3850,8 +3816,8 @@ TEST(BreakOnCompileException) { .ToLocalChecked() ->Run(context) .IsEmpty()); - CHECK_EQ(4, exception_hit_count); - CHECK_EQ(4, uncaught_exception_hit_count); + CHECK_EQ(2, exception_hit_count); + CHECK_EQ(2, uncaught_exception_hit_count); CHECK_EQ(4, message_callback_count); CHECK_EQ(1, last_js_stack_height); } @@ -4422,7 +4388,7 @@ TEST(HiddenPrototypePropertyMirror) { .FromJust()); // The prototype (__proto__) for o0 should be o3 as o1 and o2 are hidden. - CHECK(CompileRun("o0_mirror.protoObject() == o3_mirror") + CHECK(CompileRun("o0_mirror.protoObject().value() == o3_mirror.value()") ->BooleanValue(context) .FromJust()); } @@ -6456,14 +6422,13 @@ TEST(BreakLocationIterator) { Handle<i::SharedFunctionInfo> shared(function->shared()); EnableDebugger(isolate); - CHECK(i_isolate->debug()->EnsureDebugInfo(shared, function)); + CHECK(i_isolate->debug()->EnsureDebugInfo(shared)); Handle<i::DebugInfo> debug_info(shared->GetDebugInfo()); Handle<i::AbstractCode> abstract_code(shared->abstract_code()); { - auto iterator = i::BreakIterator::GetIterator(debug_info, abstract_code, - i::ALL_BREAK_LOCATIONS); + auto iterator = i::BreakIterator::GetIterator(debug_info, abstract_code); CHECK(iterator->GetBreakLocation().IsDebuggerStatement()); CHECK_EQ(17, iterator->GetBreakLocation().position()); iterator->Next(); @@ -6482,18 +6447,6 @@ TEST(BreakLocationIterator) { CHECK(iterator->Done()); } - { - auto iterator = i::BreakIterator::GetIterator(debug_info, abstract_code, - i::CALLS_AND_RETURNS); - CHECK(iterator->GetBreakLocation().IsCall()); - CHECK_EQ(32, iterator->GetBreakLocation().position()); - iterator->Next(); - CHECK(iterator->GetBreakLocation().IsReturn()); - CHECK_EQ(60, iterator->GetBreakLocation().position()); - iterator->Next(); - CHECK(iterator->Done()); - } - DisableDebugger(isolate); } @@ -6642,7 +6595,7 @@ TEST(DebugStepOverFunctionWithCaughtException) { "foo();\n"); v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); - CHECK_EQ(break_point_hit_count, 4); + CHECK_EQ(4, break_point_hit_count); } bool out_of_memory_callback_called = false; @@ -6672,3 +6625,41 @@ UNINITIALIZED_TEST(DebugSetOutOfMemoryListener) { } isolate->Dispose(); } + +TEST(DebugCoverage) { + i::FLAG_always_opt = false; + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + v8::debug::Coverage::TogglePrecise(isolate, true); + v8::Local<v8::String> source = v8_str( + "function f() {\n" + "}\n" + "f();\n" + "f();"); + CompileRun(source); + v8::debug::Coverage coverage = v8::debug::Coverage::Collect(isolate, false); + CHECK_EQ(1u, coverage.ScriptCount()); + v8::debug::Coverage::ScriptData script_data = coverage.GetScriptData(0); + v8::Local<v8::debug::Script> script = script_data.GetScript(); + CHECK(script->Source() + .ToLocalChecked() + ->Equals(env.local(), source) + .FromMaybe(false)); + + CHECK_EQ(2u, script_data.FunctionCount()); + v8::debug::Coverage::FunctionData function_data = + script_data.GetFunctionData(0); + CHECK_EQ(0, function_data.Start().GetLineNumber()); + CHECK_EQ(0, function_data.Start().GetColumnNumber()); + CHECK_EQ(3, function_data.End().GetLineNumber()); + CHECK_EQ(4, function_data.End().GetColumnNumber()); + CHECK_EQ(1, function_data.Count()); + + function_data = script_data.GetFunctionData(1); + CHECK_EQ(0, function_data.Start().GetLineNumber()); + CHECK_EQ(0, function_data.Start().GetColumnNumber()); + CHECK_EQ(1, function_data.End().GetLineNumber()); + CHECK_EQ(1, function_data.End().GetColumnNumber()); + CHECK_EQ(2, function_data.Count()); +} diff --git a/deps/v8/test/cctest/test-deoptimization.cc b/deps/v8/test/cctest/test-deoptimization.cc index 0d435c5e10..06d746b2e6 100644 --- a/deps/v8/test/cctest/test-deoptimization.cc +++ b/deps/v8/test/cctest/test-deoptimization.cc @@ -35,6 +35,7 @@ #include "src/debug/debug.h" #include "src/deoptimizer.h" #include "src/isolate.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" using ::v8::base::OS; diff --git a/deps/v8/test/cctest/test-dictionary.cc b/deps/v8/test/cctest/test-dictionary.cc index d7344a142f..b0d429f5c8 100644 --- a/deps/v8/test/cctest/test-dictionary.cc +++ b/deps/v8/test/cctest/test-dictionary.cc @@ -33,8 +33,9 @@ #include "src/execution.h" #include "src/factory.h" #include "src/global-handles.h" +#include "src/heap/spaces.h" #include "src/macro-assembler.h" -#include "src/objects.h" +#include "src/objects-inl.h" #include "test/cctest/heap/heap-utils.h" using namespace v8::internal; @@ -50,27 +51,27 @@ static void TestHashMap(Handle<HashMap> table) { Handle<JSObject> a = factory->NewJSArray(7); Handle<JSObject> b = factory->NewJSArray(11); table = HashMap::Put(table, a, b); - CHECK_EQ(table->NumberOfElements(), 1); + CHECK_EQ(1, table->NumberOfElements()); CHECK_EQ(table->Lookup(a), *b); // When the key does not exist in the map, Lookup returns the hole. CHECK_EQ(table->Lookup(b), CcTest::heap()->the_hole_value()); // Keys still have to be valid after objects were moved. CcTest::CollectGarbage(NEW_SPACE); - CHECK_EQ(table->NumberOfElements(), 1); + CHECK_EQ(1, table->NumberOfElements()); CHECK_EQ(table->Lookup(a), *b); CHECK_EQ(table->Lookup(b), CcTest::heap()->the_hole_value()); // Keys that are overwritten should not change number of elements. table = HashMap::Put(table, a, factory->NewJSArray(13)); - CHECK_EQ(table->NumberOfElements(), 1); + CHECK_EQ(1, table->NumberOfElements()); CHECK_NE(table->Lookup(a), *b); // Keys that have been removed are mapped to the hole. bool was_present = false; table = HashMap::Remove(table, a, &was_present); CHECK(was_present); - CHECK_EQ(table->NumberOfElements(), 0); + CHECK_EQ(0, table->NumberOfElements()); CHECK_EQ(table->Lookup(a), CcTest::heap()->the_hole_value()); // Keys should map back to their respective values and also should get @@ -121,19 +122,19 @@ static void TestHashSet(Handle<HashSet> table) { Handle<JSObject> a = factory->NewJSArray(7); Handle<JSObject> b = factory->NewJSArray(11); table = HashSet::Add(table, a); - CHECK_EQ(table->NumberOfElements(), 1); + CHECK_EQ(1, table->NumberOfElements()); CHECK(table->Has(isolate, a)); CHECK(!table->Has(isolate, b)); // Keys still have to be valid after objects were moved. CcTest::CollectGarbage(NEW_SPACE); - CHECK_EQ(table->NumberOfElements(), 1); + CHECK_EQ(1, table->NumberOfElements()); CHECK(table->Has(isolate, a)); CHECK(!table->Has(isolate, b)); // Keys that are overwritten should not change number of elements. table = HashSet::Add(table, a); - CHECK_EQ(table->NumberOfElements(), 1); + CHECK_EQ(1, table->NumberOfElements()); CHECK(table->Has(isolate, a)); CHECK(!table->Has(isolate, b)); @@ -142,7 +143,7 @@ static void TestHashSet(Handle<HashSet> table) { // bool was_present = false; // table = HashSet::Remove(table, a, &was_present); // CHECK(was_present); - // CHECK_EQ(table->NumberOfElements(), 0); + // CHECK_EQ(0, table->NumberOfElements()); // CHECK(!table->Has(a)); // CHECK(!table->Has(b)); diff --git a/deps/v8/test/cctest/test-disasm-arm.cc b/deps/v8/test/cctest/test-disasm-arm.cc index 3ba6bee8d4..0a3b8f1dec 100644 --- a/deps/v8/test/cctest/test-disasm-arm.cc +++ b/deps/v8/test/cctest/test-disasm-arm.cc @@ -1047,6 +1047,12 @@ TEST(Neon) { "f2142860 vadd.i16 q1, q2, q8"); COMPARE(vadd(Neon32, q15, q0, q8), "f260e860 vadd.i32 q15, q0, q8"); + COMPARE(vqadd(NeonU8, q0, q1, q2), + "f3020054 vqadd.u8 q0, q1, q2"); + COMPARE(vqadd(NeonS16, q1, q2, q8), + "f2142070 vqadd.s16 q1, q2, q8"); + COMPARE(vqadd(NeonU32, q15, q0, q8), + "f360e070 vqadd.u32 q15, q0, q8"); COMPARE(vsub(q15, q0, q8), "f260ed60 vsub.f32 q15, q0, q8"); COMPARE(vsub(Neon8, q0, q1, q2), @@ -1055,6 +1061,12 @@ TEST(Neon) { "f3142860 vsub.i16 q1, q2, q8"); COMPARE(vsub(Neon32, q15, q0, q8), "f360e860 vsub.i32 q15, q0, q8"); + COMPARE(vqsub(NeonU8, q0, q1, q2), + "f3020254 vqsub.u8 q0, q1, q2"); + COMPARE(vqsub(NeonS16, q1, q2, q8), + "f2142270 vqsub.s16 q1, q2, q8"); + COMPARE(vqsub(NeonU32, q15, q0, q8), + "f360e270 vqsub.u32 q15, q0, q8"); COMPARE(vmul(q0, q1, q2), "f3020d54 vmul.f32 q0, q1, q2"); COMPARE(vmul(Neon8, q0, q1, q2), @@ -1063,6 +1075,18 @@ TEST(Neon) { "f2142970 vmul.i16 q1, q2, q8"); COMPARE(vmul(Neon32, q15, q0, q8), "f260e970 vmul.i32 q15, q0, q8"); + COMPARE(vshl(NeonS8, q15, q0, 6), + "f2cee550 vshl.i8 q15, q0, #6"); + COMPARE(vshl(NeonU16, q15, q0, 10), + "f2dae550 vshl.i16 q15, q0, #10"); + COMPARE(vshl(NeonS32, q15, q0, 17), + "f2f1e550 vshl.i32 q15, q0, #17"); + COMPARE(vshr(NeonS8, q15, q0, 6), + "f2cae050 vshr.s8 q15, q0, #6"); + COMPARE(vshr(NeonU16, q15, q0, 10), + "f3d6e050 vshr.u16 q15, q0, #10"); + COMPARE(vshr(NeonS32, q15, q0, 17), + "f2efe050 vshr.s32 q15, q0, #17"); COMPARE(vrecpe(q15, q0), "f3fbe540 vrecpe.f32 q15, q0"); COMPARE(vrecps(q15, q0, q8), diff --git a/deps/v8/test/cctest/test-disasm-ia32.cc b/deps/v8/test/cctest/test-disasm-ia32.cc index 88471a26c8..73c9490d31 100644 --- a/deps/v8/test/cctest/test-disasm-ia32.cc +++ b/deps/v8/test/cctest/test-disasm-ia32.cc @@ -298,9 +298,6 @@ TEST(DisasmIa320) { __ jmp(&L1); __ jmp(Operand(ebx, ecx, times_4, 10000)); - ExternalReference after_break_target = - ExternalReference::debug_after_break_target_address(isolate); - __ jmp(Operand::StaticVariable(after_break_target)); __ jmp(ic, RelocInfo::CODE_TARGET); __ nop(); diff --git a/deps/v8/test/cctest/test-disasm-x64.cc b/deps/v8/test/cctest/test-disasm-x64.cc index af8beaaa83..e65ccc55e7 100644 --- a/deps/v8/test/cctest/test-disasm-x64.cc +++ b/deps/v8/test/cctest/test-disasm-x64.cc @@ -34,6 +34,7 @@ #include "src/disasm.h" #include "src/disassembler.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" using namespace v8::internal; @@ -290,9 +291,6 @@ TEST(DisasmX64) { __ jmp(&L1); // TODO(mstarzinger): The following is protected. // __ jmp(Operand(rbx, rcx, times_4, 10000)); - ExternalReference after_break_target = - ExternalReference::debug_after_break_target_address(isolate); - USE(after_break_target); __ jmp(ic, RelocInfo::CODE_TARGET); __ nop(); @@ -386,6 +384,7 @@ TEST(DisasmX64) { __ cvtsd2ss(xmm0, xmm1); __ cvtsd2ss(xmm0, Operand(rbx, rcx, times_4, 10000)); __ movaps(xmm0, xmm1); + __ shufps(xmm0, xmm9, 0x0); // logic operation __ andps(xmm0, xmm1); diff --git a/deps/v8/test/cctest/test-elements-kind.cc b/deps/v8/test/cctest/test-elements-kind.cc index ee1f09d0a0..3478fca1cd 100644 --- a/deps/v8/test/cctest/test-elements-kind.cc +++ b/deps/v8/test/cctest/test-elements-kind.cc @@ -14,7 +14,7 @@ #include "src/factory.h" #include "src/global-handles.h" #include "src/ic/stub-cache.h" -#include "src/objects.h" +#include "src/objects-inl.h" using namespace v8::internal; @@ -78,7 +78,7 @@ TEST(JSObjectAddingProperties) { Handle<JSObject> object = factory->NewJSObject(function); Handle<Map> previous_map(object->map()); - CHECK_EQ(previous_map->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, previous_map->elements_kind()); CHECK(EQUALS(object->properties(), empty_fixed_array)); CHECK(EQUALS(object->elements(), empty_fixed_array)); @@ -88,7 +88,7 @@ TEST(JSObjectAddingProperties) { JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE) .Check(); CHECK_NE(object->map(), *previous_map); - CHECK_EQ(object->map()->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, object->map()->elements_kind()); CHECK_LE(1, object->properties()->length()); CHECK(EQUALS(object->elements(), empty_fixed_array)); } @@ -109,7 +109,7 @@ TEST(JSObjectInObjectAddingProperties) { Handle<JSObject> object = factory->NewJSObject(function); Handle<Map> previous_map(object->map()); - CHECK_EQ(previous_map->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, previous_map->elements_kind()); CHECK(EQUALS(object->properties(), empty_fixed_array)); CHECK(EQUALS(object->elements(), empty_fixed_array)); @@ -121,7 +121,7 @@ TEST(JSObjectInObjectAddingProperties) { .Check(); } CHECK_NE(object->map(), *previous_map); - CHECK_EQ(object->map()->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, object->map()->elements_kind()); CHECK(EQUALS(object->properties(), empty_fixed_array)); CHECK(EQUALS(object->elements(), empty_fixed_array)); @@ -132,7 +132,7 @@ TEST(JSObjectInObjectAddingProperties) { JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE) .Check(); CHECK_NE(object->map(), *previous_map); - CHECK_EQ(object->map()->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, object->map()->elements_kind()); // there must be at least 1 element in the properies store CHECK_LE(1, object->properties()->length()); CHECK(EQUALS(object->elements(), empty_fixed_array)); @@ -152,7 +152,7 @@ TEST(JSObjectAddingElements) { Handle<JSObject> object = factory->NewJSObject(function); Handle<Map> previous_map(object->map()); - CHECK_EQ(previous_map->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, previous_map->elements_kind()); CHECK(EQUALS(object->properties(), empty_fixed_array)); CHECK(EQUALS(object->elements(), empty_fixed_array)); @@ -162,7 +162,7 @@ TEST(JSObjectAddingElements) { .Check(); // no change in elements_kind => no map transition CHECK_EQ(object->map(), *previous_map); - CHECK_EQ(object->map()->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, object->map()->elements_kind()); CHECK(EQUALS(object->properties(), empty_fixed_array)); CHECK_LE(1, object->elements()->length()); @@ -175,7 +175,7 @@ TEST(JSObjectAddingElements) { } // no change in elements_kind => no map transition CHECK_EQ(object->map(), *previous_map); - CHECK_EQ(object->map()->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, object->map()->elements_kind()); CHECK(EQUALS(object->properties(), empty_fixed_array)); CHECK_LE(non_dict_backing_store_limit, object->elements()->length()); @@ -186,7 +186,7 @@ TEST(JSObjectAddingElements) { .Check(); // change in elements_kind => map transition CHECK_NE(object->map(), *previous_map); - CHECK_EQ(object->map()->elements_kind(), DICTIONARY_ELEMENTS); + CHECK_EQ(DICTIONARY_ELEMENTS, object->map()->elements_kind()); CHECK(EQUALS(object->properties(), empty_fixed_array)); CHECK_LE(non_dict_backing_store_limit, object->elements()->length()); } @@ -204,10 +204,10 @@ TEST(JSArrayAddingProperties) { Handle<JSArray> array = factory->NewJSArray(ElementsKind::FAST_SMI_ELEMENTS, 0, 0); Handle<Map> previous_map(array->map()); - CHECK_EQ(previous_map->elements_kind(), FAST_SMI_ELEMENTS); + CHECK_EQ(FAST_SMI_ELEMENTS, previous_map->elements_kind()); CHECK(EQUALS(array->properties(), empty_fixed_array)); CHECK(EQUALS(array->elements(), empty_fixed_array)); - CHECK_EQ(Smi::cast(array->length())->value(), 0); + CHECK_EQ(0, Smi::cast(array->length())->value()); // for the default constructor function no in-object properties are reserved // hence adding a single property will initialize the property-array @@ -216,10 +216,10 @@ TEST(JSArrayAddingProperties) { .Check(); // No change in elements_kind but added property => new map CHECK_NE(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_SMI_ELEMENTS); + CHECK_EQ(FAST_SMI_ELEMENTS, array->map()->elements_kind()); CHECK_LE(1, array->properties()->length()); CHECK(EQUALS(array->elements(), empty_fixed_array)); - CHECK_EQ(Smi::cast(array->length())->value(), 0); + CHECK_EQ(0, Smi::cast(array->length())->value()); } @@ -236,10 +236,10 @@ TEST(JSArrayAddingElements) { Handle<JSArray> array = factory->NewJSArray(ElementsKind::FAST_SMI_ELEMENTS, 0, 0); Handle<Map> previous_map(array->map()); - CHECK_EQ(previous_map->elements_kind(), FAST_SMI_ELEMENTS); + CHECK_EQ(FAST_SMI_ELEMENTS, previous_map->elements_kind()); CHECK(EQUALS(array->properties(), empty_fixed_array)); CHECK(EQUALS(array->elements(), empty_fixed_array)); - CHECK_EQ(Smi::cast(array->length())->value(), 0); + CHECK_EQ(0, Smi::cast(array->length())->value()); // Adding an indexed element initializes the elements array name = MakeString("0"); @@ -247,7 +247,7 @@ TEST(JSArrayAddingElements) { .Check(); // no change in elements_kind => no map transition CHECK_EQ(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_SMI_ELEMENTS); + CHECK_EQ(FAST_SMI_ELEMENTS, array->map()->elements_kind()); CHECK(EQUALS(array->properties(), empty_fixed_array)); CHECK_LE(1, array->elements()->length()); CHECK_EQ(1, Smi::cast(array->length())->value()); @@ -261,7 +261,7 @@ TEST(JSArrayAddingElements) { } // no change in elements_kind => no map transition CHECK_EQ(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_SMI_ELEMENTS); + CHECK_EQ(FAST_SMI_ELEMENTS, array->map()->elements_kind()); CHECK(EQUALS(array->properties(), empty_fixed_array)); CHECK_LE(non_dict_backing_store_limit, array->elements()->length()); CHECK_EQ(non_dict_backing_store_limit, Smi::cast(array->length())->value()); @@ -274,7 +274,7 @@ TEST(JSArrayAddingElements) { .Check(); // change in elements_kind => map transition CHECK_NE(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), DICTIONARY_ELEMENTS); + CHECK_EQ(DICTIONARY_ELEMENTS, array->map()->elements_kind()); CHECK(EQUALS(array->properties(), empty_fixed_array)); CHECK_LE(non_dict_backing_store_limit, array->elements()->length()); CHECK_LE(array->elements()->length(), index); @@ -296,8 +296,8 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) { Handle<JSArray> array = factory->NewJSArray(ElementsKind::FAST_SMI_ELEMENTS, 0, 0); Handle<Map> previous_map(array->map()); - CHECK_EQ(previous_map->elements_kind(), FAST_SMI_ELEMENTS); - CHECK_EQ(Smi::cast(array->length())->value(), 0); + CHECK_EQ(FAST_SMI_ELEMENTS, previous_map->elements_kind()); + CHECK_EQ(0, Smi::cast(array->length())->value()); // `array[0] = smi_value` doesn't change the elements_kind name = MakeString("0"); @@ -306,14 +306,14 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) { .Check(); // no change in elements_kind => no map transition CHECK_EQ(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_SMI_ELEMENTS); + CHECK_EQ(FAST_SMI_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(1, Smi::cast(array->length())->value()); // `delete array[0]` does not alter length, but changes the elments_kind name = MakeString("0"); CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false)); CHECK_NE(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_HOLEY_SMI_ELEMENTS); + CHECK_EQ(FAST_HOLEY_SMI_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(1, Smi::cast(array->length())->value()); previous_map = handle(array->map()); @@ -327,7 +327,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) { NONE) .Check(); CHECK_EQ(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_HOLEY_SMI_ELEMENTS); + CHECK_EQ(FAST_HOLEY_SMI_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(2, Smi::cast(array->length())->value()); // Adding a string to the array changes from FAST_HOLEY_SMI to FAST_HOLEY @@ -336,7 +336,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) { NONE) .Check(); CHECK_NE(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(2, Smi::cast(array->length())->value()); previous_map = handle(array->map()); @@ -369,8 +369,8 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) { Handle<JSArray> array = factory->NewJSArray(ElementsKind::FAST_ELEMENTS, 0, 0); Handle<Map> previous_map(array->map()); - CHECK_EQ(previous_map->elements_kind(), FAST_ELEMENTS); - CHECK_EQ(Smi::cast(array->length())->value(), 0); + CHECK_EQ(FAST_ELEMENTS, previous_map->elements_kind()); + CHECK_EQ(0, Smi::cast(array->length())->value()); // `array[0] = smi_value` doesn't change the elements_kind name = MakeString("0"); @@ -379,14 +379,14 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) { .Check(); // no change in elements_kind => no map transition CHECK_EQ(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_ELEMENTS); + CHECK_EQ(FAST_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(1, Smi::cast(array->length())->value()); // `delete array[0]` does not alter length, but changes the elments_kind name = MakeString("0"); CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false)); CHECK_NE(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(1, Smi::cast(array->length())->value()); previous_map = handle(array->map()); @@ -400,7 +400,7 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) { NONE) .Check(); CHECK_EQ(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(2, Smi::cast(array->length())->value()); } @@ -426,7 +426,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) { NONE) .Check(); CHECK_NE(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_DOUBLE_ELEMENTS); + CHECK_EQ(FAST_DOUBLE_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(1, Smi::cast(array->length())->value()); previous_map = handle(array->map()); @@ -436,14 +436,14 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) { NONE) .Check(); CHECK_EQ(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_DOUBLE_ELEMENTS); + CHECK_EQ(FAST_DOUBLE_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(2, Smi::cast(array->length())->value()); // `delete array[0]` does not alter length, but changes the elments_kind name = MakeString("0"); CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false)); CHECK_NE(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_HOLEY_DOUBLE_ELEMENTS); + CHECK_EQ(FAST_HOLEY_DOUBLE_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(2, Smi::cast(array->length())->value()); previous_map = handle(array->map()); @@ -453,7 +453,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) { NONE) .Check(); CHECK_EQ(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_HOLEY_DOUBLE_ELEMENTS); + CHECK_EQ(FAST_HOLEY_DOUBLE_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(2, Smi::cast(array->length())->value()); // Adding a string to the array changes to elements_kind FAST_ELEMENTS @@ -462,7 +462,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) { NONE) .Check(); CHECK_NE(array->map(), *previous_map); - CHECK_EQ(array->map()->elements_kind(), FAST_HOLEY_ELEMENTS); + CHECK_EQ(FAST_HOLEY_ELEMENTS, array->map()->elements_kind()); CHECK_EQ(2, Smi::cast(array->length())->value()); previous_map = handle(array->map()); diff --git a/deps/v8/test/cctest/test-feedback-vector.cc b/deps/v8/test/cctest/test-feedback-vector.cc index 254a150af0..0d6fc55911 100644 --- a/deps/v8/test/cctest/test-feedback-vector.cc +++ b/deps/v8/test/cctest/test-feedback-vector.cc @@ -11,7 +11,7 @@ #include "src/factory.h" #include "src/global-handles.h" #include "src/macro-assembler.h" -#include "src/objects.h" +#include "src/objects-inl.h" #include "test/cctest/test-feedback-vector.h" using namespace v8::internal; @@ -38,13 +38,7 @@ TEST(VectorStructure) { Factory* factory = isolate->factory(); Zone zone(isolate->allocator(), ZONE_NAME); - // Empty vectors are the empty fixed array. - StaticFeedbackVectorSpec empty; - Handle<FeedbackVector> vector = NewFeedbackVector(isolate, &empty); - CHECK(Handle<FixedArray>::cast(vector).is_identical_to( - factory->empty_feedback_vector())); - // Which can nonetheless be queried. - CHECK(vector->is_empty()); + Handle<FeedbackVector> vector; { FeedbackVectorSpec one_slot(&zone); @@ -84,30 +78,28 @@ TEST(VectorStructure) { CHECK_EQ(helper.slot(3), vector->ToSlot(index)); index = vector->GetIndex(helper.slot(7)); - CHECK_EQ( - FeedbackVector::kReservedIndexCount + 3 + - 4 * FeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind::CALL_IC), - index); + CHECK_EQ(FeedbackVector::kReservedIndexCount + 3 + + 4 * FeedbackMetadata::GetSlotSize(FeedbackSlotKind::kCall), + index); CHECK_EQ(helper.slot(7), vector->ToSlot(index)); - CHECK_EQ( - FeedbackVector::kReservedIndexCount + 3 + - 5 * FeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind::CALL_IC), - vector->length()); + CHECK_EQ(FeedbackVector::kReservedIndexCount + 3 + + 5 * FeedbackMetadata::GetSlotSize(FeedbackSlotKind::kCall), + vector->length()); } { FeedbackVectorSpec spec(&zone); spec.AddGeneralSlot(); - spec.AddCreateClosureSlot(5); + spec.AddCreateClosureSlot(); spec.AddGeneralSlot(); vector = NewFeedbackVector(isolate, &spec); FeedbackVectorHelper helper(vector); - CHECK_EQ(1, FeedbackMetadata::GetSlotSize( - FeedbackVectorSlotKind::CREATE_CLOSURE)); - FeedbackVectorSlot slot = helper.slot(1); - FixedArray* array = FixedArray::cast(vector->Get(slot)); - CHECK_EQ(array, *factory->empty_literals_array()); + CHECK_EQ(1, + FeedbackMetadata::GetSlotSize(FeedbackSlotKind::kCreateClosure)); + FeedbackSlot slot = helper.slot(1); + Cell* cell = Cell::cast(vector->Get(slot)); + CHECK_EQ(cell->value(), *factory->undefined_value()); } } @@ -144,23 +136,23 @@ TEST(VectorICMetadata) { // Meanwhile set some feedback values and type feedback values to // verify the data structure remains intact. - vector->Set(FeedbackVectorSlot(0), *vector); + vector->Set(FeedbackSlot(0), *vector); // Verify the metadata is correctly set up from the spec. for (int i = 0; i < 40; i++) { - FeedbackVectorSlotKind kind = vector->GetKind(helper.slot(i)); + FeedbackSlotKind kind = vector->GetKind(helper.slot(i)); switch (i % 4) { case 0: - CHECK_EQ(FeedbackVectorSlotKind::GENERAL, kind); + CHECK_EQ(FeedbackSlotKind::kGeneral, kind); break; case 1: - CHECK_EQ(FeedbackVectorSlotKind::CALL_IC, kind); + CHECK_EQ(FeedbackSlotKind::kCall, kind); break; case 2: - CHECK_EQ(FeedbackVectorSlotKind::LOAD_IC, kind); + CHECK_EQ(FeedbackSlotKind::kLoadProperty, kind); break; case 3: - CHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, kind); + CHECK_EQ(FeedbackSlotKind::kLoadKeyed, kind); break; } } @@ -174,9 +166,11 @@ TEST(VectorSlotClearing) { Factory* factory = isolate->factory(); Zone zone(isolate->allocator(), ZONE_NAME); - // We only test clearing FeedbackVectorSlots, not FeedbackVectorSlots. - // The reason is that FeedbackVectorSlots need a full code environment - // to fully test (See VectorICProfilerStatistics test below). + CompileRun("function f() {};"); + Handle<JSFunction> f = GetFunction("f"); + + // We only test clearing of a FeedbackSlotKind::kGeneral slots because all + // the other slot kinds require a host function for clearing. FeedbackVectorSpec spec(&zone); for (int i = 0; i < 5; i++) { spec.AddGeneralSlot(); @@ -191,12 +185,7 @@ TEST(VectorSlotClearing) { Handle<AllocationSite> site = factory->NewAllocationSite(); vector->Set(helper.slot(2), *site); - // GC time clearing leaves slots alone. - vector->ClearSlotsAtGCTime(NULL); - Object* obj = vector->Get(helper.slot(1)); - CHECK(obj->IsWeakCell() && !WeakCell::cast(obj)->cleared()); - - vector->ClearSlots(NULL); + vector->ClearSlots(*f); // The feedback vector slots are cleared. AllocationSites are still granted // an exemption from clearing, as are smis. @@ -221,7 +210,7 @@ TEST(VectorCallICStates) { // There should be one IC. Handle<FeedbackVector> feedback_vector = Handle<FeedbackVector>(f->feedback_vector(), isolate); - FeedbackVectorSlot slot(0); + FeedbackSlot slot(0); CallICNexus nexus(feedback_vector, slot); CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); // CallIC doesn't return map feedback. @@ -249,7 +238,7 @@ TEST(VectorCallFeedbackForArray) { // There should be one IC. Handle<FeedbackVector> feedback_vector = Handle<FeedbackVector>(f->feedback_vector(), isolate); - FeedbackVectorSlot slot(0); + FeedbackSlot slot(0); CallICNexus nexus(feedback_vector, slot); // A call to Array is special, it contains an AllocationSite as feedback. @@ -276,7 +265,7 @@ TEST(VectorCallCounts) { // There should be one IC. Handle<FeedbackVector> feedback_vector = Handle<FeedbackVector>(f->feedback_vector(), isolate); - FeedbackVectorSlot slot(0); + FeedbackSlot slot(0); CallICNexus nexus(feedback_vector, slot); CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); @@ -305,7 +294,7 @@ TEST(VectorConstructCounts) { Handle<FeedbackVector> feedback_vector = Handle<FeedbackVector>(f->feedback_vector(), isolate); - FeedbackVectorSlot slot(0); + FeedbackSlot slot(0); CallICNexus nexus(feedback_vector, slot); CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); @@ -336,7 +325,7 @@ TEST(VectorLoadICStates) { // There should be one IC. Handle<FeedbackVector> feedback_vector = Handle<FeedbackVector>(f->feedback_vector(), isolate); - FeedbackVectorSlot slot(0); + FeedbackSlot slot(0); LoadICNexus nexus(feedback_vector, slot); CHECK_EQ(PREMONOMORPHIC, nexus.StateFromFeedback()); @@ -374,32 +363,38 @@ TEST(VectorLoadICStates) { CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); } - -TEST(VectorLoadICSlotSharing) { +TEST(VectorLoadGlobalICSlotSharing) { if (i::FLAG_always_opt) return; CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); Isolate* isolate = CcTest::i_isolate(); - // Function f has 3 LoadICs, one for each o, but the ICs share the same - // feedback vector IC slot. + // Function f has 5 LoadGlobalICs: 3 for {o} references outside of "typeof" + // operator and 2 for {o} references inside "typeof" operator. CompileRun( "o = 10;" "function f() {" " var x = o || 10;" - " return o , x , o;" + " var y = typeof o;" + " return o , typeof o, x , y, o;" "}" "f();"); Handle<JSFunction> f = GetFunction("f"); - // There should be one IC slot. + // There should be two IC slots for {o} references outside and inside + // typeof operator respectively. Handle<FeedbackVector> feedback_vector = Handle<FeedbackVector>(f->feedback_vector(), isolate); FeedbackVectorHelper helper(feedback_vector); - CHECK_EQ(1, helper.slot_count()); - FeedbackVectorSlot slot(0); - LoadGlobalICNexus nexus(feedback_vector, slot); - CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); + CHECK_EQ(2, helper.slot_count()); + CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kLoadGlobalNotInsideTypeof); + CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kLoadGlobalInsideTypeof); + FeedbackSlot slot1 = helper.slot(0); + FeedbackSlot slot2 = helper.slot(1); + CHECK_EQ(MONOMORPHIC, + LoadGlobalICNexus(feedback_vector, slot1).StateFromFeedback()); + CHECK_EQ(MONOMORPHIC, + LoadGlobalICNexus(feedback_vector, slot2).StateFromFeedback()); } @@ -419,7 +414,7 @@ TEST(VectorLoadICOnSmi) { // There should be one IC. Handle<FeedbackVector> feedback_vector = Handle<FeedbackVector>(f->feedback_vector(), isolate); - FeedbackVectorSlot slot(0); + FeedbackSlot slot(0); LoadICNexus nexus(feedback_vector, slot); CHECK_EQ(PREMONOMORPHIC, nexus.StateFromFeedback()); @@ -486,15 +481,16 @@ TEST(ReferenceContextAllocatesNoSlots) { handle(f->feedback_vector(), isolate); FeedbackVectorHelper helper(feedback_vector); CHECK_EQ(4, helper.slot_count()); - CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::STORE_IC); - CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::LOAD_GLOBAL_IC); - CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::STORE_IC); - CHECK_SLOT_KIND(helper, 3, FeedbackVectorSlotKind::LOAD_GLOBAL_IC); + CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kStoreNamedSloppy); + CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kLoadGlobalNotInsideTypeof); + CHECK_SLOT_KIND(helper, 2, FeedbackSlotKind::kStoreNamedSloppy); + CHECK_SLOT_KIND(helper, 3, FeedbackSlotKind::kLoadGlobalNotInsideTypeof); } { CompileRun( "function testprop(x) {" + " 'use strict';" " x.blue = a;" "}" "testprop({ blue: 3 });"); @@ -505,8 +501,8 @@ TEST(ReferenceContextAllocatesNoSlots) { Handle<FeedbackVector> feedback_vector(f->feedback_vector()); FeedbackVectorHelper helper(feedback_vector); CHECK_EQ(2, helper.slot_count()); - CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::LOAD_GLOBAL_IC); - CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::STORE_IC); + CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kLoadGlobalNotInsideTypeof); + CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kStoreNamedStrict); } { @@ -525,11 +521,11 @@ TEST(ReferenceContextAllocatesNoSlots) { Handle<FeedbackVector> feedback_vector(f->feedback_vector()); FeedbackVectorHelper helper(feedback_vector); CHECK_EQ(5, helper.slot_count()); - CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::CALL_IC); - CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::LOAD_GLOBAL_IC); - CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::STORE_IC); - CHECK_SLOT_KIND(helper, 3, FeedbackVectorSlotKind::CALL_IC); - CHECK_SLOT_KIND(helper, 4, FeedbackVectorSlotKind::LOAD_IC); + CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kCall); + CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kLoadGlobalNotInsideTypeof); + CHECK_SLOT_KIND(helper, 2, FeedbackSlotKind::kStoreNamedSloppy); + CHECK_SLOT_KIND(helper, 3, FeedbackSlotKind::kCall); + CHECK_SLOT_KIND(helper, 4, FeedbackSlotKind::kLoadProperty); } { @@ -547,14 +543,36 @@ TEST(ReferenceContextAllocatesNoSlots) { Handle<FeedbackVector> feedback_vector(f->feedback_vector()); FeedbackVectorHelper helper(feedback_vector); CHECK_EQ(3, helper.slot_count()); - CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::LOAD_GLOBAL_IC); - CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::KEYED_STORE_IC); - CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::KEYED_LOAD_IC); + CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kLoadGlobalNotInsideTypeof); + CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kStoreKeyedSloppy); + CHECK_SLOT_KIND(helper, 2, FeedbackSlotKind::kLoadKeyed); + } + + { + CompileRun( + "function testkeyedprop(x) {" + " 'use strict';" + " x[0] = a;" + " return x[0];" + "}" + "testkeyedprop([0, 1, 2]);"); + + Handle<JSFunction> f = GetFunction("testkeyedprop"); + + // There should be 1 LOAD_GLOBAL_ICs for the load of a, and one + // KEYED_LOAD_IC for the load of x[0] in the return statement. + Handle<FeedbackVector> feedback_vector(f->feedback_vector()); + FeedbackVectorHelper helper(feedback_vector); + CHECK_EQ(3, helper.slot_count()); + CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kLoadGlobalNotInsideTypeof); + CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kStoreKeyedStrict); + CHECK_SLOT_KIND(helper, 2, FeedbackSlotKind::kLoadKeyed); } { CompileRun( "function testcompound(x) {" + " 'use strict';" " x.old = x.young = x.in_between = a;" " return x.old + x.young;" "}" @@ -567,13 +585,13 @@ TEST(ReferenceContextAllocatesNoSlots) { Handle<FeedbackVector> feedback_vector(f->feedback_vector()); FeedbackVectorHelper helper(feedback_vector); CHECK_EQ(7, helper.slot_count()); - CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::LOAD_GLOBAL_IC); - CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::STORE_IC); - CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::STORE_IC); - CHECK_SLOT_KIND(helper, 3, FeedbackVectorSlotKind::STORE_IC); - CHECK_SLOT_KIND(helper, 4, FeedbackVectorSlotKind::LOAD_IC); - CHECK_SLOT_KIND(helper, 5, FeedbackVectorSlotKind::LOAD_IC); - CHECK_SLOT_KIND(helper, 6, FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC); + CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kLoadGlobalNotInsideTypeof); + CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kStoreNamedStrict); + CHECK_SLOT_KIND(helper, 2, FeedbackSlotKind::kStoreNamedStrict); + CHECK_SLOT_KIND(helper, 3, FeedbackSlotKind::kStoreNamedStrict); + CHECK_SLOT_KIND(helper, 4, FeedbackSlotKind::kLoadProperty); + CHECK_SLOT_KIND(helper, 5, FeedbackSlotKind::kLoadProperty); + CHECK_SLOT_KIND(helper, 6, FeedbackSlotKind::kBinaryOp); } } @@ -598,9 +616,34 @@ TEST(VectorStoreICBasic) { Handle<FeedbackVector> feedback_vector(f->feedback_vector()); FeedbackVectorHelper helper(feedback_vector); CHECK_EQ(1, helper.slot_count()); - FeedbackVectorSlot slot(0); + FeedbackSlot slot(0); StoreICNexus nexus(feedback_vector, slot); CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); } +TEST(StoreOwnIC) { + if (i::FLAG_always_opt) return; + + CcTest::InitializeVM(); + LocalContext context; + v8::HandleScope scope(context->GetIsolate()); + + CompileRun( + "function f(v) {" + " return {a: 0, b: v, c: 0};" + "}" + "f(1);" + "f(2);" + "f(3);"); + Handle<JSFunction> f = GetFunction("f"); + // There should be one IC slot. + Handle<FeedbackVector> feedback_vector(f->feedback_vector()); + FeedbackVectorHelper helper(feedback_vector); + CHECK_EQ(2, helper.slot_count()); + CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kLiteral); + CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kStoreOwnNamed); + StoreOwnICNexus nexus(feedback_vector, helper.slot(1)); + CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); +} + } // namespace diff --git a/deps/v8/test/cctest/test-feedback-vector.h b/deps/v8/test/cctest/test-feedback-vector.h index c73ad01c51..6bae553c85 100644 --- a/deps/v8/test/cctest/test-feedback-vector.h +++ b/deps/v8/test/cctest/test-feedback-vector.h @@ -21,7 +21,7 @@ class FeedbackVectorHelper { slots_.reserve(slot_count); FeedbackMetadataIterator iter(vector->metadata()); while (iter.HasNext()) { - FeedbackVectorSlot slot = iter.Next(); + FeedbackSlot slot = iter.Next(); slots_.push_back(slot); } } @@ -29,22 +29,29 @@ class FeedbackVectorHelper { Handle<FeedbackVector> vector() { return vector_; } // Returns slot identifier by numerical index. - FeedbackVectorSlot slot(int index) const { return slots_[index]; } + FeedbackSlot slot(int index) const { return slots_[index]; } // Returns the number of slots in the feedback vector. int slot_count() const { return static_cast<int>(slots_.size()); } private: Handle<FeedbackVector> vector_; - std::vector<FeedbackVectorSlot> slots_; + std::vector<FeedbackSlot> slots_; }; template <typename Spec> Handle<FeedbackVector> NewFeedbackVector(Isolate* isolate, Spec* spec) { Handle<FeedbackMetadata> metadata = FeedbackMetadata::New(isolate, spec); - return FeedbackVector::New(isolate, metadata); + Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( + isolate->factory()->empty_string(), MaybeHandle<Code>(), false); + shared->set_feedback_metadata(*metadata); + return FeedbackVector::New(isolate, shared); } +template <typename Spec> +Handle<FeedbackMetadata> NewFeedbackMetadata(Isolate* isolate, Spec* spec) { + return FeedbackMetadata::New(isolate, spec); +} } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-field-type-tracking.cc b/deps/v8/test/cctest/test-field-type-tracking.cc index 4abde16cd6..04e23790ad 100644 --- a/deps/v8/test/cctest/test-field-type-tracking.cc +++ b/deps/v8/test/cctest/test-field-type-tracking.cc @@ -18,13 +18,16 @@ #include "src/global-handles.h" #include "src/ic/stub-cache.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" +#include "src/property.h" +#include "src/transitions.h" using namespace v8::internal; // TODO(ishell): fix this once TransitionToPrototype stops generalizing // all field representations (similar to crbug/448711 where elements kind -// and observed transitions caused generalization of all field representations). +// and observed transitions caused generalization of all fields). const bool IS_PROTO_TRANS_ISSUE_FIXED = false; @@ -79,6 +82,7 @@ class Expectations { ElementsKind elements_kind_; PropertyKind kinds_[MAX_PROPERTIES]; PropertyLocation locations_[MAX_PROPERTIES]; + PropertyConstness constnesses_[MAX_PROPERTIES]; PropertyAttributes attributes_[MAX_PROPERTIES]; Representation representations_[MAX_PROPERTIES]; // FieldType for kField, value for DATA_CONSTANT and getter for @@ -100,11 +104,12 @@ class Expectations { isolate->object_function()->initial_map()->elements_kind()) {} void Init(int index, PropertyKind kind, PropertyAttributes attributes, - PropertyLocation location, Representation representation, - Handle<Object> value) { + PropertyConstness constness, PropertyLocation location, + Representation representation, Handle<Object> value) { CHECK(index < MAX_PROPERTIES); kinds_[index] = kind; locations_[index] = location; + constnesses_[index] = constness; attributes_[index] = attributes; representations_[index] = representation; values_[index] = value; @@ -126,6 +131,7 @@ class Expectations { } os << " ("; + if (constnesses_[i] == kConst) os << "const "; os << (kinds_[i] == kData ? "data " : "accessor "); if (locations_[i] == kField) { os << "field" @@ -149,18 +155,20 @@ class Expectations { } void SetDataField(int index, PropertyAttributes attrs, - Representation representation, + PropertyConstness constness, Representation representation, Handle<FieldType> field_type) { - Init(index, kData, attrs, kField, representation, field_type); + Init(index, kData, attrs, constness, kField, representation, field_type); } - void SetDataField(int index, Representation representation, + void SetDataField(int index, PropertyConstness constness, + Representation representation, Handle<FieldType> field_type) { - SetDataField(index, attributes_[index], representation, field_type); + SetDataField(index, attributes_[index], constness, representation, + field_type); } void SetAccessorField(int index, PropertyAttributes attrs) { - Init(index, kAccessor, attrs, kDescriptor, Representation::Tagged(), + Init(index, kAccessor, attrs, kConst, kDescriptor, Representation::Tagged(), FieldType::Any(isolate_)); } @@ -170,7 +178,15 @@ class Expectations { void SetDataConstant(int index, PropertyAttributes attrs, Handle<JSFunction> value) { - Init(index, kData, attrs, kDescriptor, Representation::HeapObject(), value); + if (FLAG_track_constant_fields) { + Handle<FieldType> field_type(FieldType::Class(value->map()), isolate_); + Init(index, kData, attrs, kConst, kField, Representation::HeapObject(), + field_type); + + } else { + Init(index, kData, attrs, kConst, kDescriptor, + Representation::HeapObject(), value); + } } void SetDataConstant(int index, Handle<JSFunction> value) { @@ -179,7 +195,7 @@ class Expectations { void SetAccessorConstant(int index, PropertyAttributes attrs, Handle<Object> getter, Handle<Object> setter) { - Init(index, kAccessor, attrs, kDescriptor, Representation::Tagged(), + Init(index, kAccessor, attrs, kConst, kDescriptor, Representation::Tagged(), getter); setter_values_[index] = setter; } @@ -215,7 +231,7 @@ class Expectations { SetAccessorConstant(index, getter, setter); } - void GeneralizeRepresentation(int index) { + void GeneralizeField(int index) { CHECK(index < number_of_properties_); representations_[index] = Representation::Tagged(); if (locations_[index] == kField) { @@ -223,12 +239,12 @@ class Expectations { } } - bool Check(DescriptorArray* descriptors, int descriptor) const { PropertyDetails details = descriptors->GetDetails(descriptor); if (details.kind() != kinds_[descriptor]) return false; if (details.location() != locations_[descriptor]) return false; + if (details.constness() != constnesses_[descriptor]) return false; PropertyAttributes expected_attributes = attributes_[descriptor]; if (details.attributes() != expected_attributes) return false; @@ -250,6 +266,7 @@ class Expectations { } else { // kDescriptor if (details.kind() == kData) { + CHECK(!FLAG_track_constant_fields); return value == expected_value; } else { // kAccessor @@ -300,15 +317,17 @@ class Expectations { } Handle<Map> AddDataField(Handle<Map> map, PropertyAttributes attributes, + PropertyConstness constness, Representation representation, Handle<FieldType> heap_type) { CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); int property_index = number_of_properties_++; - SetDataField(property_index, attributes, representation, heap_type); + SetDataField(property_index, attributes, constness, representation, + heap_type); Handle<String> name = MakeName("prop", property_index); - return Map::CopyWithField(map, name, heap_type, attributes, representation, - INSERT_TRANSITION) + return Map::CopyWithField(map, name, heap_type, attributes, constness, + representation, INSERT_TRANSITION) .ToHandleChecked(); } @@ -326,16 +345,19 @@ class Expectations { Handle<Map> TransitionToDataField(Handle<Map> map, PropertyAttributes attributes, + PropertyConstness constness, Representation representation, Handle<FieldType> heap_type, Handle<Object> value) { CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); int property_index = number_of_properties_++; - SetDataField(property_index, attributes, representation, heap_type); + SetDataField(property_index, attributes, constness, representation, + heap_type); Handle<String> name = MakeName("prop", property_index); return Map::TransitionToDataProperty( - map, name, value, attributes, Object::CERTAINLY_NOT_STORE_FROM_KEYED); + map, name, value, attributes, constness, + Object::CERTAINLY_NOT_STORE_FROM_KEYED); } Handle<Map> TransitionToDataConstant(Handle<Map> map, @@ -347,16 +369,19 @@ class Expectations { Handle<String> name = MakeName("prop", property_index); return Map::TransitionToDataProperty( - map, name, value, attributes, Object::CERTAINLY_NOT_STORE_FROM_KEYED); + map, name, value, attributes, kConst, + Object::CERTAINLY_NOT_STORE_FROM_KEYED); } Handle<Map> FollowDataTransition(Handle<Map> map, PropertyAttributes attributes, + PropertyConstness constness, Representation representation, Handle<FieldType> heap_type) { CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); int property_index = number_of_properties_++; - SetDataField(property_index, attributes, representation, heap_type); + SetDataField(property_index, attributes, constness, representation, + heap_type); Handle<String> name = MakeName("prop", property_index); Map* target = @@ -461,7 +486,9 @@ TEST(ReconfigureAccessorToNonExistingDataField) { CHECK(!map->is_stable()); CHECK(expectations.Check(*map)); - expectations.SetDataField(0, NONE, Representation::None(), none_type); + // Property kind reconfiguration always makes the field mutable. + expectations.SetDataField(0, NONE, kMutable, Representation::None(), + none_type); CHECK(!new_map->is_deprecated()); CHECK(new_map->is_stable()); @@ -472,11 +499,12 @@ TEST(ReconfigureAccessorToNonExistingDataField) { CHECK_EQ(*new_map, *new_map2); Handle<Object> value(Smi::kZero, isolate); - Handle<Map> prepared_map = Map::PrepareForDataProperty(new_map, 0, value); + Handle<Map> prepared_map = + Map::PrepareForDataProperty(new_map, 0, kConst, value); // None to Smi generalization is trivial, map does not change. CHECK_EQ(*new_map, *prepared_map); - expectations.SetDataField(0, NONE, Representation::Smi(), any_type); + expectations.SetDataField(0, NONE, kMutable, Representation::Smi(), any_type); CHECK(prepared_map->is_stable()); CHECK(expectations.Check(*prepared_map)); @@ -534,12 +562,19 @@ TEST(ReconfigureAccessorToNonExistingDataFieldHeavy) { //////////////////////////////////////////////////////////////////////////////// -// A set of tests for representation generalization case. +// A set of tests for field generalization case. // -// This test ensures that representation/field type generalization at -// |property_index| is done correctly independently of the fact that the |map| -// is detached from transition tree or not. +// <Constness, Representation, FieldType> data. +struct CRFTData { + PropertyConstness constness; + Representation representation; + Handle<FieldType> type; +}; + +// This test ensures that field generalization at |property_index| is done +// correctly independently of the fact that the |map| is detached from +// transition tree or not. // // {} - p0 - p1 - p2: |detach_point_map| // | @@ -549,12 +584,11 @@ TEST(ReconfigureAccessorToNonExistingDataFieldHeavy) { // // Detaching does not happen if |detach_property_at_index| is -1. // -static void TestGeneralizeRepresentation( - int detach_property_at_index, int property_index, - Representation from_representation, Handle<FieldType> from_type, - Representation to_representation, Handle<FieldType> to_type, - Representation expected_representation, Handle<FieldType> expected_type, - bool expected_deprecation, bool expected_field_type_dependency) { +static void TestGeneralizeField(int detach_property_at_index, + int property_index, const CRFTData& from, + const CRFTData& to, const CRFTData& expected, + bool expected_deprecation, + bool expected_field_type_dependency) { Isolate* isolate = CcTest::i_isolate(); Handle<FieldType> any_type = FieldType::Any(isolate); @@ -573,11 +607,11 @@ static void TestGeneralizeRepresentation( Handle<Map> detach_point_map; for (int i = 0; i < kPropCount; i++) { if (i == property_index) { - map = - expectations.AddDataField(map, NONE, from_representation, from_type); + map = expectations.AddDataField(map, NONE, from.constness, + from.representation, from.type); } else { - map = - expectations.AddDataField(map, NONE, Representation::Smi(), any_type); + map = expectations.AddDataField(map, NONE, kDefaultFieldConstness, + Representation::Smi(), any_type); if (i == detach_property_at_index) { detach_point_map = map; } @@ -593,7 +627,7 @@ static void TestGeneralizeRepresentation( detach_point_map = Map::ReconfigureProperty( detach_point_map, detach_property_at_index, kData, NONE, Representation::Tagged(), any_type); - expectations.SetDataField(detach_property_at_index, + expectations.SetDataField(detach_property_at_index, kDefaultFieldConstness, Representation::Tagged(), any_type); CHECK(map->is_deprecated()); CHECK(expectations.Check(*detach_point_map, @@ -608,10 +642,10 @@ static void TestGeneralizeRepresentation( dependencies.AssumeFieldOwner(field_owner); Handle<Map> new_map = Map::ReconfigureProperty( - map, property_index, kData, NONE, to_representation, to_type); + map, property_index, kData, NONE, to.representation, to.type); - expectations.SetDataField(property_index, expected_representation, - expected_type); + expectations.SetDataField(property_index, expected.constness, + expected.representation, expected.type); CHECK(!new_map->is_deprecated()); CHECK(expectations.Check(*new_map)); @@ -656,84 +690,65 @@ static void TestGeneralizeRepresentation( CHECK_EQ(*new_map, *updated_map); } -static void TestGeneralizeRepresentation( - Representation from_representation, Handle<FieldType> from_type, - Representation to_representation, Handle<FieldType> to_type, - Representation expected_representation, Handle<FieldType> expected_type, - bool expected_deprecation, bool expected_field_type_dependency) { +static void TestGeneralizeField(const CRFTData& from, const CRFTData& to, + const CRFTData& expected, + bool expected_deprecation, + bool expected_field_type_dependency) { // Check the cases when the map being reconfigured is a part of the // transition tree. STATIC_ASSERT(kPropCount > 4); int indices[] = {0, 2, kPropCount - 1}; for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { - TestGeneralizeRepresentation( - -1, indices[i], from_representation, from_type, to_representation, - to_type, expected_representation, expected_type, expected_deprecation, - expected_field_type_dependency); + TestGeneralizeField(-1, indices[i], from, to, expected, + expected_deprecation, expected_field_type_dependency); } - if (!from_representation.IsNone()) { + if (!from.representation.IsNone()) { // Check the cases when the map being reconfigured is NOT a part of the // transition tree. "None -> anything" representation changes make sense // only for "attached" maps. int indices[] = {0, kPropCount - 1}; for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { - TestGeneralizeRepresentation( - indices[i], 2, from_representation, from_type, to_representation, - to_type, expected_representation, expected_type, expected_deprecation, - expected_field_type_dependency); + TestGeneralizeField(indices[i], 2, from, to, expected, + expected_deprecation, expected_field_type_dependency); } // Check that reconfiguration to the very same field works correctly. - Representation representation = from_representation; - Handle<FieldType> type = from_type; - TestGeneralizeRepresentation(-1, 2, representation, type, representation, - type, representation, type, false, false); + CRFTData data = from; + TestGeneralizeField(-1, 2, data, data, data, false, false); } } -static void TestGeneralizeRepresentation(Representation from_representation, - Handle<FieldType> from_type, - Representation to_representation, - Handle<FieldType> to_type, - Representation expected_representation, - Handle<FieldType> expected_type) { +static void TestGeneralizeField(const CRFTData& from, const CRFTData& to, + const CRFTData& expected) { const bool expected_deprecation = true; const bool expected_field_type_dependency = false; - TestGeneralizeRepresentation( - from_representation, from_type, to_representation, to_type, - expected_representation, expected_type, expected_deprecation, - expected_field_type_dependency); + TestGeneralizeField(from, to, expected, expected_deprecation, + expected_field_type_dependency); } -static void TestGeneralizeRepresentationTrivial( - Representation from_representation, Handle<FieldType> from_type, - Representation to_representation, Handle<FieldType> to_type, - Representation expected_representation, Handle<FieldType> expected_type, +static void TestGeneralizeFieldTrivial( + const CRFTData& from, const CRFTData& to, const CRFTData& expected, bool expected_field_type_dependency = true) { const bool expected_deprecation = false; - TestGeneralizeRepresentation( - from_representation, from_type, to_representation, to_type, - expected_representation, expected_type, expected_deprecation, - expected_field_type_dependency); + TestGeneralizeField(from, to, expected, expected_deprecation, + expected_field_type_dependency); } - -TEST(GeneralizeRepresentationSmiToDouble) { +TEST(GeneralizeSmiFieldToDouble) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); Handle<FieldType> any_type = FieldType::Any(isolate); - TestGeneralizeRepresentation(Representation::Smi(), any_type, - Representation::Double(), any_type, - Representation::Double(), any_type); + TestGeneralizeField({kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::Double(), any_type}, + {kMutable, Representation::Double(), any_type}); } - -TEST(GeneralizeRepresentationSmiToTagged) { +TEST(GeneralizeSmiFieldToTagged) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -741,13 +756,12 @@ TEST(GeneralizeRepresentationSmiToTagged) { Handle<FieldType> value_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestGeneralizeRepresentation(Representation::Smi(), any_type, - Representation::HeapObject(), value_type, - Representation::Tagged(), any_type); + TestGeneralizeField({kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); } - -TEST(GeneralizeRepresentationDoubleToTagged) { +TEST(GeneralizeDoubleFieldToTagged) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -755,13 +769,12 @@ TEST(GeneralizeRepresentationDoubleToTagged) { Handle<FieldType> value_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestGeneralizeRepresentation(Representation::Double(), any_type, - Representation::HeapObject(), value_type, - Representation::Tagged(), any_type); + TestGeneralizeField({kMutable, Representation::Double(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); } - -TEST(GeneralizeRepresentationHeapObjectToTagged) { +TEST(GeneralizeHeapObjectFieldToTagged) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -769,13 +782,12 @@ TEST(GeneralizeRepresentationHeapObjectToTagged) { Handle<FieldType> value_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestGeneralizeRepresentation(Representation::HeapObject(), value_type, - Representation::Smi(), any_type, - Representation::Tagged(), any_type); + TestGeneralizeField({kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::Tagged(), any_type}); } - -TEST(GeneralizeRepresentationHeapObjectToHeapObject) { +TEST(GeneralizeHeapObjectFieldToHeapObject) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -789,21 +801,21 @@ TEST(GeneralizeRepresentationHeapObjectToHeapObject) { Handle<FieldType> expected_type = any_type; - TestGeneralizeRepresentationTrivial( - Representation::HeapObject(), current_type, - Representation::HeapObject(), new_type, Representation::HeapObject(), - expected_type); - current_type = expected_type; + TestGeneralizeFieldTrivial( + {kMutable, Representation::HeapObject(), current_type}, + {kMutable, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), expected_type}); + current_type = expected_type; - new_type = FieldType::Class(Map::Create(isolate, 0), isolate); + new_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestGeneralizeRepresentationTrivial( - Representation::HeapObject(), any_type, Representation::HeapObject(), - new_type, Representation::HeapObject(), any_type, false); + TestGeneralizeFieldTrivial({kMutable, Representation::HeapObject(), any_type}, + {kMutable, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), any_type}, + false); } - -TEST(GeneralizeRepresentationNoneToSmi) { +TEST(GeneralizeNoneFieldToSmi) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -811,13 +823,12 @@ TEST(GeneralizeRepresentationNoneToSmi) { Handle<FieldType> any_type = FieldType::Any(isolate); // None -> Smi representation change is trivial. - TestGeneralizeRepresentationTrivial(Representation::None(), none_type, - Representation::Smi(), any_type, - Representation::Smi(), any_type); + TestGeneralizeFieldTrivial({kMutable, Representation::None(), none_type}, + {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::Smi(), any_type}); } - -TEST(GeneralizeRepresentationNoneToDouble) { +TEST(GeneralizeNoneFieldToDouble) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -825,13 +836,12 @@ TEST(GeneralizeRepresentationNoneToDouble) { Handle<FieldType> any_type = FieldType::Any(isolate); // None -> Double representation change is NOT trivial. - TestGeneralizeRepresentation(Representation::None(), none_type, - Representation::Double(), any_type, - Representation::Double(), any_type); + TestGeneralizeField({kMutable, Representation::None(), none_type}, + {kMutable, Representation::Double(), any_type}, + {kMutable, Representation::Double(), any_type}); } - -TEST(GeneralizeRepresentationNoneToHeapObject) { +TEST(GeneralizeNoneFieldToHeapObject) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -840,13 +850,13 @@ TEST(GeneralizeRepresentationNoneToHeapObject) { FieldType::Class(Map::Create(isolate, 0), isolate); // None -> HeapObject representation change is trivial. - TestGeneralizeRepresentationTrivial(Representation::None(), none_type, - Representation::HeapObject(), value_type, - Representation::HeapObject(), value_type); + TestGeneralizeFieldTrivial( + {kMutable, Representation::None(), none_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::HeapObject(), value_type}); } - -TEST(GeneralizeRepresentationNoneToTagged) { +TEST(GeneralizeNoneFieldToTagged) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -854,18 +864,17 @@ TEST(GeneralizeRepresentationNoneToTagged) { Handle<FieldType> any_type = FieldType::Any(isolate); // None -> HeapObject representation change is trivial. - TestGeneralizeRepresentationTrivial(Representation::None(), none_type, - Representation::Tagged(), any_type, - Representation::Tagged(), any_type); + TestGeneralizeFieldTrivial({kMutable, Representation::None(), none_type}, + {kMutable, Representation::Tagged(), any_type}, + {kMutable, Representation::Tagged(), any_type}); } //////////////////////////////////////////////////////////////////////////////// -// A set of tests for representation generalization case with kAccessor -// properties. +// A set of tests for field generalization case with kAccessor properties. // -TEST(GeneralizeRepresentationWithAccessorProperties) { +TEST(GeneralizeFieldWithAccessorProperties) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -882,8 +891,8 @@ TEST(GeneralizeRepresentationWithAccessorProperties) { if (i == kAccessorProp) { map = expectations.AddAccessorConstant(map, NONE, pair); } else { - map = - expectations.AddDataField(map, NONE, Representation::Smi(), any_type); + map = expectations.AddDataField(map, NONE, kMutable, + Representation::Smi(), any_type); } } CHECK(!map->is_deprecated()); @@ -902,7 +911,7 @@ TEST(GeneralizeRepresentationWithAccessorProperties) { map, i, kData, NONE, Representation::Double(), any_type); maps[i] = new_map; - expectations.SetDataField(i, Representation::Double(), any_type); + expectations.SetDataField(i, kMutable, Representation::Double(), any_type); CHECK(!map->is_stable()); CHECK(map->is_deprecated()); @@ -930,8 +939,8 @@ TEST(GeneralizeRepresentationWithAccessorProperties) { // A set of tests for attribute reconfiguration case. // -// This test ensures that representation/field type generalization is correctly -// propagated from one branch of transition tree (|map2|) to another (|map|). +// This test ensures that field generalization is correctly propagated from one +// branch of transition tree (|map2|) to another (|map|). // // + - p2B - p3 - p4: |map2| // | @@ -939,10 +948,8 @@ TEST(GeneralizeRepresentationWithAccessorProperties) { // // where "p2A" and "p2B" differ only in the attributes. // -static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( - Representation from_representation, Handle<FieldType> from_type, - Representation to_representation, Handle<FieldType> to_type, - Representation expected_representation, Handle<FieldType> expected_type) { +static void TestReconfigureDataFieldAttribute_GeneralizeField( + const CRFTData& from, const CRFTData& to, const CRFTData& expected) { Isolate* isolate = CcTest::i_isolate(); Expectations expectations(isolate); @@ -951,7 +958,8 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( Handle<Map> initial_map = Map::Create(isolate, 0); Handle<Map> map = initial_map; for (int i = 0; i < kPropCount; i++) { - map = expectations.AddDataField(map, NONE, from_representation, from_type); + map = expectations.AddDataField(map, NONE, from.constness, + from.representation, from.type); } CHECK(!map->is_deprecated()); CHECK(map->is_stable()); @@ -965,14 +973,15 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( Handle<Map> map2 = initial_map; for (int i = 0; i < kSplitProp; i++) { - map2 = expectations2.FollowDataTransition(map2, NONE, from_representation, - from_type); + map2 = expectations2.FollowDataTransition(map2, NONE, from.constness, + from.representation, from.type); } - map2 = - expectations2.AddDataField(map2, READ_ONLY, to_representation, to_type); + map2 = expectations2.AddDataField(map2, READ_ONLY, to.constness, + to.representation, to.type); for (int i = kSplitProp + 1; i < kPropCount; i++) { - map2 = expectations2.AddDataField(map2, NONE, to_representation, to_type); + map2 = expectations2.AddDataField(map2, NONE, to.constness, + to.representation, to.type); } CHECK(!map2->is_deprecated()); CHECK(map2->is_stable()); @@ -997,7 +1006,8 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( // |map| should be deprecated and |new_map| should match new expectations. for (int i = kSplitProp; i < kPropCount; i++) { - expectations.SetDataField(i, expected_representation, expected_type); + expectations.SetDataField(i, expected.constness, expected.representation, + expected.type); } CHECK(map->is_deprecated()); CHECK(!dependencies.HasAborted()); @@ -1012,10 +1022,9 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( CHECK_EQ(*new_map, *updated_map); } - -// This test ensures that trivial representation/field type generalization -// (from HeapObject to HeapObject) is correctly propagated from one branch of -// transition tree (|map2|) to another (|map|). +// This test ensures that trivial field generalization (from HeapObject to +// HeapObject) is correctly propagated from one branch of transition tree +// (|map2|) to another (|map|). // // + - p2B - p3 - p4: |map2| // | @@ -1023,10 +1032,8 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( // // where "p2A" and "p2B" differ only in the attributes. // -static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( - Representation from_representation, Handle<FieldType> from_type, - Representation to_representation, Handle<FieldType> to_type, - Representation expected_representation, Handle<FieldType> expected_type, +static void TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( + const CRFTData& from, const CRFTData& to, const CRFTData& expected, bool expected_field_type_dependency = true) { Isolate* isolate = CcTest::i_isolate(); @@ -1036,7 +1043,8 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( Handle<Map> initial_map = Map::Create(isolate, 0); Handle<Map> map = initial_map; for (int i = 0; i < kPropCount; i++) { - map = expectations.AddDataField(map, NONE, from_representation, from_type); + map = expectations.AddDataField(map, NONE, from.constness, + from.representation, from.type); } CHECK(!map->is_deprecated()); CHECK(map->is_stable()); @@ -1050,14 +1058,15 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( Handle<Map> map2 = initial_map; for (int i = 0; i < kSplitProp; i++) { - map2 = expectations2.FollowDataTransition(map2, NONE, from_representation, - from_type); + map2 = expectations2.FollowDataTransition(map2, NONE, from.constness, + from.representation, from.type); } - map2 = - expectations2.AddDataField(map2, READ_ONLY, to_representation, to_type); + map2 = expectations2.AddDataField(map2, READ_ONLY, to.constness, + to.representation, to.type); for (int i = kSplitProp + 1; i < kPropCount; i++) { - map2 = expectations2.AddDataField(map2, NONE, to_representation, to_type); + map2 = expectations2.AddDataField(map2, NONE, to.constness, + to.representation, to.type); } CHECK(!map2->is_deprecated()); CHECK(map2->is_stable()); @@ -1085,7 +1094,8 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( // respective code dependencies should be invalidated. |map| should be NOT // deprecated and it should match new expectations. for (int i = kSplitProp; i < kPropCount; i++) { - expectations.SetDataField(i, expected_representation, expected_type); + expectations.SetDataField(i, expected.constness, expected.representation, + expected.type); } CHECK(!map->is_deprecated()); CHECK_EQ(*map, *new_map); @@ -1099,20 +1109,36 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( CHECK_EQ(*new_map, *updated_map); } - -TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToDouble) { +TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToDouble) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); Handle<FieldType> any_type = FieldType::Any(isolate); - TestReconfigureDataFieldAttribute_GeneralizeRepresentation( - Representation::Smi(), any_type, Representation::Double(), any_type, - Representation::Double(), any_type); -} + if (FLAG_track_constant_fields) { + TestReconfigureDataFieldAttribute_GeneralizeField( + {kConst, Representation::Smi(), any_type}, + {kConst, Representation::Double(), any_type}, + {kConst, Representation::Double(), any_type}); + + TestReconfigureDataFieldAttribute_GeneralizeField( + {kConst, Representation::Smi(), any_type}, + {kMutable, Representation::Double(), any_type}, + {kMutable, Representation::Double(), any_type}); + + TestReconfigureDataFieldAttribute_GeneralizeField( + {kMutable, Representation::Smi(), any_type}, + {kConst, Representation::Double(), any_type}, + {kMutable, Representation::Double(), any_type}); + } + TestReconfigureDataFieldAttribute_GeneralizeField( + {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::Double(), any_type}, + {kMutable, Representation::Double(), any_type}); +} -TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToTagged) { +TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToTagged) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -1120,13 +1146,30 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToTagged) { Handle<FieldType> value_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestReconfigureDataFieldAttribute_GeneralizeRepresentation( - Representation::Smi(), any_type, Representation::HeapObject(), value_type, - Representation::Tagged(), any_type); -} + if (FLAG_track_constant_fields) { + TestReconfigureDataFieldAttribute_GeneralizeField( + {kConst, Representation::Smi(), any_type}, + {kConst, Representation::HeapObject(), value_type}, + {kConst, Representation::Tagged(), any_type}); + TestReconfigureDataFieldAttribute_GeneralizeField( + {kConst, Representation::Smi(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); + + TestReconfigureDataFieldAttribute_GeneralizeField( + {kMutable, Representation::Smi(), any_type}, + {kConst, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); + } -TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationDoubleToTagged) { + TestReconfigureDataFieldAttribute_GeneralizeField( + {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); +} + +TEST(ReconfigureDataFieldAttribute_GeneralizeDoubleFieldToTagged) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -1134,13 +1177,30 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationDoubleToTagged) { Handle<FieldType> value_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestReconfigureDataFieldAttribute_GeneralizeRepresentation( - Representation::Double(), any_type, Representation::HeapObject(), - value_type, Representation::Tagged(), any_type); -} + if (FLAG_track_constant_fields) { + TestReconfigureDataFieldAttribute_GeneralizeField( + {kConst, Representation::Double(), any_type}, + {kConst, Representation::HeapObject(), value_type}, + {kConst, Representation::Tagged(), any_type}); + + TestReconfigureDataFieldAttribute_GeneralizeField( + {kConst, Representation::Double(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); + TestReconfigureDataFieldAttribute_GeneralizeField( + {kMutable, Representation::Double(), any_type}, + {kConst, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); + } + + TestReconfigureDataFieldAttribute_GeneralizeField( + {kMutable, Representation::Double(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); +} -TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjToHeapObj) { +TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjFieldToHeapObj) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -1154,20 +1214,59 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjToHeapObj) { Handle<FieldType> expected_type = any_type; - TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( - Representation::HeapObject(), current_type, Representation::HeapObject(), - new_type, Representation::HeapObject(), expected_type); + // Check generalizations that trigger deopts. + if (FLAG_track_constant_fields) { + TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( + {kConst, Representation::HeapObject(), current_type}, + {kConst, Representation::HeapObject(), new_type}, + {kConst, Representation::HeapObject(), expected_type}); + + // Currently, kConst to kMutable migration causes map change, therefore + // non-trivial generalization. + TestReconfigureDataFieldAttribute_GeneralizeField( + {kConst, Representation::HeapObject(), current_type}, + {kMutable, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), expected_type}); + + TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( + {kMutable, Representation::HeapObject(), current_type}, + {kConst, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), expected_type}); + } + TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( + {kMutable, Representation::HeapObject(), current_type}, + {kMutable, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), expected_type}); current_type = expected_type; + // Check generalizations that do not trigger deopts. new_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( - Representation::HeapObject(), any_type, Representation::HeapObject(), - new_type, Representation::HeapObject(), any_type, false); + if (FLAG_track_constant_fields) { + TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( + {kConst, Representation::HeapObject(), any_type}, + {kConst, Representation::HeapObject(), new_type}, + {kConst, Representation::HeapObject(), any_type}, false); + + // Currently, kConst to kMutable migration causes map change, therefore + // non-trivial generalization. + TestReconfigureDataFieldAttribute_GeneralizeField( + {kConst, Representation::HeapObject(), any_type}, + {kMutable, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), any_type}); + + TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( + {kMutable, Representation::HeapObject(), any_type}, + {kConst, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), any_type}, false); + } + TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( + {kMutable, Representation::HeapObject(), any_type}, + {kMutable, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), any_type}, false); } - -TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjectToTagged) { +TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjectFieldToTagged) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -1175,9 +1274,10 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjectToTagged) { Handle<FieldType> value_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestReconfigureDataFieldAttribute_GeneralizeRepresentation( - Representation::HeapObject(), value_type, Representation::Smi(), any_type, - Representation::Tagged(), any_type); + TestReconfigureDataFieldAttribute_GeneralizeField( + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::Tagged(), any_type}); } @@ -1243,7 +1343,7 @@ struct CheckCopyGeneralizeAllFields { CHECK(new_map->GetBackPointer()->IsUndefined(map->GetIsolate())); for (int i = 0; i < kPropCount; i++) { - expectations.GeneralizeRepresentation(i); + expectations.GeneralizeField(i); } CHECK(!new_map->is_deprecated()); @@ -1251,9 +1351,8 @@ struct CheckCopyGeneralizeAllFields { } }; - -// This test ensures that representation/field type generalization is correctly -// propagated from one branch of transition tree (|map2|) to another (|map1|). +// This test ensures that field generalization is correctly propagated from one +// branch of transition tree (|map2|) to another (|map1|). // // + - p2B - p3 - p4: |map2| // | @@ -1277,13 +1376,15 @@ static void TestReconfigureProperty_CustomPropertyAfterTargetMap( const int kSplitProp = 2; CHECK(kSplitProp < kCustomPropIndex); + const PropertyConstness constness = kMutable; const Representation representation = Representation::Smi(); // Create common part of transition tree. Handle<Map> initial_map = Map::Create(isolate, 0); Handle<Map> map = initial_map; for (int i = 0; i < kSplitProp; i++) { - map = expectations.AddDataField(map, NONE, representation, any_type); + map = expectations.AddDataField(map, NONE, constness, representation, + any_type); } CHECK(!map->is_deprecated()); CHECK(map->is_stable()); @@ -1294,11 +1395,13 @@ static void TestReconfigureProperty_CustomPropertyAfterTargetMap( Handle<Map> map1 = map; Expectations expectations1 = expectations; for (int i = kSplitProp; i < kCustomPropIndex; i++) { - map1 = expectations1.AddDataField(map1, NONE, representation, any_type); + map1 = expectations1.AddDataField(map1, NONE, constness, representation, + any_type); } map1 = config.AddPropertyAtBranch(1, expectations1, map1); for (int i = kCustomPropIndex + 1; i < kPropCount; i++) { - map1 = expectations1.AddDataField(map1, NONE, representation, any_type); + map1 = expectations1.AddDataField(map1, NONE, constness, representation, + any_type); } CHECK(!map1->is_deprecated()); CHECK(map1->is_stable()); @@ -1309,13 +1412,16 @@ static void TestReconfigureProperty_CustomPropertyAfterTargetMap( // has different attributes), initialize expectations. Handle<Map> map2 = map; Expectations expectations2 = expectations; - map2 = expectations2.AddDataField(map2, READ_ONLY, representation, any_type); + map2 = expectations2.AddDataField(map2, READ_ONLY, constness, representation, + any_type); for (int i = kSplitProp + 1; i < kCustomPropIndex; i++) { - map2 = expectations2.AddDataField(map2, NONE, representation, any_type); + map2 = expectations2.AddDataField(map2, NONE, constness, representation, + any_type); } map2 = config.AddPropertyAtBranch(2, expectations2, map2); for (int i = kCustomPropIndex + 1; i < kPropCount; i++) { - map2 = expectations2.AddDataField(map2, NONE, representation, any_type); + map2 = expectations2.AddDataField(map2, NONE, constness, representation, + any_type); } CHECK(!map2->is_deprecated()); CHECK(map2->is_stable()); @@ -1403,15 +1509,23 @@ TEST(ReconfigureDataFieldAttribute_DataConstantToDataFieldAfterTargetMap) { } void UpdateExpectations(int property_index, Expectations& expectations) { - expectations.SetDataField(property_index, Representation::HeapObject(), - function_type_); + PropertyConstness expected_constness = + FLAG_track_constant_fields ? kConst : kMutable; + expectations.SetDataField(property_index, expected_constness, + Representation::HeapObject(), function_type_); } }; TestConfig config; - // Two branches are "incompatible" so the |map1| should be deprecated. - CheckDeprecated checker; - TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); + if (FLAG_track_constant_fields) { + CheckSameMap checker; + TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); + + } else { + // Two branches are "incompatible" so the |map1| should be deprecated. + CheckDeprecated checker; + TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); + } } @@ -1534,8 +1648,8 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) { } else { Isolate* isolate = CcTest::i_isolate(); Handle<FieldType> any_type = FieldType::Any(isolate); - return expectations.AddDataField(map, NONE, Representation::Smi(), - any_type); + return expectations.AddDataField(map, NONE, kDefaultFieldConstness, + Representation::Smi(), any_type); } } @@ -1553,8 +1667,8 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) { // A set of tests for elements kind reconfiguration case. // -// This test ensures that representation/field type generalization is correctly -// propagated from one branch of transition tree (|map2) to another (|map|). +// This test ensures that field generalization is correctly propagated from one +// branch of transition tree (|map2) to another (|map|). // // + - p0 - p1 - p2A - p3 - p4: |map| // | @@ -1564,10 +1678,8 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) { // // where "p2A" and "p2B" differ only in the representation/field type. // -static void TestReconfigureElementsKind_GeneralizeRepresentation( - Representation from_representation, Handle<FieldType> from_type, - Representation to_representation, Handle<FieldType> to_type, - Representation expected_representation, Handle<FieldType> expected_type) { +static void TestReconfigureElementsKind_GeneralizeField( + const CRFTData& from, const CRFTData& to, const CRFTData& expected) { Isolate* isolate = CcTest::i_isolate(); Expectations expectations(isolate, FAST_SMI_ELEMENTS); @@ -1579,7 +1691,8 @@ static void TestReconfigureElementsKind_GeneralizeRepresentation( Handle<Map> map = initial_map; map = expectations.AsElementsKind(map, FAST_ELEMENTS); for (int i = 0; i < kPropCount; i++) { - map = expectations.AddDataField(map, NONE, from_representation, from_type); + map = expectations.AddDataField(map, NONE, from.constness, + from.representation, from.type); } CHECK(!map->is_deprecated()); CHECK(map->is_stable()); @@ -1593,10 +1706,11 @@ static void TestReconfigureElementsKind_GeneralizeRepresentation( Handle<Map> map2 = initial_map; for (int i = 0; i < kPropCount; i++) { if (i == kDiffProp) { - map2 = expectations2.AddDataField(map2, NONE, to_representation, to_type); + map2 = expectations2.AddDataField(map2, NONE, to.constness, + to.representation, to.type); } else { - map2 = expectations2.AddDataField(map2, NONE, from_representation, - from_type); + map2 = expectations2.AddDataField(map2, NONE, from.constness, + from.representation, from.type); } } CHECK(!map2->is_deprecated()); @@ -1620,7 +1734,8 @@ static void TestReconfigureElementsKind_GeneralizeRepresentation( CHECK(expectations2.Check(*map2)); // |map| should be deprecated and |new_map| should match new expectations. - expectations.SetDataField(kDiffProp, expected_representation, expected_type); + expectations.SetDataField(kDiffProp, expected.constness, + expected.representation, expected.type); CHECK(map->is_deprecated()); CHECK(!dependencies.HasAborted()); @@ -1644,9 +1759,9 @@ static void TestReconfigureElementsKind_GeneralizeRepresentation( } } -// This test ensures that trivial representation/field type generalization -// (from HeapObject to HeapObject) is correctly propagated from one branch of -// transition tree (|map2|) to another (|map|). +// This test ensures that trivial field generalization (from HeapObject to +// HeapObject) is correctly propagated from one branch of transition tree +// (|map2|) to another (|map|). // // + - p0 - p1 - p2A - p3 - p4: |map| // | @@ -1656,10 +1771,8 @@ static void TestReconfigureElementsKind_GeneralizeRepresentation( // // where "p2A" and "p2B" differ only in the representation/field type. // -static void TestReconfigureElementsKind_GeneralizeRepresentationTrivial( - Representation from_representation, Handle<FieldType> from_type, - Representation to_representation, Handle<FieldType> to_type, - Representation expected_representation, Handle<FieldType> expected_type, +static void TestReconfigureElementsKind_GeneralizeFieldTrivial( + const CRFTData& from, const CRFTData& to, const CRFTData& expected, bool expected_field_type_dependency = true) { Isolate* isolate = CcTest::i_isolate(); @@ -1672,7 +1785,8 @@ static void TestReconfigureElementsKind_GeneralizeRepresentationTrivial( Handle<Map> map = initial_map; map = expectations.AsElementsKind(map, FAST_ELEMENTS); for (int i = 0; i < kPropCount; i++) { - map = expectations.AddDataField(map, NONE, from_representation, from_type); + map = expectations.AddDataField(map, NONE, from.constness, + from.representation, from.type); } CHECK(!map->is_deprecated()); CHECK(map->is_stable()); @@ -1686,10 +1800,11 @@ static void TestReconfigureElementsKind_GeneralizeRepresentationTrivial( Handle<Map> map2 = initial_map; for (int i = 0; i < kPropCount; i++) { if (i == kDiffProp) { - map2 = expectations2.AddDataField(map2, NONE, to_representation, to_type); + map2 = expectations2.AddDataField(map2, NONE, to.constness, + to.representation, to.type); } else { - map2 = expectations2.AddDataField(map2, NONE, from_representation, - from_type); + map2 = expectations2.AddDataField(map2, NONE, from.constness, + from.representation, from.type); } } CHECK(!map2->is_deprecated()); @@ -1716,7 +1831,8 @@ static void TestReconfigureElementsKind_GeneralizeRepresentationTrivial( // kind reconfiguration, respective field types should be generalized and // respective code dependencies should be invalidated. |map| should be NOT // deprecated and it should match new expectations. - expectations.SetDataField(kDiffProp, expected_representation, expected_type); + expectations.SetDataField(kDiffProp, expected.constness, + expected.representation, expected.type); CHECK(!map->is_deprecated()); CHECK_EQ(*map, *new_map); CHECK_EQ(expected_field_type_dependency, dependencies.HasAborted()); @@ -1738,18 +1854,35 @@ static void TestReconfigureElementsKind_GeneralizeRepresentationTrivial( } } -TEST(ReconfigureElementsKind_GeneralizeRepresentationSmiToDouble) { +TEST(ReconfigureElementsKind_GeneralizeSmiFieldToDouble) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); Handle<FieldType> any_type = FieldType::Any(isolate); - TestReconfigureElementsKind_GeneralizeRepresentation( - Representation::Smi(), any_type, Representation::Double(), any_type, - Representation::Double(), any_type); + if (FLAG_track_constant_fields) { + TestReconfigureElementsKind_GeneralizeField( + {kConst, Representation::Smi(), any_type}, + {kConst, Representation::Double(), any_type}, + {kConst, Representation::Double(), any_type}); + + TestReconfigureElementsKind_GeneralizeField( + {kConst, Representation::Smi(), any_type}, + {kMutable, Representation::Double(), any_type}, + {kMutable, Representation::Double(), any_type}); + + TestReconfigureElementsKind_GeneralizeField( + {kMutable, Representation::Smi(), any_type}, + {kConst, Representation::Double(), any_type}, + {kMutable, Representation::Double(), any_type}); + } + TestReconfigureElementsKind_GeneralizeField( + {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::Double(), any_type}, + {kMutable, Representation::Double(), any_type}); } -TEST(ReconfigureElementsKind_GeneralizeRepresentationSmiToTagged) { +TEST(ReconfigureElementsKind_GeneralizeSmiFieldToTagged) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -1757,12 +1890,29 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationSmiToTagged) { Handle<FieldType> value_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestReconfigureElementsKind_GeneralizeRepresentation( - Representation::Smi(), any_type, Representation::HeapObject(), value_type, - Representation::Tagged(), any_type); + if (FLAG_track_constant_fields) { + TestReconfigureElementsKind_GeneralizeField( + {kConst, Representation::Smi(), any_type}, + {kConst, Representation::HeapObject(), value_type}, + {kConst, Representation::Tagged(), any_type}); + + TestReconfigureElementsKind_GeneralizeField( + {kConst, Representation::Smi(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); + + TestReconfigureElementsKind_GeneralizeField( + {kMutable, Representation::Smi(), any_type}, + {kConst, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); + } + TestReconfigureElementsKind_GeneralizeField( + {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); } -TEST(ReconfigureElementsKind_GeneralizeRepresentationDoubleToTagged) { +TEST(ReconfigureElementsKind_GeneralizeDoubleFieldToTagged) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -1770,12 +1920,29 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationDoubleToTagged) { Handle<FieldType> value_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestReconfigureElementsKind_GeneralizeRepresentation( - Representation::Double(), any_type, Representation::HeapObject(), - value_type, Representation::Tagged(), any_type); + if (FLAG_track_constant_fields) { + TestReconfigureElementsKind_GeneralizeField( + {kConst, Representation::Double(), any_type}, + {kConst, Representation::HeapObject(), value_type}, + {kConst, Representation::Tagged(), any_type}); + + TestReconfigureElementsKind_GeneralizeField( + {kConst, Representation::Double(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); + + TestReconfigureElementsKind_GeneralizeField( + {kMutable, Representation::Double(), any_type}, + {kConst, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); + } + TestReconfigureElementsKind_GeneralizeField( + {kMutable, Representation::Double(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); } -TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjToHeapObj) { +TEST(ReconfigureElementsKind_GeneralizeHeapObjFieldToHeapObj) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -1789,19 +1956,59 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjToHeapObj) { Handle<FieldType> expected_type = any_type; - TestReconfigureElementsKind_GeneralizeRepresentationTrivial( - Representation::HeapObject(), current_type, Representation::HeapObject(), - new_type, Representation::HeapObject(), expected_type); + // Check generalizations that trigger deopts. + if (FLAG_track_constant_fields) { + TestReconfigureElementsKind_GeneralizeFieldTrivial( + {kConst, Representation::HeapObject(), current_type}, + {kConst, Representation::HeapObject(), new_type}, + {kConst, Representation::HeapObject(), expected_type}); + + // Currently, kConst to kMutable migration causes map change, therefore + // non-trivial generalization. + TestReconfigureElementsKind_GeneralizeField( + {kConst, Representation::HeapObject(), current_type}, + {kMutable, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), expected_type}); + + TestReconfigureElementsKind_GeneralizeFieldTrivial( + {kMutable, Representation::HeapObject(), current_type}, + {kConst, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), expected_type}); + } + TestReconfigureElementsKind_GeneralizeFieldTrivial( + {kMutable, Representation::HeapObject(), current_type}, + {kMutable, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), expected_type}); current_type = expected_type; + // Check generalizations that do not trigger deopts. new_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestReconfigureElementsKind_GeneralizeRepresentationTrivial( - Representation::HeapObject(), any_type, Representation::HeapObject(), - new_type, Representation::HeapObject(), any_type, false); + if (FLAG_track_constant_fields) { + TestReconfigureElementsKind_GeneralizeFieldTrivial( + {kConst, Representation::HeapObject(), any_type}, + {kConst, Representation::HeapObject(), new_type}, + {kConst, Representation::HeapObject(), any_type}, false); + + // Currently, kConst to kMutable migration causes map change, therefore + // non-trivial generalization. + TestReconfigureElementsKind_GeneralizeField( + {kConst, Representation::HeapObject(), any_type}, + {kMutable, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), any_type}); + + TestReconfigureElementsKind_GeneralizeFieldTrivial( + {kMutable, Representation::HeapObject(), any_type}, + {kConst, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), any_type}, false); + } + TestReconfigureElementsKind_GeneralizeFieldTrivial( + {kMutable, Representation::HeapObject(), any_type}, + {kMutable, Representation::HeapObject(), new_type}, + {kMutable, Representation::HeapObject(), any_type}, false); } -TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjectToTagged) { +TEST(ReconfigureElementsKind_GeneralizeHeapObjectFieldToTagged) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); @@ -1809,9 +2016,26 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjectToTagged) { Handle<FieldType> value_type = FieldType::Class(Map::Create(isolate, 0), isolate); - TestReconfigureElementsKind_GeneralizeRepresentation( - Representation::HeapObject(), value_type, Representation::Smi(), any_type, - Representation::Tagged(), any_type); + if (FLAG_track_constant_fields) { + TestReconfigureElementsKind_GeneralizeField( + {kConst, Representation::HeapObject(), value_type}, + {kConst, Representation::Smi(), any_type}, + {kConst, Representation::Tagged(), any_type}); + + TestReconfigureElementsKind_GeneralizeField( + {kConst, Representation::HeapObject(), value_type}, + {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::Tagged(), any_type}); + + TestReconfigureElementsKind_GeneralizeField( + {kMutable, Representation::HeapObject(), value_type}, + {kConst, Representation::Smi(), any_type}, + {kMutable, Representation::Tagged(), any_type}); + } + TestReconfigureElementsKind_GeneralizeField( + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::Tagged(), any_type}); } //////////////////////////////////////////////////////////////////////////////// @@ -1830,7 +2054,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) { Handle<Map> initial_map = Map::Create(isolate, 0); Handle<Map> map = initial_map; for (int i = 0; i < kPropCount; i++) { - map = expectations.AddDataField(map, NONE, Representation::Smi(), any_type); + map = expectations.AddDataField(map, NONE, kMutable, Representation::Smi(), + any_type); } CHECK(!map->is_deprecated()); CHECK(map->is_stable()); @@ -1854,7 +2079,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) { map2 = Map::ReconfigureProperty(map2, kSplitProp, kData, NONE, Representation::Double(), any_type); - expectations.SetDataField(kSplitProp, Representation::Double(), any_type); + expectations.SetDataField(kSplitProp, kMutable, Representation::Double(), + any_type); CHECK(expectations.Check(*split_map, kSplitProp)); CHECK(expectations.Check(*map2, kSplitProp + 1)); @@ -1871,8 +2097,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) { for (int i = 0; i < TransitionArray::kMaxNumberOfTransitions; i++) { CHECK(TransitionArray::CanHaveMoreTransitions(map2)); Handle<String> name = MakeName("foo", i); - Map::CopyWithField(map2, name, any_type, NONE, Representation::Smi(), - INSERT_TRANSITION) + Map::CopyWithField(map2, name, any_type, NONE, kMutable, + Representation::Smi(), INSERT_TRANSITION) .ToHandleChecked(); } CHECK(!TransitionArray::CanHaveMoreTransitions(map2)); @@ -1883,7 +2109,7 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) { CHECK(updated_map->GetBackPointer()->IsUndefined(isolate)); for (int i = 0; i < kPropCount; i++) { - expectations.SetDataField(i, Representation::Tagged(), any_type); + expectations.SetDataField(i, kMutable, Representation::Tagged(), any_type); } CHECK(expectations.Check(*updated_map)); } @@ -1894,8 +2120,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) { // transition, observed transition or prototype transition). // -// This test ensures that representation/field type generalization is correctly -// propagated from one branch of transition tree (|map2|) to another (|map|). +// This test ensures that field generalization is correctly propagated from one +// branch of transition tree (|map2|) to another (|map|). // // p4B: |map2| // | @@ -1906,15 +2132,14 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) { // where "p4A" and "p4B" are exactly the same properties. // // TODO(ishell): unify this test template with -// TestReconfigureDataFieldAttribute_GeneralizeRepresentation once +// TestReconfigureDataFieldAttribute_GeneralizeField once // IS_PROTO_TRANS_ISSUE_FIXED and IS_NON_EQUIVALENT_TRANSITION_SUPPORTED are // fixed. template <typename TestConfig> -static void TestGeneralizeRepresentationWithSpecialTransition( - TestConfig& config, Representation from_representation, - Handle<FieldType> from_type, Representation to_representation, - Handle<FieldType> to_type, Representation expected_representation, - Handle<FieldType> expected_type) { +static void TestGeneralizeFieldWithSpecialTransition(TestConfig& config, + const CRFTData& from, + const CRFTData& to, + const CRFTData& expected) { Isolate* isolate = CcTest::i_isolate(); Expectations expectations(isolate); @@ -1923,7 +2148,8 @@ static void TestGeneralizeRepresentationWithSpecialTransition( Handle<Map> initial_map = Map::Create(isolate, 0); Handle<Map> map = initial_map; for (int i = 0; i < kPropCount; i++) { - map = expectations.AddDataField(map, NONE, from_representation, from_type); + map = expectations.AddDataField(map, NONE, from.constness, + from.representation, from.type); } CHECK(!map->is_deprecated()); CHECK(map->is_stable()); @@ -1941,7 +2167,7 @@ static void TestGeneralizeRepresentationWithSpecialTransition( if (config.generalizes_representations()) { for (int i = 0; i < kPropCount; i++) { - expectations2.GeneralizeRepresentation(i); + expectations2.GeneralizeField(i); } } @@ -1953,10 +2179,11 @@ static void TestGeneralizeRepresentationWithSpecialTransition( Handle<Map> maps[kPropCount]; for (int i = 0; i < kPropCount; i++) { Handle<Map> new_map = Map::ReconfigureProperty(map, i, kData, NONE, - to_representation, to_type); + to.representation, to.type); maps[i] = new_map; - expectations.SetDataField(i, expected_representation, expected_type); + expectations.SetDataField(i, expected.constness, expected.representation, + expected.type); CHECK(map->is_deprecated()); CHECK_NE(*map, *new_map); @@ -1978,7 +2205,7 @@ static void TestGeneralizeRepresentationWithSpecialTransition( // In case of non-equivalent transition currently we generalize all // representations. for (int i = 0; i < kPropCount; i++) { - expectations2.GeneralizeRepresentation(i); + expectations2.GeneralizeField(i); } CHECK(new_map2->GetBackPointer()->IsUndefined(isolate)); CHECK(expectations2.Check(*new_map2)); @@ -2021,9 +2248,10 @@ TEST(ElementsKindTransitionFromMapOwningDescriptor) { bool is_non_equevalent_transition() const { return true; } }; TestConfig config; - TestGeneralizeRepresentationWithSpecialTransition( - config, Representation::Smi(), any_type, Representation::HeapObject(), - value_type, Representation::Tagged(), any_type); + TestGeneralizeFieldWithSpecialTransition( + config, {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); } @@ -2043,7 +2271,7 @@ TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { // Add one more transition to |map| in order to prevent descriptors // ownership. CHECK(map->owns_descriptors()); - Map::CopyWithField(map, MakeString("foo"), any_type, NONE, + Map::CopyWithField(map, MakeString("foo"), any_type, NONE, kMutable, Representation::Smi(), INSERT_TRANSITION) .ToHandleChecked(); CHECK(!map->owns_descriptors()); @@ -2058,9 +2286,10 @@ TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { bool is_non_equevalent_transition() const { return true; } }; TestConfig config; - TestGeneralizeRepresentationWithSpecialTransition( - config, Representation::Smi(), any_type, Representation::HeapObject(), - value_type, Representation::Tagged(), any_type); + TestGeneralizeFieldWithSpecialTransition( + config, {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); } @@ -2092,9 +2321,10 @@ TEST(PrototypeTransitionFromMapOwningDescriptor) { bool is_non_equevalent_transition() const { return true; } }; TestConfig config; - TestGeneralizeRepresentationWithSpecialTransition( - config, Representation::Smi(), any_type, Representation::HeapObject(), - value_type, Representation::Tagged(), any_type); + TestGeneralizeFieldWithSpecialTransition( + config, {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); } @@ -2123,7 +2353,7 @@ TEST(PrototypeTransitionFromMapNotOwningDescriptor) { // Add one more transition to |map| in order to prevent descriptors // ownership. CHECK(map->owns_descriptors()); - Map::CopyWithField(map, MakeString("foo"), any_type, NONE, + Map::CopyWithField(map, MakeString("foo"), any_type, NONE, kMutable, Representation::Smi(), INSERT_TRANSITION) .ToHandleChecked(); CHECK(!map->owns_descriptors()); @@ -2137,9 +2367,10 @@ TEST(PrototypeTransitionFromMapNotOwningDescriptor) { bool is_non_equevalent_transition() const { return true; } }; TestConfig config; - TestGeneralizeRepresentationWithSpecialTransition( - config, Representation::Smi(), any_type, Representation::HeapObject(), - value_type, Representation::Tagged(), any_type); + TestGeneralizeFieldWithSpecialTransition( + config, {kMutable, Representation::Smi(), any_type}, + {kMutable, Representation::HeapObject(), value_type}, + {kMutable, Representation::Tagged(), any_type}); } @@ -2148,23 +2379,26 @@ TEST(PrototypeTransitionFromMapNotOwningDescriptor) { // struct TransitionToDataFieldOperator { + PropertyConstness constness_; Representation representation_; PropertyAttributes attributes_; Handle<FieldType> heap_type_; Handle<Object> value_; - TransitionToDataFieldOperator(Representation representation, + TransitionToDataFieldOperator(PropertyConstness constness, + Representation representation, Handle<FieldType> heap_type, Handle<Object> value, PropertyAttributes attributes = NONE) - : representation_(representation), + : constness_(constness), + representation_(representation), attributes_(attributes), heap_type_(heap_type), value_(value) {} Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { - return expectations.TransitionToDataField(map, attributes_, representation_, - heap_type_, value_); + return expectations.TransitionToDataField( + map, attributes_, constness_, representation_, heap_type_, value_); } }; @@ -2213,7 +2447,8 @@ struct ReconfigureAsDataPropertyOperator { heap_type_(heap_type) {} Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { - expectations.SetDataField(descriptor_, representation_, heap_type_); + expectations.SetDataField(descriptor_, kMutable, representation_, + heap_type_); return Map::ReconfigureExistingProperty(map, descriptor_, kData, attributes_); } @@ -2235,18 +2470,20 @@ struct ReconfigureAsAccessorPropertyOperator { } }; - -// Checks that representation/field type generalization happened. +// Checks that field generalization happened. struct FieldGeneralizationChecker { int descriptor_; + PropertyConstness constness_; Representation representation_; PropertyAttributes attributes_; Handle<FieldType> heap_type_; - FieldGeneralizationChecker(int descriptor, Representation representation, + FieldGeneralizationChecker(int descriptor, PropertyConstness constness, + Representation representation, Handle<FieldType> heap_type, PropertyAttributes attributes = NONE) : descriptor_(descriptor), + constness_(constness), representation_(representation), attributes_(attributes), heap_type_(heap_type) {} @@ -2259,8 +2496,8 @@ struct FieldGeneralizationChecker { Handle<Map> updated_map = Map::Update(map1); CHECK_EQ(*map2, *updated_map); - expectations2.SetDataField(descriptor_, attributes_, representation_, - heap_type_); + expectations2.SetDataField(descriptor_, attributes_, constness_, + representation_, heap_type_); CHECK(expectations2.Check(*map2)); } }; @@ -2315,7 +2552,8 @@ static void TestTransitionTo(TransitionOp1& transition_op1, Handle<Map> initial_map = Map::Create(isolate, 0); Handle<Map> map = initial_map; for (int i = 0; i < kPropCount - 1; i++) { - map = expectations.AddDataField(map, NONE, Representation::Smi(), any_type); + map = expectations.AddDataField(map, NONE, kMutable, Representation::Smi(), + any_type); } CHECK(expectations.Check(*map)); @@ -2338,15 +2576,15 @@ TEST(TransitionDataFieldToDataField) { Handle<FieldType> any_type = FieldType::Any(isolate); Handle<Object> value1 = handle(Smi::kZero, isolate); - TransitionToDataFieldOperator transition_op1(Representation::Smi(), any_type, - value1); + TransitionToDataFieldOperator transition_op1(kMutable, Representation::Smi(), + any_type, value1); Handle<Object> value2 = isolate->factory()->NewHeapNumber(0); - TransitionToDataFieldOperator transition_op2(Representation::Double(), - any_type, value2); + TransitionToDataFieldOperator transition_op2( + kMutable, Representation::Double(), any_type, value2); - FieldGeneralizationChecker checker(kPropCount - 1, Representation::Double(), - any_type); + FieldGeneralizationChecker checker(kPropCount - 1, kMutable, + Representation::Double(), any_type); TestTransitionTo(transition_op1, transition_op2, checker); } @@ -2386,9 +2624,15 @@ TEST(TransitionDataConstantToAnotherDataConstant) { factory->NewFunction(sloppy_map, info, isolate->native_context()); TransitionToDataConstantOperator transition_op2(js_func2); - FieldGeneralizationChecker checker( - kPropCount - 1, Representation::HeapObject(), function_type); - TestTransitionTo(transition_op1, transition_op2, checker); + if (FLAG_track_constant_fields) { + SameMapChecker checker; + TestTransitionTo(transition_op1, transition_op2, checker); + + } else { + FieldGeneralizationChecker checker( + kPropCount - 1, kMutable, Representation::HeapObject(), function_type); + TestTransitionTo(transition_op1, transition_op2, checker); + } } @@ -2403,11 +2647,11 @@ TEST(TransitionDataConstantToDataField) { TransitionToDataConstantOperator transition_op1(js_func1); Handle<Object> value2 = isolate->factory()->NewHeapNumber(0); - TransitionToDataFieldOperator transition_op2(Representation::Double(), - any_type, value2); + TransitionToDataFieldOperator transition_op2( + kMutable, Representation::Double(), any_type, value2); - FieldGeneralizationChecker checker(kPropCount - 1, Representation::Tagged(), - any_type); + FieldGeneralizationChecker checker(kPropCount - 1, kMutable, + Representation::Tagged(), any_type); TestTransitionTo(transition_op1, transition_op2, checker); } @@ -2436,3 +2680,31 @@ TEST(FieldTypeConvertSimple) { // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. // TEST(TransitionAccessorConstantToAnotherAccessorConstant) + +TEST(HoleyMutableHeapNumber) { + CcTest::InitializeVM(); + v8::HandleScope scope(CcTest::isolate()); + Isolate* isolate = CcTest::i_isolate(); + + Handle<HeapNumber> mhn = isolate->factory()->NewMutableHeapNumber(); + CHECK_EQ(kHoleNanInt64, mhn->value_as_bits()); + + mhn = isolate->factory()->NewHeapNumber(0.0, MUTABLE); + CHECK_EQ(V8_UINT64_C(0), mhn->value_as_bits()); + + mhn->set_value_as_bits(kHoleNanInt64); + CHECK_EQ(kHoleNanInt64, mhn->value_as_bits()); + + // Ensure that new storage for uninitialized value or mutable heap number + // with uninitialized sentinel (kHoleNanInt64) is a mutable heap number + // with uninitialized sentinel. + Handle<Object> obj = + Object::NewStorageFor(isolate, isolate->factory()->uninitialized_value(), + Representation::Double()); + CHECK(obj->IsMutableHeapNumber()); + CHECK_EQ(kHoleNanInt64, HeapNumber::cast(*obj)->value_as_bits()); + + obj = Object::NewStorageFor(isolate, mhn, Representation::Double()); + CHECK(obj->IsMutableHeapNumber()); + CHECK_EQ(kHoleNanInt64, HeapNumber::cast(*obj)->value_as_bits()); +} diff --git a/deps/v8/test/cctest/test-flags.cc b/deps/v8/test/cctest/test-flags.cc index 230b3d1dd0..0abbca6909 100644 --- a/deps/v8/test/cctest/test-flags.cc +++ b/deps/v8/test/cctest/test-flags.cc @@ -257,5 +257,5 @@ TEST(FlagsRemoveIncomplete) { const_cast<char **>(argv), true)); CHECK(argv[1]); - CHECK_EQ(argc, 2); + CHECK_EQ(2, argc); } diff --git a/deps/v8/test/cctest/test-func-name-inference.cc b/deps/v8/test/cctest/test-func-name-inference.cc index 8c43bbfa54..e5ccbc3275 100644 --- a/deps/v8/test/cctest/test-func-name-inference.cc +++ b/deps/v8/test/cctest/test-func-name-inference.cc @@ -31,6 +31,7 @@ #include "src/api.h" #include "src/debug/debug.h" +#include "src/objects-inl.h" #include "src/string-search.h" #include "test/cctest/cctest.h" diff --git a/deps/v8/test/cctest/test-hashing.cc b/deps/v8/test/cctest/test-hashing.cc index d6f055e321..ef1b363560 100644 --- a/deps/v8/test/cctest/test-hashing.cc +++ b/deps/v8/test/cctest/test-hashing.cc @@ -32,7 +32,7 @@ #include "src/code-stubs.h" #include "src/factory.h" #include "src/macro-assembler.h" -#include "src/objects.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #ifdef USE_SIMULATOR diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index 9780b3f519..7855f75b38 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -34,9 +34,11 @@ #include "src/v8.h" #include "include/v8-profiler.h" +#include "src/api.h" #include "src/base/hashmap.h" #include "src/collector.h" #include "src/debug/debug.h" +#include "src/objects-inl.h" #include "src/profiler/allocation-tracker.h" #include "src/profiler/heap-profiler.h" #include "src/profiler/heap-snapshot-generator-inl.h" @@ -476,48 +478,6 @@ TEST(HeapSnapshotSymbol) { CHECK(v8_str("mySymbol")->Equals(env.local(), name->GetName()).FromJust()); } - -void CheckSimdSnapshot(const char* program, const char* var_name) { - i::FLAG_harmony_simd = true; - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); - v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); - - CompileRun(program); - // The TakeHeapSnapshot function does not do enough GCs to ensure - // that all garbage is collected. We perform addition GC here - // to reclaim a floating AllocationSite and to fix the following failure: - // # Check failed: ValidateSnapshot(snapshot). - // Stdout: - // 28 @ 13523 entry with no retainer: /hidden/ system / AllocationSite - // 44 @ 767 $map: /hidden/ system / Map - // 44 @ 59 $map: /hidden/ system / Map - CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); - - const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); - CHECK(ValidateSnapshot(snapshot)); - const v8::HeapGraphNode* global = GetGlobalObject(snapshot); - const v8::HeapGraphNode* var = - GetProperty(global, v8::HeapGraphEdge::kProperty, var_name); - CHECK(var); - CHECK_EQ(var->GetType(), v8::HeapGraphNode::kSimdValue); -} - - -TEST(HeapSnapshotSimd) { - CheckSimdSnapshot("a = SIMD.Float32x4();\n", "a"); - CheckSimdSnapshot("a = SIMD.Int32x4();\n", "a"); - CheckSimdSnapshot("a = SIMD.Uint32x4();\n", "a"); - CheckSimdSnapshot("a = SIMD.Bool32x4();\n", "a"); - CheckSimdSnapshot("a = SIMD.Int16x8();\n", "a"); - CheckSimdSnapshot("a = SIMD.Uint16x8();\n", "a"); - CheckSimdSnapshot("a = SIMD.Bool16x8();\n", "a"); - CheckSimdSnapshot("a = SIMD.Int8x16();\n", "a"); - CheckSimdSnapshot("a = SIMD.Uint8x16();\n", "a"); - CheckSimdSnapshot("a = SIMD.Bool8x16();\n", "a"); -} - - TEST(HeapSnapshotWeakCollection) { LocalContext env; v8::HandleScope scope(env->GetIsolate()); @@ -2252,15 +2212,19 @@ TEST(AllocationSitesAreVisible) { const v8::HeapGraphNode* fun_code = GetProperty(global, v8::HeapGraphEdge::kProperty, "fun"); CHECK(fun_code); - const v8::HeapGraphNode* literals = - GetProperty(fun_code, v8::HeapGraphEdge::kInternal, "literals"); - CHECK(literals); - CHECK_EQ(v8::HeapGraphNode::kArray, literals->GetType()); - CHECK_EQ(1, literals->GetChildrenCount()); - - // The first value in the literals array should be the boilerplate, + const v8::HeapGraphNode* vector_cell = GetProperty( + fun_code, v8::HeapGraphEdge::kInternal, "feedback_vector_cell"); + // TODO(mvstanton): I'm not sure if this is the best way to expose + // literals. Is it too much to expose the Cell? + CHECK(vector_cell); + const v8::HeapGraphNode* vector = + GetProperty(vector_cell, v8::HeapGraphEdge::kInternal, "value"); + CHECK_EQ(v8::HeapGraphNode::kArray, vector->GetType()); + CHECK_EQ(3, vector->GetChildrenCount()); + + // The first value in the feedback vector should be the boilerplate, // after an AllocationSite. - const v8::HeapGraphEdge* prop = literals->GetChild(0); + const v8::HeapGraphEdge* prop = vector->GetChild(2); const v8::HeapGraphNode* allocation_site = prop->GetToNode(); v8::String::Utf8Value name(allocation_site->GetName()); CHECK_EQ(0, strcmp("system / AllocationSite", *name)); @@ -2703,33 +2667,6 @@ TEST(ArrayBufferSharedBackingStore) { } -TEST(BoxObject) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope scope(isolate); - LocalContext env; - v8::Local<v8::Object> global_proxy = env->Global(); - v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); - - i::Factory* factory = CcTest::i_isolate()->factory(); - i::Handle<i::String> string = factory->NewStringFromStaticChars("string"); - i::Handle<i::Object> box = factory->NewBox(string); - global->Set(env.local(), 0, v8::ToApiHandle<v8::Object>(box)).FromJust(); - - v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); - const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); - CHECK(ValidateSnapshot(snapshot)); - const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); - const v8::HeapGraphNode* box_node = - GetProperty(global_node, v8::HeapGraphEdge::kElement, "0"); - CHECK(box_node); - v8::String::Utf8Value box_node_name(box_node->GetName()); - CHECK_EQ(0, strcmp("system / Box", *box_node_name)); - const v8::HeapGraphNode* box_value = - GetProperty(box_node, v8::HeapGraphEdge::kInternal, "value"); - CHECK(box_value); -} - - TEST(WeakContainers) { i::FLAG_allow_natives_syntax = true; LocalContext env; diff --git a/deps/v8/test/cctest/test-identity-map.cc b/deps/v8/test/cctest/test-identity-map.cc index aac39827c0..aca09103d3 100644 --- a/deps/v8/test/cctest/test-identity-map.cc +++ b/deps/v8/test/cctest/test-identity-map.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <set> + #include "src/factory.h" #include "src/identity-map.h" #include "src/isolate.h" @@ -24,9 +26,9 @@ namespace internal { // "move" objects to simulate GC for testing the internals of the map. class IdentityMapTester : public HandleAndZoneScope { public: - IdentityMap<void*> map; + IdentityMap<void*, ZoneAllocationPolicy> map; - IdentityMapTester() : map(heap(), main_zone()) {} + IdentityMapTester() : map(heap(), ZoneAllocationPolicy(main_zone())) {} Heap* heap() { return isolate()->heap(); } Isolate* isolate() { return main_isolate(); } @@ -79,6 +81,63 @@ class IdentityMapTester : public HandleAndZoneScope { } } + void TestFindDelete(Handle<Object> key1, void* val1, Handle<Object> key2, + void* val2) { + CHECK_NULL(map.Find(key1)); + CHECK_NULL(map.Find(key2)); + + // Set {key1} and {key2} for the first time. + void** entry1 = map.Get(key1); + CHECK_NOT_NULL(entry1); + *entry1 = val1; + void** entry2 = map.Get(key2); + CHECK_NOT_NULL(entry2); + *entry2 = val2; + + for (int i = 0; i < 3; i++) { // Find {key1} and {key2} 3 times. + { + void** nentry = map.Find(key2); + CHECK_EQ(val2, *nentry); + } + { + void** nentry = map.Find(key1); + CHECK_EQ(val1, *nentry); + } + } + + // Delete {key1} + void* deleted_entry_1 = map.Delete(key1); + CHECK_NOT_NULL(deleted_entry_1); + deleted_entry_1 = val1; + + for (int i = 0; i < 3; i++) { // Find {key1} and not {key2} 3 times. + { + void** nentry = map.Find(key1); + CHECK_NULL(nentry); + } + { + void** nentry = map.Find(key2); + CHECK_EQ(val2, *nentry); + } + } + + // Delete {key2} + void* deleted_entry_2 = map.Delete(key2); + CHECK_NOT_NULL(deleted_entry_2); + deleted_entry_2 = val2; + + for (int i = 0; i < 3; i++) { // Don't find {key1} and {key2} 3 times. + { + void** nentry = map.Find(key1); + CHECK_NULL(nentry); + } + { + void** nentry = map.Find(key2); + CHECK_NULL(nentry); + } + } + } + Handle<Smi> smi(int value) { return Handle<Smi>(Smi::FromInt(value), isolate()); } @@ -88,7 +147,7 @@ class IdentityMapTester : public HandleAndZoneScope { } void SimulateGCByIncrementingSmisBy(int shift) { - for (int i = 0; i < map.size_; i++) { + for (int i = 0; i < map.capacity_; i++) { if (map.keys_[i]->IsSmi()) { map.keys_[i] = Smi::FromInt(Smi::cast(map.keys_[i])->value() + shift); } @@ -108,16 +167,22 @@ class IdentityMapTester : public HandleAndZoneScope { CHECK_EQ(value, *entry); } + void CheckDelete(Handle<Object> key, void* value) { + void* entry = map.Delete(key); + CHECK_NOT_NULL(entry); + CHECK_EQ(value, entry); + } + void PrintMap() { PrintF("{\n"); - for (int i = 0; i < map.size_; i++) { + for (int i = 0; i < map.capacity_; i++) { PrintF(" %3d: %p => %p\n", i, reinterpret_cast<void*>(map.keys_[i]), reinterpret_cast<void*>(map.values_[i])); } PrintF("}\n"); } - void Resize() { map.Resize(); } + void Resize() { map.Resize(map.capacity_ * 4); } void Rehash() { map.Rehash(); } }; @@ -138,18 +203,46 @@ TEST(Find_num_not_found) { } } +TEST(Delete_smi_not_found) { + IdentityMapTester t; + for (int i = 0; i < 100; i++) { + CHECK_NULL(t.map.Delete(t.smi(i))); + } +} + +TEST(Delete_num_not_found) { + IdentityMapTester t; + for (int i = 0; i < 100; i++) { + CHECK_NULL(t.map.Delete(t.num(i + 0.2))); + } +} + +TEST(GetFind_smi_0) { + IdentityMapTester t; + t.TestGetFind(t.smi(0), t.isolate(), t.smi(1), t.heap()); +} TEST(GetFind_smi_13) { IdentityMapTester t; t.TestGetFind(t.smi(13), t.isolate(), t.smi(17), t.heap()); } - TEST(GetFind_num_13) { IdentityMapTester t; t.TestGetFind(t.num(13.1), t.isolate(), t.num(17.1), t.heap()); } +TEST(Delete_smi_13) { + IdentityMapTester t; + t.TestFindDelete(t.smi(13), t.isolate(), t.smi(17), t.heap()); + CHECK(t.map.empty()); +} + +TEST(Delete_num_13) { + IdentityMapTester t; + t.TestFindDelete(t.num(13.1), t.isolate(), t.num(17.1), t.heap()); + CHECK(t.map.empty()); +} TEST(GetFind_smi_17m) { const int kInterval = 17; @@ -179,6 +272,32 @@ TEST(GetFind_smi_17m) { } } +TEST(Delete_smi_17m) { + const int kInterval = 17; + const int kShift = 1099; + IdentityMapTester t; + + for (int i = 1; i < 100; i += kInterval) { + t.map.Set(t.smi(i), reinterpret_cast<void*>(i + kShift)); + } + + for (int i = 1; i < 100; i += kInterval) { + t.CheckFind(t.smi(i), reinterpret_cast<void*>(i + kShift)); + } + + for (int i = 1; i < 100; i += kInterval) { + t.CheckDelete(t.smi(i), reinterpret_cast<void*>(i + kShift)); + for (int j = 1; j < 100; j += kInterval) { + void** entry = t.map.Find(t.smi(j)); + if (j <= i) { + CHECK_NULL(entry); + } else { + CHECK_NOT_NULL(entry); + CHECK_EQ(reinterpret_cast<void*>(j + kShift), *entry); + } + } + } +} TEST(GetFind_num_1000) { const int kPrime = 137; @@ -191,6 +310,41 @@ TEST(GetFind_num_1000) { } } +TEST(Delete_num_1000) { + const int kPrime = 137; + IdentityMapTester t; + + for (int i = 0; i < 1000; i++) { + t.map.Set(t.smi(i * kPrime), reinterpret_cast<void*>(i * kPrime)); + } + + // Delete every second value in reverse. + for (int i = 999; i >= 0; i -= 2) { + void* entry = t.map.Delete(t.smi(i * kPrime)); + CHECK_EQ(reinterpret_cast<void*>(i * kPrime), entry); + } + + for (int i = 0; i < 1000; i++) { + void** entry = t.map.Find(t.smi(i * kPrime)); + if (i % 2) { + CHECK_NULL(entry); + } else { + CHECK_NOT_NULL(entry); + CHECK_EQ(reinterpret_cast<void*>(i * kPrime), *entry); + } + } + + // Delete the rest. + for (int i = 0; i < 1000; i += 2) { + void* entry = t.map.Delete(t.smi(i * kPrime)); + CHECK_EQ(reinterpret_cast<void*>(i * kPrime), entry); + } + + for (int i = 0; i < 1000; i++) { + void** entry = t.map.Find(t.smi(i * kPrime)); + CHECK_NULL(entry); + } +} TEST(GetFind_smi_gc) { const int kKey = 33; @@ -203,6 +357,15 @@ TEST(GetFind_smi_gc) { t.CheckGet(t.smi(kKey + kShift), &t); } +TEST(Delete_smi_gc) { + const int kKey = 33; + const int kShift = 1211; + IdentityMapTester t; + + t.map.Set(t.smi(kKey), &t); + t.SimulateGCByIncrementingSmisBy(kShift); + t.CheckDelete(t.smi(kKey + kShift), &t); +} TEST(GetFind_smi_gc2) { int kKey1 = 1; @@ -219,6 +382,18 @@ TEST(GetFind_smi_gc2) { t.CheckGet(t.smi(kKey2 + kShift), &kKey2); } +TEST(Delete_smi_gc2) { + int kKey1 = 1; + int kKey2 = 33; + const int kShift = 1211; + IdentityMapTester t; + + t.map.Set(t.smi(kKey1), &kKey1); + t.map.Set(t.smi(kKey2), &kKey2); + t.SimulateGCByIncrementingSmisBy(kShift); + t.CheckDelete(t.smi(kKey1 + kShift), &kKey1); + t.CheckDelete(t.smi(kKey2 + kShift), &kKey2); +} TEST(GetFind_smi_gc_n) { const int kShift = 12011; @@ -245,6 +420,22 @@ TEST(GetFind_smi_gc_n) { } } +TEST(Delete_smi_gc_n) { + const int kShift = 12011; + IdentityMapTester t; + int keys[12] = {1, 2, 7, 8, 15, 23, + 1 + 32, 2 + 32, 7 + 32, 8 + 32, 15 + 32, 23 + 32}; + // Initialize the map first. + for (size_t i = 0; i < arraysize(keys); i++) { + t.map.Set(t.smi(keys[i]), &keys[i]); + } + // Simulate a GC by "moving" the smis in the internal keys array. + t.SimulateGCByIncrementingSmisBy(kShift); + // Check that deleting for the incremented smis finds the same values. + for (size_t i = 0; i < arraysize(keys); i++) { + t.CheckDelete(t.smi(keys[i] + kShift), &keys[i]); + } +} TEST(GetFind_smi_num_gc_n) { const int kShift = 12019; @@ -285,6 +476,158 @@ TEST(GetFind_smi_num_gc_n) { } } +TEST(Delete_smi_num_gc_n) { + const int kShift = 12019; + IdentityMapTester t; + int smi_keys[] = {1, 2, 7, 15, 23}; + Handle<Object> num_keys[] = {t.num(1.1), t.num(2.2), t.num(3.3), t.num(4.4), + t.num(5.5), t.num(6.6), t.num(7.7), t.num(8.8), + t.num(9.9), t.num(10.1)}; + // Initialize the map first. + for (size_t i = 0; i < arraysize(smi_keys); i++) { + t.map.Set(t.smi(smi_keys[i]), &smi_keys[i]); + } + for (size_t i = 0; i < arraysize(num_keys); i++) { + t.map.Set(num_keys[i], &num_keys[i]); + } + + // Simulate a GC by moving SMIs. + // Ironically the SMIs "move", but the heap numbers don't! + t.SimulateGCByIncrementingSmisBy(kShift); + + // Check that deleting for the incremented smis finds the same values. + for (size_t i = 0; i < arraysize(smi_keys); i++) { + t.CheckDelete(t.smi(smi_keys[i] + kShift), &smi_keys[i]); + } + + // Check that deleting the numbers finds the same values. + for (size_t i = 0; i < arraysize(num_keys); i++) { + t.CheckDelete(num_keys[i], &num_keys[i]); + } +} + +TEST(Delete_smi_resizes) { + const int kKeyCount = 1024; + const int kValueOffset = 27; + IdentityMapTester t; + + // Insert one element to initialize map. + t.map.Set(t.smi(0), reinterpret_cast<void*>(kValueOffset)); + + int initial_capacity = t.map.capacity(); + CHECK_LT(initial_capacity, kKeyCount); + + // Insert another kKeyCount - 1 keys. + for (int i = 1; i < kKeyCount; i++) { + t.map.Set(t.smi(i), reinterpret_cast<void*>(i + kValueOffset)); + } + + // Check capacity increased. + CHECK_GT(t.map.capacity(), initial_capacity); + CHECK_GE(t.map.capacity(), kKeyCount); + + // Delete all the keys. + for (int i = 0; i < kKeyCount; i++) { + t.CheckDelete(t.smi(i), reinterpret_cast<void*>(i + kValueOffset)); + } + + // Should resize back to initial capacity. + CHECK_EQ(t.map.capacity(), initial_capacity); +} + +TEST(Iterator_smi_num) { + IdentityMapTester t; + int smi_keys[] = {1, 2, 7, 15, 23}; + Handle<Object> num_keys[] = {t.num(1.1), t.num(2.2), t.num(3.3), t.num(4.4), + t.num(5.5), t.num(6.6), t.num(7.7), t.num(8.8), + t.num(9.9), t.num(10.1)}; + // Initialize the map. + for (size_t i = 0; i < arraysize(smi_keys); i++) { + t.map.Set(t.smi(smi_keys[i]), reinterpret_cast<void*>(i)); + } + for (size_t i = 0; i < arraysize(num_keys); i++) { + t.map.Set(num_keys[i], reinterpret_cast<void*>(i + 5)); + } + + // Check iterator sees all values. + std::set<intptr_t> seen; + { + IdentityMap<void*, ZoneAllocationPolicy>::IteratableScope it_scope(&t.map); + for (auto it = it_scope.begin(); it != it_scope.end(); ++it) { + seen.insert(reinterpret_cast<intptr_t>(**it)); + } + } + for (intptr_t i = 0; i < 15; i++) { + CHECK(seen.find(i) != seen.end()); + } +} + +TEST(Iterator_smi_num_gc) { + const int kShift = 16039; + IdentityMapTester t; + int smi_keys[] = {1, 2, 7, 15, 23}; + Handle<Object> num_keys[] = {t.num(1.1), t.num(2.2), t.num(3.3), t.num(4.4), + t.num(5.5), t.num(6.6), t.num(7.7), t.num(8.8), + t.num(9.9), t.num(10.1)}; + // Initialize the map. + for (size_t i = 0; i < arraysize(smi_keys); i++) { + t.map.Set(t.smi(smi_keys[i]), reinterpret_cast<void*>(i)); + } + for (size_t i = 0; i < arraysize(num_keys); i++) { + t.map.Set(num_keys[i], reinterpret_cast<void*>(i + 5)); + } + + // Simulate GC by moving the SMIs. + t.SimulateGCByIncrementingSmisBy(kShift); + + // Check iterator sees all values. + std::set<intptr_t> seen; + { + IdentityMap<void*, ZoneAllocationPolicy>::IteratableScope it_scope(&t.map); + for (auto it = it_scope.begin(); it != it_scope.end(); ++it) { + seen.insert(reinterpret_cast<intptr_t>(**it)); + } + } + for (intptr_t i = 0; i < 15; i++) { + CHECK(seen.find(i) != seen.end()); + } +} + +TEST(Iterator_smi_delete) { + IdentityMapTester t; + int smi_keys[] = {1, 2, 7, 15, 23}; + + // Initialize the map. + for (size_t i = 0; i < arraysize(smi_keys); i++) { + t.map.Set(t.smi(smi_keys[i]), reinterpret_cast<void*>(i)); + } + + // Iterate and delete half the elements. + std::set<intptr_t> deleted; + { + int i = 0; + IdentityMap<void*, ZoneAllocationPolicy>::IteratableScope it_scope(&t.map); + for (auto it = it_scope.begin(); it != it_scope.end();) { + if (i % 2) { + deleted.insert(reinterpret_cast<intptr_t>(**it)); + it.DeleteAndIncrement(); + } else { + ++it; + } + } + } + + // Check values in map are correct. + for (intptr_t i = 0; i < 5; i++) { + void** entry = t.map.Find(t.smi(smi_keys[i])); + if (deleted.find(i) != deleted.end()) { + CHECK_NULL(entry); + } else { + CHECK_NOT_NULL(entry); + CHECK_EQ(reinterpret_cast<void*>(i), *entry); + } + } +} void CollisionTest(int stride, bool rehash = false, bool resize = false) { for (int load = 15; load <= 120; load = load * 2) { @@ -313,7 +656,6 @@ void CollisionTest(int stride, bool rehash = false, bool resize = false) { } } - TEST(Collisions_1) { CollisionTest(1); } TEST(Collisions_2) { CollisionTest(2); } TEST(Collisions_3) { CollisionTest(3); } diff --git a/deps/v8/test/cctest/test-inobject-slack-tracking.cc b/deps/v8/test/cctest/test-inobject-slack-tracking.cc index 3c46fbee06..650770e055 100644 --- a/deps/v8/test/cctest/test-inobject-slack-tracking.cc +++ b/deps/v8/test/cctest/test-inobject-slack-tracking.cc @@ -724,6 +724,132 @@ TEST(InobjectPropetiesCountOverflowInSubclass) { TestClassHierarchy(hierarchy_desc, kNoOverflowCount); } +static void CheckExpectedProperties(int expected, std::ostringstream& os) { + Handle<HeapObject> obj = Handle<HeapObject>::cast( + v8::Utils::OpenHandle(*CompileRun(os.str().c_str()))); + CHECK_EQ(expected, obj->map()->GetInObjectProperties()); +} + +TEST(ObjectLiteralPropertyBackingStoreSize) { + v8::HandleScope scope(CcTest::isolate()); + LocalContext env; + + std::ostringstream os; + + // An index key does not require space in the property backing store. + os << "(function() {\n" + " function f() {\n" + " var o = {\n" + " '-1': 42,\n" // Allocate for non-index key. + " 1: 42,\n" // Do not allocate for index key. + " '2': 42\n" // Do not allocate for index key. + " };\n" + " return o;\n" + " }\n" + "\n" + " return f();\n" + "} )();"; + CheckExpectedProperties(1, os); + + // Avoid over-/under-allocation for computed property names. + os << "(function() {\n" + " 'use strict';\n" + " function f(x) {\n" + " var o = {\n" + " 1: 42,\n" // Do not allocate for index key. + " '2': 42,\n" // Do not allocate for index key. + " [x]: 42,\n" // Allocate for property with computed name. + " 3: 42,\n" // Do not allocate for index key. + " '4': 42\n" // Do not allocate for index key. + " };\n" + " return o;\n" + " }\n" + "\n" + " var x = 'hello'\n" + "\n" + " return f(x);\n" + "} )();"; + CheckExpectedProperties(1, os); + + // Conversion to index key. + os << "(function() {\n" + " function f(x) {\n" + " var o = {\n" + " 1: 42,\n" // Do not allocate for index key. + " '2': 42,\n" // Do not allocate for index key. + " [x]: 42,\n" // Allocate for property with computed name. + " 3: 42,\n" // Do not allocate for index key. + " get 12() {}\n" // Do not allocate for index key. + " };\n" + " return o;\n" + " }\n" + "\n" + " var x = 'hello'\n" + "\n" + " return f(x);\n" + "} )();"; + CheckExpectedProperties(1, os); + + os << "(function() {\n" + " function f() {\n" + " var o = {};\n" + " return o;\n" + " }\n" + "\n" + " return f();\n" + "} )();"; + // Empty objects have slack for 4 properties. + CheckExpectedProperties(4, os); + + os << "(function() {\n" + " function f(x) {\n" + " var o = {\n" + " a: 42,\n" // Allocate for constant property. + " [x]: 42,\n" // Allocate for property with computed name. + " b: 42\n" // Allocate for constant property. + " };\n" + " return o;\n" + " }\n" + "\n" + " var x = 'hello'\n" + "\n" + " return f(x);\n" + "} )();"; + CheckExpectedProperties(3, os); + + os << "(function() {\n" + " function f(x) {\n" + " var o = {\n" + " a: 42,\n" // Allocate for constant property. + " __proto__: 42,\n" // Do not allocate for __proto__. + " [x]: 42\n" // Allocate for property with computed name. + " };\n" + " return o;\n" + " }\n" + "\n" + " var x = 'hello'\n" + "\n" + " return f(x);\n" + "} )();"; + // __proto__ is not allocated in the backing store. + CheckExpectedProperties(2, os); + + os << "(function() {\n" + " function f(x) {\n" + " var o = {\n" + " a: 42,\n" // Allocate for constant property. + " [x]: 42,\n" // Allocate for property with computed name. + " __proto__: 42\n" // Do not allocate for __proto__. + " };\n" + " return o;\n" + " }\n" + "\n" + " var x = 'hello'\n" + "\n" + " return f(x);\n" + "} )();"; + CheckExpectedProperties(2, os); +} TEST(SlowModeSubclass) { // Avoid eventual completion of in-object slack tracking. diff --git a/deps/v8/test/cctest/test-log-stack-tracer.cc b/deps/v8/test/cctest/test-log-stack-tracer.cc index 09257bcda2..02feb64536 100644 --- a/deps/v8/test/cctest/test-log-stack-tracer.cc +++ b/deps/v8/test/cctest/test-log-stack-tracer.cc @@ -35,6 +35,7 @@ #include "src/disassembler.h" #include "src/isolate.h" #include "src/log.h" +#include "src/objects-inl.h" #include "src/v8.h" #include "src/vm-state-inl.h" #include "test/cctest/cctest.h" diff --git a/deps/v8/test/cctest/test-macro-assembler-mips64.cc b/deps/v8/test/cctest/test-macro-assembler-mips64.cc index cfcdeb2d40..9527e620bd 100644 --- a/deps/v8/test/cctest/test-macro-assembler-mips64.cc +++ b/deps/v8/test/cctest/test-macro-assembler-mips64.cc @@ -193,7 +193,7 @@ TEST(LoadAddress) { __ bind(&skip); __ li(a4, Operand(masm->jump_address(&to_jump)), ADDRESS_LOAD); int check_size = masm->InstructionsGeneratedSince(&skip); - CHECK_EQ(check_size, 4); + CHECK_EQ(4, check_size); __ jr(a4); __ nop(); __ stop("invalid"); diff --git a/deps/v8/test/cctest/test-macro-assembler-x64.cc b/deps/v8/test/cctest/test-macro-assembler-x64.cc index 1f6c247288..05beed1dd1 100644 --- a/deps/v8/test/cctest/test-macro-assembler-x64.cc +++ b/deps/v8/test/cctest/test-macro-assembler-x64.cc @@ -32,6 +32,7 @@ #include "src/base/platform/platform.h" #include "src/factory.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" namespace i = v8::internal; diff --git a/deps/v8/test/cctest/test-managed.cc b/deps/v8/test/cctest/test-managed.cc new file mode 100644 index 0000000000..21452b32f8 --- /dev/null +++ b/deps/v8/test/cctest/test-managed.cc @@ -0,0 +1,78 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#include "src/managed.h" + +#include "src/objects-inl.h" +#include "test/cctest/cctest.h" + +using namespace v8::base; +using namespace v8::internal; + +class DeleteRecorder { + public: + explicit DeleteRecorder(bool* deleted) : deleted_(deleted) { + *deleted_ = false; + } + ~DeleteRecorder() { *deleted_ = true; } + static void Deleter(void* value) { + delete reinterpret_cast<DeleteRecorder*>(value); + } + + private: + bool* deleted_; +}; + +TEST(ManagedCollect) { + Isolate* isolate = CcTest::InitIsolateOnce(); + bool deleted1 = false; + bool deleted2 = false; + DeleteRecorder* d1 = new DeleteRecorder(&deleted1); + DeleteRecorder* d2 = new DeleteRecorder(&deleted2); + Isolate::ManagedObjectFinalizer* finalizer = + isolate->RegisterForReleaseAtTeardown(d2, DeleteRecorder::Deleter); + { + HandleScope scope(isolate); + auto handle = Managed<DeleteRecorder>::New(isolate, d1); + USE(handle); + } + + CcTest::CollectAllAvailableGarbage(); + + CHECK(deleted1); + CHECK(!deleted2); + isolate->UnregisterFromReleaseAtTeardown(&finalizer); + CHECK_NULL(finalizer); + delete d2; + CHECK(deleted2); +} + +TEST(DisposeCollect) { + v8::Isolate::CreateParams create_params; + create_params.array_buffer_allocator = + CcTest::InitIsolateOnce()->array_buffer_allocator(); + + v8::Isolate* isolate = v8::Isolate::New(create_params); + isolate->Enter(); + Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + bool deleted1 = false; + bool deleted2 = false; + DeleteRecorder* d1 = new DeleteRecorder(&deleted1); + DeleteRecorder* d2 = new DeleteRecorder(&deleted2); + { + HandleScope scope(i_isolate); + auto handle = Managed<DeleteRecorder>::New(i_isolate, d1); + USE(handle); + } + i_isolate->RegisterForReleaseAtTeardown(d2, DeleteRecorder::Deleter); + + isolate->Exit(); + isolate->Dispose(); + CHECK(deleted1); + CHECK(deleted2); +} diff --git a/deps/v8/test/cctest/test-modules.cc b/deps/v8/test/cctest/test-modules.cc index e086a407f9..9a9bfef990 100644 --- a/deps/v8/test/cctest/test-modules.cc +++ b/deps/v8/test/cctest/test-modules.cc @@ -19,6 +19,14 @@ using v8::ScriptOrigin; using v8::String; using v8::Value; +ScriptOrigin ModuleOrigin(Local<v8::Value> resource_name, Isolate* isolate) { + ScriptOrigin origin(resource_name, Local<v8::Integer>(), Local<v8::Integer>(), + Local<v8::Boolean>(), Local<v8::Integer>(), + Local<v8::Value>(), Local<v8::Boolean>(), + Local<v8::Boolean>(), True(isolate)); + return origin; +} + MaybeLocal<Module> AlwaysEmptyResolveCallback(Local<Context> context, Local<String> specifier, Local<Module> referrer) { @@ -31,7 +39,7 @@ MaybeLocal<Module> FailOnSecondCallResolveCallback(Local<Context> context, Local<Module> referrer) { if (g_count++ > 0) return MaybeLocal<Module>(); Local<String> source_text = v8_str(""); - ScriptOrigin origin(v8_str("module.js")); + ScriptOrigin origin = ModuleOrigin(v8_str("module.js"), CcTest::isolate()); ScriptCompiler::Source source(source_text, origin); return ScriptCompiler::CompileModule(CcTest::isolate(), &source) .ToLocalChecked(); @@ -45,7 +53,7 @@ TEST(ModuleInstantiationFailures) { Local<String> source_text = v8_str( "import './foo.js';" "export {} from './bar.js';"); - ScriptOrigin origin(v8_str("file.js")); + ScriptOrigin origin = ModuleOrigin(v8_str("file.js"), CcTest::isolate()); ScriptCompiler::Source source(source_text, origin); Local<Module> module = ScriptCompiler::CompileModule(isolate, &source).ToLocalChecked(); @@ -66,7 +74,7 @@ TEST(ModuleInstantiationFailures) { static MaybeLocal<Module> CompileSpecifierAsModuleResolveCallback( Local<Context> context, Local<String> specifier, Local<Module> referrer) { - ScriptOrigin origin(v8_str("module.js")); + ScriptOrigin origin = ModuleOrigin(v8_str("module.js"), CcTest::isolate()); ScriptCompiler::Source source(specifier, origin); return ScriptCompiler::CompileModule(CcTest::isolate(), &source) .ToLocalChecked(); @@ -80,7 +88,7 @@ TEST(ModuleEvaluation) { Local<String> source_text = v8_str( "import 'Object.expando = 5';" "import 'Object.expando *= 2';"); - ScriptOrigin origin(v8_str("file.js")); + ScriptOrigin origin = ModuleOrigin(v8_str("file.js"), CcTest::isolate()); ScriptCompiler::Source source(source_text, origin); Local<Module> module = ScriptCompiler::CompileModule(isolate, &source).ToLocalChecked(); diff --git a/deps/v8/test/cctest/test-object.cc b/deps/v8/test/cctest/test-object.cc index cade4284ae..71681b87d1 100644 --- a/deps/v8/test/cctest/test-object.cc +++ b/deps/v8/test/cctest/test-object.cc @@ -58,9 +58,6 @@ TEST(NoSideEffectsToString) { CheckObject(isolate, factory->undefined_value(), "undefined"); CheckObject(isolate, factory->null_value(), "null"); - int lanes[] = {0, 1, 2, 3}; - CheckObject(isolate, factory->NewInt32x4(lanes), "SIMD.Int32x4(0, 1, 2, 3)"); - CheckObject(isolate, factory->error_to_string(), "[object Error]"); CheckObject(isolate, factory->stack_trace_symbol(), "Symbol(stack_trace_symbol)"); diff --git a/deps/v8/test/cctest/test-parsing.cc b/deps/v8/test/cctest/test-parsing.cc index fd904b110c..f2e90ae259 100644 --- a/deps/v8/test/cctest/test-parsing.cc +++ b/deps/v8/test/cctest/test-parsing.cc @@ -53,6 +53,8 @@ #include "src/utils.h" #include "test/cctest/cctest.h" +#include "test/cctest/scope-test-helper.h" +#include "test/cctest/unicode-helpers.h" TEST(ScanKeywords) { struct KeywordToken { @@ -702,29 +704,6 @@ TEST(RegExpScanning) { TestScanRegExp("/=?/", "=?"); } -static int Ucs2CharLength(unibrow::uchar c) { - if (c == unibrow::Utf8::kIncomplete || c == unibrow::Utf8::kBufferEmpty) { - return 0; - } else if (c < 0xffff) { - return 1; - } else { - return 2; - } -} - -static int Utf8LengthHelper(const char* s) { - unibrow::Utf8::Utf8IncrementalBuffer buffer(unibrow::Utf8::kBufferEmpty); - int length = 0; - for (; *s != '\0'; s++) { - unibrow::uchar tmp = unibrow::Utf8::ValueOfIncremental(*s, &buffer); - length += Ucs2CharLength(tmp); - } - unibrow::uchar tmp = unibrow::Utf8::ValueOfIncrementalFinish(&buffer); - length += Ucs2CharLength(tmp); - return length; -} - - TEST(ScopeUsesArgumentsSuperThis) { static const struct { const char* prefix; @@ -825,8 +804,7 @@ TEST(ScopeUsesArgumentsSuperThis) { factory->NewStringFromUtf8(i::CStrVector(program.start())) .ToHandleChecked(); i::Handle<i::Script> script = factory->NewScript(source); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); // The information we're checking is only produced when eager parsing. info.set_allow_lazy_parsing(false); CHECK(i::parsing::ParseProgram(&info)); @@ -882,7 +860,7 @@ static void CheckParsesToNumber(const char* source, bool with_dot) { i::Handle<i::Script> script = factory->NewScript(source_code); - i::ParseInfo info(handles.main_zone(), script); + i::ParseInfo info(script); i::Parser parser(&info); info.set_allow_lazy_parsing(false); info.set_toplevel(true); @@ -1180,8 +1158,7 @@ TEST(ScopePositions) { i::CStrVector(program.start())).ToHandleChecked(); CHECK_EQ(source->length(), kProgramSize); i::Handle<i::Script> script = factory->NewScript(source); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); info.set_language_mode(source_data[i].language_mode); i::parsing::ParseProgram(&info); CHECK_NOT_NULL(info.literal()); @@ -1189,7 +1166,7 @@ TEST(ScopePositions) { // Check scope types and positions. i::Scope* scope = info.literal()->scope(); CHECK(scope->is_script_scope()); - CHECK_EQ(scope->start_position(), 0); + CHECK_EQ(0, scope->start_position()); CHECK_EQ(scope->end_position(), kProgramSize); i::Scope* inner_scope = scope->inner_scope(); @@ -1227,8 +1204,7 @@ TEST(DiscardFunctionBody) { i::Handle<i::String> source_code = factory->NewStringFromUtf8(i::CStrVector(source)).ToHandleChecked(); i::Handle<i::Script> script = factory->NewScript(source_code); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); i::parsing::ParseProgram(&info); function = info.literal(); CHECK_NOT_NULL(function); @@ -1284,7 +1260,10 @@ enum ParserFlag { kAllowHarmonyRestrictiveGenerators, kAllowHarmonyTrailingCommas, kAllowHarmonyClassFields, - kAllowHarmonyObjectSpread, + kAllowHarmonyObjectRestSpread, + kAllowHarmonyDynamicImport, + kAllowHarmonyAsyncIteration, + kAllowHarmonyTemplateEscapes, }; enum ParserSyncTestResult { @@ -1300,7 +1279,12 @@ void SetGlobalFlags(i::EnumSet<ParserFlag> flags) { flags.Contains(kAllowHarmonyRestrictiveGenerators); i::FLAG_harmony_trailing_commas = flags.Contains(kAllowHarmonyTrailingCommas); i::FLAG_harmony_class_fields = flags.Contains(kAllowHarmonyClassFields); - i::FLAG_harmony_object_spread = flags.Contains(kAllowHarmonyObjectSpread); + i::FLAG_harmony_object_rest_spread = + flags.Contains(kAllowHarmonyObjectRestSpread); + i::FLAG_harmony_dynamic_import = flags.Contains(kAllowHarmonyDynamicImport); + i::FLAG_harmony_async_iteration = flags.Contains(kAllowHarmonyAsyncIteration); + i::FLAG_harmony_template_escapes = + flags.Contains(kAllowHarmonyTemplateEscapes); } void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { @@ -1313,21 +1297,25 @@ void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { flags.Contains(kAllowHarmonyTrailingCommas)); parser->set_allow_harmony_class_fields( flags.Contains(kAllowHarmonyClassFields)); - parser->set_allow_harmony_object_spread( - flags.Contains(kAllowHarmonyObjectSpread)); + parser->set_allow_harmony_object_rest_spread( + flags.Contains(kAllowHarmonyObjectRestSpread)); + parser->set_allow_harmony_dynamic_import( + flags.Contains(kAllowHarmonyDynamicImport)); + parser->set_allow_harmony_async_iteration( + flags.Contains(kAllowHarmonyAsyncIteration)); + parser->set_allow_harmony_template_escapes( + flags.Contains(kAllowHarmonyTemplateEscapes)); } void TestParserSyncWithFlags(i::Handle<i::String> source, i::EnumSet<ParserFlag> flags, ParserSyncTestResult result, - bool is_module = false, - bool test_preparser = true) { + bool is_module = false, bool test_preparser = true, + bool ignore_error_msg = false) { i::Isolate* isolate = CcTest::i_isolate(); i::Factory* factory = isolate->factory(); uintptr_t stack_limit = isolate->stack_guard()->real_climit(); - int preparser_materialized_literals = -1; - int parser_materialized_literals = -2; // Preparse the data. i::PendingCompilationErrorHandler pending_error_handler; @@ -1344,8 +1332,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, isolate->counters()->runtime_call_stats()); SetParserFlags(&preparser, flags); scanner.Initialize(stream.get()); - i::PreParser::PreParseResult result = - preparser.PreParseProgram(&preparser_materialized_literals, is_module); + i::PreParser::PreParseResult result = preparser.PreParseProgram(is_module); CHECK_EQ(i::PreParser::kPreParseSuccess, result); } @@ -1353,16 +1340,12 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, i::FunctionLiteral* function; { i::Handle<i::Script> script = factory->NewScript(source); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); info.set_allow_lazy_parsing(flags.Contains(kAllowLazy)); SetGlobalFlags(flags); if (is_module) info.set_module(); i::parsing::ParseProgram(&info); function = info.literal(); - if (function) { - parser_materialized_literals = function->materialized_literal_count(); - } } // Check that preparsing fails iff parsing fails. @@ -1398,7 +1381,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, CHECK(false); } // Check that preparser and parser produce the same error. - if (test_preparser) { + if (test_preparser && !ignore_error_msg) { i::Handle<i::String> preparser_message = pending_error_handler.FormatMessage(CcTest::i_isolate()); if (!i::String::Equals(message_string, preparser_message)) { @@ -1432,20 +1415,9 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, "However, parser and preparser succeeded", source->ToCString().get()); CHECK(false); - } else if (test_preparser && - preparser_materialized_literals != parser_materialized_literals) { - v8::base::OS::Print( - "Preparser materialized literals (%d) differ from Parser materialized " - "literals (%d) on:\n" - "\t%s\n" - "However, parser and preparser succeeded", - preparser_materialized_literals, parser_materialized_literals, - source->ToCString().get()); - CHECK(false); } } - void TestParserSync(const char* source, const ParserFlag* varying_flags, size_t varying_flags_length, ParserSyncTestResult result = kSuccessOrError, @@ -1453,7 +1425,8 @@ void TestParserSync(const char* source, const ParserFlag* varying_flags, size_t always_true_flags_length = 0, const ParserFlag* always_false_flags = NULL, size_t always_false_flags_length = 0, - bool is_module = false, bool test_preparser = true) { + bool is_module = false, bool test_preparser = true, + bool ignore_error_msg = false) { i::Handle<i::String> str = CcTest::i_isolate()->factory()->NewStringFromAsciiChecked(source); for (int bits = 0; bits < (1 << varying_flags_length); bits++) { @@ -1470,7 +1443,8 @@ void TestParserSync(const char* source, const ParserFlag* varying_flags, ++flag_index) { flags.Remove(always_false_flags[flag_index]); } - TestParserSyncWithFlags(str, flags, result, is_module, test_preparser); + TestParserSyncWithFlags(str, flags, result, is_module, test_preparser, + ignore_error_msg); } } @@ -1610,16 +1584,13 @@ TEST(StrictOctal) { *exception)); } - -void RunParserSyncTest(const char* context_data[][2], - const char* statement_data[], - ParserSyncTestResult result, - const ParserFlag* flags = NULL, int flags_len = 0, - const ParserFlag* always_true_flags = NULL, - int always_true_len = 0, - const ParserFlag* always_false_flags = NULL, - int always_false_len = 0, bool is_module = false, - bool test_preparser = true) { +void RunParserSyncTest( + const char* context_data[][2], const char* statement_data[], + ParserSyncTestResult result, const ParserFlag* flags = NULL, + int flags_len = 0, const ParserFlag* always_true_flags = NULL, + int always_true_len = 0, const ParserFlag* always_false_flags = NULL, + int always_false_len = 0, bool is_module = false, + bool test_preparser = true, bool ignore_error_msg = false) { v8::HandleScope handles(CcTest::isolate()); v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); v8::Context::Scope context_scope(context); @@ -1674,25 +1645,23 @@ void RunParserSyncTest(const char* context_data[][2], CHECK(length == kProgramSize); TestParserSync(program.start(), flags, flags_len, result, always_true_flags, always_true_len, always_false_flags, - always_false_len, is_module, test_preparser); + always_false_len, is_module, test_preparser, + ignore_error_msg); } } delete[] generated_flags; } - -void RunModuleParserSyncTest(const char* context_data[][2], - const char* statement_data[], - ParserSyncTestResult result, - const ParserFlag* flags = NULL, int flags_len = 0, - const ParserFlag* always_true_flags = NULL, - int always_true_len = 0, - const ParserFlag* always_false_flags = NULL, - int always_false_len = 0, - bool test_preparser = true) { +void RunModuleParserSyncTest( + const char* context_data[][2], const char* statement_data[], + ParserSyncTestResult result, const ParserFlag* flags = NULL, + int flags_len = 0, const ParserFlag* always_true_flags = NULL, + int always_true_len = 0, const ParserFlag* always_false_flags = NULL, + int always_false_len = 0, bool test_preparser = true, + bool ignore_error_msg = false) { RunParserSyncTest(context_data, statement_data, result, flags, flags_len, always_true_flags, always_true_len, always_false_flags, - always_false_len, true, test_preparser); + always_false_len, true, test_preparser, ignore_error_msg); } @@ -2485,8 +2454,7 @@ TEST(DontRegressPreParserDataSizes) { i::Handle<i::String> source = factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); i::Handle<i::Script> script = factory->NewScript(source); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); i::ScriptData* sd = NULL; info.set_cached_data(&sd); info.set_compile_options(v8::ScriptCompiler::kProduceParserCache); @@ -3373,7 +3341,6 @@ TEST(InnerAssignment) { i::SNPrintF(program, "%s%s%s%s%s", prefix, outer, midfix, inner, suffix); - i::Zone zone(isolate->allocator(), ZONE_NAME); std::unique_ptr<i::ParseInfo> info; if (lazy) { printf("%s\n", program.start()); @@ -3381,7 +3348,7 @@ TEST(InnerAssignment) { i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared()); - info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, shared)); + info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(shared)); CHECK(i::parsing::ParseFunction(info.get())); } else { i::Handle<i::String> source = @@ -3389,7 +3356,7 @@ TEST(InnerAssignment) { source->PrintOn(stdout); printf("\n"); i::Handle<i::Script> script = factory->NewScript(source); - info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, script)); + info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(script)); info->set_allow_lazy_parsing(false); CHECK(i::parsing::ParseProgram(info.get())); } @@ -3488,14 +3455,13 @@ TEST(MaybeAssignedParameters) { i::ScopedVector<char> program(Utf8LengthHelper(source) + Utf8LengthHelper(suffix) + 1); i::SNPrintF(program, "%s%s", source, suffix); - i::Zone zone(isolate->allocator(), ZONE_NAME); std::unique_ptr<i::ParseInfo> info; printf("%s\n", program.start()); v8::Local<v8::Value> v = CompileRun(program.start()); i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared()); - info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, shared)); + info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(shared)); info->set_allow_lazy_parsing(allow_lazy); CHECK(i::parsing::ParseFunction(info.get())); CHECK(i::Compiler::Analyze(info.get())); @@ -3515,64 +3481,433 @@ TEST(MaybeAssignedParameters) { } } +struct Input { + bool assigned; + std::string source; + std::vector<unsigned> location; // "Directions" to the relevant scope. +}; + +static void TestMaybeAssigned(Input input, const char* variable, bool module, + bool allow_lazy_parsing) { + i::Factory* factory = CcTest::i_isolate()->factory(); + i::Handle<i::String> string = + factory->InternalizeUtf8String(input.source.c_str()); + string->PrintOn(stdout); + printf("\n"); + i::Handle<i::Script> script = factory->NewScript(string); + + std::unique_ptr<i::ParseInfo> info; + info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(script)); + info->set_module(module); + info->set_allow_lazy_parsing(allow_lazy_parsing); + + CHECK(i::parsing::ParseProgram(info.get())); + CHECK(i::Compiler::Analyze(info.get())); + + CHECK_NOT_NULL(info->literal()); + i::Scope* scope = info->literal()->scope(); + CHECK(!scope->AsDeclarationScope()->was_lazily_parsed()); + CHECK_NULL(scope->sibling()); + CHECK(module ? scope->is_module_scope() : scope->is_script_scope()); + + i::Variable* var; + { + // Find the variable. + for (auto it = input.location.begin(); it != input.location.end(); ++it) { + unsigned n = *it; + scope = scope->inner_scope(); + while (n-- > 0) { + scope = scope->sibling(); + } + } + CHECK_NOT_NULL(scope); + const i::AstRawString* var_name = + info->ast_value_factory()->GetOneByteString(variable); + var = scope->Lookup(var_name); + } + + CHECK(var->is_used()); + STATIC_ASSERT(true == i::kMaybeAssigned); + CHECK_EQ(input.assigned, var->maybe_assigned() == i::kMaybeAssigned); +} + +static Input wrap(Input input) { + Input result; + result.assigned = input.assigned; + result.source = "function WRAPPED() { " + input.source + " }"; + result.location.push_back(0); + for (auto n : input.location) { + result.location.push_back(n); + } + return result; +} + +TEST(MaybeAssignedInsideLoop) { + i::Isolate* isolate = CcTest::i_isolate(); + i::HandleScope scope(isolate); + LocalContext env; + + std::vector<unsigned> top; // Can't use {} in initializers below. + + Input module_and_script_tests[] = { + {1, "for (j=x; j<10; ++j) { foo = j }", top}, + {1, "for (j=x; j<10; ++j) { [foo] = [j] }", top}, + {1, "for (j=x; j<10; ++j) { var foo = j }", top}, + {1, "for (j=x; j<10; ++j) { var [foo] = [j] }", top}, + {0, "for (j=x; j<10; ++j) { let foo = j }", {0}}, + {0, "for (j=x; j<10; ++j) { let [foo] = [j] }", {0}}, + {0, "for (j=x; j<10; ++j) { const foo = j }", {0}}, + {0, "for (j=x; j<10; ++j) { const [foo] = [j] }", {0}}, + {0, "for (j=x; j<10; ++j) { function foo() {return j} }", {0}}, + + {1, "for ({j}=x; j<10; ++j) { foo = j }", top}, + {1, "for ({j}=x; j<10; ++j) { [foo] = [j] }", top}, + {1, "for ({j}=x; j<10; ++j) { var foo = j }", top}, + {1, "for ({j}=x; j<10; ++j) { var [foo] = [j] }", top}, + {0, "for ({j}=x; j<10; ++j) { let foo = j }", {0}}, + {0, "for ({j}=x; j<10; ++j) { let [foo] = [j] }", {0}}, + {0, "for ({j}=x; j<10; ++j) { const foo = j }", {0}}, + {0, "for ({j}=x; j<10; ++j) { const [foo] = [j] }", {0}}, + {0, "for ({j}=x; j<10; ++j) { function foo() {return j} }", {0}}, + + {1, "for (var j=x; j<10; ++j) { foo = j }", top}, + {1, "for (var j=x; j<10; ++j) { [foo] = [j] }", top}, + {1, "for (var j=x; j<10; ++j) { var foo = j }", top}, + {1, "for (var j=x; j<10; ++j) { var [foo] = [j] }", top}, + {0, "for (var j=x; j<10; ++j) { let foo = j }", {0}}, + {0, "for (var j=x; j<10; ++j) { let [foo] = [j] }", {0}}, + {0, "for (var j=x; j<10; ++j) { const foo = j }", {0}}, + {0, "for (var j=x; j<10; ++j) { const [foo] = [j] }", {0}}, + {0, "for (var j=x; j<10; ++j) { function foo() {return j} }", {0}}, + + {1, "for (var {j}=x; j<10; ++j) { foo = j }", top}, + {1, "for (var {j}=x; j<10; ++j) { [foo] = [j] }", top}, + {1, "for (var {j}=x; j<10; ++j) { var foo = j }", top}, + {1, "for (var {j}=x; j<10; ++j) { var [foo] = [j] }", top}, + {0, "for (var {j}=x; j<10; ++j) { let foo = j }", {0}}, + {0, "for (var {j}=x; j<10; ++j) { let [foo] = [j] }", {0}}, + {0, "for (var {j}=x; j<10; ++j) { const foo = j }", {0}}, + {0, "for (var {j}=x; j<10; ++j) { const [foo] = [j] }", {0}}, + {0, "for (var {j}=x; j<10; ++j) { function foo() {return j} }", {0}}, + + {1, "for (let j=x; j<10; ++j) { foo = j }", top}, + {1, "for (let j=x; j<10; ++j) { [foo] = [j] }", top}, + {1, "for (let j=x; j<10; ++j) { var foo = j }", top}, + {1, "for (let j=x; j<10; ++j) { var [foo] = [j] }", top}, + {0, "for (let j=x; j<10; ++j) { let foo = j }", {0, 0, 0}}, + {0, "for (let j=x; j<10; ++j) { let [foo] = [j] }", {0, 0, 0}}, + {0, "for (let j=x; j<10; ++j) { const foo = j }", {0, 0, 0}}, + {0, "for (let j=x; j<10; ++j) { const [foo] = [j] }", {0, 0, 0}}, + {0, "for (let j=x; j<10; ++j) { function foo() {return j} }", {0, 0, 0}}, + + {1, "for (let {j}=x; j<10; ++j) { foo = j }", top}, + {1, "for (let {j}=x; j<10; ++j) { [foo] = [j] }", top}, + {1, "for (let {j}=x; j<10; ++j) { var foo = j }", top}, + {1, "for (let {j}=x; j<10; ++j) { var [foo] = [j] }", top}, + {0, "for (let {j}=x; j<10; ++j) { let foo = j }", {0, 0, 0}}, + {0, "for (let {j}=x; j<10; ++j) { let [foo] = [j] }", {0, 0, 0}}, + {0, "for (let {j}=x; j<10; ++j) { const foo = j }", {0, 0, 0}}, + {0, "for (let {j}=x; j<10; ++j) { const [foo] = [j] }", {0, 0, 0}}, + {0, "for (let {j}=x; j<10; ++j) { function foo(){return j} }", {0, 0, 0}}, + + {1, "for (j of x) { foo = j }", top}, + {1, "for (j of x) { [foo] = [j] }", top}, + {1, "for (j of x) { var foo = j }", top}, + {1, "for (j of x) { var [foo] = [j] }", top}, + {0, "for (j of x) { let foo = j }", {0}}, + {0, "for (j of x) { let [foo] = [j] }", {0}}, + {0, "for (j of x) { const foo = j }", {0}}, + {0, "for (j of x) { const [foo] = [j] }", {0}}, + {0, "for (j of x) { function foo() {return j} }", {0}}, + + {1, "for ({j} of x) { foo = j }", top}, + {1, "for ({j} of x) { [foo] = [j] }", top}, + {1, "for ({j} of x) { var foo = j }", top}, + {1, "for ({j} of x) { var [foo] = [j] }", top}, + {0, "for ({j} of x) { let foo = j }", {0}}, + {0, "for ({j} of x) { let [foo] = [j] }", {0}}, + {0, "for ({j} of x) { const foo = j }", {0}}, + {0, "for ({j} of x) { const [foo] = [j] }", {0}}, + {0, "for ({j} of x) { function foo() {return j} }", {0}}, + + {1, "for (var j of x) { foo = j }", top}, + {1, "for (var j of x) { [foo] = [j] }", top}, + {1, "for (var j of x) { var foo = j }", top}, + {1, "for (var j of x) { var [foo] = [j] }", top}, + {0, "for (var j of x) { let foo = j }", {0}}, + {0, "for (var j of x) { let [foo] = [j] }", {0}}, + {0, "for (var j of x) { const foo = j }", {0}}, + {0, "for (var j of x) { const [foo] = [j] }", {0}}, + {0, "for (var j of x) { function foo() {return j} }", {0}}, + + {1, "for (var {j} of x) { foo = j }", top}, + {1, "for (var {j} of x) { [foo] = [j] }", top}, + {1, "for (var {j} of x) { var foo = j }", top}, + {1, "for (var {j} of x) { var [foo] = [j] }", top}, + {0, "for (var {j} of x) { let foo = j }", {0}}, + {0, "for (var {j} of x) { let [foo] = [j] }", {0}}, + {0, "for (var {j} of x) { const foo = j }", {0}}, + {0, "for (var {j} of x) { const [foo] = [j] }", {0}}, + {0, "for (var {j} of x) { function foo() {return j} }", {0}}, + + {1, "for (let j of x) { foo = j }", top}, + {1, "for (let j of x) { [foo] = [j] }", top}, + {1, "for (let j of x) { var foo = j }", top}, + {1, "for (let j of x) { var [foo] = [j] }", top}, + {0, "for (let j of x) { let foo = j }", {0, 2, 0}}, + {0, "for (let j of x) { let [foo] = [j] }", {0, 2, 0}}, + {0, "for (let j of x) { const foo = j }", {0, 2, 0}}, + {0, "for (let j of x) { const [foo] = [j] }", {0, 2, 0}}, + {0, "for (let j of x) { function foo() {return j} }", {0, 2, 0}}, + + {1, "for (let {j} of x) { foo = j }", top}, + {1, "for (let {j} of x) { [foo] = [j] }", top}, + {1, "for (let {j} of x) { var foo = j }", top}, + {1, "for (let {j} of x) { var [foo] = [j] }", top}, + {0, "for (let {j} of x) { let foo = j }", {0, 2, 0}}, + {0, "for (let {j} of x) { let [foo] = [j] }", {0, 2, 0}}, + {0, "for (let {j} of x) { const foo = j }", {0, 2, 0}}, + {0, "for (let {j} of x) { const [foo] = [j] }", {0, 2, 0}}, + {0, "for (let {j} of x) { function foo() {return j} }", {0, 2, 0}}, + + {1, "for (const j of x) { foo = j }", top}, + {1, "for (const j of x) { [foo] = [j] }", top}, + {1, "for (const j of x) { var foo = j }", top}, + {1, "for (const j of x) { var [foo] = [j] }", top}, + {0, "for (const j of x) { let foo = j }", {0, 2, 0}}, + {0, "for (const j of x) { let [foo] = [j] }", {0, 2, 0}}, + {0, "for (const j of x) { const foo = j }", {0, 2, 0}}, + {0, "for (const j of x) { const [foo] = [j] }", {0, 2, 0}}, + {0, "for (const j of x) { function foo() {return j} }", {0, 2, 0}}, + + {1, "for (const {j} of x) { foo = j }", top}, + {1, "for (const {j} of x) { [foo] = [j] }", top}, + {1, "for (const {j} of x) { var foo = j }", top}, + {1, "for (const {j} of x) { var [foo] = [j] }", top}, + {0, "for (const {j} of x) { let foo = j }", {0, 2, 0}}, + {0, "for (const {j} of x) { let [foo] = [j] }", {0, 2, 0}}, + {0, "for (const {j} of x) { const foo = j }", {0, 2, 0}}, + {0, "for (const {j} of x) { const [foo] = [j] }", {0, 2, 0}}, + {0, "for (const {j} of x) { function foo() {return j} }", {0, 2, 0}}, + + {1, "for (j in x) { foo = j }", top}, + {1, "for (j in x) { [foo] = [j] }", top}, + {1, "for (j in x) { var foo = j }", top}, + {1, "for (j in x) { var [foo] = [j] }", top}, + {0, "for (j in x) { let foo = j }", {0}}, + {0, "for (j in x) { let [foo] = [j] }", {0}}, + {0, "for (j in x) { const foo = j }", {0}}, + {0, "for (j in x) { const [foo] = [j] }", {0}}, + {0, "for (j in x) { function foo() {return j} }", {0}}, + + {1, "for ({j} in x) { foo = j }", top}, + {1, "for ({j} in x) { [foo] = [j] }", top}, + {1, "for ({j} in x) { var foo = j }", top}, + {1, "for ({j} in x) { var [foo] = [j] }", top}, + {0, "for ({j} in x) { let foo = j }", {0}}, + {0, "for ({j} in x) { let [foo] = [j] }", {0}}, + {0, "for ({j} in x) { const foo = j }", {0}}, + {0, "for ({j} in x) { const [foo] = [j] }", {0}}, + {0, "for ({j} in x) { function foo() {return j} }", {0}}, + + {1, "for (var j in x) { foo = j }", top}, + {1, "for (var j in x) { [foo] = [j] }", top}, + {1, "for (var j in x) { var foo = j }", top}, + {1, "for (var j in x) { var [foo] = [j] }", top}, + {0, "for (var j in x) { let foo = j }", {0}}, + {0, "for (var j in x) { let [foo] = [j] }", {0}}, + {0, "for (var j in x) { const foo = j }", {0}}, + {0, "for (var j in x) { const [foo] = [j] }", {0}}, + {0, "for (var j in x) { function foo() {return j} }", {0}}, + + {1, "for (var {j} in x) { foo = j }", top}, + {1, "for (var {j} in x) { [foo] = [j] }", top}, + {1, "for (var {j} in x) { var foo = j }", top}, + {1, "for (var {j} in x) { var [foo] = [j] }", top}, + {0, "for (var {j} in x) { let foo = j }", {0}}, + {0, "for (var {j} in x) { let [foo] = [j] }", {0}}, + {0, "for (var {j} in x) { const foo = j }", {0}}, + {0, "for (var {j} in x) { const [foo] = [j] }", {0}}, + {0, "for (var {j} in x) { function foo() {return j} }", {0}}, + + {1, "for (let j in x) { foo = j }", top}, + {1, "for (let j in x) { [foo] = [j] }", top}, + {1, "for (let j in x) { var foo = j }", top}, + {1, "for (let j in x) { var [foo] = [j] }", top}, + {0, "for (let j in x) { let foo = j }", {0, 0, 0}}, + {0, "for (let j in x) { let [foo] = [j] }", {0, 0, 0}}, + {0, "for (let j in x) { const foo = j }", {0, 0, 0}}, + {0, "for (let j in x) { const [foo] = [j] }", {0, 0, 0}}, + {0, "for (let j in x) { function foo() {return j} }", {0, 0, 0}}, + + {1, "for (let {j} in x) { foo = j }", top}, + {1, "for (let {j} in x) { [foo] = [j] }", top}, + {1, "for (let {j} in x) { var foo = j }", top}, + {1, "for (let {j} in x) { var [foo] = [j] }", top}, + {0, "for (let {j} in x) { let foo = j }", {0, 0, 0}}, + {0, "for (let {j} in x) { let [foo] = [j] }", {0, 0, 0}}, + {0, "for (let {j} in x) { const foo = j }", {0, 0, 0}}, + {0, "for (let {j} in x) { const [foo] = [j] }", {0, 0, 0}}, + {0, "for (let {j} in x) { function foo() {return j} }", {0, 0, 0}}, + + {1, "for (const j in x) { foo = j }", top}, + {1, "for (const j in x) { [foo] = [j] }", top}, + {1, "for (const j in x) { var foo = j }", top}, + {1, "for (const j in x) { var [foo] = [j] }", top}, + {0, "for (const j in x) { let foo = j }", {0, 0, 0}}, + {0, "for (const j in x) { let [foo] = [j] }", {0, 0, 0}}, + {0, "for (const j in x) { const foo = j }", {0, 0, 0}}, + {0, "for (const j in x) { const [foo] = [j] }", {0, 0, 0}}, + {0, "for (const j in x) { function foo() {return j} }", {0, 0, 0}}, + + {1, "for (const {j} in x) { foo = j }", top}, + {1, "for (const {j} in x) { [foo] = [j] }", top}, + {1, "for (const {j} in x) { var foo = j }", top}, + {1, "for (const {j} in x) { var [foo] = [j] }", top}, + {0, "for (const {j} in x) { let foo = j }", {0, 0, 0}}, + {0, "for (const {j} in x) { let [foo] = [j] }", {0, 0, 0}}, + {0, "for (const {j} in x) { const foo = j }", {0, 0, 0}}, + {0, "for (const {j} in x) { const [foo] = [j] }", {0, 0, 0}}, + {0, "for (const {j} in x) { function foo() {return j} }", {0, 0, 0}}, + + {1, "while (j) { foo = j }", top}, + {1, "while (j) { [foo] = [j] }", top}, + {1, "while (j) { var foo = j }", top}, + {1, "while (j) { var [foo] = [j] }", top}, + {0, "while (j) { let foo = j }", {0}}, + {0, "while (j) { let [foo] = [j] }", {0}}, + {0, "while (j) { const foo = j }", {0}}, + {0, "while (j) { const [foo] = [j] }", {0}}, + {0, "while (j) { function foo() {return j} }", {0}}, + + {1, "do { foo = j } while (j)", top}, + {1, "do { [foo] = [j] } while (j)", top}, + {1, "do { var foo = j } while (j)", top}, + {1, "do { var [foo] = [j] } while (j)", top}, + {0, "do { let foo = j } while (j)", {0}}, + {0, "do { let [foo] = [j] } while (j)", {0}}, + {0, "do { const foo = j } while (j)", {0}}, + {0, "do { const [foo] = [j] } while (j)", {0}}, + {0, "do { function foo() {return j} } while (j)", {0}}, + }; + + Input script_only_tests[] = { + {1, "for (j=x; j<10; ++j) { function foo() {return j} }", top}, + {1, "for ({j}=x; j<10; ++j) { function foo() {return j} }", top}, + {1, "for (var j=x; j<10; ++j) { function foo() {return j} }", top}, + {1, "for (var {j}=x; j<10; ++j) { function foo() {return j} }", top}, + {1, "for (let j=x; j<10; ++j) { function foo() {return j} }", top}, + {1, "for (let {j}=x; j<10; ++j) { function foo() {return j} }", top}, + {1, "for (j of x) { function foo() {return j} }", top}, + {1, "for ({j} of x) { function foo() {return j} }", top}, + {1, "for (var j of x) { function foo() {return j} }", top}, + {1, "for (var {j} of x) { function foo() {return j} }", top}, + {1, "for (let j of x) { function foo() {return j} }", top}, + {1, "for (let {j} of x) { function foo() {return j} }", top}, + {1, "for (const j of x) { function foo() {return j} }", top}, + {1, "for (const {j} of x) { function foo() {return j} }", top}, + {1, "for (j in x) { function foo() {return j} }", top}, + {1, "for ({j} in x) { function foo() {return j} }", top}, + {1, "for (var j in x) { function foo() {return j} }", top}, + {1, "for (var {j} in x) { function foo() {return j} }", top}, + {1, "for (let j in x) { function foo() {return j} }", top}, + {1, "for (let {j} in x) { function foo() {return j} }", top}, + {1, "for (const j in x) { function foo() {return j} }", top}, + {1, "for (const {j} in x) { function foo() {return j} }", top}, + {1, "while (j) { function foo() {return j} }", top}, + {1, "do { function foo() {return j} } while (j)", top}, + }; + + for (unsigned i = 0; i < arraysize(module_and_script_tests); ++i) { + Input input = module_and_script_tests[i]; + for (unsigned module = 0; module <= 1; ++module) { + for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1; + ++allow_lazy_parsing) { + TestMaybeAssigned(input, "foo", module, allow_lazy_parsing); + } + TestMaybeAssigned(wrap(input), "foo", module, false); + } + } + + for (unsigned i = 0; i < arraysize(script_only_tests); ++i) { + Input input = script_only_tests[i]; + for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1; + ++allow_lazy_parsing) { + TestMaybeAssigned(input, "foo", false, allow_lazy_parsing); + } + TestMaybeAssigned(wrap(input), "foo", false, false); + } +} + TEST(MaybeAssignedTopLevel) { i::Isolate* isolate = CcTest::i_isolate(); i::HandleScope scope(isolate); LocalContext env; - i::Factory* factory = isolate->factory(); const char* prefixes[] = { - "let foo; ", "let foo = 0; ", - "let [foo] = [1]; ", "let {foo} = {foo: 2}; ", + "let foo; ", + "let foo = 0; ", + "let [foo] = [1]; ", + "let {foo} = {foo: 2}; ", "let {foo=3} = {}; ", - }; - const char* sources[] = { + "var foo; ", + "var foo = 0; ", + "var [foo] = [1]; ", + "var {foo} = {foo: 2}; ", + "var {foo=3} = {}; ", + "{ var foo; }; ", + "{ var foo = 0; }; ", + "{ var [foo] = [1]; }; ", + "{ var {foo} = {foo: 2}; }; ", + "{ var {foo=3} = {}; }; ", + "function foo() {}; ", + "function* foo() {}; ", + "async function foo() {}; ", + "class foo {}; ", + "class foo extends null {}; ", + }; + + const char* module_and_script_tests[] = { "function bar() {foo = 42}; ext(bar); ext(foo)", "ext(function() {foo++}); ext(foo)", "bar = () => --foo; ext(bar); ext(foo)", "function* bar() {eval(ext)}; ext(bar); ext(foo)", }; - for (unsigned i = 0; i < arraysize(prefixes); ++i) { - const char* prefix = prefixes[i]; - for (unsigned j = 0; j < arraysize(sources); ++j) { - const char* source = sources[j]; - i::ScopedVector<char> program(Utf8LengthHelper(prefix) + - Utf8LengthHelper(source) + 1); - i::SNPrintF(program, "%s%s", prefix, source); - i::Zone zone(isolate->allocator(), ZONE_NAME); - - i::Handle<i::String> string = - factory->InternalizeUtf8String(program.start()); - string->PrintOn(stdout); - printf("\n"); - i::Handle<i::Script> script = factory->NewScript(string); - - for (unsigned allow_lazy = 0; allow_lazy < 2; ++allow_lazy) { - for (unsigned module = 0; module < 2; ++module) { - std::unique_ptr<i::ParseInfo> info; - info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, script)); - info->set_module(module); - info->set_allow_lazy_parsing(allow_lazy); + const char* script_only_tests[] = { + "", + "{ function foo() {}; }; ", + "{ function* foo() {}; }; ", + "{ async function foo() {}; }; ", + }; - CHECK(i::parsing::ParseProgram(info.get())); - CHECK(i::Compiler::Analyze(info.get())); - - CHECK_NOT_NULL(info->literal()); - i::Scope* scope = info->literal()->scope(); - CHECK(!scope->AsDeclarationScope()->was_lazily_parsed()); - CHECK_NULL(scope->sibling()); - CHECK(module ? scope->is_module_scope() : scope->is_script_scope()); - - const i::AstRawString* var_name = - info->ast_value_factory()->GetOneByteString("foo"); - i::Variable* var = scope->Lookup(var_name); - CHECK(var->is_used()); - CHECK(var->maybe_assigned() == i::kMaybeAssigned); + for (unsigned i = 0; i < arraysize(prefixes); ++i) { + for (unsigned j = 0; j < arraysize(module_and_script_tests); ++j) { + std::string source(prefixes[i]); + source += module_and_script_tests[j]; + std::vector<unsigned> top; + Input input({true, source, top}); + for (unsigned module = 0; module <= 1; ++module) { + for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1; + ++allow_lazy_parsing) { + TestMaybeAssigned(input, "foo", module, allow_lazy_parsing); } } } } + + for (unsigned i = 0; i < arraysize(prefixes); ++i) { + for (unsigned j = 0; j < arraysize(script_only_tests); ++j) { + std::string source(prefixes[i]); + source += script_only_tests[j]; + std::vector<unsigned> top; + Input input({true, source, top}); + for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1; + ++allow_lazy_parsing) { + TestMaybeAssigned(input, "foo", false, allow_lazy_parsing); + } + } + } } namespace { @@ -4141,6 +4476,140 @@ TEST(SuperErrors) { RunParserSyncTest(context_data, expression_data, kError); } +TEST(ImportExpressionSuccess) { + // clang-format off + const char* context_data[][2] = { + {"", ""}, + {NULL, NULL} + }; + + const char* data[] = { + "import(1)", + "import(y=x)", + "f(...[import(y=x)])", + "x = {[import(y=x)]: 1}", + "var {[import(y=x)]: x} = {}", + "({[import(y=x)]: x} = {})", + "async () => { await import(x) }", + "() => { import(x) }", + "(import(y=x))", + "{import(y=x)}", + "import(import(x))", + "x = import(x)", + "var x = import(x)", + "let x = import(x)", + "for(x of import(x)) {}", + "import(x).then()", + NULL + }; + + // clang-format on + + // We ignore test error messages because the error message from the + // parser/preparser is different for the same data depending on the + // context. + // For example, a top level "import(" is parsed as an + // import declaration. The parser parses the import token correctly + // and then shows an "Unexpected token (" error message. The + // preparser does not understand the import keyword (this test is + // run without kAllowHarmonyDynamicImport flag), so this results in + // an "Unexpected token import" error. + RunParserSyncTest(context_data, data, kError); + RunModuleParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0, NULL, 0, + true, true); + static const ParserFlag flags[] = {kAllowHarmonyDynamicImport}; + RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, + arraysize(flags)); + RunModuleParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, + arraysize(flags)); +} + +TEST(ImportExpressionErrors) { + { + // clang-format off + const char* context_data[][2] = { + {"", ""}, + {"var ", ""}, + {"let ", ""}, + {"new ", ""}, + {NULL, NULL} + }; + + const char* data[] = { + "import(", + "import)", + "import()", + "import('x", + "import('x']", + "import['x')", + "import = x", + "import[", + "import[]", + "import]", + "import[x]", + "import{", + "import{x", + "import{x}", + "import(x, y)", + "import(...y)", + "import(x,)", + "import(,)", + "import(,y)", + "import(;)", + "[import]", + "{import}", + "import+", + "import = 1", + "import.wat", + "new import(x)", + NULL + }; + + // clang-format on + RunParserSyncTest(context_data, data, kError); + // We ignore the error messages for the reason explained in the + // ImportExpressionSuccess test. + RunModuleParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0, NULL, + 0, true, true); + static const ParserFlag flags[] = {kAllowHarmonyDynamicImport}; + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags)); + + // We ignore test error messages because the error message from + // the parser/preparser is different for the same data depending + // on the context. For example, a top level "import{" is parsed + // as an import declaration. The parser parses the import token + // correctly and then shows an "Unexpected end of input" error + // message because of the '{'. The preparser shows an "Unexpected + // token {" because it's not a valid token in a CallExpression. + RunModuleParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags), NULL, 0, true, true); + } + + { + // clang-format off + const char* context_data[][2] = { + {"var ", ""}, + {"let ", ""}, + {NULL, NULL} + }; + + const char* data[] = { + "import('x')", + NULL + }; + + // clang-format on + RunParserSyncTest(context_data, data, kError); + RunModuleParserSyncTest(context_data, data, kError); + + static const ParserFlag flags[] = {kAllowHarmonyDynamicImport}; + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags)); + RunModuleParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags)); + } +} TEST(SuperCall) { const char* context_data[][2] = {{"", ""}, @@ -5870,8 +6339,7 @@ TEST(BasicImportExportParsing) { // Show that parsing as a module works { i::Handle<i::Script> script = factory->NewScript(source); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); info.set_module(); if (!i::parsing::ParseProgram(&info)) { i::Handle<i::JSObject> exception_handle( @@ -5895,8 +6363,7 @@ TEST(BasicImportExportParsing) { // And that parsing a script does not. { i::Handle<i::Script> script = factory->NewScript(source); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); CHECK(!i::parsing::ParseProgram(&info)); isolate->clear_pending_exception(); } @@ -5986,8 +6453,7 @@ TEST(ImportExportParsingErrors) { factory->NewStringFromAsciiChecked(kErrorSources[i]); i::Handle<i::Script> script = factory->NewScript(source); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); info.set_module(); CHECK(!i::parsing::ParseProgram(&info)); isolate->clear_pending_exception(); @@ -6023,8 +6489,7 @@ TEST(ModuleTopLevelFunctionDecl) { factory->NewStringFromAsciiChecked(kErrorSources[i]); i::Handle<i::Script> script = factory->NewScript(source); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); info.set_module(); CHECK(!i::parsing::ParseProgram(&info)); isolate->clear_pending_exception(); @@ -6221,8 +6686,7 @@ TEST(ModuleParsingInternals) { "export {foob};"; i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); i::Handle<i::Script> script = factory->NewScript(source); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); info.set_module(); CHECK(i::parsing::ParseProgram(&info)); CHECK(i::Compiler::Analyze(&info)); @@ -6329,15 +6793,15 @@ TEST(ModuleParsingInternals) { CHECK_EQ(5u, descriptor->module_requests().size()); for (const auto& elem : descriptor->module_requests()) { if (elem.first->IsOneByteEqualTo("m.js")) - CHECK_EQ(elem.second, 0); + CHECK_EQ(0, elem.second); else if (elem.first->IsOneByteEqualTo("n.js")) - CHECK_EQ(elem.second, 1); + CHECK_EQ(1, elem.second); else if (elem.first->IsOneByteEqualTo("p.js")) - CHECK_EQ(elem.second, 2); + CHECK_EQ(2, elem.second); else if (elem.first->IsOneByteEqualTo("q.js")) - CHECK_EQ(elem.second, 3); + CHECK_EQ(3, elem.second); else if (elem.first->IsOneByteEqualTo("bar.js")) - CHECK_EQ(elem.second, 4); + CHECK_EQ(4, elem.second); else CHECK(false); } @@ -6481,8 +6945,7 @@ void TestLanguageMode(const char* source, i::Handle<i::Script> script = factory->NewScript(factory->NewStringFromAsciiChecked(source)); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); i::parsing::ParseProgram(&info); CHECK(info.literal() != NULL); CHECK_EQ(expected_language_mode, info.literal()->language_mode()); @@ -6609,66 +7072,183 @@ TEST(ObjectSpreadPositiveTests) { "{ ...async () => { }}", "{ ...new Foo()}", NULL}; + // clang-format on - static const ParserFlag flags[] = {kAllowHarmonyObjectSpread}; + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, arraysize(flags)); } TEST(ObjectSpreadNegativeTests) { - { - const char* context_data[][2] = {{"x = ", ""}, - {"'use strict'; x = ", ""}, - {NULL, NULL}}; + const char* context_data[][2] = {{"x = ", ""}, + {"'use strict'; x = ", ""}, + {NULL, NULL}}; - // clang-format off - const char* data[] = { - "{ ...var z = y}", - "{ ...var}", - "{ ...foo bar}", - NULL}; + // clang-format off + const char* data[] = { + "{ ...var z = y}", + "{ ...var}", + "{ ...foo bar}", + NULL}; - static const ParserFlag flags[] = {kAllowHarmonyObjectSpread}; - RunParserSyncTest(context_data, data, kError, NULL, 0, flags, - arraysize(flags)); - } + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags)); +} - // Destructuring tests - { - const char* context_data[][2] = { - {"var ", " = {};"}, - {"( ", " = {});"}, - {"'use strict'; const ", " = {};"}, - {"function f(", ") {}"}, - {"function f(argument1, ", ") {}"}, - {"var f = (", ") => {};"}, - {"var f = (argument1,", ") => {};"}, - {"try {} catch(", ") {}"}, - {NULL, NULL}}; +TEST(TemplateEscapesPositiveTests) { + // clang-format off + const char* context_data[][2] = { + {"", ""}, + {"'use strict';", ""}, + {NULL, NULL}}; - // clang-format off - const char* data[] = { - "{ ...y }", - "{ a: 1, ...y }", - "{ b: 1, ...y }", - "{ y, ...y}", - "{ ...z = y}", - "{ ...y, y }", - "{ ...y, ...y}", - "{ a: 1, ...y, b: 1}", - "{ ...y, b: 1}", - "{ ...1}", - "{ ...null}", - "{ ...undefined}", - "{ ...unknown}", - "{ ...var z = y}", - "({ ...z = {})", - NULL}; + // clang-format off + const char* data[] = { + "tag`\\01`", + "tag`\\01${0}right`", + "tag`left${0}\\01`", + "tag`left${0}\\01${1}right`", + "tag`\\1`", + "tag`\\1${0}right`", + "tag`left${0}\\1`", + "tag`left${0}\\1${1}right`", + "tag`\\xg`", + "tag`\\xg${0}right`", + "tag`left${0}\\xg`", + "tag`left${0}\\xg${1}right`", + "tag`\\xAg`", + "tag`\\xAg${0}right`", + "tag`left${0}\\xAg`", + "tag`left${0}\\xAg${1}right`", + "tag`\\u0`", + "tag`\\u0${0}right`", + "tag`left${0}\\u0`", + "tag`left${0}\\u0${1}right`", + "tag`\\u0g`", + "tag`\\u0g${0}right`", + "tag`left${0}\\u0g`", + "tag`left${0}\\u0g${1}right`", + "tag`\\u00g`", + "tag`\\u00g${0}right`", + "tag`left${0}\\u00g`", + "tag`left${0}\\u00g${1}right`", + "tag`\\u000g`", + "tag`\\u000g${0}right`", + "tag`left${0}\\u000g`", + "tag`left${0}\\u000g${1}right`", + "tag`\\u{}`", + "tag`\\u{}${0}right`", + "tag`left${0}\\u{}`", + "tag`left${0}\\u{}${1}right`", + "tag`\\u{-0}`", + "tag`\\u{-0}${0}right`", + "tag`left${0}\\u{-0}`", + "tag`left${0}\\u{-0}${1}right`", + "tag`\\u{g}`", + "tag`\\u{g}${0}right`", + "tag`left${0}\\u{g}`", + "tag`left${0}\\u{g}${1}right`", + "tag`\\u{0`", + "tag`\\u{0${0}right`", + "tag`left${0}\\u{0`", + "tag`left${0}\\u{0${1}right`", + "tag`\\u{\\u{0}`", + "tag`\\u{\\u{0}${0}right`", + "tag`left${0}\\u{\\u{0}`", + "tag`left${0}\\u{\\u{0}${1}right`", + "tag`\\u{110000}`", + "tag`\\u{110000}${0}right`", + "tag`left${0}\\u{110000}`", + "tag`left${0}\\u{110000}${1}right`", + NULL}; + // clang-format on - static const ParserFlag flags[] = {kAllowHarmonyObjectSpread}; - RunParserSyncTest(context_data, data, kError, NULL, 0, flags, - arraysize(flags)); - } + // No error with flag + static const ParserFlag flags[] = {kAllowHarmonyTemplateEscapes}; + RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, + arraysize(flags)); + + // Still an error without flag + RunParserSyncTest(context_data, data, kError); +} + +TEST(TemplateEscapesNegativeTests) { + // clang-format off + const char* context_data[][2] = { + {"", ""}, + {"'use strict';", ""}, + {NULL, NULL}}; + + // clang-format off + const char* data[] = { + "`\\01`", + "`\\01${0}right`", + "`left${0}\\01`", + "`left${0}\\01${1}right`", + "`\\1`", + "`\\1${0}right`", + "`left${0}\\1`", + "`left${0}\\1${1}right`", + "`\\xg`", + "`\\xg${0}right`", + "`left${0}\\xg`", + "`left${0}\\xg${1}right`", + "`\\xAg`", + "`\\xAg${0}right`", + "`left${0}\\xAg`", + "`left${0}\\xAg${1}right`", + "`\\u0`", + "`\\u0${0}right`", + "`left${0}\\u0`", + "`left${0}\\u0${1}right`", + "`\\u0g`", + "`\\u0g${0}right`", + "`left${0}\\u0g`", + "`left${0}\\u0g${1}right`", + "`\\u00g`", + "`\\u00g${0}right`", + "`left${0}\\u00g`", + "`left${0}\\u00g${1}right`", + "`\\u000g`", + "`\\u000g${0}right`", + "`left${0}\\u000g`", + "`left${0}\\u000g${1}right`", + "`\\u{}`", + "`\\u{}${0}right`", + "`left${0}\\u{}`", + "`left${0}\\u{}${1}right`", + "`\\u{-0}`", + "`\\u{-0}${0}right`", + "`left${0}\\u{-0}`", + "`left${0}\\u{-0}${1}right`", + "`\\u{g}`", + "`\\u{g}${0}right`", + "`left${0}\\u{g}`", + "`left${0}\\u{g}${1}right`", + "`\\u{0`", + "`\\u{0${0}right`", + "`left${0}\\u{0`", + "`left${0}\\u{0${1}right`", + "`\\u{\\u{0}`", + "`\\u{\\u{0}${0}right`", + "`left${0}\\u{\\u{0}`", + "`left${0}\\u{\\u{0}${1}right`", + "`\\u{110000}`", + "`\\u{110000}${0}right`", + "`left${0}\\u{110000}`", + "`left${0}\\u{110000}${1}right`", + "`\\1``\\2`", + NULL}; + // clang-format on + + // Error with flag + static const ParserFlag flags[] = {kAllowHarmonyTemplateEscapes}; + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags)); + + // Still an error without flag + RunParserSyncTest(context_data, data, kError); } TEST(DestructuringPositiveTests) { @@ -6724,8 +7304,38 @@ TEST(DestructuringPositiveTests) { "{arguments: x}", "{eval: x}", NULL}; + + const char* rest_data[] = { + "{ x : y, ...z }", + "{ x : y = 1, ...z }", + "{ x : x, y : y, ...z }", + "{ x : x = 1, y : y, ...z }", + "{ x : x, y : y = 42, ...z }", + "[{x:x, y:y, ...z}, [a,b,c]]", + "[{x:x = 1, y:y = 2, ...z}, [a = 3, b = 4, c = 5]]", + "{...x}", + "{...{ x = 5} }", + "{x, ...y}", + "{x = 42, y = 15, ...z}", + "{42 : x = 42, ...y}", + "{'hi' : x, ...z}", + "{'hi' : x = 42, ...z}", + "{var: x = 42, ...z}", + "{[x] : z, ...y}", + "{[1+1] : z, ...x}", + "{arguments: x, ...z}", + "{ __proto__: x, __proto__: y, ...z}", + NULL}; + // clang-format on RunParserSyncTest(context_data, data, kSuccess); + RunParserSyncTest(context_data, rest_data, kError); + + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; + RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, + arraysize(flags)); + RunParserSyncTest(context_data, rest_data, kSuccess, NULL, 0, flags, + arraysize(flags)); // v8:5201 { @@ -6739,6 +7349,13 @@ TEST(DestructuringPositiveTests) { {"try {} catch(", ") {}"}, {NULL, NULL} }; + + const char* rest_data[] = { + "{...arguments}", + "{...eval}", + NULL + }; + const char* data[] = { "{arguments}", "{eval}", @@ -6750,6 +7367,12 @@ TEST(DestructuringPositiveTests) { }; // clang-format on RunParserSyncTest(sloppy_context_data, data, kSuccess); + RunParserSyncTest(sloppy_context_data, rest_data, kError); + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; + RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, flags, + arraysize(flags)); + RunParserSyncTest(sloppy_context_data, rest_data, kSuccess, NULL, 0, flags, + arraysize(flags)); } } @@ -6838,8 +7461,38 @@ TEST(DestructuringNegativeTests) { "{ method() {} }", "{ *method() {} }", NULL}; + + const char* rest_data[] = { + "...a++", + "...++a", + "...typeof a", + "...[a++]", + "...(x => y)", + "{ ...x, }", + "{ ...x, y }", + "{ y, ...x, y }", + "{ ...x, ...y }", + "{ ...x, ...x }", + "{ ...x, ...x = {} }", + "{ ...x, ...x = ...x }", + "{ ...x, ...x = ...{ x } }", + "{ ,, ...x }", + "{ ...get a() {} }", + "{ ...set a() {} }", + "{ ...method() {} }", + "{ ...function() {} }", + "{ ...*method() {} }", + NULL + }; + // clang-format on RunParserSyncTest(context_data, data, kError); + RunParserSyncTest(context_data, rest_data, kError); + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags)); + RunParserSyncTest(context_data, rest_data, kError, NULL, 0, flags, + arraysize(flags)); } { // All modes. @@ -6885,8 +7538,20 @@ TEST(DestructuringNegativeTests) { "{ arguments = false }" "{ eval = false }", NULL}; + + const char* rest_data[] = { + "{ ...eval }", + "{ ...arguments }", + NULL}; + // clang-format on RunParserSyncTest(context_data, data, kError); + RunParserSyncTest(context_data, rest_data, kError); + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags)); + RunParserSyncTest(context_data, rest_data, kError, NULL, 0, flags, + arraysize(flags)); } { // 'yield' in generators. @@ -6926,11 +7591,45 @@ TEST(DestructuringNegativeTests) { "{ a }", "[ a ]", NULL}; + const char* rest_data[] = { + "{ ...a }", + NULL}; // clang-format on RunParserSyncTest(context_data, data, kError); + RunParserSyncTest(context_data, rest_data, kError); + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags)); + RunParserSyncTest(context_data, rest_data, kError, NULL, 0, flags, + arraysize(flags)); } } +TEST(ObjectRestNegativeTestSlow) { + // clang-format off + const char* context_data[][2] = { + {"var { ", " } = { a: 1};"}, + { NULL, NULL } + }; + + using v8::internal::Code; + std::string statement; + for (int i = 0; i < Code::kMaxArguments; ++i) { + statement += std::to_string(i) + " : " + "x, "; + } + statement += "...y"; + + const char* statement_data[] = { + statement.c_str(), + NULL + }; + + // clang-format on + // The test is quite slow, so run it with a reduced set of flags. + static const ParserFlag flags[] = {kAllowLazy, kAllowHarmonyObjectRestSpread}; + RunParserSyncTest(context_data, statement_data, kError, NULL, 0, flags, + arraysize(flags)); +} TEST(DestructuringAssignmentPositiveTests) { const char* context_data[][2] = { @@ -8608,17 +9307,6 @@ TEST(ArgumentsRedeclaration) { } } -namespace v8 { -namespace internal { - -class ScopeTestHelper { - public: - static bool MustAllocateInContext(Variable* var) { - return var->scope()->MustAllocateInContext(var); - } -}; -} // namespace internal -} // namespace v8 // Test that lazily parsed inner functions don't result in overly pessimistic // context allocations. @@ -8646,13 +9334,26 @@ TEST(NoPessimisticContextAllocation) { // Context allocating because we need to: {"", "my_var;", true}, {"", "if (true) { let my_var; } my_var;", true}, - {"", "eval(\"foo\");", true}, + {"", "eval('foo');", true}, {"", "function inner2() { my_var; }", true}, - {"", "function inner2() { eval(\"foo\"); }", true}, + {"", "function inner2() { eval('foo'); }", true}, {"", "var {my_var : a} = {my_var};", true}, {"", "let {my_var : a} = {my_var};", true}, {"", "const {my_var : a} = {my_var};", true}, + {"", "var [a, b = my_var] = [1, 2];", true}, + {"", "var [a, b = my_var] = [1, 2]; my_var;", true}, + {"", "let [a, b = my_var] = [1, 2];", true}, + {"", "let [a, b = my_var] = [1, 2]; my_var;", true}, + {"", "const [a, b = my_var] = [1, 2];", true}, + {"", "const [a, b = my_var] = [1, 2]; my_var;", true}, + {"", "var {a = my_var} = {}", true}, + {"", "var {a: b = my_var} = {}", true}, + {"", "let {a = my_var} = {}", true}, + {"", "let {a: b = my_var} = {}", true}, + {"", "const {a = my_var} = {}", true}, + {"", "const {a: b = my_var} = {}", true}, {"a = my_var", "", true}, + {"a = my_var", "let my_var;", true}, {"", "function inner2(a = my_var) { }", true}, {"", "(a = my_var) => { }", true}, {"{a} = {a: my_var}", "", true}, @@ -8661,6 +9362,8 @@ TEST(NoPessimisticContextAllocation) { {"[a] = [my_var]", "", true}, {"", "function inner2([a] = [my_var]) { }", true}, {"", "([a] = [my_var]) => { }", true}, + {"", "function inner2(a = eval('')) { }", true}, + {"", "(a = eval('')) => { }", true}, {"", "try { } catch (my_var) { } my_var;", true}, {"", "for (my_var in {}) { my_var; }", true}, {"", "for (my_var in {}) { }", true}, @@ -8704,6 +9407,10 @@ TEST(NoPessimisticContextAllocation) { {"", "if (true) { let my_var; if (true) { function my_var() {} } } my_var;", true}, + {"", "function inner2(a = my_var) {}", true}, + {"", "function inner2(a = my_var) { let my_var; }", true}, + {"", "(a = my_var) => {}", true}, + {"", "(a = my_var) => { let my_var; }", true}, // No pessimistic context allocation: {"", "var my_var; my_var;", false}, {"", "var my_var;", false}, @@ -8873,8 +9580,7 @@ TEST(NoPessimisticContextAllocation) { printf("\n"); i::Handle<i::Script> script = factory->NewScript(source); - i::Zone zone(isolate->allocator(), ZONE_NAME); - i::ParseInfo info(&zone, script); + i::ParseInfo info(script); CHECK(i::parsing::ParseProgram(&info)); CHECK(i::Compiler::Analyze(&info)); @@ -8892,3 +9598,340 @@ TEST(NoPessimisticContextAllocation) { } } } + +TEST(EscapedStrictReservedWord) { + // Test that identifiers which are both escaped and only reserved in the + // strict mode are accepted in non-strict mode. + const char* context_data[][2] = {{"", ""}, {NULL, NULL}}; + + const char* statement_data[] = {"if (true) l\u0065t: ;", + "function l\u0065t() { }", + "(function l\u0065t() { })", + "async function l\u0065t() { }", + "(async function l\u0065t() { })", + "l\u0065t => 42", + "async l\u0065t => 42", + NULL}; + + RunParserSyncTest(context_data, statement_data, kSuccess); +} + +TEST(ForAwaitOf) { + // clang-format off + const char* context_data[][2] = { + { "async function f() { for await ", " ; }" }, + { "async function f() { for await ", " { } }" }, + { "async function f() { 'use strict'; for await ", " ; }" }, + { "async function f() { 'use strict'; for await ", " { } }" }, + { "async function f() { for\nawait ", " ; }" }, + { "async function f() { for\nawait ", " { } }" }, + { "async function f() { 'use strict'; for\nawait ", " ; }" }, + { "async function f() { 'use strict'; for\nawait ", " { } }" }, + { "async function f() { 'use strict'; for\nawait ", " { } }" }, + { "async function f() { for await\n", " ; }" }, + { "async function f() { for await\n", " { } }" }, + { "async function f() { 'use strict'; for await\n", " ; }" }, + { "async function f() { 'use strict'; for await\n", " { } }" }, + { NULL, NULL } + }; + + const char* context_data2[][2] = { + { "async function f() { let a; for await ", " ; }" }, + { "async function f() { let a; for await ", " { } }" }, + { "async function f() { 'use strict'; let a; for await ", " ; }" }, + { "async function f() { 'use strict'; let a; for await ", " { } }" }, + { "async function f() { let a; for\nawait ", " ; }" }, + { "async function f() { let a; for\nawait ", " { } }" }, + { "async function f() { 'use strict'; let a; for\nawait ", " ; }" }, + { "async function f() { 'use strict'; let a; for\nawait ", " { } }" }, + { "async function f() { 'use strict'; let a; for\nawait ", " { } }" }, + { "async function f() { let a; for await\n", " ; }" }, + { "async function f() { let a; for await\n", " { } }" }, + { "async function f() { 'use strict'; let a; for await\n", " ; }" }, + { "async function f() { 'use strict'; let a; for await\n", " { } }" }, + { NULL, NULL } + }; + + const char* expr_data[] = { + // Primary Expressions + "(a of [])", + "(a.b of [])", + "([a] of [])", + "([a = 1] of [])", + "([a = 1, ...b] of [])", + "({a} of [])", + "({a: a} of [])", + "({'a': a} of [])", + "({\"a\": a} of [])", + "({[Symbol.iterator]: a} of [])", + "({0: a} of [])", + "({a = 1} of [])", + "({a: a = 1} of [])", + "({'a': a = 1} of [])", + "({\"a\": a = 1} of [])", + "({[Symbol.iterator]: a = 1} of [])", + "({0: a = 1} of [])", + NULL + }; + + const char* var_data[] = { + // VarDeclarations + "(var a of [])", + "(var [a] of [])", + "(var [a = 1] of [])", + "(var [a = 1, ...b] of [])", + "(var {a} of [])", + "(var {a: a} of [])", + "(var {'a': a} of [])", + "(var {\"a\": a} of [])", + "(var {[Symbol.iterator]: a} of [])", + "(var {0: a} of [])", + "(var {a = 1} of [])", + "(var {a: a = 1} of [])", + "(var {'a': a = 1} of [])", + "(var {\"a\": a = 1} of [])", + "(var {[Symbol.iterator]: a = 1} of [])", + "(var {0: a = 1} of [])", + NULL + }; + + const char* lexical_data[] = { + // LexicalDeclartions + "(let a of [])", + "(let [a] of [])", + "(let [a = 1] of [])", + "(let [a = 1, ...b] of [])", + "(let {a} of [])", + "(let {a: a} of [])", + "(let {'a': a} of [])", + "(let {\"a\": a} of [])", + "(let {[Symbol.iterator]: a} of [])", + "(let {0: a} of [])", + "(let {a = 1} of [])", + "(let {a: a = 1} of [])", + "(let {'a': a = 1} of [])", + "(let {\"a\": a = 1} of [])", + "(let {[Symbol.iterator]: a = 1} of [])", + "(let {0: a = 1} of [])", + + "(const a of [])", + "(const [a] of [])", + "(const [a = 1] of [])", + "(const [a = 1, ...b] of [])", + "(const {a} of [])", + "(const {a: a} of [])", + "(const {'a': a} of [])", + "(const {\"a\": a} of [])", + "(const {[Symbol.iterator]: a} of [])", + "(const {0: a} of [])", + "(const {a = 1} of [])", + "(const {a: a = 1} of [])", + "(const {'a': a = 1} of [])", + "(const {\"a\": a = 1} of [])", + "(const {[Symbol.iterator]: a = 1} of [])", + "(const {0: a = 1} of [])", + NULL + }; + // clang-format on + static const ParserFlag always_flags[] = {kAllowHarmonyAsyncIteration}; + RunParserSyncTest(context_data, expr_data, kSuccess, NULL, 0, always_flags, + arraysize(always_flags)); + RunParserSyncTest(context_data2, expr_data, kSuccess, NULL, 0, always_flags, + arraysize(always_flags)); + + RunParserSyncTest(context_data, var_data, kSuccess, NULL, 0, always_flags, + arraysize(always_flags)); + // TODO(marja): PreParser doesn't report early errors. + // (https://bugs.chromium.org/p/v8/issues/detail?id=2728) + // RunParserSyncTest(context_data2, var_data, kError, NULL, 0, always_flags, + // arraysize(always_flags)); + + RunParserSyncTest(context_data, lexical_data, kSuccess, NULL, 0, always_flags, + arraysize(always_flags)); + RunParserSyncTest(context_data2, lexical_data, kSuccess, NULL, 0, + always_flags, arraysize(always_flags)); +} + +TEST(ForAwaitOfErrors) { + // clang-format off + const char* context_data[][2] = { + { "async function f() { for await ", " ; }" }, + { "async function f() { for await ", " { } }" }, + { "async function f() { 'use strict'; for await ", " ; }" }, + { "async function f() { 'use strict'; for await ", " { } }" }, + { NULL, NULL } + }; + + const char* data[] = { + // Primary Expressions + "(a = 1 of [])", + "(a = 1) of [])", + "(a.b = 1 of [])", + "((a.b = 1) of [])", + "([a] = 1 of [])", + "(([a] = 1) of [])", + "([a = 1] = 1 of [])", + "(([a = 1] = 1) of [])", + "([a = 1 = 1, ...b] = 1 of [])", + "(([a = 1 = 1, ...b] = 1) of [])", + "({a} = 1 of [])", + "(({a} = 1) of [])", + "({a: a} = 1 of [])", + "(({a: a} = 1) of [])", + "({'a': a} = 1 of [])", + "(({'a': a} = 1) of [])", + "({\"a\": a} = 1 of [])", + "(({\"a\": a} = 1) of [])", + "({[Symbol.iterator]: a} = 1 of [])", + "(({[Symbol.iterator]: a} = 1) of [])", + "({0: a} = 1 of [])", + "(({0: a} = 1) of [])", + "({a = 1} = 1 of [])", + "(({a = 1} = 1) of [])", + "({a: a = 1} = 1 of [])", + "(({a: a = 1} = 1) of [])", + "({'a': a = 1} = 1 of [])", + "(({'a': a = 1} = 1) of [])", + "({\"a\": a = 1} = 1 of [])", + "(({\"a\": a = 1} = 1) of [])", + "({[Symbol.iterator]: a = 1} = 1 of [])", + "(({[Symbol.iterator]: a = 1} = 1) of [])", + "({0: a = 1} = 1 of [])", + "(({0: a = 1} = 1) of [])", + "(function a() {} of [])", + "([1] of [])", + "({a: 1} of [])" + + // VarDeclarations + "(var a = 1 of [])", + "(var a, b of [])", + "(var [a] = 1 of [])", + "(var [a], b of [])", + "(var [a = 1] = 1 of [])", + "(var [a = 1], b of [])", + "(var [a = 1 = 1, ...b] of [])", + "(var [a = 1, ...b], c of [])", + "(var {a} = 1 of [])", + "(var {a}, b of [])", + "(var {a: a} = 1 of [])", + "(var {a: a}, b of [])", + "(var {'a': a} = 1 of [])", + "(var {'a': a}, b of [])", + "(var {\"a\": a} = 1 of [])", + "(var {\"a\": a}, b of [])", + "(var {[Symbol.iterator]: a} = 1 of [])", + "(var {[Symbol.iterator]: a}, b of [])", + "(var {0: a} = 1 of [])", + "(var {0: a}, b of [])", + "(var {a = 1} = 1 of [])", + "(var {a = 1}, b of [])", + "(var {a: a = 1} = 1 of [])", + "(var {a: a = 1}, b of [])", + "(var {'a': a = 1} = 1 of [])", + "(var {'a': a = 1}, b of [])", + "(var {\"a\": a = 1} = 1 of [])", + "(var {\"a\": a = 1}, b of [])", + "(var {[Symbol.iterator]: a = 1} = 1 of [])", + "(var {[Symbol.iterator]: a = 1}, b of [])", + "(var {0: a = 1} = 1 of [])", + "(var {0: a = 1}, b of [])", + + // LexicalDeclartions + "(let a = 1 of [])", + "(let a, b of [])", + "(let [a] = 1 of [])", + "(let [a], b of [])", + "(let [a = 1] = 1 of [])", + "(let [a = 1], b of [])", + "(let [a = 1, ...b] = 1 of [])", + "(let [a = 1, ...b], c of [])", + "(let {a} = 1 of [])", + "(let {a}, b of [])", + "(let {a: a} = 1 of [])", + "(let {a: a}, b of [])", + "(let {'a': a} = 1 of [])", + "(let {'a': a}, b of [])", + "(let {\"a\": a} = 1 of [])", + "(let {\"a\": a}, b of [])", + "(let {[Symbol.iterator]: a} = 1 of [])", + "(let {[Symbol.iterator]: a}, b of [])", + "(let {0: a} = 1 of [])", + "(let {0: a}, b of [])", + "(let {a = 1} = 1 of [])", + "(let {a = 1}, b of [])", + "(let {a: a = 1} = 1 of [])", + "(let {a: a = 1}, b of [])", + "(let {'a': a = 1} = 1 of [])", + "(let {'a': a = 1}, b of [])", + "(let {\"a\": a = 1} = 1 of [])", + "(let {\"a\": a = 1}, b of [])", + "(let {[Symbol.iterator]: a = 1} = 1 of [])", + "(let {[Symbol.iterator]: a = 1}, b of [])", + "(let {0: a = 1} = 1 of [])", + "(let {0: a = 1}, b of [])", + + "(const a = 1 of [])", + "(const a, b of [])", + "(const [a] = 1 of [])", + "(const [a], b of [])", + "(const [a = 1] = 1 of [])", + "(const [a = 1], b of [])", + "(const [a = 1, ...b] = 1 of [])", + "(const [a = 1, ...b], b of [])", + "(const {a} = 1 of [])", + "(const {a}, b of [])", + "(const {a: a} = 1 of [])", + "(const {a: a}, b of [])", + "(const {'a': a} = 1 of [])", + "(const {'a': a}, b of [])", + "(const {\"a\": a} = 1 of [])", + "(const {\"a\": a}, b of [])", + "(const {[Symbol.iterator]: a} = 1 of [])", + "(const {[Symbol.iterator]: a}, b of [])", + "(const {0: a} = 1 of [])", + "(const {0: a}, b of [])", + "(const {a = 1} = 1 of [])", + "(const {a = 1}, b of [])", + "(const {a: a = 1} = 1 of [])", + "(const {a: a = 1}, b of [])", + "(const {'a': a = 1} = 1 of [])", + "(const {'a': a = 1}, b of [])", + "(const {\"a\": a = 1} = 1 of [])", + "(const {\"a\": a = 1}, b of [])", + "(const {[Symbol.iterator]: a = 1} = 1 of [])", + "(const {[Symbol.iterator]: a = 1}, b of [])", + "(const {0: a = 1} = 1 of [])", + "(const {0: a = 1}, b of [])", + + NULL + }; + // clang-format on + static const ParserFlag always_flags[] = {kAllowHarmonyAsyncIteration}; + RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, + arraysize(always_flags)); +} + +TEST(ForAwaitOfFunctionDeclaration) { + // clang-format off + const char* context_data[][2] = { + { "async function f() {", "}" }, + { "async function f() { 'use strict'; ", "}" }, + { NULL, NULL } + }; + + const char* data[] = { + "for await (x of []) function d() {};", + "for await (x of []) function d() {}; return d;", + "for await (x of []) function* g() {};", + "for await (x of []) function* g() {}; return g;", + // TODO(caitp): handle async function declarations in ParseScopedStatement. + // "for await (x of []) async function a() {};", + // "for await (x of []) async function a() {}; return a;", + NULL + }; + + // clang-format on + static const ParserFlag always_flags[] = {kAllowHarmonyAsyncIteration}; + RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, + arraysize(always_flags)); +} diff --git a/deps/v8/test/cctest/test-profile-generator.cc b/deps/v8/test/cctest/test-profile-generator.cc index 71728924db..2f38f02c07 100644 --- a/deps/v8/test/cctest/test-profile-generator.cc +++ b/deps/v8/test/cctest/test-profile-generator.cc @@ -350,7 +350,7 @@ TEST(RecordTickSample) { CpuProfiler profiler(isolate); profiles.set_cpu_profiler(&profiler); profiles.StartProfiling("", false); - ProfileGenerator generator(isolate, &profiles); + ProfileGenerator generator(&profiles); CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); CodeEntry* entry2 = new CodeEntry(i::Logger::FUNCTION_TAG, "bbb"); CodeEntry* entry3 = new CodeEntry(i::Logger::FUNCTION_TAG, "ccc"); @@ -423,7 +423,7 @@ TEST(SampleIds) { CpuProfiler profiler(isolate); profiles.set_cpu_profiler(&profiler); profiles.StartProfiling("", true); - ProfileGenerator generator(isolate, &profiles); + ProfileGenerator generator(&profiles); CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); CodeEntry* entry2 = new CodeEntry(i::Logger::FUNCTION_TAG, "bbb"); CodeEntry* entry3 = new CodeEntry(i::Logger::FUNCTION_TAG, "ccc"); @@ -481,7 +481,7 @@ TEST(NoSamples) { CpuProfiler profiler(isolate); profiles.set_cpu_profiler(&profiler); profiles.StartProfiling("", false); - ProfileGenerator generator(isolate, &profiles); + ProfileGenerator generator(&profiles); CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); @@ -697,6 +697,8 @@ TEST(LineNumber) { } TEST(BailoutReason) { + i::FLAG_allow_natives_syntax = true; + i::FLAG_always_opt = false; v8::HandleScope scope(CcTest::isolate()); v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); v8::Context::Scope context_scope(env); @@ -704,14 +706,21 @@ TEST(BailoutReason) { i::ProfilerExtension::set_profiler(iprofiler.get()); CHECK_EQ(0, iprofiler->GetProfilesCount()); - v8::Local<v8::Script> script = - v8_compile(v8_str("function Debugger() {\n" - " debugger;\n" - " startProfiling();\n" - "}\n" - "Debugger();\n" - "stopProfiling();")); - script->Run(v8::Isolate::GetCurrent()->GetCurrentContext()).ToLocalChecked(); + v8::Local<v8::Function> function = CompileRun( + "function Debugger() {\n" + " startProfiling();\n" + "}" + "Debugger") + .As<v8::Function>(); + i::Handle<i::JSFunction> i_function = + i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*function)); + // Set a high opt count to trigger bail out. + i_function->shared()->set_opt_count(10000); + + CompileRun( + "%OptimizeFunctionOnNextCall(Debugger);" + "Debugger();" + "stopProfiling()"); CHECK_EQ(1, iprofiler->GetProfilesCount()); const v8::CpuProfile* profile = i::ProfilerExtension::last_profile; CHECK(profile); @@ -721,11 +730,11 @@ TEST(BailoutReason) { // The tree should look like this: // (root) // "" - // kDebuggerStatement + // kFunctionBeingDebugged current = PickChild(current, ""); CHECK(const_cast<v8::CpuProfileNode*>(current)); current = PickChild(current, "Debugger"); CHECK(const_cast<v8::CpuProfileNode*>(current)); - CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason())); + CHECK(!strcmp("Deoptimized too many times", current->GetBailoutReason())); } diff --git a/deps/v8/test/cctest/test-regexp.cc b/deps/v8/test/cctest/test-regexp.cc index ee6a6c2ab7..c5a86c1395 100644 --- a/deps/v8/test/cctest/test-regexp.cc +++ b/deps/v8/test/cctest/test-regexp.cc @@ -199,8 +199,8 @@ void TestRegExpParser(bool lookbehind) { CheckParseEq("xyz{1,}?", "(: 'xy' (# 1 - n 'z'))"); CheckParseEq("a\\fb\\nc\\rd\\te\\vf", "'a\\x0cb\\x0ac\\x0dd\\x09e\\x0bf'"); CheckParseEq("a\\nb\\bc", "(: 'a\\x0ab' @b 'c')"); - CheckParseEq("(?:foo)", "'foo'"); - CheckParseEq("(?: foo )", "' foo '"); + CheckParseEq("(?:foo)", "(?: 'foo')"); + CheckParseEq("(?: foo )", "(?: ' foo ')"); CheckParseEq("(foo|bar|baz)", "(^ (| 'foo' 'bar' 'baz'))"); CheckParseEq("foo|(bar|baz)|quux", "(| 'foo' (^ (| 'bar' 'baz')) 'quux')"); CheckParseEq("foo(?=bar)baz", "(: 'foo' (-> + 'bar') 'baz')"); @@ -294,7 +294,7 @@ void TestRegExpParser(bool lookbehind) { CheckParseEq("(?!\\1(a\\1)\\1)\\1", "(: (-> - (: (<- 1) (^ 'a') (<- 1))) (<- 1))"); CheckParseEq("\\1\\2(a(?:\\1(b\\1\\2))\\2)\\1", - "(: (<- 1) (<- 2) (^ (: 'a' (^ 'b') (<- 2))) (<- 1))"); + "(: (<- 1) (<- 2) (^ (: 'a' (?: (^ 'b')) (<- 2))) (<- 1))"); if (lookbehind) { CheckParseEq("\\1\\2(a(?<=\\1(b\\1\\2))\\2)\\1", "(: (<- 1) (<- 2) (^ (: 'a' (<- + (^ 'b')) (<- 2))) (<- 1))"); diff --git a/deps/v8/test/cctest/test-run-wasm-relocation-arm.cc b/deps/v8/test/cctest/test-run-wasm-relocation-arm.cc index 4fd186e565..1666b69a57 100644 --- a/deps/v8/test/cctest/test-run-wasm-relocation-arm.cc +++ b/deps/v8/test/cctest/test-run-wasm-relocation-arm.cc @@ -55,15 +55,10 @@ TEST(WasmRelocationArmMemoryReference) { // Relocating references by offset int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemoryReference(mode)) { - // Dummy values of size used here as the objective of the test is to - // verify that the immediate is patched correctly - it.rinfo()->update_wasm_memory_reference( - it.rinfo()->wasm_memory_reference(), - it.rinfo()->wasm_memory_reference() + offset, 1, 2, - SKIP_ICACHE_FLUSH); - } + DCHECK(RelocInfo::IsWasmMemoryReference(it.rinfo()->rmode())); + it.rinfo()->update_wasm_memory_reference( + it.rinfo()->wasm_memory_reference(), + it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); } // Call into relocated code object @@ -114,13 +109,10 @@ TEST(WasmRelocationArmMemorySizeReference) { int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemorySizeReference(mode)) { - it.rinfo()->update_wasm_memory_reference( - reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234), - it.rinfo()->wasm_memory_size_reference(), - it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); - } + DCHECK(RelocInfo::IsWasmMemorySizeReference(it.rinfo()->rmode())); + it.rinfo()->update_wasm_memory_size( + it.rinfo()->wasm_memory_size_reference(), + it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); } ret_value = runnable.Call(); diff --git a/deps/v8/test/cctest/test-run-wasm-relocation-arm64.cc b/deps/v8/test/cctest/test-run-wasm-relocation-arm64.cc index c59a01aaed..920efee600 100644 --- a/deps/v8/test/cctest/test-run-wasm-relocation-arm64.cc +++ b/deps/v8/test/cctest/test-run-wasm-relocation-arm64.cc @@ -57,15 +57,10 @@ TEST(WasmRelocationArm64MemoryReference) { // Relocating reference by offset int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemoryReference(mode)) { - // Dummy values of size used here as the objective of the test is to - // verify that the immediate is patched correctly - it.rinfo()->update_wasm_memory_reference( - it.rinfo()->wasm_memory_reference(), - it.rinfo()->wasm_memory_reference() + offset, 1, 2, - SKIP_ICACHE_FLUSH); - } + DCHECK(RelocInfo::IsWasmMemoryReference(it.rinfo()->rmode())); + it.rinfo()->update_wasm_memory_reference( + it.rinfo()->wasm_memory_reference(), + it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); } // Call into relocated code object @@ -117,13 +112,10 @@ TEST(WasmRelocationArm64MemorySizeReference) { int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemorySizeReference(mode)) { - it.rinfo()->update_wasm_memory_reference( - reinterpret_cast<Address>(0x1234), reinterpret_cast<Address>(0x1234), - it.rinfo()->wasm_memory_size_reference(), - it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); - } + DCHECK(RelocInfo::IsWasmMemorySizeReference(it.rinfo()->rmode())); + it.rinfo()->update_wasm_memory_size( + it.rinfo()->wasm_memory_size_reference(), + it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); } ret_value = runnable.Call(); diff --git a/deps/v8/test/cctest/test-run-wasm-relocation-ia32.cc b/deps/v8/test/cctest/test-run-wasm-relocation-ia32.cc index f2241d5f92..0b3f061568 100644 --- a/deps/v8/test/cctest/test-run-wasm-relocation-ia32.cc +++ b/deps/v8/test/cctest/test-run-wasm-relocation-ia32.cc @@ -61,15 +61,10 @@ TEST(WasmRelocationIa32MemoryReference) { // Relocating references by offset int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemoryReference(mode)) { - // Dummy values of size used here as the objective of the test is to - // verify that the immediate is patched correctly - it.rinfo()->update_wasm_memory_reference( - it.rinfo()->wasm_memory_reference(), - it.rinfo()->wasm_memory_reference() + offset, 1, 2, - SKIP_ICACHE_FLUSH); - } + DCHECK(RelocInfo::IsWasmMemoryReference(it.rinfo()->rmode())); + it.rinfo()->update_wasm_memory_reference( + it.rinfo()->wasm_memory_reference(), + it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); } // Check if immediate is updated correctly @@ -128,13 +123,10 @@ TEST(WasmRelocationIa32MemorySizeReference) { int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemorySizeReference(mode)) { - it.rinfo()->update_wasm_memory_reference( - reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234), - it.rinfo()->wasm_memory_size_reference(), - it.rinfo()->wasm_memory_size_reference() + offset, SKIP_ICACHE_FLUSH); - } + DCHECK(RelocInfo::IsWasmMemorySizeReference(it.rinfo()->rmode())); + it.rinfo()->update_wasm_memory_size( + it.rinfo()->wasm_memory_size_reference(), + it.rinfo()->wasm_memory_size_reference() + offset, SKIP_ICACHE_FLUSH); } ret_value = runnable.Call(); diff --git a/deps/v8/test/cctest/test-run-wasm-relocation-x64.cc b/deps/v8/test/cctest/test-run-wasm-relocation-x64.cc index a5df703410..29491e8c87 100644 --- a/deps/v8/test/cctest/test-run-wasm-relocation-x64.cc +++ b/deps/v8/test/cctest/test-run-wasm-relocation-x64.cc @@ -11,6 +11,8 @@ #include "src/disassembler.h" #include "src/ic/ic.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" +#include "src/ostreams.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/c-signature.h" #include "test/cctest/compiler/call-tester.h" @@ -57,15 +59,10 @@ TEST(WasmRelocationX64MemoryReference) { // Relocating references by offset int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemoryReference(mode)) { - // Dummy values of size used here as the objective of the test is to - // verify that the immediate is patched correctly - it.rinfo()->update_wasm_memory_reference( - it.rinfo()->wasm_memory_reference(), - it.rinfo()->wasm_memory_reference() + offset, 1, 2, - SKIP_ICACHE_FLUSH); - } + DCHECK(RelocInfo::IsWasmMemoryReference(it.rinfo()->rmode())); + it.rinfo()->update_wasm_memory_reference( + it.rinfo()->wasm_memory_reference(), + it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); } // Check if immediate is updated correctly @@ -120,13 +117,10 @@ TEST(WasmRelocationX64WasmMemorySizeReference) { int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemorySizeReference(mode)) { - it.rinfo()->update_wasm_memory_reference( - reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234), - it.rinfo()->wasm_memory_size_reference(), - it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); - } + DCHECK(RelocInfo::IsWasmMemorySizeReference(it.rinfo()->rmode())); + it.rinfo()->update_wasm_memory_size( + it.rinfo()->wasm_memory_size_reference(), + it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); } ret_value = runnable.Call(); diff --git a/deps/v8/test/cctest/test-run-wasm-relocation-x87.cc b/deps/v8/test/cctest/test-run-wasm-relocation-x87.cc index 17b340ac9e..77dc86e0fb 100644 --- a/deps/v8/test/cctest/test-run-wasm-relocation-x87.cc +++ b/deps/v8/test/cctest/test-run-wasm-relocation-x87.cc @@ -61,15 +61,10 @@ TEST(WasmRelocationX87MemoryReference) { // Relocating references by offset int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemoryReference(mode)) { - // Dummy values of size used here as the objective of the test is to - // verify that the immediate is patched correctly - it.rinfo()->update_wasm_memory_reference( - it.rinfo()->wasm_memory_reference(), - it.rinfo()->wasm_memory_reference() + offset, 1, 2, - SKIP_ICACHE_FLUSH); - } + DCHECK(RelocInfo::IsWasmMemoryReference(it.rinfo()->rmode())); + it.rinfo()->update_wasm_memory_reference( + it.rinfo()->wasm_memory_reference(), + it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); } // Check if immediate is updated correctly @@ -129,12 +124,10 @@ TEST(WasmRelocationX87MemorySizeReference) { int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemorySizeReference(mode)) { - it.rinfo()->update_wasm_memory_reference( - reinterpret_cast<Address>(1234), reinterpret_cast<Address>(1234), - it.rinfo()->wasm_memory_size_reference(), - it.rinfo()->wasm_memory_size_reference() + offset, SKIP_ICACHE_FLUSH); - } + DCHECK(RelocInfo::IsWasmMemorySizeReference(mode)); + it.rinfo()->update_wasm_memory_size( + it.rinfo()->wasm_memory_size_reference(), + it.rinfo()->wasm_memory_size_reference() + offset, SKIP_ICACHE_FLUSH); } ret_value = runnable.Call(); diff --git a/deps/v8/test/cctest/test-serialize.cc b/deps/v8/test/cctest/test-serialize.cc index 9644d09624..20085a23c0 100644 --- a/deps/v8/test/cctest/test-serialize.cc +++ b/deps/v8/test/cctest/test-serialize.cc @@ -31,13 +31,15 @@ #include "src/v8.h" +#include "src/api.h" +#include "src/assembler-inl.h" #include "src/bootstrapper.h" #include "src/compilation-cache.h" #include "src/compiler.h" #include "src/debug/debug.h" #include "src/heap/spaces.h" #include "src/macro-assembler.h" -#include "src/objects.h" +#include "src/objects-inl.h" #include "src/runtime/runtime.h" #include "src/snapshot/code-serializer.h" #include "src/snapshot/deserializer.h" @@ -262,10 +264,9 @@ static void PartiallySerializeObject(Vector<const byte>* startup_blob_out, isolate->bootstrapper()->SourceLookup<Natives>(i); } } - heap->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask, - i::GarbageCollectionReason::kTesting); - heap->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask, - i::GarbageCollectionReason::kTesting); + + heap->CollectAllAvailableGarbage(i::GarbageCollectionReason::kTesting); + heap->CollectAllAvailableGarbage(i::GarbageCollectionReason::kTesting); Object* raw_foo; { @@ -370,10 +371,10 @@ static void PartiallySerializeContext(Vector<const byte>* startup_blob_out, isolate->bootstrapper()->SourceLookup<Natives>(i); } } + // If we don't do this then we end up with a stray root pointing at the // context even after we have disposed of env. - heap->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask, - i::GarbageCollectionReason::kTesting); + heap->CollectAllAvailableGarbage(i::GarbageCollectionReason::kTesting); { v8::HandleScope handle_scope(v8_isolate); @@ -931,7 +932,7 @@ static Handle<SharedFunctionInfo> CompileScript( return Compiler::GetSharedFunctionInfoForScript( source, name, 0, 0, v8::ScriptOriginOptions(), Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, cached_data, options, - NOT_NATIVES_CODE, false); + NOT_NATIVES_CODE); } TEST(CodeSerializerOnePlusOne) { @@ -1005,11 +1006,11 @@ TEST(CodeSerializerPromotedToCompilationCache) { Handle<SharedFunctionInfo> copy = CompileScript( isolate, src, src, &cache, v8::ScriptCompiler::kConsumeCodeCache); - CHECK(isolate->compilation_cache() - ->LookupScript(src, src, 0, 0, v8::ScriptOriginOptions(), - isolate->native_context(), SLOPPY) - .ToHandleChecked() - .is_identical_to(copy)); + InfoVectorPair pair = isolate->compilation_cache()->LookupScript( + src, src, 0, 0, v8::ScriptOriginOptions(), isolate->native_context(), + SLOPPY); + + CHECK(pair.shared() == *copy); delete cache; } @@ -1687,96 +1688,6 @@ TEST(CodeSerializerWithHarmonyScoping) { isolate2->Dispose(); } -TEST(CodeSerializerInternalReference) { -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 - return; -#endif - // In ignition there are only relative jumps, so the following code - // would not have any internal references. This test is not relevant - // for ignition. - if (FLAG_ignition || FLAG_turbo) { - return; - } - // Disable experimental natives that are loaded after deserialization. - FLAG_function_context_specialization = false; - FLAG_always_opt = true; - const char* flag = "--turbo-filter=foo"; - FlagList::SetFlagsFromString(flag, StrLength(flag)); - - const char* source = - "var foo = (function(stdlib, foreign, heap) {" - " function foo(i) {" - " i = i|0;" - " var j = 0;" - " switch (i) {" - " case 0:" - " case 1: j = 1; break;" - " case 2:" - " case 3: j = 2; break;" - " case 4:" - " case 5: j = foo(3) + 1; break;" - " default: j = 0; break;" - " }" - " return j + 10;" - " }" - " return { foo: foo };" - "})(this, {}, undefined).foo;" - "foo(1);"; - - v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source); - CHECK(data.data); - - v8::Isolate::CreateParams params; - params.snapshot_blob = &data; - params.array_buffer_allocator = CcTest::array_buffer_allocator(); - v8::Isolate* isolate = v8::Isolate::New(params); - { - v8::Isolate::Scope i_scope(isolate); - v8::HandleScope h_scope(isolate); - v8::Local<v8::Context> context = v8::Context::New(isolate); - delete[] data.data; // We can dispose of the snapshot blob now. - v8::Context::Scope c_scope(context); - v8::Local<v8::Function> foo = - v8::Local<v8::Function>::Cast(CompileRun("foo")); - - // There are at least 6 internal references. - int mask = RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | - RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); - RelocIterator it( - Handle<JSFunction>::cast(v8::Utils::OpenHandle(*foo))->code(), mask); - for (int i = 0; i < 6; ++i) { - CHECK(!it.done()); - it.next(); - } - - CHECK(Handle<JSFunction>::cast(v8::Utils::OpenHandle(*foo)) - ->code() - ->is_turbofanned()); - CHECK_EQ(11, CompileRun("foo(0)") - ->Int32Value(isolate->GetCurrentContext()) - .FromJust()); - CHECK_EQ(11, CompileRun("foo(1)") - ->Int32Value(isolate->GetCurrentContext()) - .FromJust()); - CHECK_EQ(12, CompileRun("foo(2)") - ->Int32Value(isolate->GetCurrentContext()) - .FromJust()); - CHECK_EQ(12, CompileRun("foo(3)") - ->Int32Value(isolate->GetCurrentContext()) - .FromJust()); - CHECK_EQ(23, CompileRun("foo(4)") - ->Int32Value(isolate->GetCurrentContext()) - .FromJust()); - CHECK_EQ(23, CompileRun("foo(5)") - ->Int32Value(isolate->GetCurrentContext()) - .FromJust()); - CHECK_EQ(10, CompileRun("foo(6)") - ->Int32Value(isolate->GetCurrentContext()) - .FromJust()); - } - isolate->Dispose(); -} - TEST(CodeSerializerEagerCompilationAndPreAge) { if (FLAG_ignition || FLAG_turbo) return; @@ -1846,8 +1757,7 @@ TEST(Regress503552) { Handle<SharedFunctionInfo> shared = Compiler::GetSharedFunctionInfoForScript( source, Handle<String>(), 0, 0, v8::ScriptOriginOptions(), Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, - &script_data, v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE, - false); + &script_data, v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); delete script_data; heap::SimulateIncrementalMarking(isolate->heap()); @@ -2078,6 +1988,7 @@ intptr_t original_external_references[] = { reinterpret_cast<intptr_t>(&NamedPropertyGetterForSerialization), reinterpret_cast<intptr_t>(&AccessorForSerialization), reinterpret_cast<intptr_t>(&SerializedExtension::FunctionCallback), + reinterpret_cast<intptr_t>(&serialized_static_field), // duplicate entry 0}; intptr_t replaced_external_references[] = { @@ -2086,6 +1997,7 @@ intptr_t replaced_external_references[] = { reinterpret_cast<intptr_t>(&NamedPropertyGetterForSerialization), reinterpret_cast<intptr_t>(&AccessorForSerialization), reinterpret_cast<intptr_t>(&SerializedExtension::FunctionCallback), + reinterpret_cast<intptr_t>(&serialized_static_field), 0}; TEST(SnapshotCreatorExternalReferences) { diff --git a/deps/v8/test/cctest/test-simd.cc b/deps/v8/test/cctest/test-simd.cc deleted file mode 100644 index 5394d2ad10..0000000000 --- a/deps/v8/test/cctest/test-simd.cc +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/v8.h" - -#include "src/factory.h" -#include "src/isolate.h" -#include "src/objects.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h -#include "src/objects-inl.h" -#include "src/ostreams.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" -#include "test/cctest/cctest.h" - -using namespace v8::internal; - -#define FLOAT_TEST(type, lane_count) \ - { \ - float nan = std::numeric_limits<float>::quiet_NaN(); \ - float lanes[lane_count] = {0}; \ - Handle<type> a = factory->New##type(lanes); \ - Handle<type> b = factory->New##type(lanes); \ - CHECK(a->BitwiseEquals(*b)); \ - CHECK(a->SameValue(*b)); \ - CHECK(a->SameValueZero(*b)); \ - CHECK_EQ(a->Hash(), b->Hash()); \ - for (int i = 0; i < lane_count; i++) { \ - a->set_lane(i, -0.0); \ - CHECK(!a->BitwiseEquals(*b)); \ - CHECK_NE(a->Hash(), b->Hash()); \ - CHECK(!a->SameValue(*b)); \ - CHECK(a->SameValueZero(*b)); \ - b->set_lane(i, -0.0); \ - CHECK(a->BitwiseEquals(*b)); \ - CHECK_EQ(a->Hash(), b->Hash()); \ - CHECK(a->SameValue(*b)); \ - CHECK(a->SameValueZero(*b)); \ - a->set_lane(i, nan); \ - CHECK(!a->BitwiseEquals(*b)); \ - CHECK(!a->SameValue(*b)); \ - CHECK(!a->SameValueZero(*b)); \ - CHECK_NE(a->Hash(), b->Hash()); \ - b->set_lane(i, nan); \ - CHECK(a->BitwiseEquals(*b)); \ - CHECK_EQ(a->Hash(), b->Hash()); \ - CHECK(a->SameValue(*b)); \ - CHECK(a->SameValueZero(*b)); \ - } \ - } - -#define INT_TEST(type, lane_count, lane_type) \ - { \ - lane_type lanes[lane_count] = {0}; \ - Handle<type> a = factory->New##type(lanes); \ - Handle<type> b = factory->New##type(lanes); \ - CHECK(a->BitwiseEquals(*b)); \ - CHECK(a->SameValue(*b)); \ - CHECK(a->SameValueZero(*b)); \ - CHECK_EQ(a->Hash(), b->Hash()); \ - for (int i = 0; i < lane_count; i++) { \ - a->set_lane(i, i + 1); \ - CHECK(!a->BitwiseEquals(*b)); \ - CHECK_NE(a->Hash(), b->Hash()); \ - CHECK(!a->SameValue(*b)); \ - CHECK(!a->SameValueZero(*b)); \ - b->set_lane(i, i + 1); \ - CHECK(a->BitwiseEquals(*b)); \ - CHECK_EQ(a->Hash(), b->Hash()); \ - CHECK(a->SameValue(*b)); \ - CHECK(a->SameValueZero(*b)); \ - a->set_lane(i, -(i + 1)); \ - CHECK(!a->BitwiseEquals(*b)); \ - CHECK_NE(a->Hash(), b->Hash()); \ - CHECK(!a->SameValue(*b)); \ - CHECK(!a->SameValueZero(*b)); \ - b->set_lane(i, -(i + 1)); \ - CHECK(a->BitwiseEquals(*b)); \ - CHECK_EQ(a->Hash(), b->Hash()); \ - CHECK(a->SameValue(*b)); \ - CHECK(a->SameValueZero(*b)); \ - } \ - } - -#define BOOL_TEST(type, lane_count) \ - { \ - bool lanes[lane_count] = {false}; \ - Handle<type> a = factory->New##type(lanes); \ - Handle<type> b = factory->New##type(lanes); \ - CHECK(a->BitwiseEquals(*b)); \ - CHECK(a->SameValue(*b)); \ - CHECK(a->SameValueZero(*b)); \ - CHECK_EQ(a->Hash(), b->Hash()); \ - for (int i = 0; i < lane_count; i++) { \ - a->set_lane(i, true); \ - CHECK(!a->BitwiseEquals(*b)); \ - CHECK_NE(a->Hash(), b->Hash()); \ - CHECK(!a->SameValue(*b)); \ - CHECK(!a->SameValueZero(*b)); \ - b->set_lane(i, true); \ - CHECK(a->BitwiseEquals(*b)); \ - CHECK_EQ(a->Hash(), b->Hash()); \ - CHECK(a->SameValue(*b)); \ - CHECK(a->SameValueZero(*b)); \ - } \ - } - -TEST(SimdTypes) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - Factory* factory = isolate->factory(); - - HandleScope sc(isolate); - - FLOAT_TEST(Float32x4, 4) - INT_TEST(Int32x4, 4, int32_t) - INT_TEST(Uint32x4, 4, uint32_t) - BOOL_TEST(Bool32x4, 4) - INT_TEST(Int16x8, 8, int16_t) - INT_TEST(Uint16x8, 8, uint16_t) - BOOL_TEST(Bool16x8, 8) - INT_TEST(Int8x16, 16, int8_t) - INT_TEST(Uint8x16, 16, uint8_t) - BOOL_TEST(Bool8x16, 16) -} diff --git a/deps/v8/test/cctest/test-simulator-arm.cc b/deps/v8/test/cctest/test-simulator-arm.cc new file mode 100644 index 0000000000..a34837665e --- /dev/null +++ b/deps/v8/test/cctest/test-simulator-arm.cc @@ -0,0 +1,387 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "src/v8.h" +#include "test/cctest/cctest.h" + +#include "src/arm/simulator-arm.h" +#include "src/disassembler.h" +#include "src/factory.h" +#include "src/macro-assembler.h" + +#if defined(USE_SIMULATOR) + +#ifndef V8_TARGET_LITTLE_ENDIAN +#error Expected ARM to be little-endian +#endif + +using namespace v8::base; +using namespace v8::internal; + +// Define these function prototypes to match JSEntryFunction in execution.cc. +typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); +typedef Object* (*F3)(void* p0, int p1, int p2, int p3, int p4); + +#define __ assm. + +struct MemoryAccess { + enum class Kind { + None, + Load, + LoadExcl, + Store, + StoreExcl, + }; + + enum class Size { + Byte, + HalfWord, + Word, + }; + + MemoryAccess() : kind(Kind::None) {} + MemoryAccess(Kind kind, Size size, size_t offset, int value = 0) + : kind(kind), size(size), offset(offset), value(value) {} + + Kind kind; + Size size; + size_t offset; + int value; +}; + +struct TestData { + explicit TestData(int w) : w(w) {} + + union { + int32_t w; + int16_t h; + int8_t b; + }; + int dummy; +}; + +static void AssembleMemoryAccess(Assembler* assembler, MemoryAccess access, + Register dest_reg, Register value_reg, + Register addr_reg) { + Assembler& assm = *assembler; + __ add(addr_reg, r0, Operand(access.offset)); + + switch (access.kind) { + case MemoryAccess::Kind::None: + break; + + case MemoryAccess::Kind::Load: + switch (access.size) { + case MemoryAccess::Size::Byte: + __ ldrb(value_reg, MemOperand(addr_reg)); + break; + + case MemoryAccess::Size::HalfWord: + __ ldrh(value_reg, MemOperand(addr_reg)); + break; + + case MemoryAccess::Size::Word: + __ ldr(value_reg, MemOperand(addr_reg)); + break; + } + break; + + case MemoryAccess::Kind::LoadExcl: + switch (access.size) { + case MemoryAccess::Size::Byte: + __ ldrexb(value_reg, addr_reg); + break; + + case MemoryAccess::Size::HalfWord: + __ ldrexh(value_reg, addr_reg); + break; + + case MemoryAccess::Size::Word: + __ ldrex(value_reg, addr_reg); + break; + } + break; + + case MemoryAccess::Kind::Store: + switch (access.size) { + case MemoryAccess::Size::Byte: + __ mov(value_reg, Operand(access.value)); + __ strb(value_reg, MemOperand(addr_reg)); + break; + + case MemoryAccess::Size::HalfWord: + __ mov(value_reg, Operand(access.value)); + __ strh(value_reg, MemOperand(addr_reg)); + break; + + case MemoryAccess::Size::Word: + __ mov(value_reg, Operand(access.value)); + __ str(value_reg, MemOperand(addr_reg)); + break; + } + break; + + case MemoryAccess::Kind::StoreExcl: + switch (access.size) { + case MemoryAccess::Size::Byte: + __ mov(value_reg, Operand(access.value)); + __ strexb(dest_reg, value_reg, addr_reg); + break; + + case MemoryAccess::Size::HalfWord: + __ mov(value_reg, Operand(access.value)); + __ strexh(dest_reg, value_reg, addr_reg); + break; + + case MemoryAccess::Size::Word: + __ mov(value_reg, Operand(access.value)); + __ strex(dest_reg, value_reg, addr_reg); + break; + } + break; + } +} + +static void AssembleLoadExcl(Assembler* assembler, MemoryAccess access, + Register value_reg, Register addr_reg) { + DCHECK(access.kind == MemoryAccess::Kind::LoadExcl); + AssembleMemoryAccess(assembler, access, no_reg, value_reg, addr_reg); +} + +static void AssembleStoreExcl(Assembler* assembler, MemoryAccess access, + Register dest_reg, Register value_reg, + Register addr_reg) { + DCHECK(access.kind == MemoryAccess::Kind::StoreExcl); + AssembleMemoryAccess(assembler, access, dest_reg, value_reg, addr_reg); +} + +static void TestInvalidateExclusiveAccess( + TestData initial_data, MemoryAccess access1, MemoryAccess access2, + MemoryAccess access3, int expected_res, TestData expected_data) { + Isolate* isolate = CcTest::i_isolate(); + HandleScope scope(isolate); + + Assembler assm(isolate, NULL, 0); + + AssembleLoadExcl(&assm, access1, r1, r1); + AssembleMemoryAccess(&assm, access2, r3, r2, r1); + AssembleStoreExcl(&assm, access3, r0, r3, r1); + + __ mov(pc, Operand(lr)); + + CodeDesc desc; + assm.GetCode(&desc); + Handle<Code> code = isolate->factory()->NewCode( + desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + F3 f = FUNCTION_CAST<F3>(code->entry()); + TestData t = initial_data; + + int res = + reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0)); + CHECK_EQ(expected_res, res); + switch (access3.size) { + case MemoryAccess::Size::Byte: + CHECK_EQ(expected_data.b, t.b); + break; + + case MemoryAccess::Size::HalfWord: + CHECK_EQ(expected_data.h, t.h); + break; + + case MemoryAccess::Size::Word: + CHECK_EQ(expected_data.w, t.w); + break; + } +} + +TEST(simulator_invalidate_exclusive_access) { + using Kind = MemoryAccess::Kind; + using Size = MemoryAccess::Size; + + MemoryAccess ldrex_w(Kind::LoadExcl, Size::Word, offsetof(TestData, w)); + MemoryAccess strex_w(Kind::StoreExcl, Size::Word, offsetof(TestData, w), 7); + + // Address mismatch. + TestInvalidateExclusiveAccess( + TestData(1), ldrex_w, + MemoryAccess(Kind::LoadExcl, Size::Word, offsetof(TestData, dummy)), + strex_w, 1, TestData(1)); + + // Size mismatch. + TestInvalidateExclusiveAccess( + TestData(1), ldrex_w, MemoryAccess(), + MemoryAccess(Kind::StoreExcl, Size::HalfWord, offsetof(TestData, w), 7), + 1, TestData(1)); + + // Load between ldrex/strex. + TestInvalidateExclusiveAccess( + TestData(1), ldrex_w, + MemoryAccess(Kind::Load, Size::Word, offsetof(TestData, dummy)), strex_w, + 1, TestData(1)); + + // Store between ldrex/strex. + TestInvalidateExclusiveAccess( + TestData(1), ldrex_w, + MemoryAccess(Kind::Store, Size::Word, offsetof(TestData, dummy)), strex_w, + 1, TestData(1)); + + // Match + TestInvalidateExclusiveAccess(TestData(1), ldrex_w, MemoryAccess(), strex_w, + 0, TestData(7)); +} + +static int ExecuteMemoryAccess(Isolate* isolate, TestData* test_data, + MemoryAccess access) { + HandleScope scope(isolate); + Assembler assm(isolate, NULL, 0); + AssembleMemoryAccess(&assm, access, r0, r2, r1); + __ bx(lr); + + CodeDesc desc; + assm.GetCode(&desc); + Handle<Code> code = isolate->factory()->NewCode( + desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + F3 f = FUNCTION_CAST<F3>(code->entry()); + + return reinterpret_cast<int>( + CALL_GENERATED_CODE(isolate, f, test_data, 0, 0, 0, 0)); +} + +class MemoryAccessThread : public v8::base::Thread { + public: + MemoryAccessThread() + : Thread(Options("MemoryAccessThread")), + test_data_(NULL), + is_finished_(false), + has_request_(false), + did_request_(false) {} + + virtual void Run() { + v8::Isolate::CreateParams create_params; + create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); + v8::Isolate* isolate = v8::Isolate::New(create_params); + Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); + v8::Isolate::Scope scope(isolate); + + v8::base::LockGuard<v8::base::Mutex> lock_guard(&mutex_); + while (!is_finished_) { + while (!(has_request_ || is_finished_)) { + has_request_cv_.Wait(&mutex_); + } + + if (is_finished_) { + break; + } + + ExecuteMemoryAccess(i_isolate, test_data_, access_); + has_request_ = false; + did_request_ = true; + did_request_cv_.NotifyOne(); + } + } + + void NextAndWait(TestData* test_data, MemoryAccess access) { + DCHECK(!has_request_); + v8::base::LockGuard<v8::base::Mutex> lock_guard(&mutex_); + test_data_ = test_data; + access_ = access; + has_request_ = true; + has_request_cv_.NotifyOne(); + while (!did_request_) { + did_request_cv_.Wait(&mutex_); + } + did_request_ = false; + } + + void Finish() { + v8::base::LockGuard<v8::base::Mutex> lock_guard(&mutex_); + is_finished_ = true; + has_request_cv_.NotifyOne(); + } + + private: + TestData* test_data_; + MemoryAccess access_; + bool is_finished_; + bool has_request_; + bool did_request_; + v8::base::Mutex mutex_; + v8::base::ConditionVariable has_request_cv_; + v8::base::ConditionVariable did_request_cv_; +}; + +TEST(simulator_invalidate_exclusive_access_threaded) { + using Kind = MemoryAccess::Kind; + using Size = MemoryAccess::Size; + + Isolate* isolate = CcTest::i_isolate(); + HandleScope scope(isolate); + + TestData test_data(1); + + MemoryAccessThread thread; + thread.Start(); + + MemoryAccess ldrex_w(Kind::LoadExcl, Size::Word, offsetof(TestData, w)); + MemoryAccess strex_w(Kind::StoreExcl, Size::Word, offsetof(TestData, w), 7); + + // Exclusive store completed by another thread first. + test_data = TestData(1); + thread.NextAndWait(&test_data, MemoryAccess(Kind::LoadExcl, Size::Word, + offsetof(TestData, w))); + ExecuteMemoryAccess(isolate, &test_data, ldrex_w); + thread.NextAndWait(&test_data, MemoryAccess(Kind::StoreExcl, Size::Word, + offsetof(TestData, w), 5)); + CHECK_EQ(1, ExecuteMemoryAccess(isolate, &test_data, strex_w)); + CHECK_EQ(5, test_data.w); + + // Exclusive store completed by another thread; different address, but masked + // to same + test_data = TestData(1); + ExecuteMemoryAccess(isolate, &test_data, ldrex_w); + thread.NextAndWait(&test_data, MemoryAccess(Kind::LoadExcl, Size::Word, + offsetof(TestData, dummy))); + thread.NextAndWait(&test_data, MemoryAccess(Kind::StoreExcl, Size::Word, + offsetof(TestData, dummy), 5)); + CHECK_EQ(1, ExecuteMemoryAccess(isolate, &test_data, strex_w)); + CHECK_EQ(1, test_data.w); + + // Test failure when store between ldrex/strex. + test_data = TestData(1); + ExecuteMemoryAccess(isolate, &test_data, ldrex_w); + thread.NextAndWait(&test_data, MemoryAccess(Kind::Store, Size::Word, + offsetof(TestData, dummy))); + CHECK_EQ(1, ExecuteMemoryAccess(isolate, &test_data, strex_w)); + CHECK_EQ(1, test_data.w); + + thread.Finish(); + thread.Join(); +} + +#undef __ + +#endif // USE_SIMULATOR diff --git a/deps/v8/test/cctest/test-strings.cc b/deps/v8/test/cctest/test-strings.cc index d7b51f8274..e4df339d8b 100644 --- a/deps/v8/test/cctest/test-strings.cc +++ b/deps/v8/test/cctest/test-strings.cc @@ -1195,6 +1195,33 @@ class OneByteVectorResource : public v8::String::ExternalOneByteStringResource { i::Vector<const char> data_; }; +TEST(InternalizeExternal) { + FLAG_thin_strings = true; + CcTest::InitializeVM(); + i::Isolate* isolate = CcTest::i_isolate(); + Factory* factory = isolate->factory(); + // This won't leak; the external string mechanism will call Dispose() on it. + OneByteVectorResource* resource = + new OneByteVectorResource(i::Vector<const char>("prop", 4)); + { + v8::HandleScope scope(CcTest::isolate()); + v8::Local<v8::String> ext_string = + v8::String::NewExternalOneByte(CcTest::isolate(), resource) + .ToLocalChecked(); + Handle<String> string = v8::Utils::OpenHandle(*ext_string); + CHECK(string->IsExternalString()); + CHECK(!string->IsInternalizedString()); + CHECK(isolate->heap()->InNewSpace(*string)); + factory->InternalizeName(string); + CHECK(string->IsThinString()); + CcTest::CollectGarbage(i::NEW_SPACE); + CcTest::CollectGarbage(i::NEW_SPACE); + CHECK(string->IsInternalizedString()); + CHECK(!isolate->heap()->InNewSpace(*string)); + } + CcTest::CollectGarbage(i::OLD_SPACE); + CcTest::CollectGarbage(i::OLD_SPACE); +} TEST(SliceFromExternal) { FLAG_string_slices = true; diff --git a/deps/v8/test/cctest/test-transitions.cc b/deps/v8/test/cctest/test-transitions.cc index 842a6ca47f..a38c6b2aa5 100644 --- a/deps/v8/test/cctest/test-transitions.cc +++ b/deps/v8/test/cctest/test-transitions.cc @@ -38,11 +38,13 @@ TEST(TransitionArray_SimpleFieldTransitions) { Handle<Map> map0 = Map::Create(isolate, 0); Handle<Map> map1 = Map::CopyWithField(map0, name1, handle(FieldType::Any(), isolate), - attributes, Representation::Tagged(), OMIT_TRANSITION) + attributes, kMutable, Representation::Tagged(), + OMIT_TRANSITION) .ToHandleChecked(); Handle<Map> map2 = Map::CopyWithField(map0, name2, handle(FieldType::Any(), isolate), - attributes, Representation::Tagged(), OMIT_TRANSITION) + attributes, kMutable, Representation::Tagged(), + OMIT_TRANSITION) .ToHandleChecked(); CHECK(map0->raw_transitions()->IsSmi()); @@ -89,11 +91,13 @@ TEST(TransitionArray_FullFieldTransitions) { Handle<Map> map0 = Map::Create(isolate, 0); Handle<Map> map1 = Map::CopyWithField(map0, name1, handle(FieldType::Any(), isolate), - attributes, Representation::Tagged(), OMIT_TRANSITION) + attributes, kMutable, Representation::Tagged(), + OMIT_TRANSITION) .ToHandleChecked(); Handle<Map> map2 = Map::CopyWithField(map0, name2, handle(FieldType::Any(), isolate), - attributes, Representation::Tagged(), OMIT_TRANSITION) + attributes, kMutable, Representation::Tagged(), + OMIT_TRANSITION) .ToHandleChecked(); CHECK(map0->raw_transitions()->IsSmi()); @@ -145,10 +149,11 @@ TEST(TransitionArray_DifferentFieldNames) { EmbeddedVector<char, 64> buffer; SNPrintF(buffer, "prop%d", i); Handle<String> name = factory->InternalizeUtf8String(buffer.start()); - Handle<Map> map = Map::CopyWithField( - map0, name, handle(FieldType::Any(), isolate), - attributes, Representation::Tagged(), OMIT_TRANSITION) - .ToHandleChecked(); + Handle<Map> map = + Map::CopyWithField(map0, name, handle(FieldType::Any(), isolate), + attributes, kMutable, Representation::Tagged(), + OMIT_TRANSITION) + .ToHandleChecked(); names[i] = name; maps[i] = map; @@ -194,10 +199,10 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) { for (int i = 0; i < ATTRS_COUNT; i++) { PropertyAttributes attributes = static_cast<PropertyAttributes>(i); - Handle<Map> map = Map::CopyWithField( - map0, name, handle(FieldType::Any(), isolate), - attributes, Representation::Tagged(), OMIT_TRANSITION) - .ToHandleChecked(); + Handle<Map> map = + Map::CopyWithField(map0, name, FieldType::Any(isolate), attributes, + kMutable, Representation::Tagged(), OMIT_TRANSITION) + .ToHandleChecked(); attr_maps[i] = map; TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION); @@ -239,7 +244,7 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) { Handle<String> name = factory->InternalizeUtf8String(buffer.start()); Handle<Map> map = Map::CopyWithField(map0, name, handle(FieldType::Any(), isolate), NONE, - Representation::Tagged(), OMIT_TRANSITION) + kMutable, Representation::Tagged(), OMIT_TRANSITION) .ToHandleChecked(); names[i] = name; maps[i] = map; @@ -256,10 +261,11 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) { for (int i = 0; i < ATTRS_COUNT; i++) { PropertyAttributes attributes = static_cast<PropertyAttributes>(i); - Handle<Map> map = Map::CopyWithField( - map0, name, handle(FieldType::Any(), isolate), - attributes, Representation::Tagged(), OMIT_TRANSITION) - .ToHandleChecked(); + Handle<Map> map = + Map::CopyWithField(map0, name, handle(FieldType::Any(), isolate), + attributes, kMutable, Representation::Tagged(), + OMIT_TRANSITION) + .ToHandleChecked(); attr_maps[i] = map; TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION); diff --git a/deps/v8/test/cctest/test-unboxed-doubles.cc b/deps/v8/test/cctest/test-unboxed-doubles.cc index 582e2757fb..52d0455652 100644 --- a/deps/v8/test/cctest/test-unboxed-doubles.cc +++ b/deps/v8/test/cctest/test-unboxed-doubles.cc @@ -7,13 +7,20 @@ #include "src/v8.h" +#include "src/accessors.h" +#include "src/api.h" #include "src/compilation-cache.h" #include "src/execution.h" #include "src/factory.h" #include "src/field-type.h" #include "src/global-handles.h" +#include "src/heap/incremental-marking.h" +#include "src/heap/spaces.h" #include "src/ic/ic.h" +#include "src/layout-descriptor.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" +#include "src/property.h" #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-utils.h" @@ -70,11 +77,16 @@ static double GetDoubleFieldValue(JSObject* obj, FieldIndex field_index) { } } -const int kNumberOfBits = 32; +void WriteToField(JSObject* object, int descriptor, Object* value) { + DescriptorArray* descriptors = object->map()->instance_descriptors(); + PropertyDetails details = descriptors->GetDetails(descriptor); + object->WriteToField(descriptor, details, value); +} +const int kNumberOfBits = 32; enum TestPropertyKind { - PROP_CONSTANT, + PROP_ACCESSOR_INFO, PROP_SMI, PROP_DOUBLE, PROP_TAGGED, @@ -91,9 +103,6 @@ static Handle<DescriptorArray> CreateDescriptorArray(Isolate* isolate, int kPropsCount) { Factory* factory = isolate->factory(); - Handle<String> func_name = factory->InternalizeUtf8String("func"); - Handle<JSFunction> func = factory->NewFunction(func_name); - Handle<DescriptorArray> descriptors = DescriptorArray::Allocate(isolate, 0, kPropsCount); @@ -105,15 +114,20 @@ static Handle<DescriptorArray> CreateDescriptorArray(Isolate* isolate, TestPropertyKind kind = props[i]; - if (kind == PROP_CONSTANT) { - Descriptor d = Descriptor::DataConstant(name, func, NONE); - descriptors->Append(&d); + Descriptor d; + if (kind == PROP_ACCESSOR_INFO) { + Handle<AccessorInfo> info = + Accessors::MakeAccessor(isolate, name, nullptr, nullptr, NONE); + d = Descriptor::AccessorConstant(name, info, NONE); } else { - Descriptor d = Descriptor::DataField(name, next_field_offset, NONE, - representations[kind]); - next_field_offset += d.GetDetails().field_width_in_words(); - descriptors->Append(&d); + d = Descriptor::DataField(name, next_field_offset, NONE, + representations[kind]); + } + descriptors->Append(&d); + PropertyDetails details = d.GetDetails(); + if (details.location() == kField) { + next_field_offset += details.field_width_in_words(); } } return descriptors; @@ -131,18 +145,18 @@ TEST(LayoutDescriptorBasicFast) { CHECK_EQ(kSmiValueSize, layout_desc->capacity()); for (int i = 0; i < kSmiValueSize + 13; i++) { - CHECK_EQ(true, layout_desc->IsTagged(i)); + CHECK(layout_desc->IsTagged(i)); } - CHECK_EQ(true, layout_desc->IsTagged(-1)); - CHECK_EQ(true, layout_desc->IsTagged(-12347)); - CHECK_EQ(true, layout_desc->IsTagged(15635)); + CHECK(layout_desc->IsTagged(-1)); + CHECK(layout_desc->IsTagged(-12347)); + CHECK(layout_desc->IsTagged(15635)); CHECK(layout_desc->IsFastPointerLayout()); for (int i = 0; i < kSmiValueSize; i++) { layout_desc = layout_desc->SetTaggedForTesting(i, false); - CHECK_EQ(false, layout_desc->IsTagged(i)); + CHECK(!layout_desc->IsTagged(i)); layout_desc = layout_desc->SetTaggedForTesting(i, true); - CHECK_EQ(true, layout_desc->IsTagged(i)); + CHECK(layout_desc->IsTagged(i)); } CHECK(layout_desc->IsFastPointerLayout()); @@ -151,7 +165,7 @@ TEST(LayoutDescriptorBasicFast) { &sequence_length)); CHECK_EQ(std::numeric_limits<int>::max(), sequence_length); - CHECK_EQ(true, layout_desc->IsTagged(0, 7, &sequence_length)); + CHECK(layout_desc->IsTagged(0, 7, &sequence_length)); CHECK_EQ(7, sequence_length); } @@ -197,9 +211,9 @@ TEST(LayoutDescriptorBasicSlow) { CHECK(!layout_descriptor->IsSlowLayout()); CHECK(!layout_descriptor->IsFastPointerLayout()); - CHECK_EQ(false, layout_descriptor->IsTagged(0)); + CHECK(!layout_descriptor->IsTagged(0)); for (int i = 1; i < kPropsCount; i++) { - CHECK_EQ(true, layout_descriptor->IsTagged(i)); + CHECK(layout_descriptor->IsTagged(i)); } InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); } @@ -214,26 +228,26 @@ TEST(LayoutDescriptorBasicSlow) { CHECK(!layout_descriptor->IsFastPointerLayout()); CHECK(layout_descriptor->capacity() > kSmiValueSize); - CHECK_EQ(false, layout_descriptor->IsTagged(0)); - CHECK_EQ(false, layout_descriptor->IsTagged(kPropsCount - 1)); + CHECK(!layout_descriptor->IsTagged(0)); + CHECK(!layout_descriptor->IsTagged(kPropsCount - 1)); for (int i = 1; i < kPropsCount - 1; i++) { - CHECK_EQ(true, layout_descriptor->IsTagged(i)); + CHECK(layout_descriptor->IsTagged(i)); } InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); // Here we have truly slow layout descriptor, so play with the bits. - CHECK_EQ(true, layout_descriptor->IsTagged(-1)); - CHECK_EQ(true, layout_descriptor->IsTagged(-12347)); - CHECK_EQ(true, layout_descriptor->IsTagged(15635)); + CHECK(layout_descriptor->IsTagged(-1)); + CHECK(layout_descriptor->IsTagged(-12347)); + CHECK(layout_descriptor->IsTagged(15635)); LayoutDescriptor* layout_desc = *layout_descriptor; // Play with the bits but leave it in consistent state with map at the end. for (int i = 1; i < kPropsCount - 1; i++) { layout_desc = layout_desc->SetTaggedForTesting(i, false); - CHECK_EQ(false, layout_desc->IsTagged(i)); + CHECK(!layout_desc->IsTagged(i)); layout_desc = layout_desc->SetTaggedForTesting(i, true); - CHECK_EQ(true, layout_desc->IsTagged(i)); + CHECK(layout_desc->IsTagged(i)); } CHECK(layout_desc->IsSlowLayout()); CHECK(!layout_desc->IsFastPointerLayout()); @@ -482,13 +496,13 @@ TEST(LayoutDescriptorCreateNewFast) { Handle<LayoutDescriptor> layout_descriptor; TestPropertyKind props[] = { - PROP_CONSTANT, + PROP_ACCESSOR_INFO, PROP_TAGGED, // field #0 - PROP_CONSTANT, + PROP_ACCESSOR_INFO, PROP_DOUBLE, // field #1 - PROP_CONSTANT, + PROP_ACCESSOR_INFO, PROP_TAGGED, // field #2 - PROP_CONSTANT, + PROP_ACCESSOR_INFO, }; const int kPropsCount = arraysize(props); @@ -514,10 +528,10 @@ TEST(LayoutDescriptorCreateNewFast) { layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); CHECK(!layout_descriptor->IsSlowLayout()); - CHECK_EQ(true, layout_descriptor->IsTagged(0)); - CHECK_EQ(false, layout_descriptor->IsTagged(1)); - CHECK_EQ(true, layout_descriptor->IsTagged(2)); - CHECK_EQ(true, layout_descriptor->IsTagged(125)); + CHECK(layout_descriptor->IsTagged(0)); + CHECK(!layout_descriptor->IsTagged(1)); + CHECK(layout_descriptor->IsTagged(2)); + CHECK(layout_descriptor->IsTagged(125)); InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); } } @@ -557,10 +571,10 @@ TEST(LayoutDescriptorCreateNewSlow) { layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); CHECK(!layout_descriptor->IsSlowLayout()); - CHECK_EQ(true, layout_descriptor->IsTagged(0)); - CHECK_EQ(false, layout_descriptor->IsTagged(1)); - CHECK_EQ(true, layout_descriptor->IsTagged(2)); - CHECK_EQ(true, layout_descriptor->IsTagged(125)); + CHECK(layout_descriptor->IsTagged(0)); + CHECK(!layout_descriptor->IsTagged(1)); + CHECK(layout_descriptor->IsTagged(2)); + CHECK(layout_descriptor->IsTagged(125)); InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); } @@ -577,7 +591,7 @@ TEST(LayoutDescriptorCreateNewSlow) { } // Every property after inobject_properties must be tagged. for (int i = inobject_properties; i < kPropsCount; i++) { - CHECK_EQ(true, layout_descriptor->IsTagged(i)); + CHECK(layout_descriptor->IsTagged(i)); } InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); @@ -610,9 +624,6 @@ static Handle<LayoutDescriptor> TestLayoutDescriptorAppend( int kPropsCount) { Factory* factory = isolate->factory(); - Handle<String> func_name = factory->InternalizeUtf8String("func"); - Handle<JSFunction> func = factory->NewFunction(func_name); - Handle<DescriptorArray> descriptors = DescriptorArray::Allocate(isolate, 0, kPropsCount); @@ -628,20 +639,24 @@ static Handle<LayoutDescriptor> TestLayoutDescriptorAppend( Handle<LayoutDescriptor> layout_descriptor; TestPropertyKind kind = props[i]; - if (kind == PROP_CONSTANT) { - Descriptor d = Descriptor::DataConstant(name, func, NONE); - layout_descriptor = LayoutDescriptor::ShareAppend(map, d.GetDetails()); - descriptors->Append(&d); + Descriptor d; + if (kind == PROP_ACCESSOR_INFO) { + Handle<AccessorInfo> info = + Accessors::MakeAccessor(isolate, name, nullptr, nullptr, NONE); + d = Descriptor::AccessorConstant(name, info, NONE); } else { - Descriptor d = Descriptor::DataField(name, next_field_offset, NONE, - representations[kind]); - int field_width_in_words = d.GetDetails().field_width_in_words(); + d = Descriptor::DataField(name, next_field_offset, NONE, + representations[kind]); + } + PropertyDetails details = d.GetDetails(); + layout_descriptor = LayoutDescriptor::ShareAppend(map, details); + descriptors->Append(&d); + if (details.location() == kField) { + int field_width_in_words = details.field_width_in_words(); next_field_offset += field_width_in_words; - layout_descriptor = LayoutDescriptor::ShareAppend(map, d.GetDetails()); - descriptors->Append(&d); - int field_index = d.GetDetails().field_index(); + int field_index = details.field_index(); bool is_inobject = field_index < map->GetInObjectProperties(); for (int bit = 0; bit < field_width_in_words; bit++) { CHECK_EQ(is_inobject && (kind == PROP_DOUBLE), @@ -920,11 +935,11 @@ TEST(Regress436816) { HeapObject* fake_object = HeapObject::FromAddress(fake_address); CHECK(fake_object->IsHeapObject()); - double boom_value = bit_cast<double>(fake_object); + uint64_t boom_value = bit_cast<uint64_t>(fake_object); for (int i = 0; i < kPropsCount; i++) { FieldIndex index = FieldIndex::ForDescriptor(*map, i); CHECK(map->IsUnboxedDoubleField(index)); - object->RawFastDoublePropertyAtPut(index, boom_value); + object->RawFastDoublePropertyAsBitsAtPut(index, boom_value); } CHECK(object->HasFastProperties()); CHECK(!object->map()->HasFastPointerLayout()); @@ -952,13 +967,14 @@ TEST(DescriptorArrayTrimming) { Handle<FieldType> any_type = FieldType::Any(isolate); Handle<Map> map = Map::Create(isolate, kFieldCount); for (int i = 0; i < kSplitFieldIndex; i++) { - map = Map::CopyWithField(map, MakeName("prop", i), any_type, NONE, - Representation::Smi(), - INSERT_TRANSITION).ToHandleChecked(); + map = Map::CopyWithField(map, MakeName("prop", i), any_type, NONE, kMutable, + Representation::Smi(), INSERT_TRANSITION) + .ToHandleChecked(); } - map = Map::CopyWithField(map, MakeName("dbl", kSplitFieldIndex), any_type, - NONE, Representation::Double(), - INSERT_TRANSITION).ToHandleChecked(); + map = + Map::CopyWithField(map, MakeName("dbl", kSplitFieldIndex), any_type, NONE, + kMutable, Representation::Double(), INSERT_TRANSITION) + .ToHandleChecked(); CHECK(map->layout_descriptor()->IsConsistentWithMap(*map, true)); CHECK(map->layout_descriptor()->IsSlowLayout()); CHECK(map->owns_descriptors()); @@ -971,8 +987,9 @@ TEST(DescriptorArrayTrimming) { Handle<Map> tmp_map = map; for (int i = kSplitFieldIndex + 1; i < kFieldCount; i++) { tmp_map = Map::CopyWithField(tmp_map, MakeName("dbl", i), any_type, NONE, - Representation::Double(), - INSERT_TRANSITION).ToHandleChecked(); + kMutable, Representation::Double(), + INSERT_TRANSITION) + .ToHandleChecked(); CHECK(tmp_map->layout_descriptor()->IsConsistentWithMap(*tmp_map, true)); } // Check that descriptors are shared. @@ -1010,13 +1027,15 @@ TEST(DescriptorArrayTrimming) { Handle<Map> tmp_map = map; for (int i = kSplitFieldIndex + 1; i < kFieldCount - 1; i++) { tmp_map = Map::CopyWithField(tmp_map, MakeName("tagged", i), any_type, - NONE, Representation::Tagged(), - INSERT_TRANSITION).ToHandleChecked(); + NONE, kMutable, Representation::Tagged(), + INSERT_TRANSITION) + .ToHandleChecked(); CHECK(tmp_map->layout_descriptor()->IsConsistentWithMap(*tmp_map, true)); } - tmp_map = Map::CopyWithField(tmp_map, MakeString("dbl"), any_type, NONE, - Representation::Double(), - INSERT_TRANSITION).ToHandleChecked(); + tmp_map = + Map::CopyWithField(tmp_map, MakeString("dbl"), any_type, NONE, kMutable, + Representation::Double(), INSERT_TRANSITION) + .ToHandleChecked(); CHECK(tmp_map->layout_descriptor()->IsConsistentWithMap(*tmp_map, true)); // Check that descriptors are shared. CHECK(tmp_map->owns_descriptors()); @@ -1039,15 +1058,15 @@ TEST(DoScavenge) { Handle<FieldType> any_type = FieldType::Any(isolate); Handle<Map> map = Map::Create(isolate, 10); - map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, - Representation::Double(), - INSERT_TRANSITION).ToHandleChecked(); + map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, kMutable, + Representation::Double(), INSERT_TRANSITION) + .ToHandleChecked(); // Create object in new space. Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); - obj->WriteToField(0, *heap_number); + WriteToField(*obj, 0, *heap_number); { // Ensure the object is properly set up. @@ -1101,12 +1120,12 @@ TEST(DoScavengeWithIncrementalWriteBarrier) { Handle<FieldType> any_type = FieldType::Any(isolate); Handle<Map> map = Map::Create(isolate, 10); - map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, - Representation::Double(), - INSERT_TRANSITION).ToHandleChecked(); - map = Map::CopyWithField(map, MakeName("prop", 1), any_type, NONE, - Representation::Tagged(), - INSERT_TRANSITION).ToHandleChecked(); + map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, kMutable, + Representation::Double(), INSERT_TRANSITION) + .ToHandleChecked(); + map = Map::CopyWithField(map, MakeName("prop", 1), any_type, NONE, kMutable, + Representation::Tagged(), INSERT_TRANSITION) + .ToHandleChecked(); // Create |obj_value| in old space. Handle<HeapObject> obj_value; @@ -1123,8 +1142,8 @@ TEST(DoScavengeWithIncrementalWriteBarrier) { Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); - obj->WriteToField(0, *heap_number); - obj->WriteToField(1, *obj_value); + WriteToField(*obj, 0, *heap_number); + WriteToField(*obj, 1, *obj_value); { // Ensure the object is properly set up. @@ -1218,19 +1237,19 @@ static void TestLayoutDescriptorHelper(Isolate* isolate, if (end_of_region_offset < instance_size) { CHECK_EQ(!expected_tagged, helper.IsTagged(end_of_region_offset)); } else { - CHECK_EQ(true, helper.IsTagged(end_of_region_offset)); + CHECK(helper.IsTagged(end_of_region_offset)); } } for (int offset = 0; offset < JSObject::kHeaderSize; offset += kPointerSize) { // Header queries - CHECK_EQ(true, helper.IsTagged(offset)); + CHECK(helper.IsTagged(offset)); int end_of_region_offset; - CHECK_EQ(true, helper.IsTagged(offset, end_offset, &end_of_region_offset)); + CHECK(helper.IsTagged(offset, end_offset, &end_of_region_offset)); CHECK_EQ(first_non_tagged_field_offset, end_of_region_offset); // Out of bounds queries - CHECK_EQ(true, helper.IsTagged(offset + instance_size)); + CHECK(helper.IsTagged(offset + instance_size)); } CHECK_EQ(all_fields_tagged, helper.all_fields_tagged()); @@ -1329,12 +1348,14 @@ TEST(LayoutDescriptorSharing) { Handle<Map> map = Map::Create(isolate, 64); for (int i = 0; i < 32; i++) { Handle<String> name = MakeName("prop", i); - map = Map::CopyWithField(map, name, any_type, NONE, Representation::Smi(), - INSERT_TRANSITION).ToHandleChecked(); + map = Map::CopyWithField(map, name, any_type, NONE, kMutable, + Representation::Smi(), INSERT_TRANSITION) + .ToHandleChecked(); } - split_map = Map::CopyWithField(map, MakeString("dbl"), any_type, NONE, - Representation::Double(), - INSERT_TRANSITION).ToHandleChecked(); + split_map = + Map::CopyWithField(map, MakeString("dbl"), any_type, NONE, kMutable, + Representation::Double(), INSERT_TRANSITION) + .ToHandleChecked(); } Handle<LayoutDescriptor> split_layout_descriptor( split_map->layout_descriptor(), isolate); @@ -1342,9 +1363,10 @@ TEST(LayoutDescriptorSharing) { CHECK(split_layout_descriptor->IsSlowLayout()); CHECK(split_map->owns_descriptors()); - Handle<Map> map1 = Map::CopyWithField(split_map, MakeString("foo"), any_type, - NONE, Representation::Double(), - INSERT_TRANSITION).ToHandleChecked(); + Handle<Map> map1 = + Map::CopyWithField(split_map, MakeString("foo"), any_type, NONE, kMutable, + Representation::Double(), INSERT_TRANSITION) + .ToHandleChecked(); CHECK(!split_map->owns_descriptors()); CHECK_EQ(*split_layout_descriptor, split_map->layout_descriptor()); @@ -1353,9 +1375,10 @@ TEST(LayoutDescriptorSharing) { CHECK_EQ(*split_layout_descriptor, map1->layout_descriptor()); CHECK(map1->layout_descriptor()->IsConsistentWithMap(*map1, true)); - Handle<Map> map2 = Map::CopyWithField(split_map, MakeString("bar"), any_type, - NONE, Representation::Tagged(), - INSERT_TRANSITION).ToHandleChecked(); + Handle<Map> map2 = + Map::CopyWithField(split_map, MakeString("bar"), any_type, NONE, kMutable, + Representation::Tagged(), INSERT_TRANSITION) + .ToHandleChecked(); // Layout descriptors should not be shared with |split_map|. CHECK(map2->owns_descriptors()); @@ -1406,12 +1429,12 @@ static void TestWriteBarrier(Handle<Map> map, Handle<Map> new_map, JSObject::MigrateToMap(obj, new_map); Address fake_object = reinterpret_cast<Address>(*obj_value) + kPointerSize; - double boom_value = bit_cast<double>(fake_object); + uint64_t boom_value = bit_cast<uint64_t>(fake_object); FieldIndex double_field_index = FieldIndex::ForDescriptor(*new_map, double_descriptor); CHECK(obj->IsUnboxedDoubleField(double_field_index)); - obj->RawFastDoublePropertyAtPut(double_field_index, boom_value); + obj->RawFastDoublePropertyAsBitsAtPut(double_field_index, boom_value); // Trigger GC to evacuate all candidates. CcTest::CollectGarbage(NEW_SPACE); @@ -1421,7 +1444,7 @@ static void TestWriteBarrier(Handle<Map> map, Handle<Map> new_map, FieldIndex::ForDescriptor(*new_map, tagged_descriptor); CHECK_EQ(*obj_value, obj->RawFastPropertyAt(tagged_field_index)); } - CHECK_EQ(boom_value, obj->RawFastDoublePropertyAt(double_field_index)); + CHECK_EQ(boom_value, obj->RawFastDoublePropertyAsBitsAt(double_field_index)); } @@ -1485,12 +1508,12 @@ static void TestIncrementalWriteBarrier(Handle<Map> map, Handle<Map> new_map, // barrier. JSObject::MigrateToMap(obj, new_map); - double boom_value = bit_cast<double>(UINT64_C(0xbaad0176a37c28e1)); + uint64_t boom_value = UINT64_C(0xbaad0176a37c28e1); FieldIndex double_field_index = FieldIndex::ForDescriptor(*new_map, double_descriptor); CHECK(obj->IsUnboxedDoubleField(double_field_index)); - obj->RawFastDoublePropertyAtPut(double_field_index, boom_value); + obj->RawFastDoublePropertyAsBitsAtPut(double_field_index, boom_value); // Trigger GC to evacuate all candidates. CcTest::CollectGarbage(OLD_SPACE); @@ -1503,7 +1526,7 @@ static void TestIncrementalWriteBarrier(Handle<Map> map, Handle<Map> new_map, FieldIndex::ForDescriptor(*new_map, tagged_descriptor); CHECK_EQ(*obj_value, obj->RawFastPropertyAt(tagged_field_index)); } - CHECK_EQ(boom_value, obj->RawFastDoublePropertyAt(double_field_index)); + CHECK_EQ(boom_value, obj->RawFastDoublePropertyAsBitsAt(double_field_index)); } enum OldToWriteBarrierKind { @@ -1525,12 +1548,12 @@ static void TestWriteBarrierObjectShiftFieldsRight( Handle<Map> map = Map::Create(isolate, 10); map = Map::CopyWithConstant(map, MakeName("prop", 0), func, NONE, INSERT_TRANSITION).ToHandleChecked(); - map = Map::CopyWithField(map, MakeName("prop", 1), any_type, NONE, - Representation::Double(), - INSERT_TRANSITION).ToHandleChecked(); - map = Map::CopyWithField(map, MakeName("prop", 2), any_type, NONE, - Representation::Tagged(), - INSERT_TRANSITION).ToHandleChecked(); + map = Map::CopyWithField(map, MakeName("prop", 1), any_type, NONE, kMutable, + Representation::Double(), INSERT_TRANSITION) + .ToHandleChecked(); + map = Map::CopyWithField(map, MakeName("prop", 2), any_type, NONE, kMutable, + Representation::Tagged(), INSERT_TRANSITION) + .ToHandleChecked(); // Shift fields right by turning constant property to a field. Handle<Map> new_map = Map::ReconfigureProperty( diff --git a/deps/v8/test/cctest/test-utils.cc b/deps/v8/test/cctest/test-utils.cc index 463672ccc8..b38bae5ba6 100644 --- a/deps/v8/test/cctest/test-utils.cc +++ b/deps/v8/test/cctest/test-utils.cc @@ -88,11 +88,11 @@ TEST(BitSetComputer) { uint32_t data = 0; data = BoolComputer::encode(data, 1, true); data = BoolComputer::encode(data, 4, true); - CHECK_EQ(true, BoolComputer::decode(data, 1)); - CHECK_EQ(true, BoolComputer::decode(data, 4)); - CHECK_EQ(false, BoolComputer::decode(data, 0)); - CHECK_EQ(false, BoolComputer::decode(data, 2)); - CHECK_EQ(false, BoolComputer::decode(data, 3)); + CHECK(BoolComputer::decode(data, 1)); + CHECK(BoolComputer::decode(data, 4)); + CHECK(!BoolComputer::decode(data, 0)); + CHECK(!BoolComputer::decode(data, 2)); + CHECK(!BoolComputer::decode(data, 3)); // Lets store 2 bits per item with 3000 items and verify the values are // correct. diff --git a/deps/v8/test/cctest/test-weakmaps.cc b/deps/v8/test/cctest/test-weakmaps.cc index d7a624f56a..79edee5577 100644 --- a/deps/v8/test/cctest/test-weakmaps.cc +++ b/deps/v8/test/cctest/test-weakmaps.cc @@ -111,13 +111,10 @@ TEST(Weakness) { 0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); // Make the global reference to the key weak. - { - HandleScope scope(isolate); - std::pair<Handle<Object>*, int> handle_and_id(&key, 1234); - GlobalHandles::MakeWeak( - key.location(), reinterpret_cast<void*>(&handle_and_id), - &WeakPointerCallback, v8::WeakCallbackType::kParameter); - } + std::pair<Handle<Object>*, int> handle_and_id(&key, 1234); + GlobalHandles::MakeWeak( + key.location(), reinterpret_cast<void*>(&handle_and_id), + &WeakPointerCallback, v8::WeakCallbackType::kParameter); CHECK(global_handles->IsWeak(key.location())); CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); diff --git a/deps/v8/test/cctest/test-weaksets.cc b/deps/v8/test/cctest/test-weaksets.cc index c11e32b263..13e3b65886 100644 --- a/deps/v8/test/cctest/test-weaksets.cc +++ b/deps/v8/test/cctest/test-weaksets.cc @@ -110,13 +110,10 @@ TEST(WeakSet_Weakness) { 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); // Make the global reference to the key weak. - { - HandleScope scope(isolate); - std::pair<Handle<Object>*, int> handle_and_id(&key, 1234); - GlobalHandles::MakeWeak( - key.location(), reinterpret_cast<void*>(&handle_and_id), - &WeakPointerCallback, v8::WeakCallbackType::kParameter); - } + std::pair<Handle<Object>*, int> handle_and_id(&key, 1234); + GlobalHandles::MakeWeak( + key.location(), reinterpret_cast<void*>(&handle_and_id), + &WeakPointerCallback, v8::WeakCallbackType::kParameter); CHECK(global_handles->IsWeak(key.location())); CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); diff --git a/deps/v8/test/cctest/unicode-helpers.h b/deps/v8/test/cctest/unicode-helpers.h new file mode 100644 index 0000000000..a09a8cbb3e --- /dev/null +++ b/deps/v8/test/cctest/unicode-helpers.h @@ -0,0 +1,32 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_CCTEST_UNICODE_HELPERS_H_ +#define V8_CCTEST_UNICODE_HELPERS_H_ + +#include "src/unicode.h" + +static int Ucs2CharLength(unibrow::uchar c) { + if (c == unibrow::Utf8::kIncomplete || c == unibrow::Utf8::kBufferEmpty) { + return 0; + } else if (c < 0xffff) { + return 1; + } else { + return 2; + } +} + +static int Utf8LengthHelper(const char* s) { + unibrow::Utf8::Utf8IncrementalBuffer buffer(unibrow::Utf8::kBufferEmpty); + int length = 0; + for (; *s != '\0'; s++) { + unibrow::uchar tmp = unibrow::Utf8::ValueOfIncremental(*s, &buffer); + length += Ucs2CharLength(tmp); + } + unibrow::uchar tmp = unibrow::Utf8::ValueOfIncrementalFinish(&buffer); + length += Ucs2CharLength(tmp); + return length; +} + +#endif // V8_CCTEST_UNICODE_HELPERS_H_ diff --git a/deps/v8/test/cctest/wasm/test-managed.cc b/deps/v8/test/cctest/wasm/test-managed.cc deleted file mode 100644 index 00b1c9bb57..0000000000 --- a/deps/v8/test/cctest/wasm/test-managed.cc +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <stdint.h> -#include <stdlib.h> -#include <string.h> - -#include "src/wasm/managed.h" - -#include "test/cctest/cctest.h" -#include "test/common/wasm/test-signatures.h" - -using namespace v8::base; -using namespace v8::internal; - -class DeleteRecorder { - public: - explicit DeleteRecorder(bool* deleted) : deleted_(deleted) { - *deleted_ = false; - } - ~DeleteRecorder() { *deleted_ = true; } - - private: - bool* deleted_; -}; - -TEST(ManagedCollect) { - Isolate* isolate = CcTest::InitIsolateOnce(); - bool deleted = false; - DeleteRecorder* d = new DeleteRecorder(&deleted); - - { - HandleScope scope(isolate); - auto handle = Managed<DeleteRecorder>::New(isolate, d); - USE(handle); - } - - CcTest::CollectAllAvailableGarbage(); - - CHECK(deleted); -} - -TEST(ManagedCollectNoDelete) { - Isolate* isolate = CcTest::InitIsolateOnce(); - bool deleted = false; - DeleteRecorder* d = new DeleteRecorder(&deleted); - - { - HandleScope scope(isolate); - auto handle = Managed<DeleteRecorder>::New(isolate, d, false); - USE(handle); - } - - CcTest::CollectAllAvailableGarbage(); - - CHECK(!deleted); - delete d; -} diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-64.cc b/deps/v8/test/cctest/wasm/test-run-wasm-64.cc index 4571364980..55e7a00702 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-64.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-64.cc @@ -6,7 +6,9 @@ #include <stdlib.h> #include <string.h> +#include "src/assembler-inl.h" #include "src/base/bits.h" +#include "src/objects-inl.h" #include "src/wasm/wasm-macro-gen.h" #include "test/cctest/cctest.h" @@ -1319,6 +1321,9 @@ WASM_EXEC_TEST(I64ReinterpretF64) { } } +// Do not run this test in a simulator because of signalling NaN issues on ia32. +#ifndef USE_SIMULATOR + WASM_EXEC_TEST(SignallingNanSurvivesI64ReinterpretF64) { REQUIRE(I64ReinterpretF64); WasmRunner<int64_t> r(execution_mode); @@ -1328,6 +1333,7 @@ WASM_EXEC_TEST(SignallingNanSurvivesI64ReinterpretF64) { // This is a signalling nan. CHECK_EQ(0x7ff4000000000000, r.Call()); } +#endif WASM_EXEC_TEST(F64ReinterpretI64) { REQUIRE(F64ReinterpretI64); diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-asmjs.cc b/deps/v8/test/cctest/wasm/test-run-wasm-asmjs.cc index 38430f292c..4f7c9210f9 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-asmjs.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-asmjs.cc @@ -6,6 +6,7 @@ #include <stdlib.h> #include <string.h> +#include "src/assembler-inl.h" #include "src/base/platform/elapsed-timer.h" #include "src/wasm/wasm-macro-gen.h" diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc b/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc index e355b68d19..559180cef9 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc @@ -8,10 +8,9 @@ #include <memory> -#include "src/wasm/wasm-macro-gen.h" - +#include "src/assembler-inl.h" #include "src/wasm/wasm-interpreter.h" - +#include "src/wasm/wasm-macro-gen.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" #include "test/cctest/wasm/wasm-run-utils.h" @@ -219,7 +218,7 @@ TEST(Breakpoint_I32Add) { } TEST(Step_I32Mul) { - static const int kTraceLength = 5; + static const int kTraceLength = 4; byte code[] = {WASM_I32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))}; WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreted); @@ -343,57 +342,59 @@ TEST(GrowMemoryInvalidSize) { TEST(TestPossibleNondeterminism) { { - // F32Div may produced NaN - WasmRunner<float, float, float> r(kExecuteInterpreted); - BUILD(r, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); - r.Call(1048575.5f, 2.5f); + WasmRunner<int32_t, float> r(kExecuteInterpreted); + BUILD(r, WASM_I32_REINTERPRET_F32(WASM_GET_LOCAL(0))); + r.Call(1048575.5f); CHECK(!r.possible_nondeterminism()); - r.Call(0.0f, 0.0f); + r.Call(std::numeric_limits<float>::quiet_NaN()); CHECK(r.possible_nondeterminism()); } { - // F32Sqrt may produced NaN - WasmRunner<float, float> r(kExecuteInterpreted); - BUILD(r, WASM_F32_SQRT(WASM_GET_LOCAL(0))); - r.Call(16.0f); + WasmRunner<int64_t, double> r(kExecuteInterpreted); + BUILD(r, WASM_I64_REINTERPRET_F64(WASM_GET_LOCAL(0))); + r.Call(16.0); CHECK(!r.possible_nondeterminism()); - r.Call(-1048575.5f); + r.Call(std::numeric_limits<double>::quiet_NaN()); CHECK(r.possible_nondeterminism()); } { - // F32Mul may produced NaN - WasmRunner<float, float, float> r(kExecuteInterpreted); - BUILD(r, WASM_F32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); - r.Call(1048575.5f, 2.5f); + WasmRunner<float, float> r(kExecuteInterpreted); + BUILD(r, WASM_F32_COPYSIGN(WASM_F32(42.0f), WASM_GET_LOCAL(0))); + r.Call(16.0f); CHECK(!r.possible_nondeterminism()); - r.Call(std::numeric_limits<float>::infinity(), 0.0f); + r.Call(std::numeric_limits<double>::quiet_NaN()); CHECK(r.possible_nondeterminism()); } { - // F64Div may produced NaN - WasmRunner<double, double, double> r(kExecuteInterpreted); - BUILD(r, WASM_F64_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); - r.Call(1048575.5, 2.5); + WasmRunner<double, double> r(kExecuteInterpreted); + BUILD(r, WASM_F64_COPYSIGN(WASM_F64(42.0), WASM_GET_LOCAL(0))); + r.Call(16.0); CHECK(!r.possible_nondeterminism()); - r.Call(0.0, 0.0); + r.Call(std::numeric_limits<double>::quiet_NaN()); CHECK(r.possible_nondeterminism()); } { - // F64Sqrt may produced NaN - WasmRunner<double, double> r(kExecuteInterpreted); - BUILD(r, WASM_F64_SQRT(WASM_GET_LOCAL(0))); - r.Call(1048575.5); + int32_t index = 16; + WasmRunner<int32_t, float> r(kExecuteInterpreted); + r.module().AddMemory(WasmModule::kPageSize); + BUILD(r, WASM_STORE_MEM(MachineType::Float32(), WASM_I32V(index), + WASM_GET_LOCAL(0)), + WASM_I32V(index)); + r.Call(1345.3456f); CHECK(!r.possible_nondeterminism()); - r.Call(-1048575.5); + r.Call(std::numeric_limits<float>::quiet_NaN()); CHECK(r.possible_nondeterminism()); } { - // F64Mul may produced NaN - WasmRunner<double, double, double> r(kExecuteInterpreted); - BUILD(r, WASM_F64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); - r.Call(1048575.5, 2.5); + int32_t index = 16; + WasmRunner<int32_t, double> r(kExecuteInterpreted); + r.module().AddMemory(WasmModule::kPageSize); + BUILD(r, WASM_STORE_MEM(MachineType::Float64(), WASM_I32V(index), + WASM_GET_LOCAL(0)), + WASM_I32V(index)); + r.Call(1345.3456); CHECK(!r.possible_nondeterminism()); - r.Call(std::numeric_limits<double>::infinity(), 0.0); + r.Call(std::numeric_limits<double>::quiet_NaN()); CHECK(r.possible_nondeterminism()); } } diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-js.cc b/deps/v8/test/cctest/wasm/test-run-wasm-js.cc index ee6b066282..add2b02fd4 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-js.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-js.cc @@ -7,8 +7,8 @@ #include <stdlib.h> #include <string.h> +#include "src/assembler-inl.h" #include "src/wasm/wasm-macro-gen.h" - #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" #include "test/cctest/wasm/wasm-run-utils.h" diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-module.cc b/deps/v8/test/cctest/wasm/test-run-wasm-module.cc index 468dc81159..03ffb7ac65 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-module.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-module.cc @@ -5,6 +5,7 @@ #include <stdlib.h> #include <string.h> +#include "src/objects-inl.h" #include "src/snapshot/code-serializer.h" #include "src/version.h" #include "src/wasm/module-decoder.h" @@ -270,9 +271,9 @@ class WasmSerializationTest { 0); } Handle<JSObject> instance = - WasmModule::Instantiate(current_isolate(), &thrower, module_object, - Handle<JSReceiver>::null(), - Handle<JSArrayBuffer>::null()) + SyncInstantiate(current_isolate(), &thrower, module_object, + Handle<JSReceiver>::null(), + MaybeHandle<JSArrayBuffer>()) .ToHandleChecked(); Handle<Object> params[1] = { Handle<Object>(Smi::FromInt(41), current_isolate())}; @@ -306,14 +307,6 @@ class WasmSerializationTest { } void SetUp() { - WasmModuleBuilder* builder = new (zone()) WasmModuleBuilder(zone()); - TestSignatures sigs; - - WasmFunctionBuilder* f = builder->AddFunction(sigs.i_i()); - byte code[] = {WASM_GET_LOCAL(0), kExprI32Const, 1, kExprI32Add}; - EMIT_CODE_WITH_END(f, code); - f->ExportAs(CStrVector(kFunctionName)); - ZoneBuffer buffer(&zone_); WasmSerializationTest::BuildWireBytes(zone(), &buffer); @@ -325,19 +318,13 @@ class WasmSerializationTest { HandleScope scope(serialization_isolate); testing::SetupIsolateForWasmModule(serialization_isolate); - ModuleResult decoding_result = - DecodeWasmModule(serialization_isolate, buffer.begin(), buffer.end(), - false, kWasmOrigin); - CHECK(!decoding_result.failed()); - - Handle<WasmModuleWrapper> module_wrapper = WasmModuleWrapper::New( - serialization_isolate, const_cast<WasmModule*>(decoding_result.val)); + MaybeHandle<WasmModuleObject> module_object = + SyncCompile(serialization_isolate, &thrower, + ModuleWireBytes(buffer.begin(), buffer.end())); - MaybeHandle<WasmCompiledModule> compiled_module = - decoding_result.val->CompileFunctions( - serialization_isolate, module_wrapper, &thrower, - ModuleWireBytes(buffer.begin(), buffer.end()), - Handle<Script>::null(), Vector<const byte>::empty()); + MaybeHandle<WasmCompiledModule> compiled_module( + module_object.ToHandleChecked()->compiled_module(), + serialization_isolate); CHECK(!compiled_module.is_null()); Handle<JSObject> module_obj = WasmModuleObject::New( serialization_isolate, compiled_module.ToHandleChecked()); @@ -444,10 +431,8 @@ TEST(BlockWasmCodeGen) { CcTest::isolate()->SetAllowCodeGenerationFromStringsCallback(False); ErrorThrower thrower(isolate, "block codegen"); - MaybeHandle<WasmModuleObject> ret = wasm::CreateModuleObjectFromBytes( - isolate, buffer.begin(), buffer.end(), &thrower, - wasm::ModuleOrigin::kWasmOrigin, Handle<v8::internal::Script>::null(), - Vector<const byte>::empty()); + MaybeHandle<WasmModuleObject> ret = wasm::SyncCompile( + isolate, &thrower, ModuleWireBytes(buffer.begin(), buffer.end())); CcTest::isolate()->SetAllowCodeGenerationFromStringsCallback(nullptr); CHECK(ret.is_null()); CHECK(thrower.error()); diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-relocation.cc b/deps/v8/test/cctest/wasm/test-run-wasm-relocation.cc index f34a1a323e..bd3d3ba39f 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-relocation.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-relocation.cc @@ -4,8 +4,9 @@ #include <stdlib.h> +#include "src/assembler-inl.h" +#include "src/objects-inl.h" #include "src/v8.h" - #include "test/cctest/cctest.h" #include "test/cctest/compiler/c-signature.h" #include "test/cctest/wasm/wasm-run-utils.h" diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc b/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc index 9764545d45..42b0a959f5 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/assembler-inl.h" #include "src/wasm/wasm-macro-gen.h" - #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" #include "test/cctest/wasm/wasm-run-utils.h" @@ -18,8 +18,24 @@ namespace { typedef float (*FloatUnOp)(float); typedef float (*FloatBinOp)(float, float); typedef int32_t (*FloatCompareOp)(float, float); +typedef int32_t (*Int32UnOp)(int32_t); typedef int32_t (*Int32BinOp)(int32_t, int32_t); +typedef int32_t (*Int32ShiftOp)(int32_t, int); +typedef int16_t (*Int16UnOp)(int16_t); +typedef int16_t (*Int16BinOp)(int16_t, int16_t); +typedef int16_t (*Int16ShiftOp)(int16_t, int); +typedef int8_t (*Int8UnOp)(int8_t); +typedef int8_t (*Int8BinOp)(int8_t, int8_t); +typedef int8_t (*Int8ShiftOp)(int8_t, int); + +#if V8_TARGET_ARCH_ARM +// Floating point specific value functions, only used by ARM so far. +int32_t Equal(float a, float b) { return a == b ? 1 : 0; } +int32_t NotEqual(float a, float b) { return a != b ? 1 : 0; } +#endif // V8_TARGET_ARCH_ARM + +// Generic expected value functions. template <typename T> T Negate(T a) { return -a; @@ -36,20 +52,160 @@ T Sub(T a, T b) { } template <typename T> -int32_t Equal(T a, T b) { - return a == b ? 0xFFFFFFFF : 0; +T Mul(T a, T b) { + return a * b; } template <typename T> -int32_t NotEqual(T a, T b) { - return a != b ? 0xFFFFFFFF : 0; +T Minimum(T a, T b) { + return a <= b ? a : b; } -#if V8_TARGET_ARCH_ARM -int32_t Equal(float a, float b) { return a == b ? 0xFFFFFFFF : 0; } +template <typename T> +T Maximum(T a, T b) { + return a >= b ? a : b; +} -int32_t NotEqual(float a, float b) { return a != b ? 0xFFFFFFFF : 0; } -#endif // V8_TARGET_ARCH_ARM +template <typename T> +T UnsignedMinimum(T a, T b) { + using UnsignedT = typename std::make_unsigned<T>::type; + return static_cast<UnsignedT>(a) <= static_cast<UnsignedT>(b) ? a : b; +} + +template <typename T> +T UnsignedMaximum(T a, T b) { + using UnsignedT = typename std::make_unsigned<T>::type; + return static_cast<UnsignedT>(a) >= static_cast<UnsignedT>(b) ? a : b; +} + +template <typename T> +T Equal(T a, T b) { + return a == b ? 1 : 0; +} + +template <typename T> +T NotEqual(T a, T b) { + return a != b ? 1 : 0; +} + +template <typename T> +T Greater(T a, T b) { + return a > b ? 1 : 0; +} + +template <typename T> +T GreaterEqual(T a, T b) { + return a >= b ? 1 : 0; +} + +template <typename T> +T Less(T a, T b) { + return a < b ? 1 : 0; +} + +template <typename T> +T LessEqual(T a, T b) { + return a <= b ? 1 : 0; +} + +template <typename T> +T UnsignedGreater(T a, T b) { + using UnsignedT = typename std::make_unsigned<T>::type; + return static_cast<UnsignedT>(a) > static_cast<UnsignedT>(b) ? 1 : 0; +} + +template <typename T> +T UnsignedGreaterEqual(T a, T b) { + using UnsignedT = typename std::make_unsigned<T>::type; + return static_cast<UnsignedT>(a) >= static_cast<UnsignedT>(b) ? 1 : 0; +} + +template <typename T> +T UnsignedLess(T a, T b) { + using UnsignedT = typename std::make_unsigned<T>::type; + return static_cast<UnsignedT>(a) < static_cast<UnsignedT>(b) ? 1 : 0; +} + +template <typename T> +T UnsignedLessEqual(T a, T b) { + using UnsignedT = typename std::make_unsigned<T>::type; + return static_cast<UnsignedT>(a) <= static_cast<UnsignedT>(b) ? 1 : 0; +} + +template <typename T> +T LogicalShiftLeft(T a, int shift) { + return a << shift; +} + +template <typename T> +T LogicalShiftRight(T a, int shift) { + using UnsignedT = typename std::make_unsigned<T>::type; + return static_cast<UnsignedT>(a) >> shift; +} + +template <typename T> +int64_t Widen(T value) { + static_assert(sizeof(int64_t) > sizeof(T), "T must be int32_t or smaller"); + return static_cast<int64_t>(value); +} + +template <typename T> +int64_t UnsignedWiden(T value) { + static_assert(sizeof(int64_t) > sizeof(T), "T must be int32_t or smaller"); + using UnsignedT = typename std::make_unsigned<T>::type; + return static_cast<int64_t>(static_cast<UnsignedT>(value)); +} + +template <typename T> +T Clamp(int64_t value) { + static_assert(sizeof(int64_t) > sizeof(T), "T must be int32_t or smaller"); + int64_t min = static_cast<int64_t>(std::numeric_limits<T>::min()); + int64_t max = static_cast<int64_t>(std::numeric_limits<T>::max()); + int64_t clamped = std::max(min, std::min(max, value)); + return static_cast<T>(clamped); +} + +template <typename T> +T AddSaturate(T a, T b) { + return Clamp<T>(Widen(a) + Widen(b)); +} + +template <typename T> +T SubSaturate(T a, T b) { + return Clamp<T>(Widen(a) - Widen(b)); +} + +template <typename T> +T UnsignedAddSaturate(T a, T b) { + using UnsignedT = typename std::make_unsigned<T>::type; + return Clamp<UnsignedT>(UnsignedWiden(a) + UnsignedWiden(b)); +} + +template <typename T> +T UnsignedSubSaturate(T a, T b) { + using UnsignedT = typename std::make_unsigned<T>::type; + return Clamp<UnsignedT>(UnsignedWiden(a) - UnsignedWiden(b)); +} + +template <typename T> +T And(T a, T b) { + return a & b; +} + +template <typename T> +T Or(T a, T b) { + return a | b; +} + +template <typename T> +T Xor(T a, T b) { + return a ^ b; +} + +template <typename T> +T Not(T a) { + return ~a; +} } // namespace @@ -74,6 +230,44 @@ int32_t NotEqual(float a, float b) { return a != b ? 0xFFFFFFFF : 0; } #define WASM_SIMD_CHECK_SPLAT4(TYPE, value, LANE_TYPE, lv) \ WASM_SIMD_CHECK4(TYPE, value, LANE_TYPE, lv, lv, lv, lv) +#define WASM_SIMD_CHECK8(TYPE, value, LANE_TYPE, lv0, lv1, lv2, lv3, lv4, lv5, \ + lv6, lv7) \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv0, 0) \ + , WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv1, 1), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv2, 2), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv3, 3), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv4, 4), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv5, 5), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv6, 6), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv7, 7) + +#define WASM_SIMD_CHECK_SPLAT8(TYPE, value, LANE_TYPE, lv) \ + WASM_SIMD_CHECK8(TYPE, value, LANE_TYPE, lv, lv, lv, lv, lv, lv, lv, lv) + +#define WASM_SIMD_CHECK16(TYPE, value, LANE_TYPE, lv0, lv1, lv2, lv3, lv4, \ + lv5, lv6, lv7, lv8, lv9, lv10, lv11, lv12, lv13, \ + lv14, lv15) \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv0, 0) \ + , WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv1, 1), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv2, 2), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv3, 3), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv4, 4), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv5, 5), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv6, 6), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv7, 7), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv8, 8), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv9, 9), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv10, 10), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv11, 11), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv12, 12), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv13, 13), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv14, 14), \ + WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv15, 15) + +#define WASM_SIMD_CHECK_SPLAT16(TYPE, value, LANE_TYPE, lv) \ + WASM_SIMD_CHECK16(TYPE, value, LANE_TYPE, lv, lv, lv, lv, lv, lv, lv, lv, \ + lv, lv, lv, lv, lv, lv, lv, lv) + #define WASM_SIMD_CHECK_F32_LANE(TYPE, value, lane_value, lane_index) \ WASM_IF( \ WASM_I32_NE(WASM_I32_REINTERPRET_F32(WASM_GET_LOCAL(lane_value)), \ @@ -90,6 +284,37 @@ int32_t NotEqual(float a, float b) { return a != b ? 0xFFFFFFFF : 0; } #define WASM_SIMD_CHECK_SPLAT4_F32(TYPE, value, lv) \ WASM_SIMD_CHECK4_F32(TYPE, value, lv, lv, lv, lv) +#define TO_BYTE(val) static_cast<byte>(val) +#define WASM_SIMD_OP(op) kSimdPrefix, TO_BYTE(op) +#define WASM_SIMD_SPLAT(Type, x) x, WASM_SIMD_OP(kExpr##Type##Splat) +#define WASM_SIMD_UNOP(op, x) x, WASM_SIMD_OP(op) +#define WASM_SIMD_BINOP(op, x, y) x, y, WASM_SIMD_OP(op) +#define WASM_SIMD_SHIFT_OP(op, shift, x) x, WASM_SIMD_OP(op), TO_BYTE(shift) +#define WASM_SIMD_SELECT(format, x, y, z) \ + x, y, z, WASM_SIMD_OP(kExprS##format##Select) +// Since boolean vectors can't be checked directly, materialize them into +// integer vectors using a Select operation. +#define WASM_SIMD_MATERIALIZE_BOOLS(format, x) \ + x, WASM_SIMD_I##format##_SPLAT(WASM_ONE), \ + WASM_SIMD_I##format##_SPLAT(WASM_ZERO), \ + WASM_SIMD_OP(kExprS##format##Select) + +#define WASM_SIMD_I16x8_SPLAT(x) x, WASM_SIMD_OP(kExprI16x8Splat) +#define WASM_SIMD_I16x8_EXTRACT_LANE(lane, x) \ + x, WASM_SIMD_OP(kExprI16x8ExtractLane), TO_BYTE(lane) +#define WASM_SIMD_I16x8_REPLACE_LANE(lane, x, y) \ + x, y, WASM_SIMD_OP(kExprI16x8ReplaceLane), TO_BYTE(lane) +#define WASM_SIMD_I8x16_SPLAT(x) x, WASM_SIMD_OP(kExprI8x16Splat) +#define WASM_SIMD_I8x16_EXTRACT_LANE(lane, x) \ + x, WASM_SIMD_OP(kExprI8x16ExtractLane), TO_BYTE(lane) +#define WASM_SIMD_I8x16_REPLACE_LANE(lane, x, y) \ + x, y, WASM_SIMD_OP(kExprI8x16ReplaceLane), TO_BYTE(lane) + +#define WASM_SIMD_F32x4_FROM_I32x4(x) x, WASM_SIMD_OP(kExprF32x4SConvertI32x4) +#define WASM_SIMD_F32x4_FROM_U32x4(x) x, WASM_SIMD_OP(kExprF32x4UConvertI32x4) +#define WASM_SIMD_I32x4_FROM_F32x4(x) x, WASM_SIMD_OP(kExprI32x4SConvertF32x4) +#define WASM_SIMD_U32x4_FROM_F32x4(x) x, WASM_SIMD_OP(kExprI32x4UConvertF32x4) + #if V8_TARGET_ARCH_ARM WASM_EXEC_TEST(F32x4Splat) { FLAG_wasm_simd_prototype = true; @@ -154,34 +379,6 @@ WASM_EXEC_TEST(F32x4FromInt32x4) { } } -WASM_EXEC_TEST(S32x4Select) { - FLAG_wasm_simd_prototype = true; - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); - byte val1 = 0; - byte val2 = 1; - byte mask = r.AllocateLocal(kWasmS128); - byte src1 = r.AllocateLocal(kWasmS128); - byte src2 = r.AllocateLocal(kWasmS128); - BUILD(r, - - WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_SPLAT(WASM_ZERO)), - WASM_SET_LOCAL(src1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(val1))), - WASM_SET_LOCAL(src2, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(val2))), - WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_REPLACE_LANE( - 1, WASM_GET_LOCAL(mask), WASM_I32V(-1))), - WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_REPLACE_LANE( - 2, WASM_GET_LOCAL(mask), WASM_I32V(-1))), - WASM_SET_LOCAL(mask, WASM_SIMD_S32x4_SELECT(WASM_GET_LOCAL(mask), - WASM_GET_LOCAL(src1), - WASM_GET_LOCAL(src2))), - WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val2, 0), - WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val1, 1), - WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val1, 2), - WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val2, 3), WASM_ONE); - - CHECK_EQ(1, r.Call(0x1234, 0x5678)); -} - void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op) { FLAG_wasm_simd_prototype = true; WasmRunner<int32_t, float, float> r(kExecuteCompiled); @@ -189,8 +386,7 @@ void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op) { byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), - WASM_SET_LOCAL(simd, - WASM_SIMD_UNOP(simd_op & 0xffu, WASM_GET_LOCAL(simd))), + WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, expected), WASM_ONE); FOR_FLOAT32_INPUTS(i) { @@ -212,9 +408,8 @@ void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) { byte simd1 = r.AllocateLocal(kWasmS128); BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), - WASM_SET_LOCAL(simd1, - WASM_SIMD_BINOP(simd_op & 0xffu, WASM_GET_LOCAL(simd0), - WASM_GET_LOCAL(simd1))), + WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), + WASM_GET_LOCAL(simd1))), WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected), WASM_ONE); FOR_FLOAT32_INPUTS(i) { @@ -245,8 +440,9 @@ void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), WASM_SET_LOCAL(simd1, - WASM_SIMD_BINOP(simd_op & 0xffu, WASM_GET_LOCAL(simd0), - WASM_GET_LOCAL(simd1))), + WASM_SIMD_MATERIALIZE_BOOLS( + 32x4, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), + WASM_GET_LOCAL(simd1)))), WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); FOR_FLOAT32_INPUTS(i) { @@ -317,6 +513,187 @@ WASM_EXEC_TEST(I32x4ReplaceLane) { #if V8_TARGET_ARCH_ARM +WASM_EXEC_TEST(I16x8Splat) { + FLAG_wasm_simd_prototype = true; + + WasmRunner<int32_t, int32_t> r(kExecuteCompiled); + byte lane_val = 0; + byte simd = r.AllocateLocal(kWasmS128); + BUILD(r, + WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(lane_val))), + WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, lane_val), WASM_ONE); + + FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } +} + +WASM_EXEC_TEST(I16x8ReplaceLane) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte old_val = 0; + byte new_val = 1; + byte simd = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(old_val))), + WASM_SET_LOCAL(simd, + WASM_SIMD_I16x8_REPLACE_LANE(0, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, old_val, old_val, old_val, + old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I16x8_REPLACE_LANE(1, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, old_val, old_val, + old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I16x8_REPLACE_LANE(2, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, old_val, + old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I16x8_REPLACE_LANE(3, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val, + old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I16x8_REPLACE_LANE(4, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val, + new_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I16x8_REPLACE_LANE(5, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I16x8_REPLACE_LANE(6, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I16x8_REPLACE_LANE(7, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, new_val), WASM_ONE); + + CHECK_EQ(1, r.Call(1, 2)); +} + +WASM_EXEC_TEST(I8x16Splat) { + FLAG_wasm_simd_prototype = true; + + WasmRunner<int32_t, int32_t> r(kExecuteCompiled); + byte lane_val = 0; + byte simd = r.AllocateLocal(kWasmS128); + BUILD(r, + WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))), + WASM_SIMD_CHECK_SPLAT8(I8x16, simd, I32, lane_val), WASM_ONE); + + FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } +} + +WASM_EXEC_TEST(I8x16ReplaceLane) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte old_val = 0; + byte new_val = 1; + byte simd = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(old_val))), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(0, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, old_val, old_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(1, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, old_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(2, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(3, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + old_val, old_val, old_val, old_val, old_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(4, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + new_val, old_val, old_val, old_val, old_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(5, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, old_val, old_val, old_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(6, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, old_val, old_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(7, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, new_val, old_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(8, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, new_val, new_val, old_val, + old_val, old_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(9, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, new_val, new_val, new_val, + old_val, old_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(10, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, new_val, new_val, new_val, + new_val, old_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(11, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, new_val, new_val, new_val, + new_val, new_val, old_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(12, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, old_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(13, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, new_val, old_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(14, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, new_val, new_val, new_val, + new_val, new_val, new_val, new_val, new_val, old_val), + WASM_SET_LOCAL(simd, + WASM_SIMD_I8x16_REPLACE_LANE(15, WASM_GET_LOCAL(simd), + WASM_GET_LOCAL(new_val))), + WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, new_val), WASM_ONE); + + CHECK_EQ(1, r.Call(1, 2)); +} + // Determines if conversion from float to int will be valid. bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) { const double max_uint = static_cast<double>(0xffffffffu); @@ -380,6 +757,23 @@ WASM_EXEC_TEST(I32x4FromFloat32x4) { CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value)); } } + +void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte a = 0; + byte expected = 1; + byte simd = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), + WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), + WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); + + FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } +} + +WASM_EXEC_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); } + +WASM_EXEC_TEST(S128Not) { RunI32x4UnOpTest(kExprS128Not, Not); } #endif // V8_TARGET_ARCH_ARM void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { @@ -392,9 +786,8 @@ void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { byte simd1 = r.AllocateLocal(kWasmS128); BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), - WASM_SET_LOCAL(simd1, - WASM_SIMD_BINOP(simd_op & 0xffu, WASM_GET_LOCAL(simd0), - WASM_GET_LOCAL(simd1))), + WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), + WASM_GET_LOCAL(simd1))), WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); FOR_INT32_INPUTS(i) { @@ -407,7 +800,438 @@ WASM_EXEC_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); } WASM_EXEC_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } #if V8_TARGET_ARCH_ARM -WASM_EXEC_TEST(I32x4Equal) { RunI32x4BinOpTest(kExprI32x4Eq, Equal); } +WASM_EXEC_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); } + +WASM_EXEC_TEST(I32x4Min) { RunI32x4BinOpTest(kExprI32x4MinS, Minimum); } + +WASM_EXEC_TEST(I32x4Max) { RunI32x4BinOpTest(kExprI32x4MaxS, Maximum); } + +WASM_EXEC_TEST(Ui32x4Min) { + RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum); +} + +WASM_EXEC_TEST(Ui32x4Max) { + RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum); +} + +WASM_EXEC_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); } + +WASM_EXEC_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); } + +WASM_EXEC_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); } + +void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte a = 0; + byte b = 1; + byte expected = 2; + byte simd0 = r.AllocateLocal(kWasmS128); + byte simd1 = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), + WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), + WASM_SET_LOCAL(simd1, + WASM_SIMD_MATERIALIZE_BOOLS( + 32x4, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), + WASM_GET_LOCAL(simd1)))), + WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); + + FOR_INT32_INPUTS(i) { + FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } + } +} + +WASM_EXEC_TEST(I32x4Equal) { RunI32x4CompareOpTest(kExprI32x4Eq, Equal); } + +WASM_EXEC_TEST(I32x4NotEqual) { RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual); } + +WASM_EXEC_TEST(I32x4Greater) { RunI32x4CompareOpTest(kExprI32x4GtS, Greater); } + +WASM_EXEC_TEST(I32x4GreaterEqual) { + RunI32x4CompareOpTest(kExprI32x4GeS, GreaterEqual); +} + +WASM_EXEC_TEST(I32x4Less) { RunI32x4CompareOpTest(kExprI32x4LtS, Less); } + +WASM_EXEC_TEST(I32x4LessEqual) { + RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual); +} + +WASM_EXEC_TEST(Ui32x4Greater) { + RunI32x4CompareOpTest(kExprI32x4GtU, UnsignedGreater); +} + +WASM_EXEC_TEST(Ui32x4GreaterEqual) { + RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual); +} + +WASM_EXEC_TEST(Ui32x4Less) { + RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess); +} + +WASM_EXEC_TEST(Ui32x4LessEqual) { + RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual); +} + +void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, + int shift) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte a = 0; + byte expected = 1; + byte simd = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), + WASM_SET_LOCAL( + simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), + WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); + + FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } +} + +WASM_EXEC_TEST(I32x4Shl) { + RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1); +} + +WASM_EXEC_TEST(I32x4ShrS) { + RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1); +} + +WASM_EXEC_TEST(I32x4ShrU) { + RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1); +} + +void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte a = 0; + byte expected = 1; + byte simd = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), + WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), + WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); + + FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } +} + +WASM_EXEC_TEST(I16x8Neg) { RunI16x8UnOpTest(kExprI16x8Neg, Negate); } + +void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte a = 0; + byte b = 1; + byte expected = 2; + byte simd0 = r.AllocateLocal(kWasmS128); + byte simd1 = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), + WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))), + WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), + WASM_GET_LOCAL(simd1))), + WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE); + + FOR_INT16_INPUTS(i) { + FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } + } +} + +WASM_EXEC_TEST(I16x8Add) { RunI16x8BinOpTest(kExprI16x8Add, Add); } + +WASM_EXEC_TEST(I16x8AddSaturate) { + RunI16x8BinOpTest(kExprI16x8AddSaturateS, AddSaturate); +} + +WASM_EXEC_TEST(I16x8Sub) { RunI16x8BinOpTest(kExprI16x8Sub, Sub); } + +WASM_EXEC_TEST(I16x8SubSaturate) { + RunI16x8BinOpTest(kExprI16x8SubSaturateS, SubSaturate); +} + +WASM_EXEC_TEST(I16x8Mul) { RunI16x8BinOpTest(kExprI16x8Mul, Mul); } + +WASM_EXEC_TEST(I16x8Min) { RunI16x8BinOpTest(kExprI16x8MinS, Minimum); } + +WASM_EXEC_TEST(I16x8Max) { RunI16x8BinOpTest(kExprI16x8MaxS, Maximum); } + +WASM_EXEC_TEST(Ui16x8AddSaturate) { + RunI16x8BinOpTest(kExprI16x8AddSaturateU, UnsignedAddSaturate); +} + +WASM_EXEC_TEST(Ui16x8SubSaturate) { + RunI16x8BinOpTest(kExprI16x8SubSaturateU, UnsignedSubSaturate); +} + +WASM_EXEC_TEST(Ui16x8Min) { + RunI16x8BinOpTest(kExprI16x8MinU, UnsignedMinimum); +} + +WASM_EXEC_TEST(Ui16x8Max) { + RunI16x8BinOpTest(kExprI16x8MaxU, UnsignedMaximum); +} + +void RunI16x8CompareOpTest(WasmOpcode simd_op, Int16BinOp expected_op) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte a = 0; + byte b = 1; + byte expected = 2; + byte simd0 = r.AllocateLocal(kWasmS128); + byte simd1 = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), + WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))), + WASM_SET_LOCAL(simd1, + WASM_SIMD_MATERIALIZE_BOOLS( + 16x8, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), + WASM_GET_LOCAL(simd1)))), + WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE); + + FOR_INT16_INPUTS(i) { + FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } + } +} + +WASM_EXEC_TEST(I16x8Equal) { RunI16x8CompareOpTest(kExprI16x8Eq, Equal); } + +WASM_EXEC_TEST(I16x8NotEqual) { RunI16x8CompareOpTest(kExprI16x8Ne, NotEqual); } + +WASM_EXEC_TEST(I16x8Greater) { RunI16x8CompareOpTest(kExprI16x8GtS, Greater); } + +WASM_EXEC_TEST(I16x8GreaterEqual) { + RunI16x8CompareOpTest(kExprI16x8GeS, GreaterEqual); +} + +WASM_EXEC_TEST(I16x8Less) { RunI16x8CompareOpTest(kExprI16x8LtS, Less); } + +WASM_EXEC_TEST(I16x8LessEqual) { + RunI16x8CompareOpTest(kExprI16x8LeS, LessEqual); +} + +WASM_EXEC_TEST(Ui16x8Greater) { + RunI16x8CompareOpTest(kExprI16x8GtU, UnsignedGreater); +} + +WASM_EXEC_TEST(Ui16x8GreaterEqual) { + RunI16x8CompareOpTest(kExprI16x8GeU, UnsignedGreaterEqual); +} + +WASM_EXEC_TEST(Ui16x8Less) { + RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess); +} + +WASM_EXEC_TEST(Ui16x8LessEqual) { + RunI16x8CompareOpTest(kExprI16x8LeU, UnsignedLessEqual); +} + +void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op, + int shift) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte a = 0; + byte expected = 1; + byte simd = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), + WASM_SET_LOCAL( + simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), + WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); + + FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } +} + +WASM_EXEC_TEST(I16x8Shl) { + RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1); +} + +WASM_EXEC_TEST(I16x8ShrS) { + RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1); +} + +WASM_EXEC_TEST(I16x8ShrU) { + RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1); +} + +void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte a = 0; + byte expected = 1; + byte simd = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), + WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), + WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE); + + FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } +} + +WASM_EXEC_TEST(I8x16Neg) { RunI8x16UnOpTest(kExprI8x16Neg, Negate); } + +void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte a = 0; + byte b = 1; + byte expected = 2; + byte simd0 = r.AllocateLocal(kWasmS128); + byte simd1 = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), + WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))), + WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), + WASM_GET_LOCAL(simd1))), + WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE); + + FOR_INT8_INPUTS(i) { + FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } + } +} + +WASM_EXEC_TEST(I8x16Add) { RunI8x16BinOpTest(kExprI8x16Add, Add); } + +WASM_EXEC_TEST(I8x16AddSaturate) { + RunI8x16BinOpTest(kExprI8x16AddSaturateS, AddSaturate); +} + +WASM_EXEC_TEST(I8x16Sub) { RunI8x16BinOpTest(kExprI8x16Sub, Sub); } + +WASM_EXEC_TEST(I8x16SubSaturate) { + RunI8x16BinOpTest(kExprI8x16SubSaturateS, SubSaturate); +} + +WASM_EXEC_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); } + +WASM_EXEC_TEST(I8x16Min) { RunI8x16BinOpTest(kExprI8x16MinS, Minimum); } + +WASM_EXEC_TEST(I8x16Max) { RunI8x16BinOpTest(kExprI8x16MaxS, Maximum); } + +WASM_EXEC_TEST(Ui8x16AddSaturate) { + RunI8x16BinOpTest(kExprI8x16AddSaturateU, UnsignedAddSaturate); +} + +WASM_EXEC_TEST(Ui8x16SubSaturate) { + RunI8x16BinOpTest(kExprI8x16SubSaturateU, UnsignedSubSaturate); +} + +WASM_EXEC_TEST(Ui8x16Min) { + RunI8x16BinOpTest(kExprI8x16MinU, UnsignedMinimum); +} + +WASM_EXEC_TEST(Ui8x16Max) { + RunI8x16BinOpTest(kExprI8x16MaxU, UnsignedMaximum); +} + +void RunI8x16CompareOpTest(WasmOpcode simd_op, Int8BinOp expected_op) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte a = 0; + byte b = 1; + byte expected = 2; + byte simd0 = r.AllocateLocal(kWasmS128); + byte simd1 = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), + WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))), + WASM_SET_LOCAL(simd1, + WASM_SIMD_MATERIALIZE_BOOLS( + 8x16, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), + WASM_GET_LOCAL(simd1)))), + WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE); + + FOR_INT8_INPUTS(i) { + FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } + } +} + +WASM_EXEC_TEST(I8x16Equal) { RunI8x16CompareOpTest(kExprI8x16Eq, Equal); } + +WASM_EXEC_TEST(I8x16NotEqual) { RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual); } + +WASM_EXEC_TEST(I8x16Greater) { RunI8x16CompareOpTest(kExprI8x16GtS, Greater); } + +WASM_EXEC_TEST(I8x16GreaterEqual) { + RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual); +} + +WASM_EXEC_TEST(I8x16Less) { RunI8x16CompareOpTest(kExprI8x16LtS, Less); } + +WASM_EXEC_TEST(I8x16LessEqual) { + RunI8x16CompareOpTest(kExprI8x16LeS, LessEqual); +} + +WASM_EXEC_TEST(Ui8x16Greater) { + RunI8x16CompareOpTest(kExprI8x16GtU, UnsignedGreater); +} + +WASM_EXEC_TEST(Ui8x16GreaterEqual) { + RunI8x16CompareOpTest(kExprI8x16GeU, UnsignedGreaterEqual); +} + +WASM_EXEC_TEST(Ui8x16Less) { + RunI8x16CompareOpTest(kExprI8x16LtU, UnsignedLess); +} + +WASM_EXEC_TEST(Ui8x16LessEqual) { + RunI8x16CompareOpTest(kExprI8x16LeU, UnsignedLessEqual); +} + +void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op, + int shift) { + FLAG_wasm_simd_prototype = true; + WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); + byte a = 0; + byte expected = 1; + byte simd = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), + WASM_SET_LOCAL( + simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), + WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE); + + FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } +} + +WASM_EXEC_TEST(I8x16Shl) { + RunI8x16ShiftOpTest(kExprI8x16Shl, LogicalShiftLeft, 1); +} + +WASM_EXEC_TEST(I8x16ShrS) { + RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1); +} + +WASM_EXEC_TEST(I8x16ShrU) { + RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1); +} + +// Test Select by making a mask where the first two lanes are true and the rest +// false, and comparing for non-equality with zero to materialize a bool vector. +#define WASM_SIMD_SELECT_TEST(format) \ + WASM_EXEC_TEST(S##format##Select) { \ + FLAG_wasm_simd_prototype = true; \ + WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \ + byte val1 = 0; \ + byte val2 = 1; \ + byte src1 = r.AllocateLocal(kWasmS128); \ + byte src2 = r.AllocateLocal(kWasmS128); \ + byte zero = r.AllocateLocal(kWasmS128); \ + byte mask = r.AllocateLocal(kWasmS128); \ + BUILD(r, WASM_SET_LOCAL( \ + src1, WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \ + WASM_SET_LOCAL(src2, \ + WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val2))), \ + WASM_SET_LOCAL(zero, WASM_SIMD_I##format##_SPLAT(WASM_ZERO)), \ + WASM_SET_LOCAL(mask, WASM_SIMD_I##format##_REPLACE_LANE( \ + 1, WASM_GET_LOCAL(zero), WASM_I32V(-1))), \ + WASM_SET_LOCAL(mask, WASM_SIMD_I##format##_REPLACE_LANE( \ + 2, WASM_GET_LOCAL(mask), WASM_I32V(-1))), \ + WASM_SET_LOCAL( \ + mask, \ + WASM_SIMD_SELECT(format, WASM_SIMD_BINOP(kExprI##format##Ne, \ + WASM_GET_LOCAL(mask), \ + WASM_GET_LOCAL(zero)), \ + WASM_GET_LOCAL(src1), WASM_GET_LOCAL(src2))), \ + WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 0), \ + WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 1), \ + WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 2), \ + WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 3), WASM_ONE); \ + \ + CHECK_EQ(1, r.Call(0x12, 0x34)); \ + } -WASM_EXEC_TEST(I32x4NotEqual) { RunI32x4BinOpTest(kExprI32x4Ne, NotEqual); } +WASM_SIMD_SELECT_TEST(32x4) +WASM_SIMD_SELECT_TEST(16x8) +WASM_SIMD_SELECT_TEST(8x16) #endif // V8_TARGET_ARCH_ARM diff --git a/deps/v8/test/cctest/wasm/test-run-wasm.cc b/deps/v8/test/cctest/wasm/test-run-wasm.cc index 05370b5775..38af9d500f 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm.cc @@ -6,10 +6,10 @@ #include <stdlib.h> #include <string.h> +#include "src/assembler-inl.h" #include "src/base/platform/elapsed-timer.h" #include "src/utils.h" #include "src/wasm/wasm-macro-gen.h" - #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" #include "test/cctest/wasm/wasm-run-utils.h" @@ -1047,6 +1047,9 @@ WASM_EXEC_TEST(I32ReinterpretF32) { } } +// Do not run this test in a simulator because of signalling NaN issues on ia32. +#ifndef USE_SIMULATOR + WASM_EXEC_TEST(SignallingNanSurvivesI32ReinterpretF32) { WasmRunner<int32_t> r(execution_mode); @@ -1057,6 +1060,8 @@ WASM_EXEC_TEST(SignallingNanSurvivesI32ReinterpretF32) { CHECK_EQ(0x7fa00000, r.Call()); } +#endif + WASM_EXEC_TEST_WITH_TRAP(LoadMaxUint32Offset) { WasmRunner<int32_t> r(execution_mode); r.module().AddMemoryElems<int32_t>(8); diff --git a/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc b/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc index d2374a44c0..78e949b085 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc @@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/assembler-inl.h" #include "src/debug/debug-interface.h" +#include "src/frames-inl.h" +#include "src/property-descriptor.h" +#include "src/utils.h" #include "src/wasm/wasm-macro-gen.h" #include "src/wasm/wasm-objects.h" @@ -50,21 +54,236 @@ void CheckLocationsFail(WasmCompiledModule *compiled_module, CHECK(!success); } +class BreakHandler { + public: + enum Action { + Continue = StepAction::LastStepAction + 1, + StepNext = StepAction::StepNext, + StepIn = StepAction::StepIn, + StepOut = StepAction::StepOut + }; + struct BreakPoint { + int position; + Action action; + BreakPoint(int position, Action action) + : position(position), action(action) {} + }; + + explicit BreakHandler(Isolate* isolate, + std::initializer_list<BreakPoint> expected_breaks) + : isolate_(isolate), expected_breaks_(expected_breaks) { + current_handler = this; + v8::Debug::SetDebugEventListener(reinterpret_cast<v8::Isolate*>(isolate), + DebugEventListener); + } + ~BreakHandler() { + // Check that all expected breakpoints have been hit. + CHECK_EQ(count_, expected_breaks_.size()); + // BreakHandlers must be correctly stacked. + CHECK_EQ(this, current_handler); + current_handler = nullptr; + v8::Debug::SetDebugEventListener(reinterpret_cast<v8::Isolate*>(isolate_), + nullptr); + } + + int count() const { return count_; } + + private: + Isolate* isolate_; + int count_ = 0; + std::vector<BreakPoint> expected_breaks_; + + static BreakHandler* current_handler; + + void HandleBreak() { + printf("Break #%d\n", count_); + CHECK_GT(expected_breaks_.size(), count_); + + // Check the current position. + StackTraceFrameIterator frame_it(isolate_); + auto summ = FrameSummary::GetTop(frame_it.frame()).AsWasmInterpreted(); + CHECK_EQ(expected_breaks_[count_].position, summ.byte_offset()); + + Action next_action = expected_breaks_[count_].action; + switch (next_action) { + case Continue: + break; + case StepNext: + case StepIn: + case StepOut: + isolate_->debug()->PrepareStep(static_cast<StepAction>(next_action)); + break; + default: + UNREACHABLE(); + } + ++count_; + } + + static void DebugEventListener(const v8::Debug::EventDetails& event_details) { + if (event_details.GetEvent() != v8::DebugEvent::Break) return; + + CHECK_NOT_NULL(current_handler); + current_handler->HandleBreak(); + } +}; + +// static +BreakHandler* BreakHandler::current_handler = nullptr; + +Handle<JSObject> MakeFakeBreakpoint(Isolate* isolate, int position) { + Handle<JSObject> obj = + isolate->factory()->NewJSObject(isolate->object_function()); + // Generate an "isTriggered" method that always returns true. + // This can/must be refactored once we remove remaining JS parts from the + // debugger (bug 5530). + Handle<String> source = isolate->factory()->NewStringFromStaticChars("true"); + Handle<Context> context(isolate->context(), isolate); + Handle<JSFunction> triggered_fun = + Compiler::GetFunctionFromString(context, source, NO_PARSE_RESTRICTION, + kNoSourcePosition) + .ToHandleChecked(); + PropertyDescriptor desc; + desc.set_value(triggered_fun); + Handle<String> name = + isolate->factory()->InternalizeUtf8String(CStrVector("isTriggered")); + CHECK( + JSObject::DefineOwnProperty(isolate, obj, name, &desc, Object::DONT_THROW) + .FromMaybe(false)); + return obj; +} + +void SetBreakpoint(WasmRunnerBase& runner, int function_index, int byte_offset, + int expected_set_byte_offset = -1) { + int func_offset = + runner.module().module->functions[function_index].code_start_offset; + int code_offset = func_offset + byte_offset; + if (expected_set_byte_offset == -1) expected_set_byte_offset = byte_offset; + Handle<WasmInstanceObject> instance = runner.module().instance_object(); + Handle<WasmCompiledModule> compiled_module(instance->compiled_module()); + Handle<JSObject> fake_breakpoint_object = + MakeFakeBreakpoint(runner.main_isolate(), code_offset); + CHECK(WasmCompiledModule::SetBreakPoint(compiled_module, &code_offset, + fake_breakpoint_object)); + int set_byte_offset = code_offset - func_offset; + CHECK_EQ(expected_set_byte_offset, set_byte_offset); + // Also set breakpoint on the debug info of the instance directly, since the + // instance chain is not setup properly in tests. + Handle<WasmDebugInfo> debug_info = + WasmInstanceObject::GetOrCreateDebugInfo(instance); + WasmDebugInfo::SetBreakpoint(debug_info, function_index, set_byte_offset); +} + } // namespace -TEST(CollectPossibleBreakpoints) { +TEST(WasmCollectPossibleBreakpoints) { WasmRunner<int> runner(kExecuteCompiled); BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_ZERO, WASM_ONE)); Handle<WasmInstanceObject> instance = runner.module().instance_object(); std::vector<debug::Location> locations; + // Check all locations for function 0. CheckLocations(instance->compiled_module(), {0, 0}, {1, 0}, {{0, 1}, {0, 2}, {0, 4}, {0, 6}, {0, 7}}); + // Check a range ending at an instruction. CheckLocations(instance->compiled_module(), {0, 2}, {0, 4}, {{0, 2}}); + // Check a range ending one behind an instruction. CheckLocations(instance->compiled_module(), {0, 2}, {0, 5}, {{0, 2}, {0, 4}}); + // Check a range starting at an instruction. CheckLocations(instance->compiled_module(), {0, 7}, {0, 8}, {{0, 7}}); + // Check from an instruction to beginning of next function. CheckLocations(instance->compiled_module(), {0, 7}, {1, 0}, {{0, 7}}); + // Check from end of one function (no valid instruction position) to beginning + // of next function. Must be empty, but not fail. CheckLocations(instance->compiled_module(), {0, 8}, {1, 0}, {}); + // Check from one after the end of the function. Must fail. CheckLocationsFail(instance->compiled_module(), {0, 9}, {1, 0}); } + +TEST(WasmSimpleBreak) { + WasmRunner<int> runner(kExecuteCompiled); + Isolate* isolate = runner.main_isolate(); + + BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3))); + + Handle<JSFunction> main_fun_wrapper = + runner.module().WrapCode(runner.function_index()); + SetBreakpoint(runner, runner.function_index(), 4, 4); + + BreakHandler count_breaks(isolate, {{4, BreakHandler::Continue}}); + + Handle<Object> global(isolate->context()->global_object(), isolate); + MaybeHandle<Object> retval = + Execution::Call(isolate, main_fun_wrapper, global, 0, nullptr); + CHECK(!retval.is_null()); + int result; + CHECK(retval.ToHandleChecked()->ToInt32(&result)); + CHECK_EQ(14, result); +} + +TEST(WasmSimpleStepping) { + WasmRunner<int> runner(kExecuteCompiled); + BUILD(runner, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3))); + + Isolate* isolate = runner.main_isolate(); + Handle<JSFunction> main_fun_wrapper = + runner.module().WrapCode(runner.function_index()); + + // Set breakpoint at the first I32Const. + SetBreakpoint(runner, runner.function_index(), 1, 1); + + BreakHandler count_breaks(isolate, + { + {1, BreakHandler::StepNext}, // I32Const + {3, BreakHandler::StepNext}, // I32Const + {5, BreakHandler::Continue} // I32Add + }); + + Handle<Object> global(isolate->context()->global_object(), isolate); + MaybeHandle<Object> retval = + Execution::Call(isolate, main_fun_wrapper, global, 0, nullptr); + CHECK(!retval.is_null()); + int result; + CHECK(retval.ToHandleChecked()->ToInt32(&result)); + CHECK_EQ(14, result); +} + +TEST(WasmStepInAndOut) { + WasmRunner<int, int> runner(kExecuteCompiled); + WasmFunctionCompiler& f2 = runner.NewFunction<void>(); + f2.AllocateLocal(ValueType::kWord32); + + // Call f2 via indirect call, because a direct call requires f2 to exist when + // we compile main, but we need to compile main first so that the order of + // functions in the code section matches the function indexes. + + // return arg0 + BUILD(runner, WASM_RETURN1(WASM_GET_LOCAL(0))); + // for (int i = 0; i < 10; ++i) { f2(i); } + BUILD(f2, WASM_LOOP( + WASM_BR_IF(0, WASM_BINOP(kExprI32GeU, WASM_GET_LOCAL(0), + WASM_I32V_1(10))), + WASM_SET_LOCAL( + 0, WASM_BINOP(kExprI32Sub, WASM_GET_LOCAL(0), WASM_ONE)), + WASM_CALL_FUNCTION(runner.function_index(), WASM_GET_LOCAL(0)), + WASM_DROP, WASM_BR(1))); + + Isolate* isolate = runner.main_isolate(); + Handle<JSFunction> main_fun_wrapper = + runner.module().WrapCode(f2.function_index()); + + // Set first breakpoint on the GetLocal (offset 19) before the Call. + SetBreakpoint(runner, f2.function_index(), 19, 19); + + BreakHandler count_breaks(isolate, + { + {19, BreakHandler::StepIn}, // GetLocal + {21, BreakHandler::StepIn}, // Call + {1, BreakHandler::StepOut}, // in f2 + {23, BreakHandler::Continue} // After Call + }); + + Handle<Object> global(isolate->context()->global_object(), isolate); + CHECK(!Execution::Call(isolate, main_fun_wrapper, global, 0, nullptr) + .is_null()); +} diff --git a/deps/v8/test/cctest/wasm/test-wasm-interpreter-entry.cc b/deps/v8/test/cctest/wasm/test-wasm-interpreter-entry.cc new file mode 100644 index 0000000000..17ff5ae783 --- /dev/null +++ b/deps/v8/test/cctest/wasm/test-wasm-interpreter-entry.cc @@ -0,0 +1,232 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <cstdint> + +#include "src/objects-inl.h" +#include "src/wasm/wasm-macro-gen.h" +#include "src/wasm/wasm-objects.h" + +#include "test/cctest/cctest.h" +#include "test/cctest/compiler/value-helper.h" +#include "test/cctest/wasm/wasm-run-utils.h" + +using namespace v8::internal; +using namespace v8::internal::wasm; +namespace debug = v8::debug; + +/** + * We test the interface from Wasm compiled code to the Wasm interpreter by + * building a module with two functions. The external function is called from + * this test, and will be compiled code. It takes its arguments and passes them + * on to the internal function, which will be redirected to the interpreter. + * If the internal function has an i64 parameter, is has to be replaced by two + * i32 parameters on the external function. + * The internal function just converts all its arguments to f64, sums them up + * and returns the sum. + */ +namespace { + +template <typename T> +class ArgPassingHelper { + public: + ArgPassingHelper(WasmRunnerBase& runner, WasmFunctionCompiler& inner_compiler, + std::initializer_list<uint8_t> bytes_inner_function, + std::initializer_list<uint8_t> bytes_outer_function, + const T& expected_lambda) + : isolate_(runner.main_isolate()), + expected_lambda_(expected_lambda), + debug_info_(WasmInstanceObject::GetOrCreateDebugInfo( + runner.module().instance_object())) { + std::vector<uint8_t> inner_code{bytes_inner_function}; + inner_compiler.Build(inner_code.data(), + inner_code.data() + inner_code.size()); + + std::vector<uint8_t> outer_code{bytes_outer_function}; + runner.Build(outer_code.data(), outer_code.data() + outer_code.size()); + + WasmDebugInfo::RedirectToInterpreter(debug_info_, + inner_compiler.function_index()); + main_fun_wrapper_ = runner.module().WrapCode(runner.function_index()); + } + + template <typename... Args> + void CheckCall(Args... args) { + Handle<Object> arg_objs[] = {isolate_->factory()->NewNumber(args)...}; + + uint64_t num_interpreted_before = debug_info_->NumInterpretedCalls(); + Handle<Object> global(isolate_->context()->global_object(), isolate_); + MaybeHandle<Object> retval = Execution::Call( + isolate_, main_fun_wrapper_, global, arraysize(arg_objs), arg_objs); + uint64_t num_interpreted_after = debug_info_->NumInterpretedCalls(); + // Check that we really went through the interpreter. + CHECK_EQ(num_interpreted_before + 1, num_interpreted_after); + // Check the result. + double result = retval.ToHandleChecked()->Number(); + double expected = expected_lambda_(args...); + CHECK_DOUBLE_EQ(expected, result); + } + + private: + Isolate* isolate_; + T expected_lambda_; + Handle<WasmDebugInfo> debug_info_; + Handle<JSFunction> main_fun_wrapper_; +}; + +template <typename T> +static ArgPassingHelper<T> GetHelper( + WasmRunnerBase& runner, WasmFunctionCompiler& inner_compiler, + std::initializer_list<uint8_t> bytes_inner_function, + std::initializer_list<uint8_t> bytes_outer_function, + const T& expected_lambda) { + return ArgPassingHelper<T>(runner, inner_compiler, bytes_inner_function, + bytes_outer_function, expected_lambda); +} + +} // namespace + +TEST(TestArgumentPassing_int32) { + WasmRunner<int32_t, int32_t> runner(kExecuteCompiled); + WasmFunctionCompiler& f2 = runner.NewFunction<int32_t, int32_t>(); + + auto helper = GetHelper( + runner, f2, + {// Return 2*<0> + 1. + WASM_I32_ADD(WASM_I32_MUL(WASM_I32V_1(2), WASM_GET_LOCAL(0)), WASM_ONE)}, + {// Call f2 with param <0>. + WASM_GET_LOCAL(0), WASM_CALL_FUNCTION0(f2.function_index())}, + [](int32_t a) { return 2 * a + 1; }); + + std::vector<int32_t> test_values = compiler::ValueHelper::int32_vector(); + for (int32_t v : test_values) helper.CheckCall(v); +} + +TEST(TestArgumentPassing_int64) { + WasmRunner<double, int32_t, int32_t> runner(kExecuteCompiled); + WasmFunctionCompiler& f2 = runner.NewFunction<double, int64_t>(); + + auto helper = GetHelper( + runner, f2, + {// Return (double)<0>. + WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))}, + {// Call f2 with param (<0> | (<1> << 32)). + WASM_I64_IOR(WASM_I64_UCONVERT_I32(WASM_GET_LOCAL(0)), + WASM_I64_SHL(WASM_I64_UCONVERT_I32(WASM_GET_LOCAL(1)), + WASM_I64V_1(32))), + WASM_CALL_FUNCTION0(f2.function_index())}, + [](int32_t a, int32_t b) { + int64_t a64 = static_cast<int64_t>(a) & 0xffffffff; + int64_t b64 = static_cast<int64_t>(b) << 32; + return static_cast<double>(a64 | b64); + }); + + std::vector<int32_t> test_values_i32 = compiler::ValueHelper::int32_vector(); + for (int32_t v1 : test_values_i32) { + for (int32_t v2 : test_values_i32) { + helper.CheckCall(v1, v2); + } + } + + std::vector<int64_t> test_values_i64 = compiler::ValueHelper::int64_vector(); + for (int64_t v : test_values_i64) { + int32_t v1 = static_cast<int32_t>(v); + int32_t v2 = static_cast<int32_t>(v >> 32); + helper.CheckCall(v1, v2); + helper.CheckCall(v2, v1); + } +} + +TEST(TestArgumentPassing_float_double) { + WasmRunner<double, float> runner(kExecuteCompiled); + WasmFunctionCompiler& f2 = runner.NewFunction<double, float>(); + + auto helper = GetHelper( + runner, f2, + {// Return 2*(double)<0> + 1. + WASM_F64_ADD( + WASM_F64_MUL(WASM_F64(2), WASM_F64_CONVERT_F32(WASM_GET_LOCAL(0))), + WASM_F64(1))}, + {// Call f2 with param <0>. + WASM_GET_LOCAL(0), WASM_CALL_FUNCTION0(f2.function_index())}, + [](float f) { return 2. * static_cast<double>(f) + 1.; }); + + std::vector<float> test_values = compiler::ValueHelper::float32_vector(); + for (float f : test_values) helper.CheckCall(f); +} + +TEST(TestArgumentPassing_double_double) { + WasmRunner<double, double, double> runner(kExecuteCompiled); + WasmFunctionCompiler& f2 = runner.NewFunction<double, double, double>(); + + auto helper = GetHelper(runner, f2, + {// Return <0> + <1>. + WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))}, + {// Call f2 with params <0>, <1>. + WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), + WASM_CALL_FUNCTION0(f2.function_index())}, + [](double a, double b) { return a + b; }); + + std::vector<double> test_values = compiler::ValueHelper::float64_vector(); + for (double d1 : test_values) { + for (double d2 : test_values) { + helper.CheckCall(d1, d2); + } + } +} + +TEST(TestArgumentPassing_AllTypes) { + // The second and third argument will be combined to an i64. + WasmRunner<double, int, int, int, float, double> runner(kExecuteCompiled); + WasmFunctionCompiler& f2 = + runner.NewFunction<double, int, int64_t, float, double>(); + + auto helper = GetHelper( + runner, f2, + { + // Convert all arguments to double, add them and return the sum. + WASM_F64_ADD( // <0+1+2> + <3> + WASM_F64_ADD( // <0+1> + <2> + WASM_F64_ADD( // <0> + <1> + WASM_F64_SCONVERT_I32( + WASM_GET_LOCAL(0)), // <0> to double + WASM_F64_SCONVERT_I64( + WASM_GET_LOCAL(1))), // <1> to double + WASM_F64_CONVERT_F32(WASM_GET_LOCAL(2))), // <2> to double + WASM_GET_LOCAL(3)) // <3> + }, + {WASM_GET_LOCAL(0), // first arg + WASM_I64_IOR(WASM_I64_UCONVERT_I32(WASM_GET_LOCAL(1)), // second arg + WASM_I64_SHL(WASM_I64_UCONVERT_I32(WASM_GET_LOCAL(2)), + WASM_I64V_1(32))), + WASM_GET_LOCAL(3), // third arg + WASM_GET_LOCAL(4), // fourth arg + WASM_CALL_FUNCTION0(f2.function_index())}, + [](int32_t a, int32_t b, int32_t c, float d, double e) { + return 0. + a + (static_cast<int64_t>(b) & 0xffffffff) + + ((static_cast<int64_t>(c) & 0xffffffff) << 32) + d + e; + }); + + auto CheckCall = [&](int32_t a, int64_t b, float c, double d) { + int32_t b0 = static_cast<int32_t>(b); + int32_t b1 = static_cast<int32_t>(b >> 32); + helper.CheckCall(a, b0, b1, c, d); + helper.CheckCall(a, b1, b0, c, d); + }; + + std::vector<int32_t> test_values_i32 = compiler::ValueHelper::int32_vector(); + std::vector<int64_t> test_values_i64 = compiler::ValueHelper::int64_vector(); + std::vector<float> test_values_f32 = compiler::ValueHelper::float32_vector(); + std::vector<double> test_values_f64 = compiler::ValueHelper::float64_vector(); + size_t max_len = + std::max(std::max(test_values_i32.size(), test_values_i64.size()), + std::max(test_values_f32.size(), test_values_f64.size())); + for (size_t i = 0; i < max_len; ++i) { + int32_t i32 = test_values_i32[i % test_values_i32.size()]; + int64_t i64 = test_values_i64[i % test_values_i64.size()]; + float f32 = test_values_f32[i % test_values_f32.size()]; + double f64 = test_values_f64[i % test_values_f64.size()]; + CheckCall(i32, i64, f32, f64); + } +} diff --git a/deps/v8/test/cctest/wasm/test-wasm-stack.cc b/deps/v8/test/cctest/wasm/test-wasm-stack.cc index 357a4e487e..3dc7839667 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-stack.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-stack.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/assembler-inl.h" #include "src/wasm/wasm-macro-gen.h" - #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" #include "test/cctest/wasm/wasm-run-utils.h" diff --git a/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc b/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc index 0418d46bab..91159f2154 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/assembler-inl.h" #include "src/wasm/wasm-macro-gen.h" - #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" #include "test/cctest/wasm/wasm-run-utils.h" @@ -43,6 +43,7 @@ void CheckExceptionInfos(Handle<Object> exc, // Check that it's indeed an Error object. CHECK(exc->IsJSError()); + exc->Print(); // Extract stack frame from the exception. Local<v8::Value> localExc = Utils::ToLocal(exc); v8::Local<v8::StackTrace> stack = v8::Exception::GetStackTrace(localExc); diff --git a/deps/v8/test/cctest/wasm/wasm-run-utils.h b/deps/v8/test/cctest/wasm/wasm-run-utils.h index 782e7d9635..316537604b 100644 --- a/deps/v8/test/cctest/wasm/wasm-run-utils.h +++ b/deps/v8/test/cctest/wasm/wasm-run-utils.h @@ -224,14 +224,26 @@ class TestingModule : public ModuleEnv { Handle<JSFunction> WrapCode(uint32_t index) { // Wrap the code so it can be called as a JS function. - Handle<WasmInstanceObject> instance_obj(0, isolate_); Handle<Code> code = instance->function_code[index]; Handle<Code> ret_code = compiler::CompileJSToWasmWrapper(isolate_, &module_, code, index); Handle<JSFunction> ret = WasmExportedFunction::New( - isolate_, instance_obj, MaybeHandle<String>(), static_cast<int>(index), + isolate_, instance_object(), MaybeHandle<String>(), + static_cast<int>(index), static_cast<int>(this->module->functions[index].sig->parameter_count()), ret_code); + + // Add weak reference to exported functions. + Handle<WasmCompiledModule> compiled_module( + instance_object()->compiled_module(), isolate_); + Handle<FixedArray> old_arr = compiled_module->weak_exported_functions(); + Handle<FixedArray> new_arr = + isolate_->factory()->NewFixedArray(old_arr->length() + 1); + old_arr->CopyTo(0, *new_arr, 0, old_arr->length()); + Handle<WeakCell> weak_fn = isolate_->factory()->NewWeakCell(ret); + new_arr->set(old_arr->length(), *weak_fn); + compiled_module->set_weak_exported_functions(new_arr); + return ret; } @@ -319,8 +331,10 @@ class TestingModule : public ModuleEnv { Handle<WasmInstanceObject> InitInstanceObject() { Handle<SeqOneByteString> empty_string = Handle<SeqOneByteString>::cast( isolate_->factory()->NewStringFromOneByte({}).ToHandleChecked()); - Handle<Managed<wasm::WasmModule>> module_wrapper = - Managed<wasm::WasmModule>::New(isolate_, &module_, false); + // The lifetime of the wasm module is tied to this object's, and we cannot + // rely on the mechanics of Managed<T>. + Handle<Foreign> module_wrapper = + isolate_->factory()->NewForeign(reinterpret_cast<Address>(&module)); Handle<Script> script = isolate_->factory()->NewScript(isolate_->factory()->empty_string()); script->set_type(Script::TYPE_WASM); @@ -334,6 +348,10 @@ class TestingModule : public ModuleEnv { // If tests need more (correct) information, add it later. compiled_module->set_min_mem_pages(0); compiled_module->set_max_mem_pages(Smi::kMaxValue); + Handle<FixedArray> code_table = isolate_->factory()->NewFixedArray(0); + compiled_module->set_code_table(code_table); + Handle<FixedArray> weak_exported = isolate_->factory()->NewFixedArray(0); + compiled_module->set_weak_exported_functions(weak_exported); DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); return WasmInstanceObject::New(isolate_, compiled_module); } @@ -541,6 +559,21 @@ class WasmFunctionCompiler : private GraphAndBuilders { &source_position_table_, start, end); Handle<Code> code = Compile(); testing_module_->SetFunctionCode(function_index(), code); + + // Add to code table. + Handle<WasmCompiledModule> compiled_module( + testing_module_->instance_object()->compiled_module(), isolate()); + Handle<FixedArray> code_table = compiled_module->code_table(); + if (static_cast<int>(function_index()) >= code_table->length()) { + Handle<FixedArray> new_arr = isolate()->factory()->NewFixedArray( + static_cast<int>(function_index()) + 1); + code_table->CopyTo(0, *new_arr, 0, code_table->length()); + code_table = new_arr; + compiled_module->set_code_table(code_table); + } + DCHECK(code_table->get(static_cast<int>(function_index())) + ->IsUndefined(isolate())); + code_table->set(static_cast<int>(function_index()), *code); } byte AllocateLocal(ValueType type) { @@ -659,6 +692,7 @@ class WasmRunnerBase : public HandleAndZoneScope { return functions_[0]->AllocateLocal(type); } + uint32_t function_index() { return functions_[0]->function_index(); } WasmFunction* function() { return functions_[0]->function_; } WasmInterpreter* interpreter() { return functions_[0]->interpreter_; } bool possible_nondeterminism() { return possible_nondeterminism_; } @@ -717,9 +751,9 @@ class WasmRunnerBase : public HandleAndZoneScope { bool interpret() { return module_.execution_mode() == kExecuteInterpreted; } public: - // This field has to be static. Otherwise, gcc complains about the using in + // This field has to be static. Otherwise, gcc complains about the use in // the lambda context below. - static jmp_buf jump_buffer; + static bool trap_happened; }; template <typename ReturnType, typename... ParamTypes> @@ -738,15 +772,24 @@ class WasmRunner : public WasmRunnerBase { DCHECK(compiled_); if (interpret()) return CallInterpreter(p...); - // Use setjmp/longjmp to deal with traps in WebAssembly code. ReturnType return_value = static_cast<ReturnType>(0xdeadbeefdeadbeef); - static int setjmp_ret; - setjmp_ret = setjmp(WasmRunnerBase::jump_buffer); - // setjmp returns 0 on the first return, 1 (passed to longjmp) after trap. - if (setjmp_ret == 0) { - DoCall(static_cast<void*>(&p)..., static_cast<void*>(&return_value)); - } - return return_value; + WasmRunnerBase::trap_happened = false; + auto trap_callback = []() -> void { + WasmRunnerBase::trap_happened = true; + set_trap_callback_for_testing(nullptr); + }; + set_trap_callback_for_testing(trap_callback); + + wrapper_.SetInnerCode( + module_.GetFunctionCode(functions_[0]->function_index())); + CodeRunner<int32_t> runner(CcTest::InitIsolateOnce(), + wrapper_.GetWrapperCode(), wrapper_.signature()); + int32_t result = runner.Call(static_cast<void*>(&p)..., + static_cast<void*>(&return_value)); + CHECK_EQ(WASM_WRAPPER_RETURN_VALUE, result); + return WasmRunnerBase::trap_happened + ? static_cast<ReturnType>(0xdeadbeefdeadbeef) + : return_value; } ReturnType CallInterpreter(ParamTypes... p) { @@ -767,30 +810,10 @@ class WasmRunner : public WasmRunnerBase { return ReturnType{0}; } } - - private: - // Don't inline this function. The setjmp above should be followed immediately - // by a call. - template <typename... Ptrs> - V8_NOINLINE void DoCall(Ptrs... ptrs) { - auto trap_callback = []() -> void { - set_trap_callback_for_testing(nullptr); - longjmp(WasmRunnerBase::jump_buffer, 1); - }; - set_trap_callback_for_testing(trap_callback); - - wrapper_.SetInnerCode( - module_.GetFunctionCode(functions_[0]->function_index())); - CodeRunner<int32_t> runner(CcTest::InitIsolateOnce(), - wrapper_.GetWrapperCode(), wrapper_.signature()); - int32_t result = runner.Call(ptrs...); - // If we arrive here, no trap happened. - CHECK_EQ(WASM_WRAPPER_RETURN_VALUE, result); - } }; // Declare static variable. -jmp_buf WasmRunnerBase::jump_buffer; +bool WasmRunnerBase::trap_happened; // A macro to define tests that run in different engine configurations. #define WASM_EXEC_TEST(name) \ @@ -803,9 +826,9 @@ jmp_buf WasmRunnerBase::jump_buffer; void RunWasm_##name(WasmExecutionMode execution_mode); \ TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ void RunWasm_##name(WasmExecutionMode execution_mode); \ - TEST(RunWasmCompiledWithTrapIf_##name) { \ + TEST(RunWasmCompiledWithoutTrapIf_##name) { \ bool trap_if = FLAG_wasm_trap_if; \ - FLAG_wasm_trap_if = true; \ + FLAG_wasm_trap_if = false; \ RunWasm_##name(kExecuteCompiled); \ FLAG_wasm_trap_if = trap_if; \ } \ diff --git a/deps/v8/test/common/wasm/wasm-module-runner.cc b/deps/v8/test/common/wasm/wasm-module-runner.cc index 7d0e00ee70..3036480087 100644 --- a/deps/v8/test/common/wasm/wasm-module-runner.cc +++ b/deps/v8/test/common/wasm/wasm-module-runner.cc @@ -6,6 +6,7 @@ #include "src/handles.h" #include "src/isolate.h" +#include "src/objects-inl.h" #include "src/objects.h" #include "src/property-descriptor.h" #include "src/wasm/module-decoder.h" @@ -58,17 +59,15 @@ const Handle<WasmInstanceObject> InstantiateModuleForTesting( // Although we decoded the module for some pre-validation, run the bytes // again through the normal pipeline. // TODO(wasm): Use {module} instead of decoding the module bytes again. - MaybeHandle<WasmModuleObject> module_object = CreateModuleObjectFromBytes( - isolate, wire_bytes.module_bytes.start(), wire_bytes.module_bytes.end(), - thrower, ModuleOrigin::kWasmOrigin, Handle<Script>::null(), - Vector<const byte>::empty()); + MaybeHandle<WasmModuleObject> module_object = + SyncCompile(isolate, thrower, wire_bytes); if (module_object.is_null()) { thrower->CompileError("Module pre-validation failed."); return Handle<WasmInstanceObject>::null(); } MaybeHandle<WasmInstanceObject> maybe_instance = - WasmModule::Instantiate(isolate, thrower, module_object.ToHandleChecked(), - Handle<JSReceiver>::null()); + SyncInstantiate(isolate, thrower, module_object.ToHandleChecked(), + Handle<JSReceiver>::null(), MaybeHandle<JSArrayBuffer>()); Handle<WasmInstanceObject> instance; if (!maybe_instance.ToHandle(&instance)) { return Handle<WasmInstanceObject>::null(); diff --git a/deps/v8/test/common/wasm/wasm-module-runner.h b/deps/v8/test/common/wasm/wasm-module-runner.h index ed6ad88031..4d58513c14 100644 --- a/deps/v8/test/common/wasm/wasm-module-runner.h +++ b/deps/v8/test/common/wasm/wasm-module-runner.h @@ -5,7 +5,6 @@ #ifndef V8_WASM_MODULE_RUNNER_H_ #define V8_WASM_MODULE_RUNNER_H_ -#include "src/handles.h" #include "src/isolate.h" #include "src/objects.h" #include "src/wasm/wasm-interpreter.h" @@ -16,6 +15,10 @@ namespace v8 { namespace internal { + +template <typename T> +class Handle; + namespace wasm { namespace testing { diff --git a/deps/v8/test/debugger/debug/debug-compile-optimized.js b/deps/v8/test/debugger/debug/debug-compile-optimized.js index 089f2a0970..a9d5d6add4 100644 --- a/deps/v8/test/debugger/debug/debug-compile-optimized.js +++ b/deps/v8/test/debugger/debug/debug-compile-optimized.js @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --crankshaft Debug = debug.Debug; diff --git a/deps/v8/test/debugger/debug/debug-evaluate-closure.js b/deps/v8/test/debugger/debug/debug-evaluate-closure.js index 5b8ad89c5d..d4f3867137 100644 --- a/deps/v8/test/debugger/debug/debug-evaluate-closure.js +++ b/deps/v8/test/debugger/debug/debug-evaluate-closure.js @@ -25,6 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --no-always-opt Debug = debug.Debug; var listened = false; diff --git a/deps/v8/test/debugger/debug/debug-evaluate-nested-let.js b/deps/v8/test/debugger/debug/debug-evaluate-nested-let.js index d56a36ccf6..691dd2c3f2 100644 --- a/deps/v8/test/debugger/debug/debug-evaluate-nested-let.js +++ b/deps/v8/test/debugger/debug/debug-evaluate-nested-let.js @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --crankshaft Debug = debug.Debug diff --git a/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect-builtins.js b/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect-builtins.js index 154498c911..8b08ab1db9 100644 --- a/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect-builtins.js +++ b/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect-builtins.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition --side-effect-free-debug-evaluate +// Flags: --ignition Debug = debug.Debug @@ -12,17 +12,43 @@ function listener(event, exec_state, event_data, data) { if (event != Debug.DebugEvent.Break) return; try { function success(expectation, source) { - assertEquals(expectation, exec_state.frame(0).evaluate(source).value()); + assertEquals(expectation, + exec_state.frame(0).evaluate(source, true).value()); } function fail(source) { - assertThrows(() => exec_state.frame(0).evaluate(source), EvalError); + assertThrows(() => exec_state.frame(0).evaluate(source, true), + EvalError); + } + + // Test Array functions. + var function_param = [ + "forEach", "every", "some", "reduce", "reduceRight", "find", "filter", + "map", "findIndex" + ]; + var fails = ["toString", "join", "toLocaleString", "pop", "push", + "reverse", "shift", "unshift", "slice", "splice", "sort", "filter", + "map", "copyWithin", "fill", "concat"]; + for (f of Object.getOwnPropertyNames(Array.prototype)) { + if (typeof Array.prototype[f] === "function") { + if (fails.includes(f)) { + if (function_param.includes(f)) { + fail(`[1, 2, 3].${f}(()=>{});`); + } else { + fail(`[1, 2, 3].${f}();`); + } + } else if (function_param.includes(f)) { + exec_state.frame(0).evaluate(`[1, 2, 3].${f}(()=>{});`, true); + } else { + exec_state.frame(0).evaluate(`[1, 2, 3].${f}();`, true); + } + } } // Test Math functions. for (f of Object.getOwnPropertyNames(Math)) { if (typeof Math[f] === "function") { var result = exec_state.frame(0).evaluate( - `Math.${f}(0.5, -0.5);`).value(); + `Math.${f}(0.5, -0.5);`, true).value(); if (f != "random") assertEquals(Math[f](0.5, -0.5), result); } } @@ -46,14 +72,24 @@ function listener(event, exec_state, event_data, data) { for (f of Object.getOwnPropertyNames(String.prototype)) { if (typeof String.prototype[f] === "function") { // Do not expect locale-specific or regexp-related functions to work. + // {Lower,Upper}Case (Locale-specific or not) do not work either. if (f.indexOf("locale") >= 0) continue; + if (f.indexOf("Lower") >= 0) continue; + if (f.indexOf("Upper") >= 0) continue; if (f == "normalize") continue; if (f == "match") continue; if (f == "search") continue; - if (f == "split") continue; + if (f == "split" || f == "replace") { + fail(`'abcd'.${f}(2)`); + continue; + } success("abcd"[f](2), `"abcd".${f}(2);`); } } + fail("'abCd'.toLowerCase()"); + fail("'abcd'.toUpperCase()"); + fail("'abCd'.toLocaleLowerCase()"); + fail("'abcd'.toLocaleUpperCase()"); fail("'abcd'.match(/a/)"); fail("'abcd'.replace(/a/)"); fail("'abcd'.search(/a/)"); diff --git a/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect-control.js b/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect-control.js new file mode 100644 index 0000000000..1111b49c83 --- /dev/null +++ b/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect-control.js @@ -0,0 +1,109 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --ignition + +Debug = debug.Debug + +var exception = null; + +var o = { p : 1 }; + +var successes = [ + [45, + `(function() { + var sum = 0; + for (var i = 0; i < 10; i++) sum += i; + return sum; + })()` + ], + ["0012", + `(function() { + var sum = 0; + for (var i in [1, 2, 3]) sum += i; + return sum; + })()` + ], + [15, + `(function() { + var sum = 1; + while (sum < 12) sum += sum + 1; + return sum; + })()` + ], + [15, + `(function() { + var sum = 1; + do { sum += sum + 1; } while (sum < 12); + return sum; + })()` + ], + ["023", + `(function() { + var sum = ""; + for (var i = 0; i < 4; i++) { + switch (i) { + case 0: + case 1: + if (i == 0) sum += i; + break; + default: + case 3: + sum += i; + break; + } + } + return sum; + })()` + ], + ["oups", + `(function() { + try { + if (Math.sin(1) < 1) throw new Error("oups"); + } catch (e) { + return e.message; + } + })()` + ], +]; + +var fails = [ + `(function() { // Iterator.prototype.next performs stores. + var sum = 0; + for (let i of [1, 2, 3]) sum += i; + return sum; + })()`, + `(function() { // Store to scope object. + with (o) { + p = 2; + } + })()`, +]; + +function listener(event, exec_state, event_data, data) { + if (event != Debug.DebugEvent.Break) return; + try { + successes.forEach(function ([expectation, source]) { + assertEquals(expectation, + exec_state.frame(0).evaluate(source, true).value()); + }); + fails.forEach(function (test) { + assertThrows(() => exec_state.frame(0).evaluate(test, true), EvalError); + }); + } catch (e) { + exception = e; + print(e, e.stack); + }; +}; + +// Add the debug event listener. +Debug.setListener(listener); + +function f() { + debugger; +}; + +f(); + +assertNull(exception); diff --git a/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect.js b/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect.js index 113ca3d16a..26afa9b6e9 100644 --- a/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect.js +++ b/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition --side-effect-free-debug-evaluate +// Flags: --ignition Debug = debug.Debug @@ -24,10 +24,12 @@ function listener(event, exec_state, event_data, data) { if (event != Debug.DebugEvent.Break) return; try { function success(expectation, source) { - assertEquals(expectation, exec_state.frame(0).evaluate(source).value()); + assertEquals(expectation, + exec_state.frame(0).evaluate(source, true).value()); } function fail(source) { - assertThrows(() => exec_state.frame(0).evaluate(source), EvalError); + assertThrows(() => exec_state.frame(0).evaluate(source, true), + EvalError); } // Simple test. success(3, "1 + 2"); diff --git a/deps/v8/test/debugger/debug/debug-liveedit-check-stack.js b/deps/v8/test/debugger/debug/debug-liveedit-check-stack.js index bba7acafec..e016a5391c 100644 --- a/deps/v8/test/debugger/debug/debug-liveedit-check-stack.js +++ b/deps/v8/test/debugger/debug/debug-liveedit-check-stack.js @@ -89,9 +89,28 @@ function WrapInNativeCall(f) { }; } +function ExecuteInDebugContext(f) { + var result; + var exception = null; + Debug.setListener(function(event) { + if (event == Debug.DebugEvent.Break) { + try { + result = f(); + } catch (e) { + // Rethrow this exception later. + exception = e; + } + } + }); + debugger; + Debug.setListener(null); + if (exception !== null) throw exception; + return result; +} + function WrapInDebuggerCall(f) { return function() { - return %ExecuteInDebugContext(f); + return ExecuteInDebugContext(f); }; } diff --git a/deps/v8/test/debugger/debug/debug-liveedit-double-call.js b/deps/v8/test/debugger/debug/debug-liveedit-double-call.js index 927efddf62..77d800e708 100644 --- a/deps/v8/test/debugger/debug/debug-liveedit-double-call.js +++ b/deps/v8/test/debugger/debug/debug-liveedit-double-call.js @@ -25,10 +25,10 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --noalways-opt Debug = debug.Debug - function TestCase(test_scenario, expected_output) { // Global variable, accessed from eval'd script. test_output = ""; diff --git a/deps/v8/test/debugger/debug/debug-liveedit-replace-code.js b/deps/v8/test/debugger/debug/debug-liveedit-replace-code.js new file mode 100644 index 0000000000..a3b83bb683 --- /dev/null +++ b/deps/v8/test/debugger/debug/debug-liveedit-replace-code.js @@ -0,0 +1,33 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +Debug = debug.Debug +var counter = 0; +var exception = null; + +function f() { + if (++counter > 5) return; + debugger; + return counter; +} + +function listener(event, exec_state, event_data, data) { + if (event != Debug.DebugEvent.Break) return; + try { + var script = Debug.findScript(f); + var original = 'debugger;'; + var patch = 'debugger;\n'; + var position = script.source.indexOf(original); + Debug.LiveEdit.TestApi.ApplySingleChunkPatch( + script, position, original.length, patch, []); + } catch (e) { + exception = e; + } +} + +Debug.setListener(listener); +f(); +Debug.setListener(null); +assertNull(exception); +assertEquals(6, counter); diff --git a/deps/v8/test/debugger/debug/debug-optimize.js b/deps/v8/test/debugger/debug/debug-optimize.js index 1d99da4983..5501b3fe93 100644 --- a/deps/v8/test/debugger/debug/debug-optimize.js +++ b/deps/v8/test/debugger/debug/debug-optimize.js @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --crankshaft --no-always-opt var Debug = debug.Debug; diff --git a/deps/v8/test/debugger/debug/debug-scripts-throw.js b/deps/v8/test/debugger/debug/debug-scripts-throw.js deleted file mode 100644 index e703f49054..0000000000 --- a/deps/v8/test/debugger/debug/debug-scripts-throw.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - - -Debug = debug.Debug; - -Debug.disable(); -assertThrows("Debug.scripts()"); - -Debug.enable(); -assertDoesNotThrow("Debug.scripts()"); diff --git a/deps/v8/test/debugger/debug/debug-set-variable-value.js b/deps/v8/test/debugger/debug/debug-set-variable-value.js index 67417895c6..602588a146 100644 --- a/deps/v8/test/debugger/debug/debug-set-variable-value.js +++ b/deps/v8/test/debugger/debug/debug-set-variable-value.js @@ -25,6 +25,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --noalways-opt + +// Flags: --no-always-opt var Debug = debug.Debug; diff --git a/deps/v8/test/debugger/debug/debug-stepframe-clearing.js b/deps/v8/test/debugger/debug/debug-stepframe-clearing.js deleted file mode 100644 index 8718636d9c..0000000000 --- a/deps/v8/test/debugger/debug/debug-stepframe-clearing.js +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - - -// This test ensures that IC learning doesn't interfere with stepping into -// property accessor. f1()'s ICs are allowed to learn to a monomorphic state, -// and the breakpoints flooding get() are allowed to expire, then we ensure -// that we can step into get() again later (when k == 1). -function f1() { - for (var k = 0; k < 2; k++) { // Break 1 - var v10 = 0; // Line 2 - for (var i = 0; i < 10; i++) { // Line 3 - var v12 = o.slappy; // Line 4 - var v13 = 3 // Line 5 - } // Line 6 - print("break here"); // Break 3 - } // Line 8 - print("exiting f1"); // Line 9 (dummy break) -} - -function get() { - var g0 = 0; // Break 2 - var g1 = 1; - return 3; -} - - -var o = {}; -Object.defineProperty(o, "slappy", { get : get }); - -Debug = debug.Debug; -var break_count = 0 -var exception = null; -var bp_f1_line7; -var bp_f1_line9; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var line = exec_state.frame(0).sourceLineText(); - print(line); - var match = line.match(/\/\/ Break (\d+)$/); - assertEquals(2, match.length); - var match_value = parseInt(match[1]); - - if (break_count >= 0 && break_count < 2) { - // 0, 1: Keep stepping through frames. - assertEquals(break_count, match_value); - exec_state.prepareStep(Debug.StepAction.StepFrame); - } else if (break_count === 2) { - // 2: let the code run to a breakpoint we set. The load should - // go monomorphic. - assertEquals(break_count, match_value); - } else if (break_count === 3) { - // 3: back to frame stepping. Does the monomorphic slappy accessor - // call still have the ability to break like before? - assertEquals(break_count, match_value); - Debug.clearBreakPoint(bp_f1_line7); - exec_state.prepareStep(Debug.StepAction.StepFrame); - } else { - assertEquals(4, break_count); - assertEquals(2, match_value); - // Apparently we can still stop in the accessor even though we cleared - // breakpoints earlier and there was a monomorphic step. - // Allow running to completion now. - Debug.clearBreakPoint(bp_f1_line9); - } - - break_count++; - } catch (e) { - print(e + e.stack); - exception = e; - } -} - -for (var j = 1; j < 3; j++) { - break_count = 0; - Debug.setListener(listener); - - // Breakpoints are added here rather than in the listener because their - // addition causes a full (clearing) gc that clears type feedback when we - // want to let it build up. Also, bp_f1_line9 is set simply because if we - // handled then deleted bp_f1_line7, then the debugger clears DebugInfo from - // f1 while we are still using it, again, resetting type feedback which is - // undesirable. - bp_f1_line7 = Debug.setBreakPoint(f1, 7); - bp_f1_line9 = Debug.setBreakPoint(f1, 9); - - debugger; // Break 0 - f1(); - Debug.setListener(null); - assertTrue(break_count === 5); -} - -assertNull(exception); diff --git a/deps/v8/test/debugger/debug/debug-stepframe.js b/deps/v8/test/debugger/debug/debug-stepframe.js deleted file mode 100644 index cb1675994a..0000000000 --- a/deps/v8/test/debugger/debug/debug-stepframe.js +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - - -function f0() { - var v00 = 0; // Break 1 - var v01 = 1; - // Normal function call in a catch scope. - try { - throw 1; - } catch (e) { - try { - f1(); - } catch (e) { - var v02 = 2; // Break 13 - } - } - var v03 = 3; - var v04 = 4; - eval('var v05 = 5; // Break 14'); - var v06 = 6; // Break 15 -} - -function f1() { - var v10 = 0; // Break 2 - var v11 = 1; - // Getter call. - var v12 = o.get; - var v13 = 3 // Break 4 - // Setter call. - o.set = 2; - var v14 = 4; // Break 6 - // Function.prototype.call. - f2.call(); - var v15 = 5; // Break 12 - var v16 = 6; - // Exit function by throw. - throw 1; - var v17 = 7; -} - -function get() { - var g0 = 0; // Break 3 - var g1 = 1; - return 3; -} - -function set() { - var s0 = 0; // Break 5 - return 3; -} - -function f2() { - var v20 = 0; // Break 7 - // Construct call. - var v21 = new c0(); - var v22 = 2; // Break 9 - // Bound function. - b0(); - return 2; // Break 11 -} - -function c0() { - this.v0 = 0; // Break 8 - this.v1 = 1; -} - -function f3() { - var v30 = 0; // Break 10 - var v31 = 1; - return 3; -} - -var b0 = f3.bind(o); - -var o = {}; -Object.defineProperty(o, "get", { get : get }); -Object.defineProperty(o, "set", { set : set }); - -Debug = debug.Debug; -var break_count = 0 -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var line = exec_state.frame(0).sourceLineText(); - print(line); - var match = line.match(/\/\/ Break (\d+)$/); - assertEquals(2, match.length); - assertEquals(break_count, parseInt(match[1])); - break_count ++; - exec_state.prepareStep(Debug.StepAction.StepFrame); - } catch (e) { - print(e + e.stack); - exception = e; - } -} - - -break_count = 0; -Debug.setListener(listener); -debugger; // Break 0 -f0(); -Debug.setListener(null); // Break 16 -assertTrue(break_count > 14); - -assertNull(exception); diff --git a/deps/v8/test/debugger/debug/es6/debug-blockscopes.js b/deps/v8/test/debugger/debug/es6/debug-blockscopes.js index 001c098c69..bc00df7129 100644 --- a/deps/v8/test/debugger/debug/es6/debug-blockscopes.js +++ b/deps/v8/test/debugger/debug/es6/debug-blockscopes.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --noanalyze-environment-liveness +// Flags: --noanalyze-environment-liveness --crankshaft // The functions used for testing backtraces. They are at the top to make the // testing of source line/column easier. diff --git a/deps/v8/test/debugger/debug/es6/debug-evaluate-blockscopes.js b/deps/v8/test/debugger/debug/es6/debug-evaluate-blockscopes.js index 6ed3ca66e1..026754d34a 100644 --- a/deps/v8/test/debugger/debug/es6/debug-evaluate-blockscopes.js +++ b/deps/v8/test/debugger/debug/es6/debug-evaluate-blockscopes.js @@ -29,6 +29,8 @@ // Test debug evaluation for functions without local context, but with // nested catch contexts. +// Flags: --no-always-opt + "use strict"; var x; diff --git a/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-1.js b/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-1.js index 4beebec909..40dc816b2d 100644 --- a/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-1.js +++ b/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-1.js @@ -22,8 +22,27 @@ eval(` function Dummy() {} +function ExecuteInDebugContext(f) { + var result; + var exception = null; + Debug.setListener(function(event) { + if (event == Debug.DebugEvent.Break) { + try { + result = f(); + } catch (e) { + // Rethrow this exception later. + exception = e; + } + } + }); + debugger; + Debug.setListener(null); + if (exception !== null) throw exception; + return result; +} + function Replace(fun, original, patch) { - %ExecuteInDebugContext(function() { + ExecuteInDebugContext(function() { var change_log = []; try { var script = Debug.findScript(fun); diff --git a/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-2.js b/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-2.js index e87e8b574e..764c57c54e 100644 --- a/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-2.js +++ b/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-2.js @@ -19,8 +19,27 @@ eval(` } `); +function ExecuteInDebugContext(f) { + var result; + var exception = null; + Debug.setListener(function(event) { + if (event == Debug.DebugEvent.Break) { + try { + result = f(); + } catch (e) { + // Rethrow this exception later. + exception = e; + } + } + }); + debugger; + Debug.setListener(null); + if (exception !== null) throw exception; + return result; +} + function Replace(fun, original, patch) { - %ExecuteInDebugContext(function() { + ExecuteInDebugContext(function() { var change_log = []; try { var script = Debug.findScript(fun); diff --git a/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-3.js b/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-3.js index 866323de1a..60ec9a7fa1 100644 --- a/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-3.js +++ b/deps/v8/test/debugger/debug/es6/debug-liveedit-new-target-3.js @@ -24,8 +24,27 @@ eval(` } `); +function ExecuteInDebugContext(f) { + var result; + var exception = null; + Debug.setListener(function(event) { + if (event == Debug.DebugEvent.Break) { + try { + result = f(); + } catch (e) { + // Rethrow this exception later. + exception = e; + } + } + }); + debugger; + Debug.setListener(null); + if (exception !== null) throw exception; + return result; +} + function Replace(fun, original, patch) { - %ExecuteInDebugContext(function() { + ExecuteInDebugContext(function() { var change_log = []; try { var script = Debug.findScript(fun); diff --git a/deps/v8/test/debugger/debug/es6/generators-debug-liveedit.js b/deps/v8/test/debugger/debug/es6/generators-debug-liveedit.js index 1fe039c2fc..3ae359a541 100644 --- a/deps/v8/test/debugger/debug/es6/generators-debug-liveedit.js +++ b/deps/v8/test/debugger/debug/es6/generators-debug-liveedit.js @@ -41,6 +41,25 @@ function MakeFunction() { assertIteratorResult("Cat", true, iter.next()); })(); +function ExecuteInDebugContext(f) { + var result; + var exception = null; + Debug.setListener(function(event) { + if (event == Debug.DebugEvent.Break) { + try { + result = f(); + } catch (e) { + // Rethrow this exception later. + exception = e; + } + } + }); + debugger; + Debug.setListener(null); + if (exception !== null) throw exception; + return result; +} + function patch(fun, from, to) { function debug() { var log = new Array(); @@ -53,7 +72,7 @@ function patch(fun, from, to) { print("Change log: " + JSON.stringify(log) + "\n"); } } - %ExecuteInDebugContext(debug); + ExecuteInDebugContext(debug); } // Try to edit a MakeGenerator while it's running, then again while it's diff --git a/deps/v8/test/debugger/debug/es8/debug-async-liveedit.js b/deps/v8/test/debugger/debug/es8/debug-async-liveedit.js index cad314cfad..761a24fdfa 100644 --- a/deps/v8/test/debugger/debug/es8/debug-async-liveedit.js +++ b/deps/v8/test/debugger/debug/es8/debug-async-liveedit.js @@ -48,6 +48,25 @@ function MakeFunction() { assertPromiseValue('Cat', promise); })(); +function ExecuteInDebugContext(f) { + var result; + var exception = null; + Debug.setListener(function(event) { + if (event == Debug.DebugEvent.Break) { + try { + result = f(); + } catch (e) { + // Rethrow this exception later. + exception = e; + } + } + }); + debugger; + Debug.setListener(null); + if (exception !== null) throw exception; + return result; +} + function patch(fun, from, to) { function debug() { var log = new Array(); @@ -61,7 +80,7 @@ function patch(fun, from, to) { print("Change log: " + JSON.stringify(log) + "\n"); } } - %ExecuteInDebugContext(debug); + ExecuteInDebugContext(debug); } // Try to edit a MakeAsyncFunction while it's running, then again while it's diff --git a/deps/v8/test/debugger/debug/ignition/debug-step-prefix-bytecodes.js b/deps/v8/test/debugger/debug/ignition/debug-step-prefix-bytecodes.js index b986be23e6..46350031be 100644 --- a/deps/v8/test/debugger/debug/ignition/debug-step-prefix-bytecodes.js +++ b/deps/v8/test/debugger/debug/ignition/debug-step-prefix-bytecodes.js @@ -25,8 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --ignition-filter=f - // This test tests that full code compiled without debug break slots // is recompiled with debug break slots when debugging is started. diff --git a/deps/v8/test/debugger/debug/ignition/debugger-statement.js b/deps/v8/test/debugger/debug/ignition/debugger-statement.js index 05f6c07623..ddc0b38105 100644 --- a/deps/v8/test/debugger/debug/ignition/debugger-statement.js +++ b/deps/v8/test/debugger/debug/ignition/debugger-statement.js @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition-filter=f - var Debug = debug.Debug; var break_count = 0; diff --git a/deps/v8/test/debugger/debug/regress/regress-crbug-323936.js b/deps/v8/test/debugger/debug/regress/regress-crbug-323936.js index e89f7a0a02..391b095a2b 100644 --- a/deps/v8/test/debugger/debug/regress/regress-crbug-323936.js +++ b/deps/v8/test/debugger/debug/regress/regress-crbug-323936.js @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --no-always-opt Debug = debug.Debug; diff --git a/deps/v8/test/debugger/debug/regress/regress-crbug-633999.js b/deps/v8/test/debugger/debug/regress/regress-crbug-633999.js index 18ca4d0cb7..e5f56166d5 100644 --- a/deps/v8/test/debugger/debug/regress/regress-crbug-633999.js +++ b/deps/v8/test/debugger/debug/regress/regress-crbug-633999.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --noturbo +// Flags: --crankshaft --no-turbo var Debug = debug.Debug var exception = null; diff --git a/deps/v8/test/debugger/debug/regress/regress-opt-after-debug-deopt.js b/deps/v8/test/debugger/debug/regress/regress-opt-after-debug-deopt.js index 01204fc169..2b11357f1c 100644 --- a/deps/v8/test/debugger/debug/regress/regress-opt-after-debug-deopt.js +++ b/deps/v8/test/debugger/debug/regress/regress-opt-after-debug-deopt.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --concurrent-recompilation --block-concurrent-recompilation +// Flags: --no-always-opt if (!%IsConcurrentRecompilationSupported()) { print("Concurrent recompilation is disabled. Skipping this test."); diff --git a/deps/v8/test/debugger/debug/regress/regress-prepare-break-while-recompile.js b/deps/v8/test/debugger/debug/regress/regress-prepare-break-while-recompile.js index b93de76a65..49fd619a3d 100644 --- a/deps/v8/test/debugger/debug/regress/regress-prepare-break-while-recompile.js +++ b/deps/v8/test/debugger/debug/regress/regress-prepare-break-while-recompile.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --concurrent-recompilation --block-concurrent-recompilation +// Flags: --no-always-opt if (!%IsConcurrentRecompilationSupported()) { print("Concurrent recompilation is disabled. Skipping this test."); diff --git a/deps/v8/test/debugger/debugger.status b/deps/v8/test/debugger/debugger.status index 5a16190c3d..8001708a0c 100644 --- a/deps/v8/test/debugger/debugger.status +++ b/deps/v8/test/debugger/debugger.status @@ -11,10 +11,6 @@ # not work, but we expect it to not crash. 'debug/debug-step-turbofan': [PASS, FAIL], - # Issue 5587: The eval'ed code is piped through Ignition and fails when being - # live edited. This needs investigation. - 'debug/debug-liveedit-double-call': [SKIP], - # Issue 3641: The new 'then' semantics suppress some exceptions. # These tests may be changed or removed when 'chain' is deprecated. 'debug/es6/debug-promises/reject-with-throw-in-reject': [FAIL], @@ -37,6 +33,9 @@ # TODO(jarin/mstarzinger): Functions with eval or debugger now get optimized # with Turbofan, which has issues with the debugger issues. 'debug/debug-evaluate-locals': [FAIL], + + # Very slow in stress mode. + 'regress/regress-2318': [SKIP], }], # 'stress == True' ############################################################################## @@ -66,30 +65,11 @@ ############################################################################## ['variant == turbofan_opt', { - # TODO(mstarzinger): Debugger cannot materialize de-materialized functions. - 'debug/regress/regress-crbug-323936': [FAIL], - # TODO(jarin/mstarzinger): Investigate debugger issues with TurboFan. - 'debug/debug-evaluate-closure': [FAIL], 'debug/debug-evaluate-locals': [FAIL], - 'debug/debug-liveedit-double-call': [FAIL], - 'debug/debug-set-variable-value': [FAIL], - 'debug/es6/debug-evaluate-blockscopes': [FAIL], }], # variant == turbofan_opt ############################################################################## -['variant == ignition or variant == ignition_staging', { - # TODO(5587): fails to liveedit evaled code. - 'debug/debug-liveedit-double-call': [FAIL], -}], # variant == ignition - -############################################################################## -['variant == ignition_turbofan', { - # TODO(5587): fails to liveedit evaled code. - 'debug/debug-liveedit-double-call': [FAIL], -}], # variant == ignition_turbofan - -############################################################################## ['variant == asm_wasm', { '*': [SKIP], }], # variant == asm_wasm diff --git a/deps/v8/test/debugger/regress/regress-5901-1.js b/deps/v8/test/debugger/regress/regress-5901-1.js new file mode 100644 index 0000000000..49becc9294 --- /dev/null +++ b/deps/v8/test/debugger/regress/regress-5901-1.js @@ -0,0 +1,50 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --ignition --turbo + +function f() { + throw new Error(); +} + +function g() { + try { + f(); + } catch (e) { + return 1; // Break + } +} + +function h() { + return g(); +} + +h(); +h(); + +var Debug = debug.Debug; +var step_count = 0; +var exception = null; + +function listener(event, exec_state, event_data, data) { + if (event == Debug.DebugEvent.Exception) { + step_count++; + exec_state.prepareStep(Debug.StepAction.StepNext); + } else if (event == Debug.DebugEvent.Break) { + step_count++; + try { + assertTrue(exec_state.frame().sourceLineText().includes('Break')); + } catch (e) { + exception = e; + print(e); + } + } +} + +Debug.setListener(listener); +Debug.setBreakOnException(); +% OptimizeFunctionOnNextCall(h); +h(); +Debug.setListener(null); +assertNull(exception); diff --git a/deps/v8/test/debugger/regress/regress-5901-2.js b/deps/v8/test/debugger/regress/regress-5901-2.js new file mode 100644 index 0000000000..becad1bb07 --- /dev/null +++ b/deps/v8/test/debugger/regress/regress-5901-2.js @@ -0,0 +1,45 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function f() { + debugger; + return 1; +} + +function g() { + return f(); +} // Break + +function h() { + return g(); +} + +h(); +h(); + +var Debug = debug.Debug; +var step_count = 0; +var exception = null; + +function listener(event, exec_state, event_data, data) { + if (event != Debug.DebugEvent.Break) return; + try { + if (step_count == 0) { + exec_state.prepareStep(Debug.StepAction.StepOut); + } else { + assertTrue(exec_state.frame().sourceLineText().includes('Break')); + } + step_count++; + } catch (e) { + exception = e; + print(e); + } +} + +Debug.setListener(listener); +% OptimizeFunctionOnNextCall(h); +h(); +Debug.setListener(null); +assertNull(exception); +assertEquals(2, step_count); diff --git a/deps/v8/test/debugger/regress/regress-5950.js b/deps/v8/test/debugger/regress/regress-5950.js new file mode 100644 index 0000000000..9f0ea5bc90 --- /dev/null +++ b/deps/v8/test/debugger/regress/regress-5950.js @@ -0,0 +1,37 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function f() { + debugger; +} + +function g() { + f(); +} + +function h() { + 'use strict'; + return g(); +} + +h(); +h(); + +var Debug = debug.Debug; +var exception = null; + +function listener(event, exec_state, event_data, data) { + if (event != Debug.DebugEvent.Break) return; + try { + var all_scopes = exec_state.frame().allScopes(); + } catch (e) { + exception = e; + } +} + +Debug.setListener(listener); +%OptimizeFunctionOnNextCall(h); +h(); +Debug.setListener(null); +assertNull(exception); diff --git a/deps/v8/test/debugger/test-api.js b/deps/v8/test/debugger/test-api.js index 13c0a2d85a..c4533dee85 100644 --- a/deps/v8/test/debugger/test-api.js +++ b/deps/v8/test/debugger/test-api.js @@ -32,13 +32,13 @@ class DebugWrapper { Exception: 2, AfterCompile: 3, CompileError: 4, + OOM: 5, }; // The different types of steps. this.StepAction = { StepOut: 0, StepNext: 1, StepIn: 2, - StepFrame: 3, }; // The different types of scripts matching enum ScriptType in objects.h. @@ -418,7 +418,6 @@ class DebugWrapper { case this.StepAction.StepOut: this.stepOut(); break; case this.StepAction.StepNext: this.stepOver(); break; case this.StepAction.StepIn: this.stepInto(); break; - case this.StepAction.StepFrame: %PrepareStepFrame(); break; default: %AbortJS("Unsupported StepAction"); break; } } @@ -679,12 +678,13 @@ class DebugWrapper { }; } - evaluateOnCallFrame(frame, expr) { + evaluateOnCallFrame(frame, expr, throw_on_side_effect = false) { const frameid = frame.callFrameId; const {msgid, msg} = this.createMessage( "Debugger.evaluateOnCallFrame", { callFrameId : frameid, - expression : expr + expression : expr, + throwOnSideEffect : throw_on_side_effect, }); this.sendMessage(msg); const reply = this.takeReplyChecked(msgid); @@ -729,7 +729,8 @@ class DebugWrapper { sourceLine : () => line + 1, sourceLineText : () => loc.sourceText, sourcePosition : () => loc.position, - evaluate : (expr) => this.evaluateOnCallFrame(frame, expr), + evaluate : (expr, throw_on_side_effect) => + this.evaluateOnCallFrame(frame, expr, throw_on_side_effect), functionName : () => frame.functionName, func : () => func, index : () => index, @@ -818,10 +819,21 @@ class DebugWrapper { case "promiseRejection": debugEvent = this.DebugEvent.Exception; break; - default: - // TODO(jgruber): More granularity. + case "OOM": + debugEvent = this.DebugEvent.OOM; + break; + case "other": debugEvent = this.DebugEvent.Break; break; + case "ambiguous": + case "XHR": + case "DOM": + case "EventListener": + case "assert": + case "debugCommand": + assertUnreachable(); + default: + assertUnreachable(); } if (!params.callFrames[0]) return; diff --git a/deps/v8/test/fuzzer/README.md b/deps/v8/test/fuzzer/README.md new file mode 100644 index 0000000000..ed0ce1fa2a --- /dev/null +++ b/deps/v8/test/fuzzer/README.md @@ -0,0 +1,91 @@ +# How to make a libFuzzer fuzzer in V8 + +This document describes how to make a new libFuzzer fuzzer for V8. A general +introduction to libFuzzer can be found +[here](https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/README.md). +In short, libFuzzer is an in-process coverage-driven evolutionary fuzzer. +libFuzzer serves you with a sequence of byte arrays that you can use to test +your code. libFuzzer tries to generate this sequence of byte arrays in a way +that maximizes test coverage. + +**Warning**: By itself libFuzzer typically does not generate valid JavaScript code. + +## Changes to V8 + +**tldr:** Do the same as https://codereview.chromium.org/2280623002 to introduce +a new fuzzer to V8. + +This is a step by step guide on how to make a new fuzzer in V8. In the example +the fuzzer is called `foo`. + +1. Copy one of the existing fuzzer implementations in + [test/fuzzer/](https://cs.chromium.org/chromium/src/v8/test/fuzzer/), e.g. `cp wasm.cc foo.cc` + + * Copying an existing fuzzer is a good idea to get all the required setup, + e.g. setting up the isolate + +2. Create a directory called `foo` in + [test/fuzzer/](https://cs.chromium.org/chromium/src/v8/test/fuzzer/) which + contains at least one file + + * The file is used by the trybots to check whether the fuzzer actually + compiles and runs + +3. Copy the build rules of an existing fuzzer in + [BUILD.gn](https://cs.chromium.org/chromium/src/v8/BUILD.gn), e.g. the build + rules for the + [wasm.cc](https://cs.chromium.org/chromium/src/v8/test/fuzzer/wasm.cc) fuzzer + are `v8_source_set("wasm_fuzzer")` and `v8_fuzzer("wasm_fuzzer")`. Note that + the name has to be the name of the directory created in Step 2 + `_fuzzer` so + that the scripts on the trybots work + +4. Now you can already compile the fuzzer, e.g. with `ninja -j 1000 -C + out/x64.debug/v8_simple_foo_fuzzer` + + * Use this binary to reproduce issues found by cluster fuzz, e.g. + `out/x64.debug/v8_simple_foo_fuzzer testcase.foo` + +5. Copy the build rules of an existing fuzzer in + [test/fuzzer/fuzzer.gyp](https://cs.chromium.org/chromium/src/v8/test/fuzzer/fuzzer.gyp), + e.g. the build rules for the + [wasm.cc](https://cs.chromium.org/chromium/src/v8/test/fuzzer/wasm.cc) fuzzer + are `v8_simple_wasm_fuzzer` and `wasm_fuzzer_lib` + + * This build rule is needed to compile with gyp + +6. Copy the binary name and the test directory name in + [test/fuzzer/fuzzer.isolate](https://cs.chromium.org/chromium/src/v8/test/fuzzer/fuzzer.isolate) + +7. Add the fuzzer to the FuzzerTestSuite in + [test/fuzzer/testcfg.py](https://cs.chromium.org/chromium/src/v8/test/fuzzer/testcfg.py) + + * This step is needed to run the fuzzer with the files created in Step 2 on + the trybots + +8. Commit the changes described above to the V8 repository + +## Changes to Chromium + +**tldr:** Do the same as https://codereview.chromium.org/2344823002 to add the +new fuzzer to cluster fuzz. + +1. Copy the build rules of an existing fuzzer in + [testing/libfuzzer/fuzzers/BUILD.gn](https://cs.chromium.org/chromium/src/testing/libfuzzer/fuzzers/BUILD.gn), + e.g. the build rule for the + [wasm.cc](https://cs.chromium.org/chromium/src/v8/test/fuzzer/wasm.cc) fuzzer + is `v8_wasm_fuzzer`. There is no need to set a `dictionary` , or a `seed_corpus`. + See + [chromium-fuzzing-getting-started](https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/getting_started.md) + for more information. + +2. Compile the fuzzer in chromium (for different configurations see: + https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/reproducing.md): + + * `gn gen out/libfuzzer '--args=use_libfuzzer=true is_asan=true is_debug=false enable_nacl=false'` + + * `ninja -j 1000 -C out/libfuzzer/ v8_foo_fuzzer` + +3. Run the fuzzer locally + + * `mkdir /tmp/empty_corpus && out/libfuzzer/v8_foo_fuzzer /tmp/empty_corpus` + diff --git a/deps/v8/test/fuzzer/fuzzer.gyp b/deps/v8/test/fuzzer/fuzzer.gyp index 6b40aaaf54..3b93808533 100644 --- a/deps/v8/test/fuzzer/fuzzer.gyp +++ b/deps/v8/test/fuzzer/fuzzer.gyp @@ -201,6 +201,35 @@ ], }, { + 'target_name': 'v8_simple_wasm_compile_fuzzer', + 'type': 'executable', + 'dependencies': [ + 'wasm_compile_fuzzer_lib', + ], + 'include_dirs': [ + '../..', + ], + 'sources': [ + 'fuzzer.cc', + ], + }, + { + 'target_name': 'wasm_compile_fuzzer_lib', + 'type': 'static_library', + 'dependencies': [ + 'fuzzer_support', + ], + 'include_dirs': [ + '../..', + ], + 'sources': [ ### gcmole(all) ### + 'wasm-compile.cc', + '../common/wasm/test-signatures.h', + '../common/wasm/wasm-module-runner.cc', + '../common/wasm/wasm-module-runner.h', + ], + }, + { 'target_name': 'v8_simple_wasm_data_section_fuzzer', 'type': 'executable', 'dependencies': [ diff --git a/deps/v8/test/fuzzer/fuzzer.isolate b/deps/v8/test/fuzzer/fuzzer.isolate index 788c76c010..5a4654c155 100644 --- a/deps/v8/test/fuzzer/fuzzer.isolate +++ b/deps/v8/test/fuzzer/fuzzer.isolate @@ -12,6 +12,7 @@ '<(PRODUCT_DIR)/v8_simple_wasm_asmjs_fuzzer<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/v8_simple_wasm_call_fuzzer<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/v8_simple_wasm_code_fuzzer<(EXECUTABLE_SUFFIX)', + '<(PRODUCT_DIR)/v8_simple_wasm_compile_fuzzer<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/v8_simple_wasm_data_section_fuzzer<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/v8_simple_wasm_function_sigs_section_fuzzer<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/v8_simple_wasm_globals_section_fuzzer<(EXECUTABLE_SUFFIX)', @@ -28,6 +29,7 @@ './wasm_asmjs/', './wasm_call/', './wasm_code/', + './wasm_compile/', './wasm_data_section/', './wasm_function_sigs_section/', './wasm_globals_section/', diff --git a/deps/v8/test/fuzzer/parser.cc b/deps/v8/test/fuzzer/parser.cc index 4ce4acb8bd..2b31bf5aab 100644 --- a/deps/v8/test/fuzzer/parser.cc +++ b/deps/v8/test/fuzzer/parser.cc @@ -35,8 +35,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { v8::internal::Handle<v8::internal::Script> script = factory->NewScript(source.ToHandleChecked()); - v8::internal::Zone zone(i_isolate->allocator(), ZONE_NAME); - v8::internal::ParseInfo info(&zone, script); + v8::internal::ParseInfo info(script); v8::internal::parsing::ParseProgram(&info); isolate->RequestGarbageCollectionForTesting( v8::Isolate::kFullGarbageCollection); diff --git a/deps/v8/test/fuzzer/testcfg.py b/deps/v8/test/fuzzer/testcfg.py index 0e4925bc06..0e07fb574e 100644 --- a/deps/v8/test/fuzzer/testcfg.py +++ b/deps/v8/test/fuzzer/testcfg.py @@ -19,9 +19,10 @@ class FuzzerVariantGenerator(testsuite.VariantGenerator): class FuzzerTestSuite(testsuite.TestSuite): SUB_TESTS = ( 'json', 'parser', 'regexp', 'wasm', 'wasm_asmjs', 'wasm_call', - 'wasm_code', 'wasm_data_section', 'wasm_function_sigs_section', - 'wasm_globals_section', 'wasm_imports_section', 'wasm_memory_section', - 'wasm_names_section', 'wasm_types_section' ) + 'wasm_code', 'wasm_compile', 'wasm_data_section', + 'wasm_function_sigs_section', 'wasm_globals_section', + 'wasm_imports_section', 'wasm_memory_section', 'wasm_names_section', + 'wasm_types_section' ) def __init__(self, name, root): super(FuzzerTestSuite, self).__init__(name, root) diff --git a/deps/v8/test/fuzzer/wasm-asmjs.cc b/deps/v8/test/fuzzer/wasm-asmjs.cc index d3341fa5b3..2f35ded7e3 100644 --- a/deps/v8/test/fuzzer/wasm-asmjs.cc +++ b/deps/v8/test/fuzzer/wasm-asmjs.cc @@ -17,6 +17,10 @@ #include "test/fuzzer/fuzzer-support.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + unsigned int max_mem_flag_value = v8::internal::FLAG_wasm_max_mem_pages; + unsigned int max_table_flag_value = v8::internal::FLAG_wasm_max_table_size; + v8::internal::FLAG_wasm_max_mem_pages = 32; + v8::internal::FLAG_wasm_max_table_size = 100; v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get(); v8::Isolate* isolate = support->GetIsolate(); v8::internal::Isolate* i_isolate = @@ -35,5 +39,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { v8::internal::wasm::testing::CompileAndRunWasmModule( i_isolate, data, data + size, v8::internal::wasm::ModuleOrigin::kAsmJsOrigin); + v8::internal::FLAG_wasm_max_mem_pages = max_mem_flag_value; + v8::internal::FLAG_wasm_max_table_size = max_table_flag_value; return 0; } diff --git a/deps/v8/test/fuzzer/wasm-call.cc b/deps/v8/test/fuzzer/wasm-call.cc index e18575c5d6..3291d9eab1 100644 --- a/deps/v8/test/fuzzer/wasm-call.cc +++ b/deps/v8/test/fuzzer/wasm-call.cc @@ -7,6 +7,7 @@ #include "include/v8.h" #include "src/isolate.h" +#include "src/objects-inl.h" #include "src/objects.h" #include "src/utils.h" #include "src/wasm/wasm-interpreter.h" @@ -168,15 +169,19 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { i_isolate, instance, &compiler_thrower, "main", argc, compiled_args, v8::internal::wasm::ModuleOrigin::kWasmOrigin); } + + // The WebAssembly spec allows the sign bit of NaN to be non-deterministic. + // This sign bit may cause result_interpreted to be different than + // result_compiled. Therefore we do not check the equality of the results + // if the execution may have produced a NaN at some point. + if (possible_nondeterminism) return 0; + if (result_interpreted == bit_cast<int32_t>(0xdeadbeef)) { CHECK(i_isolate->has_pending_exception()); i_isolate->clear_pending_exception(); } else { - // The WebAssembly spec allows the sign bit of NaN to be non-deterministic. - // This sign bit may cause result_interpreted to be different than - // result_compiled. Therefore we do not check the equality of the results - // if the execution may have produced a NaN at some point. - if (!possible_nondeterminism && (result_interpreted != result_compiled)) { + CHECK(!i_isolate->has_pending_exception()); + if (result_interpreted != result_compiled) { V8_Fatal(__FILE__, __LINE__, "WasmCodeFuzzerHash=%x", v8::internal::StringHasher::HashSequentialString( data, static_cast<int>(size), WASM_CODE_FUZZER_HASH_SEED)); diff --git a/deps/v8/test/fuzzer/wasm-code.cc b/deps/v8/test/fuzzer/wasm-code.cc index 167680faf2..a80cfcfaca 100644 --- a/deps/v8/test/fuzzer/wasm-code.cc +++ b/deps/v8/test/fuzzer/wasm-code.cc @@ -7,6 +7,7 @@ #include "include/v8.h" #include "src/isolate.h" +#include "src/objects-inl.h" #include "src/objects.h" #include "src/ostreams.h" #include "src/wasm/wasm-interpreter.h" @@ -38,7 +39,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { os << std::endl; os << "(function() {" << std::endl; os << " var builder = new WasmModuleBuilder();" << std::endl; - os << " builder.addMemory(32, 32, false);" << std::endl; + os << " builder.addMemory(16, 32, false);" << std::endl; os << " builder.addFunction(\"test\", kSig_i_iii)" << std::endl; os << " .addBodyWithEnd([" << std::endl; } @@ -136,15 +137,23 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { i_isolate, instance, &compiler_thrower, "main", arraysize(arguments), arguments, v8::internal::wasm::ModuleOrigin::kWasmOrigin); } + + // The WebAssembly spec allows the sign bit of NaN to be non-deterministic. + // This sign bit may cause result_interpreted to be different than + // result_compiled. Therefore we do not check the equality of the results + // if the execution may have produced a NaN at some point. + if (possible_nondeterminism) return 0; + if (result_interpreted == bit_cast<int32_t>(0xdeadbeef)) { CHECK(i_isolate->has_pending_exception()); i_isolate->clear_pending_exception(); } else { + CHECK(!i_isolate->has_pending_exception()); // The WebAssembly spec allows the sign bit of NaN to be non-deterministic. // This sign bit may cause result_interpreted to be different than // result_compiled. Therefore we do not check the equality of the results // if the execution may have produced a NaN at some point. - if (!possible_nondeterminism && (result_interpreted != result_compiled)) { + if (result_interpreted != result_compiled) { V8_Fatal(__FILE__, __LINE__, "WasmCodeFuzzerHash=%x", v8::internal::StringHasher::HashSequentialString( data, static_cast<int>(size), WASM_CODE_FUZZER_HASH_SEED)); diff --git a/deps/v8/test/fuzzer/wasm-compile.cc b/deps/v8/test/fuzzer/wasm-compile.cc new file mode 100644 index 0000000000..0b01ce2357 --- /dev/null +++ b/deps/v8/test/fuzzer/wasm-compile.cc @@ -0,0 +1,447 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <stddef.h> +#include <stdint.h> +#include <stdlib.h> + +#include <algorithm> + +#include "include/v8.h" +#include "src/isolate.h" +#include "src/objects-inl.h" +#include "src/objects.h" +#include "src/ostreams.h" +#include "src/wasm/wasm-interpreter.h" +#include "src/wasm/wasm-module-builder.h" +#include "src/wasm/wasm-module.h" +#include "test/common/wasm/test-signatures.h" +#include "test/common/wasm/wasm-module-runner.h" +#include "test/fuzzer/fuzzer-support.h" + +#define WASM_CODE_FUZZER_HASH_SEED 83 + +typedef uint8_t byte; + +using namespace v8::internal::wasm; + +namespace { + +class DataRange { + const uint8_t* data_; + size_t size_; + + public: + DataRange(const uint8_t* data, size_t size) : data_(data), size_(size) {} + + size_t size() const { return size_; } + + std::pair<DataRange, DataRange> split(uint32_t index) const { + return std::make_pair(DataRange(data_, index), + DataRange(data_ + index, size() - index)); + } + + std::pair<DataRange, DataRange> split() { + uint16_t index = get<uint16_t>(); + if (size() > 0) { + index = index % size(); + } else { + index = 0; + } + return split(index); + } + + template <typename T> + T get() { + if (size() == 0) { + return T(); + } else { + // We want to support the case where we have less than sizeof(T) bytes + // remaining in the slice. For example, if we emit an i32 constant, it's + // okay if we don't have a full four bytes available, we'll just use what + // we have. We aren't concerned about endianness because we are generating + // arbitrary expressions. + const size_t num_bytes = std::min(sizeof(T), size()); + T result = T(); + memcpy(&result, data_, num_bytes); + data_ += num_bytes; + size_ -= num_bytes; + return result; + } + } +}; + +class WasmGenerator { + template <WasmOpcode Op, ValueType... Args> + std::function<void(DataRange)> op() { + return [this](DataRange data) { + Generate<Args...>(data); + builder_->Emit(Op); + }; + } + + template <ValueType T> + std::function<void(DataRange)> block() { + return [this](DataRange data) { + blocks_.push_back(T); + builder_->EmitWithU8( + kExprBlock, static_cast<uint8_t>(WasmOpcodes::ValueTypeCodeFor(T))); + Generate<T>(data); + builder_->Emit(kExprEnd); + blocks_.pop_back(); + }; + } + + template <ValueType T> + std::function<void(DataRange)> block_br() { + return [this](DataRange data) { + blocks_.push_back(T); + builder_->EmitWithU8( + kExprBlock, static_cast<uint8_t>(WasmOpcodes::ValueTypeCodeFor(T))); + + const uint32_t target_block = data.get<uint32_t>() % blocks_.size(); + const ValueType break_type = blocks_[target_block]; + + Generate(break_type, data); + builder_->EmitWithVarInt(kExprBr, target_block); + builder_->Emit(kExprEnd); + blocks_.pop_back(); + }; + } + + public: + WasmGenerator(v8::internal::wasm::WasmFunctionBuilder* fn) : builder_(fn) {} + + void Generate(ValueType type, DataRange data); + + template <ValueType T> + void Generate(DataRange data); + + template <ValueType T1, ValueType T2, ValueType... Ts> + void Generate(DataRange data) { + const auto parts = data.split(); + Generate<T1>(parts.first); + Generate<T2, Ts...>(parts.second); + } + + private: + v8::internal::wasm::WasmFunctionBuilder* builder_; + std::vector<ValueType> blocks_; +}; + +template <> +void WasmGenerator::Generate<kWasmI32>(DataRange data) { + if (data.size() <= sizeof(uint32_t)) { + builder_->EmitI32Const(data.get<uint32_t>()); + } else { + const std::function<void(DataRange)> alternates[] = { + op<kExprI32Eqz, kWasmI32>(), // + op<kExprI32Eq, kWasmI32, kWasmI32>(), + op<kExprI32Ne, kWasmI32, kWasmI32>(), + op<kExprI32LtS, kWasmI32, kWasmI32>(), + op<kExprI32LtU, kWasmI32, kWasmI32>(), + op<kExprI32GeS, kWasmI32, kWasmI32>(), + op<kExprI32GeU, kWasmI32, kWasmI32>(), + + op<kExprI64Eqz, kWasmI64>(), // + op<kExprI64Eq, kWasmI64, kWasmI64>(), + op<kExprI64Ne, kWasmI64, kWasmI64>(), + op<kExprI64LtS, kWasmI64, kWasmI64>(), + op<kExprI64LtU, kWasmI64, kWasmI64>(), + op<kExprI64GeS, kWasmI64, kWasmI64>(), + op<kExprI64GeU, kWasmI64, kWasmI64>(), + + op<kExprF32Eq, kWasmF32, kWasmF32>(), + op<kExprF32Ne, kWasmF32, kWasmF32>(), + op<kExprF32Lt, kWasmF32, kWasmF32>(), + op<kExprF32Ge, kWasmF32, kWasmF32>(), + + op<kExprF64Eq, kWasmF64, kWasmF64>(), + op<kExprF64Ne, kWasmF64, kWasmF64>(), + op<kExprF64Lt, kWasmF64, kWasmF64>(), + op<kExprF64Ge, kWasmF64, kWasmF64>(), + + op<kExprI32Add, kWasmI32, kWasmI32>(), + op<kExprI32Sub, kWasmI32, kWasmI32>(), + op<kExprI32Mul, kWasmI32, kWasmI32>(), + + op<kExprI32DivS, kWasmI32, kWasmI32>(), + op<kExprI32DivU, kWasmI32, kWasmI32>(), + op<kExprI32RemS, kWasmI32, kWasmI32>(), + op<kExprI32RemU, kWasmI32, kWasmI32>(), + + op<kExprI32And, kWasmI32, kWasmI32>(), + op<kExprI32Ior, kWasmI32, kWasmI32>(), + op<kExprI32Xor, kWasmI32, kWasmI32>(), + op<kExprI32Shl, kWasmI32, kWasmI32>(), + op<kExprI32ShrU, kWasmI32, kWasmI32>(), + op<kExprI32ShrS, kWasmI32, kWasmI32>(), + op<kExprI32Ror, kWasmI32, kWasmI32>(), + op<kExprI32Rol, kWasmI32, kWasmI32>(), + + op<kExprI32Clz, kWasmI32>(), // + op<kExprI32Ctz, kWasmI32>(), // + op<kExprI32Popcnt, kWasmI32>(), + + op<kExprI32ConvertI64, kWasmI64>(), // + op<kExprI32SConvertF32, kWasmF32>(), + op<kExprI32UConvertF32, kWasmF32>(), + op<kExprI32SConvertF64, kWasmF64>(), + op<kExprI32UConvertF64, kWasmF64>(), + op<kExprI32ReinterpretF32, kWasmF32>(), + + block<kWasmI32>(), + block_br<kWasmI32>()}; + + static_assert(arraysize(alternates) < std::numeric_limits<uint8_t>::max(), + "Too many alternates. Replace with a bigger type if needed."); + const auto which = data.get<uint8_t>(); + + alternates[which % arraysize(alternates)](data); + } +} + +template <> +void WasmGenerator::Generate<kWasmI64>(DataRange data) { + if (data.size() <= sizeof(uint64_t)) { + const uint8_t bytes[] = {WASM_I64V(data.get<uint64_t>())}; + builder_->EmitCode(bytes, arraysize(bytes)); + } else { + const std::function<void(DataRange)> alternates[] = { + op<kExprI64Add, kWasmI64, kWasmI64>(), + op<kExprI64Sub, kWasmI64, kWasmI64>(), + op<kExprI64Mul, kWasmI64, kWasmI64>(), + + op<kExprI64DivS, kWasmI64, kWasmI64>(), + op<kExprI64DivU, kWasmI64, kWasmI64>(), + op<kExprI64RemS, kWasmI64, kWasmI64>(), + op<kExprI64RemU, kWasmI64, kWasmI64>(), + + op<kExprI64And, kWasmI64, kWasmI64>(), + op<kExprI64Ior, kWasmI64, kWasmI64>(), + op<kExprI64Xor, kWasmI64, kWasmI64>(), + op<kExprI64Shl, kWasmI64, kWasmI64>(), + op<kExprI64ShrU, kWasmI64, kWasmI64>(), + op<kExprI64ShrS, kWasmI64, kWasmI64>(), + op<kExprI64Ror, kWasmI64, kWasmI64>(), + op<kExprI64Rol, kWasmI64, kWasmI64>(), + + op<kExprI64Clz, kWasmI64>(), + op<kExprI64Ctz, kWasmI64>(), + op<kExprI64Popcnt, kWasmI64>(), + + block<kWasmI64>(), + block_br<kWasmI64>()}; + + static_assert(arraysize(alternates) < std::numeric_limits<uint8_t>::max(), + "Too many alternates. Replace with a bigger type if needed."); + const auto which = data.get<uint8_t>(); + + alternates[which % arraysize(alternates)](data); + } +} + +template <> +void WasmGenerator::Generate<kWasmF32>(DataRange data) { + if (data.size() <= sizeof(uint32_t)) { + const uint32_t i = data.get<uint32_t>(); + builder_->Emit(kExprF32Const); + builder_->EmitCode(reinterpret_cast<const uint8_t*>(&i), sizeof(i)); + } else { + const std::function<void(DataRange)> alternates[] = { + op<kExprF32Add, kWasmF32, kWasmF32>(), + op<kExprF32Sub, kWasmF32, kWasmF32>(), + op<kExprF32Mul, kWasmF32, kWasmF32>(), + + block<kWasmF32>(), block_br<kWasmF32>()}; + + static_assert(arraysize(alternates) < std::numeric_limits<uint8_t>::max(), + "Too many alternates. Replace with a bigger type if needed."); + const auto which = data.get<uint8_t>(); + + alternates[which % arraysize(alternates)](data); + } +} + +template <> +void WasmGenerator::Generate<kWasmF64>(DataRange data) { + if (data.size() <= sizeof(uint64_t)) { + // TODO (eholk): generate full 64-bit constants + uint64_t i = 0; + while (data.size() > 0) { + i <<= 8; + i |= data.get<uint8_t>(); + } + builder_->Emit(kExprF64Const); + builder_->EmitCode(reinterpret_cast<uint8_t*>(&i), sizeof(i)); + } else { + const std::function<void(DataRange)> alternates[] = { + op<kExprF64Add, kWasmF64, kWasmF64>(), + op<kExprF64Sub, kWasmF64, kWasmF64>(), + op<kExprF64Mul, kWasmF64, kWasmF64>(), + + block<kWasmF64>(), block_br<kWasmF64>()}; + + static_assert(arraysize(alternates) < std::numeric_limits<uint8_t>::max(), + "Too many alternates. Replace with a bigger type if needed."); + const auto which = data.get<uint8_t>(); + + alternates[which % arraysize(alternates)](data); + } +} + +void WasmGenerator::Generate(ValueType type, DataRange data) { + switch (type) { + case kWasmI32: + return Generate<kWasmI32>(data); + case kWasmI64: + return Generate<kWasmI64>(data); + case kWasmF32: + return Generate<kWasmF32>(data); + case kWasmF64: + return Generate<kWasmF64>(data); + default: + UNREACHABLE(); + } +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + // Save the flag so that we can change it and restore it later. + bool generate_test = v8::internal::FLAG_wasm_code_fuzzer_gen_test; + if (generate_test) { + v8::internal::OFStream os(stdout); + + os << "// Copyright 2017 the V8 project authors. All rights reserved." + << std::endl; + os << "// Use of this source code is governed by a BSD-style license that " + "can be" + << std::endl; + os << "// found in the LICENSE file." << std::endl; + os << std::endl; + os << "load(\"test/mjsunit/wasm/wasm-constants.js\");" << std::endl; + os << "load(\"test/mjsunit/wasm/wasm-module-builder.js\");" << std::endl; + os << std::endl; + os << "(function() {" << std::endl; + os << " var builder = new WasmModuleBuilder();" << std::endl; + os << " builder.addMemory(16, 32, false);" << std::endl; + os << " builder.addFunction(\"test\", kSig_i_iii)" << std::endl; + os << " .addBodyWithEnd([" << std::endl; + } + v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get(); + v8::Isolate* isolate = support->GetIsolate(); + v8::internal::Isolate* i_isolate = + reinterpret_cast<v8::internal::Isolate*>(isolate); + + // Clear any pending exceptions from a prior run. + if (i_isolate->has_pending_exception()) { + i_isolate->clear_pending_exception(); + } + + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope handle_scope(isolate); + v8::Context::Scope context_scope(support->GetContext()); + v8::TryCatch try_catch(isolate); + + v8::internal::AccountingAllocator allocator; + v8::internal::Zone zone(&allocator, ZONE_NAME); + + TestSignatures sigs; + + WasmModuleBuilder builder(&zone); + + v8::internal::wasm::WasmFunctionBuilder* f = + builder.AddFunction(sigs.i_iii()); + + WasmGenerator gen(f); + gen.Generate<kWasmI32>(DataRange(data, static_cast<uint32_t>(size))); + + uint8_t end_opcode = kExprEnd; + f->EmitCode(&end_opcode, 1); + f->ExportAs(v8::internal::CStrVector("main")); + + ZoneBuffer buffer(&zone); + builder.WriteTo(buffer); + + v8::internal::wasm::testing::SetupIsolateForWasmModule(i_isolate); + + v8::internal::HandleScope scope(i_isolate); + + ErrorThrower interpreter_thrower(i_isolate, "Interpreter"); + std::unique_ptr<const WasmModule> module(testing::DecodeWasmModuleForTesting( + i_isolate, &interpreter_thrower, buffer.begin(), buffer.end(), + v8::internal::wasm::ModuleOrigin::kWasmOrigin, true)); + + // Clear the flag so that the WebAssembly code is not printed twice. + v8::internal::FLAG_wasm_code_fuzzer_gen_test = false; + if (module == nullptr) { + if (generate_test) { + v8::internal::OFStream os(stdout); + os << " ])" << std::endl; + os << " .exportFunc();" << std::endl; + os << " assertThrows(function() { builder.instantiate(); });" + << std::endl; + os << "})();" << std::endl; + } + return 0; + } + if (generate_test) { + v8::internal::OFStream os(stdout); + os << " ])" << std::endl; + os << " .exportFunc();" << std::endl; + os << " var module = builder.instantiate();" << std::endl; + os << " module.exports.test(1, 2, 3);" << std::endl; + os << "})();" << std::endl; + } + + ModuleWireBytes wire_bytes(buffer.begin(), buffer.end()); + int32_t result_interpreted; + bool possible_nondeterminism = false; + { + WasmVal args[] = {WasmVal(1), WasmVal(2), WasmVal(3)}; + result_interpreted = testing::InterpretWasmModule( + i_isolate, &interpreter_thrower, module.get(), wire_bytes, 0, args, + &possible_nondeterminism); + } + + ErrorThrower compiler_thrower(i_isolate, "Compiler"); + v8::internal::Handle<v8::internal::JSObject> instance = + testing::InstantiateModuleForTesting(i_isolate, &compiler_thrower, + module.get(), wire_bytes); + // Restore the flag. + v8::internal::FLAG_wasm_code_fuzzer_gen_test = generate_test; + if (!interpreter_thrower.error()) { + CHECK(!instance.is_null()); + } else { + return 0; + } + int32_t result_compiled; + { + v8::internal::Handle<v8::internal::Object> arguments[] = { + v8::internal::handle(v8::internal::Smi::FromInt(1), i_isolate), + v8::internal::handle(v8::internal::Smi::FromInt(2), i_isolate), + v8::internal::handle(v8::internal::Smi::FromInt(3), i_isolate)}; + result_compiled = testing::CallWasmFunctionForTesting( + i_isolate, instance, &compiler_thrower, "main", arraysize(arguments), + arguments, v8::internal::wasm::ModuleOrigin::kWasmOrigin); + } + if (result_interpreted == bit_cast<int32_t>(0xdeadbeef) && + !possible_nondeterminism) { + CHECK(i_isolate->has_pending_exception()); + i_isolate->clear_pending_exception(); + } else { + // The WebAssembly spec allows the sign bit of NaN to be non-deterministic. + // This sign bit may cause result_interpreted to be different than + // result_compiled. Therefore we do not check the equality of the results + // if the execution may have produced a NaN at some point. + if (!possible_nondeterminism && (result_interpreted != result_compiled)) { + printf("\nInterpreter returned 0x%x but compiled code returned 0x%x\n", + result_interpreted, result_compiled); + V8_Fatal(__FILE__, __LINE__, "WasmCodeFuzzerHash=%x", + v8::internal::StringHasher::HashSequentialString( + data, static_cast<int>(size), WASM_CODE_FUZZER_HASH_SEED)); + } + } + return 0; +} diff --git a/deps/v8/test/fuzzer/wasm-data-section.cc b/deps/v8/test/fuzzer/wasm-data-section.cc index 2fbdbcd906..30b702fe8d 100644 --- a/deps/v8/test/fuzzer/wasm-data-section.cc +++ b/deps/v8/test/fuzzer/wasm-data-section.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/objects-inl.h" #include "test/fuzzer/wasm-section-fuzzers.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { diff --git a/deps/v8/test/fuzzer/wasm-function-sigs-section.cc b/deps/v8/test/fuzzer/wasm-function-sigs-section.cc index a0b66e12d0..e621aa820e 100644 --- a/deps/v8/test/fuzzer/wasm-function-sigs-section.cc +++ b/deps/v8/test/fuzzer/wasm-function-sigs-section.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/objects-inl.h" #include "test/fuzzer/wasm-section-fuzzers.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { diff --git a/deps/v8/test/fuzzer/wasm-globals-section.cc b/deps/v8/test/fuzzer/wasm-globals-section.cc index a58ef0f2b5..dccdc1079c 100644 --- a/deps/v8/test/fuzzer/wasm-globals-section.cc +++ b/deps/v8/test/fuzzer/wasm-globals-section.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/objects-inl.h" #include "test/fuzzer/wasm-section-fuzzers.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { diff --git a/deps/v8/test/fuzzer/wasm-imports-section.cc b/deps/v8/test/fuzzer/wasm-imports-section.cc index d6513e59dc..4690597bba 100644 --- a/deps/v8/test/fuzzer/wasm-imports-section.cc +++ b/deps/v8/test/fuzzer/wasm-imports-section.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/objects-inl.h" #include "test/fuzzer/wasm-section-fuzzers.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { diff --git a/deps/v8/test/fuzzer/wasm-memory-section.cc b/deps/v8/test/fuzzer/wasm-memory-section.cc index 77065f1729..4736d6e68d 100644 --- a/deps/v8/test/fuzzer/wasm-memory-section.cc +++ b/deps/v8/test/fuzzer/wasm-memory-section.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/objects-inl.h" #include "test/fuzzer/wasm-section-fuzzers.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { diff --git a/deps/v8/test/fuzzer/wasm-names-section.cc b/deps/v8/test/fuzzer/wasm-names-section.cc index 01846823ff..9a3797cf80 100644 --- a/deps/v8/test/fuzzer/wasm-names-section.cc +++ b/deps/v8/test/fuzzer/wasm-names-section.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/objects-inl.h" #include "test/fuzzer/wasm-section-fuzzers.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { diff --git a/deps/v8/test/fuzzer/wasm-section-fuzzers.cc b/deps/v8/test/fuzzer/wasm-section-fuzzers.cc index 1ef5967aa8..e98c510b77 100644 --- a/deps/v8/test/fuzzer/wasm-section-fuzzers.cc +++ b/deps/v8/test/fuzzer/wasm-section-fuzzers.cc @@ -6,6 +6,7 @@ #include "include/v8.h" #include "src/isolate.h" +#include "src/objects-inl.h" #include "src/wasm/wasm-module-builder.h" #include "src/wasm/wasm-module.h" #include "src/zone/accounting-allocator.h" diff --git a/deps/v8/test/fuzzer/wasm-section-fuzzers.h b/deps/v8/test/fuzzer/wasm-section-fuzzers.h index a28ada134e..41ff6af687 100644 --- a/deps/v8/test/fuzzer/wasm-section-fuzzers.h +++ b/deps/v8/test/fuzzer/wasm-section-fuzzers.h @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -#include "src/wasm/wasm-module.h" +#include "src/wasm/module-decoder.h" int fuzz_wasm_section(v8::internal::wasm::WasmSectionCode section, const uint8_t* data, size_t size); diff --git a/deps/v8/test/fuzzer/wasm-types-section.cc b/deps/v8/test/fuzzer/wasm-types-section.cc index 7d5fe65277..2d7e91e32a 100644 --- a/deps/v8/test/fuzzer/wasm-types-section.cc +++ b/deps/v8/test/fuzzer/wasm-types-section.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/objects-inl.h" #include "test/fuzzer/wasm-section-fuzzers.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { diff --git a/deps/v8/test/fuzzer/wasm.cc b/deps/v8/test/fuzzer/wasm.cc index 933be71344..f179450db0 100644 --- a/deps/v8/test/fuzzer/wasm.cc +++ b/deps/v8/test/fuzzer/wasm.cc @@ -17,6 +17,10 @@ #include "test/fuzzer/fuzzer-support.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + unsigned int max_mem_flag_value = v8::internal::FLAG_wasm_max_mem_pages; + unsigned int max_table_flag_value = v8::internal::FLAG_wasm_max_table_size; + v8::internal::FLAG_wasm_max_mem_pages = 32; + v8::internal::FLAG_wasm_max_table_size = 100; v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get(); v8::Isolate* isolate = support->GetIsolate(); v8::internal::Isolate* i_isolate = @@ -34,5 +38,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { v8::internal::wasm::testing::SetupIsolateForWasmModule(i_isolate); v8::internal::wasm::testing::CompileAndRunWasmModule( i_isolate, data, data + size, v8::internal::wasm::kWasmOrigin); + v8::internal::FLAG_wasm_max_mem_pages = max_mem_flag_value; + v8::internal::FLAG_wasm_max_table_size = max_table_flag_value; return 0; } diff --git a/deps/v8/test/fuzzer/wasm_compile/foo b/deps/v8/test/fuzzer/wasm_compile/foo new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/deps/v8/test/fuzzer/wasm_compile/foo diff --git a/deps/v8/test/inspector/console/destroy-context-during-log.js b/deps/v8/test/inspector/console/destroy-context-during-log.js index 2289fbefc0..9c5753ffc0 100644 --- a/deps/v8/test/inspector/console/destroy-context-during-log.js +++ b/deps/v8/test/inspector/console/destroy-context-during-log.js @@ -6,6 +6,7 @@ const expression = ` Object.defineProperty(Object.prototype, 'RemoteObject', { configurable: true, set(v) { + console.log("Should never be called"); delete Object.prototype.RemoteObject; this.RemoteObject = v; @@ -25,6 +26,7 @@ const expression = ` detachInspector(); attachInspector(); console.log("First inspector activity after attaching inspector"); + console.log("End of test"); `; Protocol.Runtime.enable(); diff --git a/deps/v8/test/inspector/cpu-profiler/coverage-expected.txt b/deps/v8/test/inspector/cpu-profiler/coverage-expected.txt new file mode 100644 index 0000000000..6b0af036fc --- /dev/null +++ b/deps/v8/test/inspector/cpu-profiler/coverage-expected.txt @@ -0,0 +1,333 @@ +Test collecting code coverage data with Profiler.collectCoverage. + +Running test: testPreciseCoverage +{ + id : <messageId> + result : { + } +} +{ + id : <messageId> + result : { + result : [ + [0] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 0 + endLineNumber : 9 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + [1] : { + functionName : fib + ranges : [ + [0] : { + count : 15 + endColumnNumber : 1 + endLineNumber : 4 + startColumnNumber : 0 + startLineNumber : 1 + } + ] + } + [2] : { + functionName : iife + ranges : [ + [0] : { + count : 1 + endColumnNumber : 1 + endLineNumber : 7 + startColumnNumber : 1 + startLineNumber : 5 + } + ] + } + ] + scriptId : <scriptId> + url : 1 + } + [1] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 11 + endLineNumber : 0 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + ] + scriptId : <scriptId> + url : + } + ] + } +} +{ + id : <messageId> + result : { + result : [ + [0] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 0 + endColumnNumber : 0 + endLineNumber : 9 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + [1] : { + functionName : fib + ranges : [ + [0] : { + count : 0 + endColumnNumber : 1 + endLineNumber : 4 + startColumnNumber : 0 + startLineNumber : 1 + } + ] + } + [2] : { + functionName : iife + ranges : [ + [0] : { + count : 0 + endColumnNumber : 1 + endLineNumber : 7 + startColumnNumber : 1 + startLineNumber : 5 + } + ] + } + ] + scriptId : <scriptId> + url : 1 + } + [1] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 0 + endColumnNumber : 11 + endLineNumber : 0 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + ] + scriptId : <scriptId> + url : + } + ] + } +} + +Running test: testPreciseCoverageFail +{ + id : <messageId> + result : { + result : { + description : 8 + type : number + value : 8 + } + } +} +{ + error : { + code : -32000 + message : Precise coverage has not been started. + } + id : <messageId> +} + +Running test: testBestEffortCoverage +{ + id : <messageId> + result : { + result : { + description : 8 + type : number + value : 8 + } + } +} +{ + id : <messageId> + result : { + result : [ + ] + } +} +{ + id : <messageId> + result : { + result : [ + ] + } +} + +Running test: testBestEffortCoveragePrecise +{ + id : <messageId> + result : { + result : { + description : 8 + type : number + value : 8 + } + } +} +{ + id : <messageId> + result : { + result : [ + [0] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 0 + endLineNumber : 9 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + [1] : { + functionName : fib + ranges : [ + [0] : { + count : 15 + endColumnNumber : 1 + endLineNumber : 4 + startColumnNumber : 0 + startLineNumber : 1 + } + ] + } + [2] : { + functionName : iife + ranges : [ + [0] : { + count : 1 + endColumnNumber : 1 + endLineNumber : 7 + startColumnNumber : 1 + startLineNumber : 5 + } + ] + } + ] + scriptId : <scriptId> + url : 4 + } + [1] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 11 + endLineNumber : 0 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + ] + scriptId : <scriptId> + url : + } + ] + } +} +{ + id : <messageId> + result : { + result : [ + [0] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 0 + endLineNumber : 9 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + [1] : { + functionName : fib + ranges : [ + [0] : { + count : 15 + endColumnNumber : 1 + endLineNumber : 4 + startColumnNumber : 0 + startLineNumber : 1 + } + ] + } + [2] : { + functionName : iife + ranges : [ + [0] : { + count : 1 + endColumnNumber : 1 + endLineNumber : 7 + startColumnNumber : 1 + startLineNumber : 5 + } + ] + } + ] + scriptId : <scriptId> + url : 4 + } + [1] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 11 + endLineNumber : 0 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + ] + scriptId : <scriptId> + url : + } + ] + } +} diff --git a/deps/v8/test/inspector/cpu-profiler/coverage.js b/deps/v8/test/inspector/cpu-profiler/coverage.js new file mode 100644 index 0000000000..16f679dc5a --- /dev/null +++ b/deps/v8/test/inspector/cpu-profiler/coverage.js @@ -0,0 +1,100 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var source = +` +function fib(x) { + if (x < 2) return 1; + return fib(x-1) + fib(x-2); +} +(function iife() { + return 1; +})(); +fib(5); +`; + +print("Test collecting code coverage data with Profiler.collectCoverage."); + +function ClearAndGC() { + return Protocol.Runtime.evaluate({ expression: "fib = null;" }) + .then(() => Protocol.HeapProfiler.enable()) + .then(() => Protocol.HeapProfiler.collectGarbage()) + .then(() => Protocol.HeapProfiler.disable()); +} + +function LogSorted(message) { + message.result.result.sort((a, b) => parseInt(a.scriptId) - parseInt(b.scriptId)); + return InspectorTest.logMessage(message); +} + +InspectorTest.runTestSuite([ + function testPreciseCoverage(next) + { + Protocol.Runtime.enable() + .then(Protocol.Profiler.enable) + .then(Protocol.Profiler.startPreciseCoverage) + .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "1", persistScript: true })) + .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId })) + .then(ClearAndGC) + .then(InspectorTest.logMessage) + .then(Protocol.Profiler.takePreciseCoverage) + .then(LogSorted) + .then(Protocol.Profiler.takePreciseCoverage) + .then(LogSorted) + .then(ClearAndGC) + .then(Protocol.Profiler.stopPreciseCoverage) + .then(Protocol.Profiler.disable) + .then(Protocol.Runtime.disable) + .then(next); + }, + function testPreciseCoverageFail(next) + { + Protocol.Runtime.enable() + .then(Protocol.Profiler.enable) + .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "2", persistScript: true })) + .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId })) + .then(InspectorTest.logMessage) + .then(ClearAndGC) + .then(Protocol.Profiler.takePreciseCoverage) + .then(InspectorTest.logMessage) + .then(ClearAndGC) + .then(Protocol.Profiler.disable) + .then(Protocol.Runtime.disable) + .then(next); + }, + function testBestEffortCoverage(next) + { + Protocol.Runtime.enable() + .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "3", persistScript: true })) + .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId })) + .then(InspectorTest.logMessage) + .then(ClearAndGC) + .then(Protocol.Profiler.getBestEffortCoverage) + .then(LogSorted) + .then(Protocol.Profiler.getBestEffortCoverage) + .then(LogSorted) + .then(ClearAndGC) + .then(Protocol.Runtime.disable) + .then(next); + }, + function testBestEffortCoveragePrecise(next) + { + Protocol.Runtime.enable() + .then(Protocol.Profiler.enable) + .then(Protocol.Profiler.startPreciseCoverage) + .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "4", persistScript: true })) + .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId })) + .then(InspectorTest.logMessage) + .then(ClearAndGC) + .then(Protocol.Profiler.getBestEffortCoverage) + .then(LogSorted) + .then(Protocol.Profiler.getBestEffortCoverage) + .then(LogSorted) + .then(ClearAndGC) + .then(Protocol.Profiler.stopPreciseCoverage) + .then(Protocol.Profiler.disable) + .then(Protocol.Runtime.disable) + .then(next); + }, +]); diff --git a/deps/v8/test/inspector/debugger/async-instrumentation-expected.txt b/deps/v8/test/inspector/debugger/async-instrumentation-expected.txt index a92c9a00fb..2a538879ae 100644 --- a/deps/v8/test/inspector/debugger/async-instrumentation-expected.txt +++ b/deps/v8/test/inspector/debugger/async-instrumentation-expected.txt @@ -1,7 +1,7 @@ Checks async instrumentation enabled in the middle. Running test: beforeAsyncTaskScheduled -test (test.js:19:2) +test (test.js:16:2) (anonymous) (expr1.js:0:0) test (test.js:21:2) @@ -19,7 +19,7 @@ test (test.js:20:2) Running test: afterAsyncTaskScheduled -test (test.js:19:2) +test (test.js:16:2) (anonymous) (expr1.js:0:0) test (test.js:21:2) @@ -31,7 +31,7 @@ foo (test.js:12:2) Running test: afterAsyncTaskStarted -test (test.js:19:2) +test (test.js:16:2) (anonymous) (expr1.js:0:0) test (test.js:21:2) diff --git a/deps/v8/test/inspector/debugger/async-instrumentation.js b/deps/v8/test/inspector/debugger/async-instrumentation.js index b61e28a2c4..777dec3a9c 100644 --- a/deps/v8/test/inspector/debugger/async-instrumentation.js +++ b/deps/v8/test/inspector/debugger/async-instrumentation.js @@ -13,10 +13,10 @@ function foo() { } function test() { + debugger; var resolve1; var p1 = new Promise(resolve => resolve1 = resolve); var p2 = p1.then(foo); - debugger; resolve1(); // asyncTaskScheduled debugger; return p2; diff --git a/deps/v8/test/inspector/debugger/async-stack-await-expected.txt b/deps/v8/test/inspector/debugger/async-stack-await-expected.txt index 1fda6b0d4b..506b9a268a 100644 --- a/deps/v8/test/inspector/debugger/async-stack-await-expected.txt +++ b/deps/v8/test/inspector/debugger/async-stack-await-expected.txt @@ -1,33 +1,34 @@ Checks that async stacks works for async/await foo2 (test.js:15:2) --- async function -- +-- async function (test.js:13:19)-- foo2 (test.js:13:19) test (test.js:24:8) (anonymous) (expr.js:0:0) foo2 (test.js:17:2) --- async function -- +-- async function (test.js:13:19)-- foo2 (test.js:13:19) test (test.js:24:8) (anonymous) (expr.js:0:0) foo1 (test.js:9:2) foo2 (test.js:18:8) --- async function -- +-- async function (test.js:13:19)-- foo2 (test.js:13:19) test (test.js:24:8) (anonymous) (expr.js:0:0) foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:19:43)-- +-- Promise.resolve (test.js:19:16)-- foo2 (test.js:19:30) --- async function -- +-- async function (test.js:13:19)-- foo2 (test.js:13:19) test (test.js:24:8) (anonymous) (expr.js:0:0) foo2 (test.js:20:2) --- async function -- +-- async function (test.js:13:19)-- foo2 (test.js:13:19) test (test.js:24:8) (anonymous) (expr.js:0:0) diff --git a/deps/v8/test/inspector/debugger/async-stack-await.js b/deps/v8/test/inspector/debugger/async-stack-await.js index a7eb741904..50f423d044 100644 --- a/deps/v8/test/inspector/debugger/async-stack-await.js +++ b/deps/v8/test/inspector/debugger/async-stack-await.js @@ -28,12 +28,7 @@ async function test() { InspectorTest.setupScriptMap(); Protocol.Debugger.onPaused(message => { InspectorTest.logCallFrames(message.params.callFrames); - var asyncStackTrace = message.params.asyncStackTrace; - while (asyncStackTrace) { - InspectorTest.log(`-- ${asyncStackTrace.description} --`); - InspectorTest.logCallFrames(asyncStackTrace.callFrames); - asyncStackTrace = asyncStackTrace.parent; - } + InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace); InspectorTest.log(''); Protocol.Debugger.resume(); }); diff --git a/deps/v8/test/inspector/debugger/async-stack-created-frame-expected.txt b/deps/v8/test/inspector/debugger/async-stack-created-frame-expected.txt new file mode 100644 index 0000000000..6e61d1aca4 --- /dev/null +++ b/deps/v8/test/inspector/debugger/async-stack-created-frame-expected.txt @@ -0,0 +1,100 @@ +Checks created frame for async call chain + +Running test: testPromise +foo1 (test.js:10:2) +-- Promise.resolve (test.js:20:14)-- +promise (test.js:21:2) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseThen +foo1 (test.js:10:2) +-- Promise.resolve (test.js:28:14)-- +promiseThen (test.js:30:2) +(anonymous) (expr.js:0:0) + +foo2 (test.js:14:2) +-- Promise.resolve (test.js:29:14)-- +-- Promise.resolve (test.js:28:14)-- +promiseThen (test.js:30:2) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseThenThen +foo1 (test.js:10:2) +-- Promise.resolve (test.js:37:14)-- +promiseThenThen (test.js:39:2) +(anonymous) (expr.js:0:0) + +foo1 (test.js:10:2) +-- Promise.resolve (test.js:38:14)-- +promiseThenThen (test.js:39:2) +(anonymous) (expr.js:0:0) + +foo2 (test.js:14:2) +-- Promise.resolve (test.js:37:25)-- +-- Promise.resolve (test.js:37:14)-- +promiseThenThen (test.js:39:2) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseResolve +foo1 (test.js:10:2) +-- Promise.resolve (test.js:44:27)-- +promiseResolve (test.js:44:17) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseReject +foo1 (test.js:10:2) +-- Promise.reject (test.js:48:31)-- +promiseReject (test.js:48:17) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseAll +foo1 (test.js:10:2) +-- Promise.resolve (test.js:52:44)-- +-- Promise.resolve (test.js:52:17)-- +promiseAll (test.js:52:31) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseRace +foo1 (test.js:10:2) +-- Promise.resolve (test.js:56:45)-- +-- Promise.resolve (test.js:56:17)-- +promiseRace (test.js:56:32) +(anonymous) (expr.js:0:0) + + +Running test: testThenableJob1 +foo1 (test.js:10:2) +-- Promise.resolve (test.js:60:72)-- +-- Promise.resolve (test.js:60:56)-- +Promise.resolve.then (test.js:60:46) +-- Promise.resolve (test.js:60:27)-- +thenableJob1 (test.js:60:17) +(anonymous) (expr.js:0:0) + + +Running test: testThenableJob2 +foo1 (test.js:10:2) +-- Promise.resolve (test.js:64:57)-- +Promise.resolve.then (test.js:64:46) +-- Promise.resolve (test.js:64:27)-- +thenableJob2 (test.js:64:17) +(anonymous) (expr.js:0:0) + + +Running test: testSetTimeouts +foo1 (test.js:10:2) +setTimeout (test.js:72:25) +-- setTimeout -- +setTimeout (test.js:72:6) +-- setTimeout -- +setTimeout (test.js:71:4) +-- setTimeout -- +setTimeouts (test.js:70:2) +(anonymous) (expr.js:0:0) + diff --git a/deps/v8/test/inspector/debugger/async-stack-created-frame.js b/deps/v8/test/inspector/debugger/async-stack-created-frame.js new file mode 100644 index 0000000000..e7430d7cfd --- /dev/null +++ b/deps/v8/test/inspector/debugger/async-stack-created-frame.js @@ -0,0 +1,178 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Checks created frame for async call chain'); + +InspectorTest.addScript( + ` +function foo1() { + debugger; +} + +function foo2() { + debugger; +} + +function promise() { + var resolve; + var p1 = new Promise(r => resolve = r); + var p2 = p1.then(foo1); + resolve(); + return p2; +} + +function promiseThen() { + var resolve; + var p1 = new Promise(r => resolve = r); + var p2 = p1.then(foo1); + var p3 = p2.then(foo2); + resolve(); + return p3; +} + +function promiseThenThen() { + var resolve; + var p1 = new Promise(r => resolve = r); + var p2 = p1.then(foo1).then(foo2); + var p3 = p1.then(foo1); + resolve(); + return p2; +} + +function promiseResolve() { + return Promise.resolve().then(foo1); +} + +function promiseReject() { + return Promise.reject().catch(foo1); +} + +function promiseAll() { + return Promise.all([ Promise.resolve() ]).then(foo1); +} + +function promiseRace() { + return Promise.race([ Promise.resolve() ]).then(foo1); +} + +function thenableJob1() { + return Promise.resolve().then(() => Promise.resolve().then(() => 42)).then(foo1); +} + +function thenableJob2() { + return Promise.resolve().then(() => Promise.resolve()).then(foo1); +} + +function setTimeouts() { + var resolve; + var p = new Promise(r => resolve = r); + setTimeout(() => + setTimeout(() => + setTimeout(() => { foo1(); resolve(); }, 0), 0), 0); + return p; +} + +//# sourceURL=test.js`, + 8, 4); + +InspectorTest.setupScriptMap(); +Protocol.Debugger.onPaused(message => { + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace); + InspectorTest.log(''); + Protocol.Debugger.resume(); +}); + +Protocol.Debugger.enable(); +Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128}); + +InspectorTest.runTestSuite([ + function testPromise(next) { + Protocol.Runtime + .evaluate( + {expression: 'promise()//# sourceURL=expr.js', awaitPromise: true}) + .then(next); + }, + + function testPromiseThen(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseThen()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testPromiseThenThen(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseThenThen()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testPromiseResolve(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseResolve()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testPromiseReject(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseReject()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testPromiseAll(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseAll()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testPromiseRace(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseRace()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testThenableJob1(next) { + Protocol.Runtime + .evaluate({ + expression: 'thenableJob1()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testThenableJob2(next) { + Protocol.Runtime + .evaluate({ + expression: 'thenableJob2()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testSetTimeouts(next) { + Protocol.Runtime + .evaluate({ + expression: 'setTimeouts()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + } +]); diff --git a/deps/v8/test/inspector/debugger/async-stack-for-promise-expected.txt b/deps/v8/test/inspector/debugger/async-stack-for-promise-expected.txt index dfa5951909..a948803f28 100644 --- a/deps/v8/test/inspector/debugger/async-stack-for-promise-expected.txt +++ b/deps/v8/test/inspector/debugger/async-stack-for-promise-expected.txt @@ -2,13 +2,14 @@ Checks that async chains for promises are correct. Running test: testPromise foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:19:14)-- promise (test.js:20:2) (anonymous) (testPromise.js:0:0) Running test: testPromiseResolvedBySetTimeout foo1 (test.js:9:2) +-- Promise.resolve (test.js:27:14)-- -- setTimeout -- promiseResolvedBySetTimeout (test.js:28:2) (anonymous) (testPromiseResolvedBySetTimeout.js:0:0) @@ -16,96 +17,103 @@ promiseResolvedBySetTimeout (test.js:28:2) Running test: testPromiseAll foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:37:35)-- +-- Promise.resolve (test.js:37:19)-- promiseAll (test.js:39:2) (anonymous) (testPromiseAll.js:0:0) Running test: testPromiseAllReverseOrder foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:48:35)-- +-- Promise.resolve (test.js:48:19)-- promiseAllReverseOrder (test.js:50:2) (anonymous) (testPromiseAllReverseOrder.js:0:0) Running test: testPromiseRace foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:59:36)-- +-- Promise.resolve (test.js:59:19)-- promiseRace (test.js:60:2) (anonymous) (testPromiseRace.js:0:0) Running test: testTwoChainedCallbacks foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:68:14)-- twoChainedCallbacks (test.js:69:2) (anonymous) (testTwoChainedCallbacks.js:0:0) foo2 (test.js:13:2) --- Promise.resolve -- +-- Promise.resolve (test.js:68:25)-- +-- Promise.resolve (test.js:68:14)-- twoChainedCallbacks (test.js:69:2) (anonymous) (testTwoChainedCallbacks.js:0:0) Running test: testPromiseResolve foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:74:27)-- promiseResolve (test.js:74:17) (anonymous) (testPromiseResolve.js:0:0) foo2 (test.js:13:2) --- Promise.resolve -- +-- Promise.resolve (test.js:74:38)-- +-- Promise.resolve (test.js:74:27)-- promiseResolve (test.js:74:17) (anonymous) (testPromiseResolve.js:0:0) Running test: testThenableJobResolvedInSetTimeout foo1 (test.js:9:2) +-- Promise.resolve (test.js:86:40)-- -- setTimeout -- thenableJob (test.js:81:4) p1.then (test.js:86:25) --- Promise.resolve -- +-- Promise.resolve (test.js:86:14)-- thenableJobResolvedInSetTimeout (test.js:87:2) (anonymous) (testThenableJobResolvedInSetTimeout.js:0:0) Running test: testThenableJobResolvedInSetTimeoutWithStack foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:104:40)-- inner (test.js:94:6) -- setTimeout -- thenableJob (test.js:99:4) p1.then (test.js:104:25) --- Promise.resolve -- +-- Promise.resolve (test.js:104:14)-- thenableJobResolvedInSetTimeoutWithStack (test.js:105:2) (anonymous) (testThenableJobResolvedInSetTimeoutWithStack.js:0:0) Running test: testThenableJobResolvedByPromise foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:118:40)-- +-- Promise.resolve (test.js:113:22)-- thenableJob (test.js:113:12) p1.then (test.js:118:25) --- Promise.resolve -- +-- Promise.resolve (test.js:118:14)-- thenableJobResolvedByPromise (test.js:119:2) (anonymous) (testThenableJobResolvedByPromise.js:0:0) Running test: testThenableJobResolvedByPromiseWithStack foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:136:40)-- inner (test.js:126:6) --- Promise.resolve -- +-- Promise.resolve (test.js:131:22)-- thenableJob (test.js:131:12) p1.then (test.js:136:25) --- Promise.resolve -- +-- Promise.resolve (test.js:136:14)-- thenableJobResolvedByPromiseWithStack (test.js:137:2) (anonymous) (testThenableJobResolvedByPromiseWithStack.js:0:0) Running test: testLateThenCallback foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:145:12)-- lateThenCallback (test.js:144:2) (anonymous) (testLateThenCallback.js:0:0) @@ -113,43 +121,54 @@ lateThenCallback (test.js:144:2) Running test: testComplex inner1 (test.js:154:6) foo1 (test.js:156:4) --- Promise.resolve -- +-- Promise.resolve (test.js:202:5)-- inner2 (test.js:162:6) --- Promise.resolve -- +-- Promise.resolve (test.js:165:22)-- foo2 (test.js:165:12) --- Promise.resolve -- +-- Promise.resolve (test.js:201:5)-- inner3 (test.js:172:6) -- setTimeout -- foo3 (test.js:175:4) --- Promise.resolve -- +-- Promise.resolve (test.js:200:5)-- +-- Promise.resolve (test.js:199:5)-- +-- Promise.resolve (test.js:188:7)-- +-- Promise.resolve (test.js:187:19)-- foo5 (test.js:187:52) --- Promise.resolve -- +-- Promise.resolve (test.js:198:5)-- +-- Promise.resolve (test.js:193:7)-- +-- Promise.resolve (test.js:192:19)-- foo6 (test.js:192:34) --- Promise.resolve -- +-- Promise.resolve (test.js:197:5)-- complex (test.js:196:18) (anonymous) (testComplex.js:0:0) p.then (test.js:207:8) --- Promise.resolve -- +-- Promise.resolve (test.js:206:8)-- +-- Promise.resolve (test.js:202:5)-- inner2 (test.js:162:6) --- Promise.resolve -- +-- Promise.resolve (test.js:165:22)-- foo2 (test.js:165:12) --- Promise.resolve -- +-- Promise.resolve (test.js:201:5)-- inner3 (test.js:172:6) -- setTimeout -- foo3 (test.js:175:4) --- Promise.resolve -- +-- Promise.resolve (test.js:200:5)-- +-- Promise.resolve (test.js:199:5)-- +-- Promise.resolve (test.js:188:7)-- +-- Promise.resolve (test.js:187:19)-- foo5 (test.js:187:52) --- Promise.resolve -- +-- Promise.resolve (test.js:198:5)-- +-- Promise.resolve (test.js:193:7)-- +-- Promise.resolve (test.js:192:19)-- foo6 (test.js:192:34) --- Promise.resolve -- +-- Promise.resolve (test.js:197:5)-- complex (test.js:196:18) (anonymous) (testComplex.js:0:0) Running test: testReject foo1 (test.js:9:2) --- Promise.reject -- +-- Promise.reject (test.js:217:31)-- reject (test.js:217:17) (anonymous) (testReject.js:0:0) diff --git a/deps/v8/test/inspector/debugger/async-stack-for-promise.js b/deps/v8/test/inspector/debugger/async-stack-for-promise.js index 705bb19086..a627747a55 100644 --- a/deps/v8/test/inspector/debugger/async-stack-for-promise.js +++ b/deps/v8/test/inspector/debugger/async-stack-for-promise.js @@ -222,12 +222,7 @@ function reject() { InspectorTest.setupScriptMap(); Protocol.Debugger.onPaused(message => { InspectorTest.logCallFrames(message.params.callFrames); - var asyncStackTrace = message.params.asyncStackTrace; - while (asyncStackTrace) { - InspectorTest.log(`-- ${asyncStackTrace.description} --`); - InspectorTest.logCallFrames(asyncStackTrace.callFrames); - asyncStackTrace = asyncStackTrace.parent; - } + InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace); InspectorTest.log(''); Protocol.Debugger.resume(); }); diff --git a/deps/v8/test/inspector/debugger/async-stacks-limit-expected.txt b/deps/v8/test/inspector/debugger/async-stacks-limit-expected.txt index 16270656c6..8dd1456990 100644 --- a/deps/v8/test/inspector/debugger/async-stacks-limit-expected.txt +++ b/deps/v8/test/inspector/debugger/async-stacks-limit-expected.txt @@ -4,7 +4,7 @@ Running test: testZeroLimit foo1 (test.js:11:2) -Running test: testOneLimit +Running test: testTwoLimit foo1 (test.js:11:2) -- Promise.resolve -- promise (test.js:23:2) @@ -17,11 +17,14 @@ foo1 (test.js:11:2) foo2 (test.js:15:2) -Running test: testTwoLimitTwoPromises +Running test: testFourLimitTwoPromises +foo1 (test.js:11:2) + +foo2 (test.js:15:2) + + +Running test: testSixLimitTwoPromises foo1 (test.js:11:2) --- Promise.resolve -- -twoPromises (test.js:34:2) -(anonymous) (expr.js:0:0) foo2 (test.js:15:2) -- Promise.resolve -- @@ -29,7 +32,7 @@ twoPromises (test.js:35:2) (anonymous) (expr.js:0:0) -Running test: testOneLimitTwoSetTimeouts +Running test: testTwoLimitTwoSetTimeouts foo1 (test.js:11:2) foo2 (test.js:15:2) @@ -38,7 +41,7 @@ twoSetTimeout (test.js:41:2) (anonymous) (expr.js:0:0) -Running test: testTwoLimitTwoSetTimeouts +Running test: testThreeLimitTwoSetTimeouts foo1 (test.js:11:2) -- setTimeout -- twoSetTimeout (test.js:40:2) @@ -84,54 +87,54 @@ foo10 (:0:18) foo11 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo12 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo13 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo14 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo15 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo16 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo17 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo18 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo19 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) diff --git a/deps/v8/test/inspector/debugger/async-stacks-limit.js b/deps/v8/test/inspector/debugger/async-stacks-limit.js index b028b74aae..d3c47dbfd4 100644 --- a/deps/v8/test/inspector/debugger/async-stacks-limit.js +++ b/deps/v8/test/inspector/debugger/async-stacks-limit.js @@ -42,12 +42,6 @@ function twoSetTimeout() { return new Promise(resolve => resolveTest = resolve); } -function threeSetTimeout() { - setTimeout(foo1, 0); - setTimeout(foo2, 0); - return new Promise(resolve => resolveTest = resolve); -} - function twentySetTimeout() { var resolve1; var p1 = new Promise(resolve => resolve1 = resolve); @@ -85,14 +79,16 @@ InspectorTest.runTestSuite([ .then(next); }, - function testOneLimit(next) { - Protocol.Runtime.evaluate({ - expression: 'setMaxAsyncTaskStacks(1)//# sourceURL=expr.js'}) - .then(() => Protocol.Runtime.evaluate({ - expression: 'promise()//# sourceURL=expr.js', awaitPromise: true - })) - .then(() => cancelAllAsyncTasks()) - .then(next); + function testTwoLimit(next) { + // we need one stack for parent task and one for next task. + Protocol.Runtime + .evaluate({expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'}) + .then(() => Protocol.Runtime.evaluate({ + expression: 'promise()//# sourceURL=expr.js', + awaitPromise: true + })) + .then(() => cancelAllAsyncTasks()) + .then(next); }, function testOneLimitTwoPromises(next) { @@ -108,19 +104,31 @@ InspectorTest.runTestSuite([ .then(next); }, - function testTwoLimitTwoPromises(next) { - Protocol.Runtime.evaluate({ - expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'}) - .then(() => Protocol.Runtime.evaluate({ - expression: 'twoPromises()//# sourceURL=expr.js', awaitPromise: true - })) - .then(() => cancelAllAsyncTasks()) - .then(next); + function testFourLimitTwoPromises(next) { + Protocol.Runtime + .evaluate({expression: 'setMaxAsyncTaskStacks(4)//# sourceURL=expr.js'}) + .then(() => Protocol.Runtime.evaluate({ + expression: 'twoPromises()//# sourceURL=expr.js', + awaitPromise: true + })) + .then(() => cancelAllAsyncTasks()) + .then(next); }, - function testOneLimitTwoSetTimeouts(next) { + function testSixLimitTwoPromises(next) { + Protocol.Runtime + .evaluate({expression: 'setMaxAsyncTaskStacks(6)//# sourceURL=expr.js'}) + .then(() => Protocol.Runtime.evaluate({ + expression: 'twoPromises()//# sourceURL=expr.js', + awaitPromise: true + })) + .then(() => cancelAllAsyncTasks()) + .then(next); + }, + + function testTwoLimitTwoSetTimeouts(next) { Protocol.Runtime.evaluate({ - expression: 'setMaxAsyncTaskStacks(1)//# sourceURL=expr.js'}) + expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'}) .then(() => Protocol.Runtime.evaluate({ expression: 'twoSetTimeout()//# sourceURL=expr.js', awaitPromise: true })) @@ -128,9 +136,9 @@ InspectorTest.runTestSuite([ .then(next); }, - function testTwoLimitTwoSetTimeouts(next) { + function testThreeLimitTwoSetTimeouts(next) { Protocol.Runtime.evaluate({ - expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'}) + expression: 'setMaxAsyncTaskStacks(3)//# sourceURL=expr.js'}) .then(() => Protocol.Runtime.evaluate({ expression: 'twoSetTimeout()//# sourceURL=expr.js', awaitPromise: true })) diff --git a/deps/v8/test/inspector/debugger/es6-module-script-parsed-expected.txt b/deps/v8/test/inspector/debugger/es6-module-script-parsed-expected.txt new file mode 100644 index 0000000000..26b35c5b26 --- /dev/null +++ b/deps/v8/test/inspector/debugger/es6-module-script-parsed-expected.txt @@ -0,0 +1,55 @@ +Debugger.scriptParsed and Debugger.scriptFailedToParse with ES6 module + +Running test: testLoadedModulesOnDebuggerEnable +{ + method : Debugger.scriptParsed + params : { + endColumn : 1 + endLine : 3 + executionContextId : <executionContextId> + hasSourceURL : false + hash : F8E59942466284E2766FD161CA6FFD024048A807 + isLiveEdit : false + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module1.js + } +} + +Running test: testScriptEventsWhenDebuggerIsEnabled +{ + method : Debugger.scriptParsed + params : { + endColumn : 1 + endLine : 3 + executionContextId : <executionContextId> + hasSourceURL : false + hash : F8E59942466284E2766FD161CA6FFD024048A807 + isLiveEdit : false + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module2.js + } +} +{ + method : Debugger.scriptFailedToParse + params : { + endColumn : 1 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : false + hash : FF746120E4E4F1BA4CB5762843D429DC872EBA18 + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module-with-syntax-error-2.js + } +} diff --git a/deps/v8/test/inspector/debugger/es6-module-script-parsed.js b/deps/v8/test/inspector/debugger/es6-module-script-parsed.js new file mode 100644 index 0000000000..c822a3db1c --- /dev/null +++ b/deps/v8/test/inspector/debugger/es6-module-script-parsed.js @@ -0,0 +1,28 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Debugger.scriptParsed and Debugger.scriptFailedToParse with ES6 module'); + +let moduleSource = ` +export function foo() { + return 42; +}`; + +InspectorTest.addModule(moduleSource, 'module1.js'); +InspectorTest.addModule('}', 'module-with-syntax-error-1.js'); + +Protocol.Debugger.onScriptParsed(InspectorTest.logMessage); +Protocol.Debugger.onScriptFailedToParse(InspectorTest.logMessage); + +InspectorTest.runTestSuite([ + function testLoadedModulesOnDebuggerEnable(next) { + Protocol.Debugger.enable().then(next); + }, + + function testScriptEventsWhenDebuggerIsEnabled(next) { + InspectorTest.addModule(moduleSource, 'module2.js'); + InspectorTest.addModule('}', 'module-with-syntax-error-2.js'); + InspectorTest.waitPendingTasks().then(next); + } +]); diff --git a/deps/v8/test/inspector/debugger/es6-module-set-script-source-expected.txt b/deps/v8/test/inspector/debugger/es6-module-set-script-source-expected.txt new file mode 100644 index 0000000000..cd0ef1fa6e --- /dev/null +++ b/deps/v8/test/inspector/debugger/es6-module-set-script-source-expected.txt @@ -0,0 +1,8 @@ +Checks that Debugger.setScriptSource doesn't crash with modules +{ + error : { + code : -32000 + message : Editing module's script is not supported. + } + id : <messageId> +} diff --git a/deps/v8/test/inspector/debugger/es6-module-set-script-source.js b/deps/v8/test/inspector/debugger/es6-module-set-script-source.js new file mode 100644 index 0000000000..747c189f5a --- /dev/null +++ b/deps/v8/test/inspector/debugger/es6-module-set-script-source.js @@ -0,0 +1,33 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Checks that Debugger.setScriptSource doesn\'t crash with modules'); + +var module1 = ` +export function foo() { + return 42; +}`; + +var editedModule1 = ` +export function foo() { + return 239; +}`; + +var module2 = ` +import { foo } from 'module1'; +console.log(foo()); +`; + +var module1Id; +Protocol.Debugger.onScriptParsed(message => { + if (message.params.url === 'module1') + module1Id = message.params.scriptId; +}); +Protocol.Debugger.enable() + .then(() => InspectorTest.addModule(module1, 'module1')) + .then(() => InspectorTest.addModule(module2, 'module2')) + .then(() => InspectorTest.waitPendingTasks()) + .then(() => Protocol.Debugger.setScriptSource({ scriptId: module1Id, scriptSource: editedModule1 })) + .then(InspectorTest.logMessage) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/debugger/framework-break-expected.txt b/deps/v8/test/inspector/debugger/framework-break-expected.txt new file mode 100644 index 0000000000..4339645cc8 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-break-expected.txt @@ -0,0 +1,70 @@ +Checks that breaks in framework code correctly processed. + +Running test: testConsoleAssert +> all frames in framework: +> mixed, top frame in framework: +frameworkAssert (framework.js:10:10) +(anonymous) (user.js:0:0) + + +Running test: testCaughtException +> all frames in framework: +> mixed, top frame in framework: + +Running test: testUncaughtException +> all frames in framework: +> mixed, top frame in framework: +throwUncaughtError (framework.js:21:2) +(anonymous) (user.js:0:0) + + +Running test: testUncaughtExceptionWithInlinedFrame +> mixed top frame in framework: +throwUserException (user.js:66:2) +inlinedWrapper (framework.js:56:4) +throwInlinedUncaughtError (framework.js:59:2) +(anonymous) (framework.js:0:0) + + +Running test: testBreakpoint +> all frames in framework: +breakpoint (framework.js:25:2) +(anonymous) (framework.js:0:0) + +> mixed, top frame in framework: +breakpoint (framework.js:25:2) +(anonymous) (user.js:0:0) + + +Running test: testDebuggerStatement +> all frames in framework: +> mixed, top frame in framework: + +Running test: testSyncDOMBreakpoint +> all frames in framework: +> mixed, top frame in framework: +syncDOMBreakpoint (framework.js:33:2) +(anonymous) (user.js:0:0) + + +Running test: testSyncDOMBreakpointWithInlinedUserFrame +> mixed, top frame in framework: +syncDOMBreakpoint (framework.js:33:2) +userFunction (user.js:70:2) +inlinedWrapper (framework.js:64:4) +syncDOMBreakpointWithInlinedUserFrame (framework.js:67:2) +(anonymous) (framework.js:0:0) + + +Running test: testAsyncDOMBreakpoint +> all frames in framework: +(anonymous) (user.js:0:0) + + +Running test: testCaughtSyntaxError +> all frames in framework: +> mixed, top frame in framework: + +Running test: testCaughtJSONParseError +> all frames in framework: +> mixed, top frame in framework: diff --git a/deps/v8/test/inspector/debugger/framework-break.js b/deps/v8/test/inspector/debugger/framework-break.js new file mode 100644 index 0000000000..42cdcf7624 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-break.js @@ -0,0 +1,234 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// Flags: --allow-natives-syntax + +print('Checks that breaks in framework code correctly processed.'); + +InspectorTest.addScript(` +function frameworkAssert() { + console.assert(false); +} + +function throwCaughtError() { + try { + throw new Error(); + } catch (e) { + } +} + +function throwUncaughtError() { + throw new Error(); +} + +function breakpoint() { + return 239; +} + +function debuggerStatement() { + debugger; +} + +function syncDOMBreakpoint() { + breakProgram('', ''); +} + +function asyncDOMBreakpoint() { + return 42; +} + +function throwCaughtSyntaxError() { + try { + eval('}'); + } catch (e) { + } +} + +function throwFromJSONParse() { + try { + JSON.parse('ping'); + } catch (e) { + } +} + +function throwInlinedUncaughtError() { + function inlinedWrapper() { + throwUserException(); + } + %OptimizeFunctionOnNextCall(inlinedWrapper); + inlinedWrapper(); +} + +function syncDOMBreakpointWithInlinedUserFrame() { + function inlinedWrapper() { + userFunction(); + } + %OptimizeFunctionOnNextCall(inlinedWrapper); + inlinedWrapper(); +} + +//# sourceURL=framework.js`, 8, 26); + +InspectorTest.addScript(` +function throwUserException() { + throw new Error(); +} + +function userFunction() { + syncDOMBreakpoint(); +} + +//# sourceURL=user.js`, 64, 26) + +InspectorTest.setupScriptMap(); +Protocol.Debugger.onPaused(message => { + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.log(''); + Protocol.Debugger.resume(); +}); + +Protocol.Debugger.enable(); +Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']}); + +InspectorTest.runTestSuite([ + function testConsoleAssert(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'frameworkAssert()//# sourceURL=framework.js'})) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'frameworkAssert()//# sourceURL=user.js'})) + .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) + .then(next); + }, + + function testCaughtException(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'throwCaughtError()//# sourceURL=framework.js'})) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'throwCaughtError()//# sourceURL=user.js'})) + .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) + .then(next); + }, + + function testUncaughtException(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'setTimeout(\'throwUncaughtError()//# sourceURL=framework.js\', 0)//# sourceURL=framework.js'})) + .then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true})) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'setTimeout(\'throwUncaughtError()//# sourceURL=user.js\', 0)'})) + .then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true})) + .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) + .then(next); + }, + + function testUncaughtExceptionWithInlinedFrame(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> mixed top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'setTimeout(\'throwInlinedUncaughtError()//# sourceURL=framework.js\', 0)//# sourceURL=framework.js'})) + .then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true})) + .then(next); + }, + + function testBreakpoint(next) { + Protocol.Debugger.setBreakpointByUrl({lineNumber: 25, url: 'framework.js'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'breakpoint()//# sourceURL=framework.js'})) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'breakpoint()//# sourceURL=user.js'})) + .then(next); + }, + + function testDebuggerStatement(next) { + InspectorTest.log('> all frames in framework:'); + Protocol.Runtime + .evaluate({expression: 'debuggerStatement()//# sourceURL=framework.js'}) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'debuggerStatement()//# sourceURL=user.js'})) + .then(next); + }, + + function testSyncDOMBreakpoint(next) { + InspectorTest.log('> all frames in framework:'); + Protocol.Runtime + .evaluate({expression: 'syncDOMBreakpoint()//# sourceURL=framework.js'}) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'syncDOMBreakpoint()//# sourceURL=user.js'})) + .then(next); + }, + + function testSyncDOMBreakpointWithInlinedUserFrame(next) { + InspectorTest.log('> mixed, top frame in framework:'); + Protocol.Runtime + .evaluate({expression: 'syncDOMBreakpointWithInlinedUserFrame()//# sourceURL=framework.js'}) + .then(next); + }, + + function testAsyncDOMBreakpoint(next) { + schedulePauseOnNextStatement('', ''); + InspectorTest.log('> all frames in framework:'); + Protocol.Runtime + .evaluate( + {expression: 'asyncDOMBreakpoint()//# sourceURL=framework.js'}) + .then(() => cancelPauseOnNextStatement()) + .then( + () => Protocol.Runtime.evaluate( + {expression: '42//# sourceURL=user.js'})) + .then(() => schedulePauseOnNextStatement('', '')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'asyncDOMBreakpoint()//# sourceURL=user.js'})) + .then(next); + }, + + function testCaughtSyntaxError(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then(() => Protocol.Runtime.evaluate({ + expression: 'throwCaughtSyntaxError()//# sourceURL=framework.js' + })) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'throwCaughtSyntaxError()//# sourceURL=user.js'})) + .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) + .then(next); + }, + + function testCaughtJSONParseError(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'throwFromJSONParse()//# sourceURL=framework.js'})) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'throwFromJSONParse()//# sourceURL=user.js'})) + .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) + .then(next); + } +]); diff --git a/deps/v8/test/inspector/debugger/framework-nested-scheduled-break-expected.txt b/deps/v8/test/inspector/debugger/framework-nested-scheduled-break-expected.txt new file mode 100644 index 0000000000..a7ab22229e --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-nested-scheduled-break-expected.txt @@ -0,0 +1,41 @@ +Checks nested scheduled break in framework code. +break reason: framework-break +break aux data: { + "data": "data for framework-break" +} +doFrameworkBreak (framework.js:20:2) +doFrameworkWork (framework.js:15:2) +frameworkCall (framework.js:9:2) +testFunction (user.js:27:2) +(anonymous) (expr.js:0:0) + +break reason: ambiguous +break aux data: { + "reasons": [ + { + "reason": "top-scheduled-break" + }, + { + "reason": "top-framework-scheduled-break", + "auxData": { + "data": "data for top-framework-scheduled-break" + } + } + ] +} +callback (user.js:31:17) +doFrameworkWork (framework.js:16:2) +frameworkCall (framework.js:9:2) +testFunction (user.js:27:2) +(anonymous) (expr.js:0:0) + +break reason: user-break +break aux data: { + "data": "data for user-break" +} +callback (user.js:32:2) +doFrameworkWork (framework.js:16:2) +frameworkCall (framework.js:9:2) +testFunction (user.js:27:2) +(anonymous) (expr.js:0:0) + diff --git a/deps/v8/test/inspector/debugger/framework-nested-scheduled-break.js b/deps/v8/test/inspector/debugger/framework-nested-scheduled-break.js new file mode 100644 index 0000000000..922cdd9fa9 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-nested-scheduled-break.js @@ -0,0 +1,49 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Checks nested scheduled break in framework code.'); + +InspectorTest.addScript(` +function frameworkCall(callback) { + callWithScheduledBreak(doFrameworkWork.bind(null, callback), + 'top-framework-scheduled-break', + JSON.stringify({ data: 'data for top-framework-scheduled-break' })); +} + +function doFrameworkWork(callback) { + callWithScheduledBreak(doFrameworkBreak, 'should-not-be-a-reason', ''); + callback(); +} + +function doFrameworkBreak() { + breakProgram('framework-break', JSON.stringify({ data: 'data for framework-break' })); +} + +//# sourceURL=framework.js`, 7, 26); + +InspectorTest.addScript(` +function testFunction() { + callWithScheduledBreak(frameworkCall.bind(null, callback), + 'top-scheduled-break', ''); +} + +function callback() { + breakProgram('user-break', JSON.stringify({ data: 'data for user-break' })); + return 42; +} + +//# sourceURL=user.js`, 25, 26); + +InspectorTest.setupScriptMap(); +Protocol.Debugger.onPaused(message => { + InspectorTest.log('break reason: ' + message.params.reason); + InspectorTest.log('break aux data: ' + JSON.stringify(message.params.data || {}, null, ' ')); + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.log(''); + Protocol.Debugger.resume(); +}); +Protocol.Debugger.enable() + .then(() => Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']})) + .then(() => Protocol.Runtime.evaluate({ expression: 'testFunction()//# sourceURL=expr.js'})) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/debugger/framework-precise-ranges-expected.txt b/deps/v8/test/inspector/debugger/framework-precise-ranges-expected.txt new file mode 100644 index 0000000000..c54587a7e2 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-precise-ranges-expected.txt @@ -0,0 +1,140 @@ +Checks framework debugging with blackboxed ranges. + +Running test: testEntireScript +{ + id : <messageId> + result : { + } +} + +Running test: testFooNotBlackboxed +{ + id : <messageId> + result : { + } +} +foo (test.js:8:12) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:9:2) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:10:0) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + + +Running test: testFooBlackboxed +{ + id : <messageId> + result : { + } +} +testFunction (test.js:14:21) +(anonymous) (expr.js:0:0) + +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:12:2) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:13:0) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +testFunction (test.js:16:0) +(anonymous) (expr.js:0:0) + + +Running test: testBooPartiallyBlackboxed1 +{ + id : <messageId> + result : { + } +} +foo (test.js:8:12) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:9:2) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:12:2) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:13:0) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:10:0) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + + +Running test: testBooPartiallyBlackboxed2 +{ + id : <messageId> + result : { + } +} +foo (test.js:8:12) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:9:2) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:12:2) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:13:0) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:10:0) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + + +Running test: testBooPartiallyBlackboxed3 +{ + id : <messageId> + result : { + } +} +foo (test.js:8:12) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:9:2) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:12:2) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:13:0) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:10:0) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + diff --git a/deps/v8/test/inspector/debugger/framework-precise-ranges.js b/deps/v8/test/inspector/debugger/framework-precise-ranges.js new file mode 100644 index 0000000000..cae0747b69 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-precise-ranges.js @@ -0,0 +1,78 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Checks framework debugging with blackboxed ranges.'); + +InspectorTest.addScript( + ` +function foo() { + return boo(); +} +function boo() { + return 42; +} +function testFunction() { + foo(); +} +//# sourceURL=test.js`, + 7, 26); + +InspectorTest.setupScriptMap(); +Protocol.Debugger.onPaused(message => { + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.log(''); + Protocol.Debugger.stepInto(); +}); +var scriptId; +Protocol.Debugger.onScriptParsed(message => { + if (message.params.url === 'test.js') { + scriptId = message.params.scriptId; + } +}); + +Protocol.Debugger.enable() + .then(() => Protocol.Debugger.setBlackboxPatterns({patterns: ['expr\.js']})) + .then(() => InspectorTest.runTestSuite(testSuite)); + +var testSuite = [ + function testEntireScript(next) { + testPositions([position(0, 0)]).then(next); + }, + function testFooNotBlackboxed(next) { + testPositions([position(11, 0)]).then(next); + }, + function testFooBlackboxed(next) { + testPositions([position(8, 0), position(10, 3)]).then(next); + }, + function testBooPartiallyBlackboxed1(next) { + // first line is not blackboxed, second and third - blackboxed. + testPositions([position(12, 0)]).then(next); + }, + function testBooPartiallyBlackboxed2(next) { + // first line is blackboxed, second - not, third - blackboxed. + testPositions([ + position(11, 0), position(12, 0), position(13, 0) + ]).then(next); + }, + function testBooPartiallyBlackboxed3(next) { + // first line is blackboxed, second and third - not. + testPositions([ + position(11, 0), position(12, 0), position(14, 0) + ]).then(next); + } +]; + +function testPositions(positions) { + schedulePauseOnNextStatement('', ''); + return Protocol.Debugger + .setBlackboxedRanges({scriptId: scriptId, positions: positions}) + .then(InspectorTest.logMessage) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'testFunction()//# sourceURL=expr.js'})); +} + +function position(line, column) { + return {lineNumber: line, columnNumber: column}; +} diff --git a/deps/v8/test/inspector/debugger/framework-stepping-expected.txt b/deps/v8/test/inspector/debugger/framework-stepping-expected.txt new file mode 100644 index 0000000000..32b3886f88 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-stepping-expected.txt @@ -0,0 +1,100 @@ +Checks stepping with blackboxed frames on stack + +Running test: testStepIntoFromUser +(anonymous) (expr.js:0:0) + +Executing stepInto... +Executing stepInto... +userFoo (user.js:23:2) +frameworkCall (framework.js:10:23) +testStepFromUser (user.js:31:2) +(anonymous) (expr.js:0:0) + +Executing stepInto... +Executing stepInto... +userBoo (user.js:27:2) +frameworkCall (framework.js:10:23) +testStepFromUser (user.js:31:2) +(anonymous) (expr.js:0:0) + +Executing stepInto... +Executing stepInto... +testStepFromUser (user.js:32:0) +(anonymous) (expr.js:0:0) + +Executing resume... + +Running test: testStepOverFromUser +(anonymous) (expr.js:0:0) + +Executing stepInto... +Executing stepInto... +userFoo (user.js:23:2) +frameworkCall (framework.js:10:23) +testStepFromUser (user.js:31:2) +(anonymous) (expr.js:0:0) + +Executing stepOver... +Executing stepOver... +userBoo (user.js:27:2) +frameworkCall (framework.js:10:23) +testStepFromUser (user.js:31:2) +(anonymous) (expr.js:0:0) + +Executing stepOver... +Executing stepOver... +testStepFromUser (user.js:32:0) +(anonymous) (expr.js:0:0) + +Executing resume... + +Running test: testStepOutFromUser +(anonymous) (expr.js:0:0) + +Executing stepInto... +Executing stepInto... +userFoo (user.js:23:2) +frameworkCall (framework.js:10:23) +testStepFromUser (user.js:31:2) +(anonymous) (expr.js:0:0) + +Executing stepOut... +testStepFromUser (user.js:32:0) +(anonymous) (expr.js:0:0) + +Executing resume... + +Running test: testStepIntoFromFramework +frameworkBreakAndCall (framework.js:14:2) +testStepFromFramework (user.js:35:2) +(anonymous) (expr.js:0:0) + +Executing stepInto... +userFoo (user.js:23:2) +frameworkBreakAndCall (framework.js:15:23) +testStepFromFramework (user.js:35:2) +(anonymous) (expr.js:0:0) + +Executing resume... + +Running test: testStepOverFromFramework +frameworkBreakAndCall (framework.js:14:2) +testStepFromFramework (user.js:35:2) +(anonymous) (expr.js:0:0) + +Executing stepOver... +testStepFromFramework (user.js:36:0) +(anonymous) (expr.js:0:0) + +Executing resume... + +Running test: testStepOutFromFramework +frameworkBreakAndCall (framework.js:14:2) +testStepFromFramework (user.js:35:2) +(anonymous) (expr.js:0:0) + +Executing stepOut... +testStepFromFramework (user.js:36:0) +(anonymous) (expr.js:0:0) + +Executing resume... diff --git a/deps/v8/test/inspector/debugger/framework-stepping.js b/deps/v8/test/inspector/debugger/framework-stepping.js new file mode 100644 index 0000000000..de75eab9ab --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-stepping.js @@ -0,0 +1,113 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Checks stepping with blackboxed frames on stack'); + +InspectorTest.addScript( + ` +function frameworkCall(funcs) { + for (var f of funcs) f(); +} + +function frameworkBreakAndCall(funcs) { + breakProgram('', ''); + for (var f of funcs) f(); +} +//# sourceURL=framework.js`, + 8, 4); + +InspectorTest.addScript( + ` +function userFoo() { + return 1; +} + +function userBoo() { + return 2; +} + +function testStepFromUser() { + frameworkCall([userFoo, userBoo]) +} + +function testStepFromFramework() { + frameworkBreakAndCall([userFoo, userBoo]); +} +//# sourceURL=user.js`, + 21, 4); + +InspectorTest.setupScriptMap(); + +Protocol.Debugger.enable() + .then( + () => Protocol.Debugger.setBlackboxPatterns( + {patterns: ['framework\.js']})) + .then(() => InspectorTest.runTestSuite(testSuite)); + +var testSuite = [ + function testStepIntoFromUser(next) { + schedulePauseOnNextStatement('', ''); + test('testStepFromUser()', [ + 'print', // before testStepFromUser call + 'stepInto', 'stepInto', 'print', // userFoo + 'stepInto', 'stepInto', 'print', // userBoo + 'stepInto', 'stepInto', 'print' // testStepFromUser + ]).then(next); + }, + + function testStepOverFromUser(next) { + schedulePauseOnNextStatement('', ''); + test('testStepFromUser()', [ + 'print', // before testStepFromUser call + 'stepInto', 'stepInto', 'print', // userFoo + 'stepOver', 'stepOver', 'print', // userBoo + 'stepOver', 'stepOver', 'print' // testStepFromUser + ]).then(next); + }, + + function testStepOutFromUser(next) { + schedulePauseOnNextStatement('', ''); + test('testStepFromUser()', [ + 'print', // before testStepFromUser call + 'stepInto', 'stepInto', 'print', // userFoo + 'stepOut', 'print' // testStepFromUser + ]).then(next); + }, + + function testStepIntoFromFramework(next) { + test('testStepFromFramework()', [ + 'print', // frameworkBreakAndCall + 'stepInto', 'print', // userFoo + ]).then(next); + }, + + function testStepOverFromFramework(next) { + test('testStepFromFramework()', [ + 'print', // frameworkBreakAndCall + 'stepOver', 'print', // testStepFromFramework + ]).then(next); + }, + + function testStepOutFromFramework(next) { + test('testStepFromFramework()', [ + 'print', // frameworkBreakAndCall + 'stepOut', 'print', // testStepFromFramework + ]).then(next); + } +]; + +function test(entryExpression, actions) { + Protocol.Debugger.onPaused(message => { + var action = actions.shift() || 'resume'; + if (action === 'print') { + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.log(''); + action = actions.shift() || 'resume'; + } + if (action) InspectorTest.log(`Executing ${action}...`); + Protocol.Debugger[action](); + }); + return Protocol.Runtime.evaluate( + {expression: entryExpression + '//# sourceURL=expr.js'}); +} diff --git a/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal.js b/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal.js index e574f69c01..13e2920cc7 100644 --- a/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal.js +++ b/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal.js @@ -9,4 +9,4 @@ Protocol.Debugger.onceScriptParsed().then(message => message.params.scriptId) .then(InspectorTest.logMessage) .then(InspectorTest.completeTest); -compileAndRunWithOrigin("() => []", "", 0, 0); +InspectorTest.addScript("() => []"); diff --git a/deps/v8/test/inspector/debugger/get-possible-breakpoints-expected.txt b/deps/v8/test/inspector/debugger/get-possible-breakpoints-expected.txt index 608abce218..c685625de8 100644 --- a/deps/v8/test/inspector/debugger/get-possible-breakpoints-expected.txt +++ b/deps/v8/test/inspector/debugger/get-possible-breakpoints-expected.txt @@ -18,1092 +18,254 @@ Test not existing scriptId. id : <messageId> } Test end < start. -{ - id : <messageId> - result : { - locations : [ - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test empty range in first line. -{ - id : <messageId> - result : { - locations : [ - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test one character range in first line. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test empty range in not first line. -{ - id : <messageId> - result : { - locations : [ - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test one character range in not first line. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 1 - scriptId : <scriptId> - } - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ #return Promise.resolve().then(() => 42); } + + Test end is undefined -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 42 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 16 - lineNumber : 1 - scriptId : <scriptId> - } - [3] : { - columnNumber : 52 - lineNumber : 1 - scriptId : <scriptId> - } - [4] : { - columnNumber : 54 - lineNumber : 1 - scriptId : <scriptId> - } - [5] : { - columnNumber : 57 - lineNumber : 1 - scriptId : <scriptId> - } - [6] : { - columnNumber : 0 - lineNumber : 2 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ #return Promise.#resolve().#then(() => #42#); #} +# + Test end.lineNumber > scripts.lineCount() -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 42 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 16 - lineNumber : 1 - scriptId : <scriptId> - } - [3] : { - columnNumber : 52 - lineNumber : 1 - scriptId : <scriptId> - } - [4] : { - columnNumber : 54 - lineNumber : 1 - scriptId : <scriptId> - } - [5] : { - columnNumber : 57 - lineNumber : 1 - scriptId : <scriptId> - } - [6] : { - columnNumber : 0 - lineNumber : 2 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ #return Promise.#resolve().#then(() => #42#); #} +# + Test one string -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 42 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ return Promise.resolve().then(() => 42); } + + Test end.columnNumber > end.line.length(), should be the same as previous. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 42 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ return Promise.resolve().then(() => 42); } + + Running test: getPossibleBreakpointsInArrow -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 53 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 56 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 69 - lineNumber : 0 - scriptId : <scriptId> - } - [4] : { - columnNumber : 71 - lineNumber : 0 - scriptId : <scriptId> - } - [5] : { - columnNumber : 84 - lineNumber : 0 - scriptId : <scriptId> - } - [6] : { - columnNumber : 90 - lineNumber : 0 - scriptId : <scriptId> - } - [7] : { - columnNumber : 92 - lineNumber : 0 - scriptId : <scriptId> - } - [8] : { - columnNumber : 94 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} +function foo() { #return Promise.#resolve().#then(() => #239#).#then(() => #42#).#then(() => #() => #42#) #} Running test: arrowFunctionFirstLine -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 18 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 47 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 49 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 51 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 18 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 47 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 49 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 51 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} +function foo1() { #Promise.#resolve().#then(() => #42#) #} +function foo2() { Promise.resolve().then(() => 42) } paused in foo1 -{ - columnNumber : 18 - lineNumber : 0 - scriptId : <scriptId> -} +function foo1() { ^Promise.resolve().then(() => 42) } +function foo2() { Promise.resolve().then(() => 42) } paused in foo1 -{ - columnNumber : 51 - lineNumber : 0 - scriptId : <scriptId> -} +function foo1() { Promise.^resolve().then(() => 42) } +function foo2() { Promise.resolve().then(() => 42) } +paused in foo1 +function foo1() { Promise.resolve().^then(() => 42) } +function foo2() { Promise.resolve().then(() => 42) } +paused in foo1 +function foo1() { Promise.resolve().then(() => 42) ^} +function foo2() { Promise.resolve().then(() => 42) } paused in Promise.resolve.then -{ - columnNumber : 47 - lineNumber : 0 - scriptId : <scriptId> -} +function foo1() { Promise.resolve().then(() => ^42) } +function foo2() { Promise.resolve().then(() => 42) } paused in Promise.resolve.then -{ - columnNumber : 49 - lineNumber : 0 - scriptId : <scriptId> -} +function foo1() { Promise.resolve().then(() => 42^) } +function foo2() { Promise.resolve().then(() => 42) } Running test: arrowFunctionOnPause -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 28 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 57 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 59 - lineNumber : 0 - scriptId : <scriptId> - } - [4] : { - columnNumber : 61 - lineNumber : 0 - scriptId : <scriptId> - } - [5] : { - columnNumber : 18 - lineNumber : 1 - scriptId : <scriptId> - } - [6] : { - columnNumber : 47 - lineNumber : 1 - scriptId : <scriptId> - } - [7] : { - columnNumber : 49 - lineNumber : 1 - scriptId : <scriptId> - } - [8] : { - columnNumber : 51 - lineNumber : 1 - scriptId : <scriptId> - } - [9] : { - columnNumber : 0 - lineNumber : 2 - scriptId : <scriptId> - } - [10] : { - columnNumber : 0 - lineNumber : 3 - scriptId : <scriptId> - } - [11] : { - columnNumber : 6 - lineNumber : 3 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 28 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 57 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 59 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 61 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 18 - lineNumber : 1 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 47 - lineNumber : 1 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 49 - lineNumber : 1 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 51 - lineNumber : 1 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 0 - lineNumber : 2 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 0 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 6 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} +#debugger; function foo3() { #Promise.#resolve().#then(() => #42#) #} +function foo4() { #Promise.#resolve().#then(() => #42#) #}; +#foo3(); +#foo4()#; paused in -{ - columnNumber : 0 - lineNumber : 2 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +^foo3(); +foo4(); paused in foo3 -{ - columnNumber : 28 - lineNumber : 0 - scriptId : <scriptId> -} +debugger; function foo3() { ^Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); paused in foo3 -{ - columnNumber : 61 - lineNumber : 0 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.^resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); +paused in foo3 +debugger; function foo3() { Promise.resolve().^then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); +paused in foo3 +debugger; function foo3() { Promise.resolve().then(() => 42) ^} +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); paused in -{ - columnNumber : 0 - lineNumber : 3 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +^foo4(); paused in foo4 -{ - columnNumber : 18 - lineNumber : 1 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { ^Promise.resolve().then(() => 42) }; +foo3(); +foo4(); paused in foo4 -{ - columnNumber : 51 - lineNumber : 1 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.^resolve().then(() => 42) }; +foo3(); +foo4(); +paused in foo4 +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().^then(() => 42) }; +foo3(); +foo4(); +paused in foo4 +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) ^}; +foo3(); +foo4(); paused in -{ - columnNumber : 6 - lineNumber : 3 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4()^; paused in Promise.resolve.then -{ - columnNumber : 57 - lineNumber : 0 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => ^42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); paused in Promise.resolve.then -{ - columnNumber : 59 - lineNumber : 0 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42^) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); paused in Promise.resolve.then -{ - columnNumber : 47 - lineNumber : 1 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => ^42) }; +foo3(); +foo4(); paused in Promise.resolve.then -{ - columnNumber : 49 - lineNumber : 1 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42^) }; +foo3(); +foo4(); Running test: getPossibleBreakpointsInRangeWithOffset Test empty range in first line. -{ - id : <messageId> - result : { - locations : [ - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test one character range in first line. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 1 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test empty range in not first line. -{ - id : <messageId> - result : { - locations : [ - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test one character range in not first line. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 2 - scriptId : <scriptId> - } - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ #return Promise.resolve().then(() => 42); } + + Test end is undefined -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 1 - scriptId : <scriptId> - } - [1] : { - columnNumber : 43 - lineNumber : 1 - scriptId : <scriptId> - } - [2] : { - columnNumber : 16 - lineNumber : 2 - scriptId : <scriptId> - } - [3] : { - columnNumber : 52 - lineNumber : 2 - scriptId : <scriptId> - } - [4] : { - columnNumber : 54 - lineNumber : 2 - scriptId : <scriptId> - } - [5] : { - columnNumber : 57 - lineNumber : 2 - scriptId : <scriptId> - } - [6] : { - columnNumber : 0 - lineNumber : 3 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ #return Promise.#resolve().#then(() => #42#); #} +# + Test end.lineNumber > scripts.lineCount() -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 1 - scriptId : <scriptId> - } - [1] : { - columnNumber : 43 - lineNumber : 1 - scriptId : <scriptId> - } - [2] : { - columnNumber : 16 - lineNumber : 2 - scriptId : <scriptId> - } - [3] : { - columnNumber : 52 - lineNumber : 2 - scriptId : <scriptId> - } - [4] : { - columnNumber : 54 - lineNumber : 2 - scriptId : <scriptId> - } - [5] : { - columnNumber : 57 - lineNumber : 2 - scriptId : <scriptId> - } - [6] : { - columnNumber : 0 - lineNumber : 3 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ #return Promise.#resolve().#then(() => #42#); #} +# + Test one string -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 1 - scriptId : <scriptId> - } - [1] : { - columnNumber : 43 - lineNumber : 1 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ return Promise.resolve().then(() => 42); } + + Test end.columnNumber > end.line.length(), should be the same as previous. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 1 - scriptId : <scriptId> - } - [1] : { - columnNumber : 43 - lineNumber : 1 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ return Promise.resolve().then(() => 42); } + + Running test: withOffset -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 36 - lineNumber : 3 - scriptId : <scriptId> - } - [1] : { - columnNumber : 65 - lineNumber : 3 - scriptId : <scriptId> - } - [2] : { - columnNumber : 67 - lineNumber : 3 - scriptId : <scriptId> - } - [3] : { - columnNumber : 69 - lineNumber : 3 - scriptId : <scriptId> - } - [4] : { - columnNumber : 18 - lineNumber : 4 - scriptId : <scriptId> - } - [5] : { - columnNumber : 47 - lineNumber : 4 - scriptId : <scriptId> - } - [6] : { - columnNumber : 49 - lineNumber : 4 - scriptId : <scriptId> - } - [7] : { - columnNumber : 51 - lineNumber : 4 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 36 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 65 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 67 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 69 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 18 - lineNumber : 4 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 47 - lineNumber : 4 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 49 - lineNumber : 4 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 51 - lineNumber : 4 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} +function foo5() { #Promise.#resolve().#then(() => #42#) #} +function foo6() { #Promise.#resolve().#then(() => #42#) #} paused in foo5 -{ - columnNumber : 36 - lineNumber : 3 - scriptId : <scriptId> -} +function foo5() { ^Promise.resolve().then(() => 42) } +function foo6() { Promise.resolve().then(() => 42) } paused in foo5 -{ - columnNumber : 69 - lineNumber : 3 - scriptId : <scriptId> -} +function foo5() { Promise.^resolve().then(() => 42) } +function foo6() { Promise.resolve().then(() => 42) } +paused in foo5 +function foo5() { Promise.resolve().^then(() => 42) } +function foo6() { Promise.resolve().then(() => 42) } +paused in foo5 +function foo5() { Promise.resolve().then(() => 42) ^} +function foo6() { Promise.resolve().then(() => 42) } paused in foo6 -{ - columnNumber : 18 - lineNumber : 4 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { ^Promise.resolve().then(() => 42) } paused in foo6 -{ - columnNumber : 51 - lineNumber : 4 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { Promise.^resolve().then(() => 42) } +paused in foo6 +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { Promise.resolve().^then(() => 42) } +paused in foo6 +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { Promise.resolve().then(() => 42) ^} paused in Promise.resolve.then -{ - columnNumber : 65 - lineNumber : 3 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => ^42) } +function foo6() { Promise.resolve().then(() => 42) } paused in Promise.resolve.then -{ - columnNumber : 67 - lineNumber : 3 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => 42^) } +function foo6() { Promise.resolve().then(() => 42) } paused in Promise.resolve.then -{ - columnNumber : 47 - lineNumber : 4 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { Promise.resolve().then(() => ^42) } paused in Promise.resolve.then -{ - columnNumber : 49 - lineNumber : 4 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { Promise.resolve().then(() => 42^) } Running test: arrowFunctionReturn -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 6 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 9 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 34 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 45 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 48 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 49 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 8 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 12 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 13 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 21 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 22 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 6 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 8 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 9 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 8 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 19 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} +#() => #239# + +function foo() { function boo() { #return 239 #} #}# + +#() => { #239 #}# + +function foo() { #239 #}# + +#() => #23#9# +#() => { #return 239 #} + +Running test: argumentsAsCalls +function foo(){#} +function boo(){#} +function main(f1,f2){#} +#main(#foo(), #boo());# + diff --git a/deps/v8/test/inspector/debugger/get-possible-breakpoints.js b/deps/v8/test/inspector/debugger/get-possible-breakpoints.js index b09c08de14..640c3e61ea 100644 --- a/deps/v8/test/inspector/debugger/get-possible-breakpoints.js +++ b/deps/v8/test/inspector/debugger/get-possible-breakpoints.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -print("Test for Debugger.getPossibleBreakpoints"); +print('Test for Debugger.getPossibleBreakpoints'); Protocol.Runtime.enable(); Protocol.Debugger.enable(); @@ -10,160 +10,150 @@ Protocol.Debugger.enable(); InspectorTest.runTestSuite([ function getPossibleBreakpointsInRange(next) { - var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n"; + var source = 'function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n'; var scriptId; compileScript(source) .then(id => scriptId = id) - .then(() => InspectorTest.log("Test start.scriptId != end.scriptId.")) - .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 0, scriptId: scriptId + "0" }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test not existing scriptId.")) - .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: "-1" }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end < start.")) + .then(() => InspectorTest.log('Test start.scriptId != end.scriptId.')) + .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 0, scriptId: scriptId + '0' }})) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test not existing scriptId.')) + .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: '-1' }})) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test end < start.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test empty range in first line.")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test empty range in first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 16, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one character range in first line.")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test one character range in first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 17, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test empty range in not first line.")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test empty range in not first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 16, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one character range in not first line.")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test one character range in not first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end is undefined")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test end is undefined')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end.lineNumber > scripts.lineCount()")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test end.lineNumber > scripts.lineCount()')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 5, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one string")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test one string')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end.columnNumber > end.line.length(), should be the same as previous.")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test end.columnNumber > end.line.length(), should be the same as previous.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 256, scriptId: scriptId }})) - .then(InspectorTest.logMessage) + .then(message => dumpAllLocations(message, source)) .then(next); }, function getPossibleBreakpointsInArrow(next) { - var source = "function foo() { return Promise.resolve().then(() => 239).then(() => 42).then(() => () => 42) }"; + var source = 'function foo() { return Promise.resolve().then(() => 239).then(() => 42).then(() => () => 42) }'; var scriptId; compileScript(source) .then(id => scriptId = id) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) + .then(message => dumpAllLocations(message, source)) .then(next); }, function arrowFunctionFirstLine(next) { - Protocol.Debugger.onPaused(message => { - InspectorTest.log("paused in " + message.params.callFrames[0].functionName); - InspectorTest.logMessage(message.params.callFrames[0].location); - Protocol.Debugger.resume(); - }); + Protocol.Debugger.onPaused(message => dumpBreakLocationInSourceAndResume(message, source)); var source = `function foo1() { Promise.resolve().then(() => 42) } function foo2() { Promise.resolve().then(() => 42) }`; waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, { lineNumber: 1, columnNumber: 0 }) - .then(InspectorTest.logMessage) + .then(message => dumpAllLocations(message, source)) .then(setAllBreakpoints) - .then(() => Protocol.Runtime.evaluate({ expression: "foo1(); foo2()"})) + .then(() => Protocol.Runtime.evaluate({ expression: 'foo1(); foo2()'})) .then(next); }, function arrowFunctionOnPause(next) { - function dumpAndResume(message) { - InspectorTest.log("paused in " + message.params.callFrames[0].functionName); - InspectorTest.logMessage(message.params.callFrames[0].location); - Protocol.Debugger.resume(); - } - var source = `debugger; function foo3() { Promise.resolve().then(() => 42) } function foo4() { Promise.resolve().then(() => 42) };\nfoo3();\nfoo4();`; waitForPossibleBreakpointsOnPause(source, { lineNumber: 0, columnNumber: 0 }, undefined, next) - .then(InspectorTest.logMessage) + .then(message => dumpAllLocations(message, source)) .then(setAllBreakpoints) - .then(() => Protocol.Debugger.onPaused(dumpAndResume)) + .then(() => Protocol.Debugger.onPaused(message => dumpBreakLocationInSourceAndResume(message, source))) .then(() => Protocol.Debugger.resume()); }, function getPossibleBreakpointsInRangeWithOffset(next) { - var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n"; + var source = 'function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n'; var scriptId; - compileScript(source, { name: "with-offset.js", line_offset: 1, column_offset: 1 }) + compileScript(source, { name: 'with-offset.js', line_offset: 1, column_offset: 1 }) .then(id => scriptId = id) - .then(() => InspectorTest.log("Test empty range in first line.")) + .then(() => InspectorTest.log('Test empty range in first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one character range in first line.")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test one character range in first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 18, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test empty range in not first line.")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test empty range in not first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 2, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 2, columnNumber: 16, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one character range in not first line.")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test one character range in not first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 2, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 2, columnNumber: 17, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end is undefined")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test end is undefined')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end.lineNumber > scripts.lineCount()")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test end.lineNumber > scripts.lineCount()')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 5, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one string")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test one string')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 1, scriptId: scriptId }, end: { lineNumber: 2, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end.columnNumber > end.line.length(), should be the same as previous.")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test end.columnNumber > end.line.length(), should be the same as previous.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 1, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 256, scriptId: scriptId }})) - .then(InspectorTest.logMessage) + .then(message => dumpAllLocations(message, source, 1, 1)) .then(next); }, function withOffset(next) { - Protocol.Debugger.onPaused(message => { - InspectorTest.log("paused in " + message.params.callFrames[0].functionName); - InspectorTest.logMessage(message.params.callFrames[0].location); - Protocol.Debugger.resume(); - }); + Protocol.Debugger.onPaused(message => dumpBreakLocationInSourceAndResume(message, source, 3, 18)); var source = `function foo5() { Promise.resolve().then(() => 42) } function foo6() { Promise.resolve().then(() => 42) }`; - waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, undefined, { name: "with-offset.js", line_offset: 3, column_offset: 18 }) - .then(InspectorTest.logMessage) + waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, undefined, { name: 'with-offset.js', line_offset: 3, column_offset: 18 }) + .then(message => dumpAllLocations(message, source, 3, 18)) .then(setAllBreakpoints) - .then(() => Protocol.Runtime.evaluate({ expression: "foo5(); foo6()"})) + .then(() => Protocol.Runtime.evaluate({ expression: 'foo5(); foo6()'})) .then(next); }, function arrowFunctionReturn(next) { - waitForPossibleBreakpoints("() => 239\n", { lineNumber: 0, columnNumber: 0 }) - .then(InspectorTest.logMessage) - .then(() => waitForPossibleBreakpoints("function foo() { function boo() { return 239 } }\n", { lineNumber: 0, columnNumber: 0 })) - .then(InspectorTest.logMessage) - .then(() => waitForPossibleBreakpoints("() => { 239 }\n", { lineNumber: 0, columnNumber: 0 })) - .then(InspectorTest.logMessage) - // TODO(kozyatinskiy): lineNumber for return position should be 21 instead of 22. - .then(() => waitForPossibleBreakpoints("function foo() { 239 }\n", { lineNumber: 0, columnNumber: 0 })) - .then(InspectorTest.logMessage) + function checkSource(source, location) { + return waitForPossibleBreakpoints(source, location) + .then(message => dumpAllLocations(message, source)); + } + + checkSource('() => 239\n', { lineNumber: 0, columnNumber: 0 }) + .then(() => checkSource('function foo() { function boo() { return 239 } }\n', { lineNumber: 0, columnNumber: 0 })) + .then(() => checkSource('() => { 239 }\n', { lineNumber: 0, columnNumber: 0 })) + .then(() => checkSource('function foo() { 239 }\n', { lineNumber: 0, columnNumber: 0 })) // TODO(kozyatinskiy): lineNumber for return position should be only 9, not 8. - .then(() => waitForPossibleBreakpoints("() => 239", { lineNumber: 0, columnNumber: 0 })) - .then(InspectorTest.logMessage) - // TODO(kozyatinskiy): lineNumber for return position should be only 19, not 20. - .then(() => waitForPossibleBreakpoints("() => { return 239 }", { lineNumber: 0, columnNumber: 0 })) - .then(InspectorTest.logMessage) - .then(next) + .then(() => checkSource('() => 239', { lineNumber: 0, columnNumber: 0 })) + .then(() => checkSource('() => { return 239 }', { lineNumber: 0, columnNumber: 0 })) + .then(next); + }, + + function argumentsAsCalls(next) { + var source = 'function foo(){}\nfunction boo(){}\nfunction main(f1,f2){}\nmain(foo(), boo());\n'; + waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }) + .then(message => dumpAllLocations(message, source)) + .then(next); } ]); function compileScript(source, origin) { var promise = Protocol.Debugger.onceScriptParsed().then(message => message.params.scriptId); - if (!origin) origin = { name: "", line_offset: 0, column_offset: 0 }; - compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column_offset); + if (!origin) origin = { name: '', line_offset: 0, column_offset: 0 }; + compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column_offset, false); return promise; } @@ -184,20 +174,60 @@ function waitForPossibleBreakpointsOnPause(source, start, end, next) { function setAllBreakpoints(message) { var promises = []; for (var location of message.result.locations) - promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(checkBreakpointAndDump)); + promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(checkBreakpoint)); return Promise.all(promises); } -function checkBreakpointAndDump(message) { +function checkBreakpoint(message) { if (message.error) { - InspectorTest.log("FAIL: error in setBreakpoint"); + InspectorTest.log('FAIL: error in setBreakpoint'); InspectorTest.logMessage(message); return; } - var id_data = message.result.breakpointId.split(":"); + var id_data = message.result.breakpointId.split(':'); if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parseInt(id_data[2]) !== message.result.actualLocation.columnNumber) { - InspectorTest.log("FAIL: possible breakpoint was resolved in another location"); + InspectorTest.log('FAIL: possible breakpoint was resolved in another location'); + } +} + +function dumpAllLocations(message, source, lineOffset, columnOffset) { + if (message.error) { InspectorTest.logMessage(message); + return; + } + + lineOffset = lineOffset || 0; + columnOffset = columnOffset || 0; + + var sourceLines = source.split('\n') + var lineOffsets = Array(sourceLines.length).fill(0); + for (var location of message.result.locations) { + var lineNumber = location.lineNumber - lineOffset; + var columnNumber = lineNumber !== 0 ? location.columnNumber : location.columnNumber - columnOffset; + var line = sourceLines[lineNumber] || ''; + var offset = lineOffsets[lineNumber]; + line = line.slice(0, columnNumber + offset) + '#' + line.slice(columnNumber + offset); + ++lineOffsets[lineNumber]; + sourceLines[lineNumber] = line; } - InspectorTest.logMessage(message); + InspectorTest.log(sourceLines.join('\n')); + return message; +} + +function dumpBreakLocationInSourceAndResume(message, source, lineOffset, columnOffset) { + lineOffset = lineOffset || 0; + columnOffset = columnOffset || 0; + + InspectorTest.log('paused in ' + message.params.callFrames[0].functionName); + var location = message.params.callFrames[0].location; + var sourceLines = source.split('\n') + + var lineNumber = location.lineNumber - lineOffset; + var columnNumber = lineNumber !== 0 ? location.columnNumber : location.columnNumber - columnOffset; + + var line = sourceLines[lineNumber]; + line = line.slice(0, columnNumber) + '^' + line.slice(columnNumber); + sourceLines[lineNumber] = line; + InspectorTest.log(sourceLines.join('\n')); + Protocol.Debugger.resume(); } diff --git a/deps/v8/test/inspector/debugger/inspector-break-api-expected.txt b/deps/v8/test/inspector/debugger/inspector-break-api-expected.txt new file mode 100644 index 0000000000..f3b019d058 --- /dev/null +++ b/deps/v8/test/inspector/debugger/inspector-break-api-expected.txt @@ -0,0 +1,38 @@ +Checks breakProgram,(schedule|cancel)PauseOnNextStatement test API + +Running test: testBreakProgram +Stack: +callBreakProgram (:9:2) +(anonymous) (:0:0) +Other data: +{ + method : Debugger.paused + params : { + data : { + a : 42 + } + hitBreakpoints : [ + ] + reason : reason + } +} + + +Running test: testSchedulePauseOnNextStatement +Stack: +(anonymous) (expr1.js:0:0) +Other data: +{ + method : Debugger.paused + params : { + data : { + a : 42 + } + hitBreakpoints : [ + ] + reason : reason + } +} + + +Running test: testCancelPauseOnNextStatement diff --git a/deps/v8/test/inspector/debugger/inspector-break-api.js b/deps/v8/test/inspector/debugger/inspector-break-api.js new file mode 100644 index 0000000000..af1f2df9dc --- /dev/null +++ b/deps/v8/test/inspector/debugger/inspector-break-api.js @@ -0,0 +1,50 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print("Checks breakProgram,(schedule|cancel)PauseOnNextStatement test API"); + +InspectorTest.addScript(` +function callBreakProgram() { + breakProgram('reason', JSON.stringify({a: 42})); +} + +function foo() { + return 42; +}`, 7, 26); + +InspectorTest.setupScriptMap(); +Protocol.Debugger.onPaused(message => { + InspectorTest.log('Stack:'); + InspectorTest.logCallFrames(message.params.callFrames); + delete message.params.callFrames; + InspectorTest.log('Other data:'); + InspectorTest.logMessage(message); + InspectorTest.log(''); + Protocol.Debugger.resume(); +}); + +Protocol.Debugger.enable(); + +InspectorTest.runTestSuite([ + function testBreakProgram(next) { + Protocol.Runtime.evaluate({ expression: 'callBreakProgram()'}) + .then(next); + }, + + function testSchedulePauseOnNextStatement(next) { + schedulePauseOnNextStatement('reason', JSON.stringify({a: 42})); + Protocol.Runtime.evaluate({ expression: 'foo()//# sourceURL=expr1.js'}) + .then(() => Protocol.Runtime.evaluate({ + expression: 'foo()//# sourceURL=expr2.js'})) + .then(() => cancelPauseOnNextStatement()) + .then(next); + }, + + function testCancelPauseOnNextStatement(next) { + schedulePauseOnNextStatement('reason', JSON.stringify({a: 42})); + cancelPauseOnNextStatement(); + Protocol.Runtime.evaluate({ expression: 'foo()'}) + .then(next); + } +]); diff --git a/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt b/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt index 481ef8b1a3..6b0b8bf177 100644 --- a/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt +++ b/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt @@ -163,23 +163,19 @@ expression: (new Map([[1,2]])).entries() [[Entries]]: [ [0] : { + key : { + description : 1 + overflow : false + properties : [ + ] + type : number + } value : { - description : Array(2) + description : 2 overflow : false properties : [ - [0] : { - name : 0 - type : number - value : 1 - } - [1] : { - name : 1 - type : number - value : 2 - } ] - subtype : array - type : object + type : number } } ] @@ -209,15 +205,13 @@ expression: (new Set([[1,2]])).entries() properties : [ [0] : { name : 0 - subtype : array - type : object - value : Array(2) + type : number + value : 1 } [1] : { name : 1 - subtype : array - type : object - value : Array(2) + type : number + value : 2 } ] subtype : array diff --git a/deps/v8/test/inspector/debugger/pause-on-oom-expected.txt b/deps/v8/test/inspector/debugger/pause-on-oom-expected.txt new file mode 100644 index 0000000000..4ca988deca --- /dev/null +++ b/deps/v8/test/inspector/debugger/pause-on-oom-expected.txt @@ -0,0 +1,2 @@ +Check pause on OOM +reason: OOM diff --git a/deps/v8/test/inspector/debugger/pause-on-oom.js b/deps/v8/test/inspector/debugger/pause-on-oom.js new file mode 100644 index 0000000000..84995dbf39 --- /dev/null +++ b/deps/v8/test/inspector/debugger/pause-on-oom.js @@ -0,0 +1,28 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --max-old-space-size=4 + +print('Check pause on OOM'); + +InspectorTest.addScript(` +var arr = []; +var stop = false; +function generateGarbage() { + while(!stop) { + arr.push(42); + } +} +//# sourceURL=test.js`, 10, 26); + +Protocol.Debugger.onPaused((message) => { + InspectorTest.log(`reason: ${message.params.reason}`); + Protocol.Debugger.evaluateOnCallFrame({ + callFrameId: message.params.callFrames[0].callFrameId, + expression: 'arr = []; stop = true;' + }).then(() => Protocol.Debugger.resume()); +}); +Protocol.Debugger.enable(); +Protocol.Runtime.evaluate({ expression: 'generateGarbage()' }) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/debugger/script-on-after-compile-expected.txt b/deps/v8/test/inspector/debugger/script-on-after-compile-expected.txt index d7c6d76346..baa832dcac 100644 --- a/deps/v8/test/inspector/debugger/script-on-after-compile-expected.txt +++ b/deps/v8/test/inspector/debugger/script-on-after-compile-expected.txt @@ -10,6 +10,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -27,6 +28,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -44,6 +46,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -61,6 +64,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -78,6 +82,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : oneline-map startColumn : 0 @@ -95,6 +100,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : oneline-without-nl-map startColumn : 0 @@ -112,6 +118,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : twoline-map startColumn : 0 @@ -129,6 +136,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : threeline-map startColumn : 0 @@ -146,6 +154,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : source-mapping-url-map startColumn : 0 @@ -163,6 +172,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : source-mapping-url-map startColumn : 0 @@ -180,6 +190,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -197,6 +208,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -214,6 +226,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -231,6 +244,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -248,6 +262,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -265,6 +280,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -282,6 +298,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -299,6 +316,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -316,6 +334,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -333,6 +352,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -350,6 +370,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -367,6 +388,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -384,6 +406,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -401,6 +424,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : oneline-map startColumn : 0 @@ -418,6 +442,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : oneline-without-nl-map startColumn : 0 @@ -435,6 +460,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : twoline-map startColumn : 0 @@ -452,6 +478,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : threeline-map startColumn : 0 @@ -469,6 +496,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : source-mapping-url-map startColumn : 0 @@ -486,6 +514,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : source-mapping-url-map startColumn : 0 @@ -503,6 +532,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -520,6 +550,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -537,6 +568,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -554,6 +586,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -571,6 +604,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -587,6 +621,7 @@ scriptFailedToParse executionContextId : <executionContextId> hasSourceURL : true hash : <hash> + isModule : false scriptId : <scriptId> sourceMapURL : failed-map startColumn : 0 @@ -604,6 +639,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -621,6 +657,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -638,6 +675,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -655,6 +693,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 diff --git a/deps/v8/test/inspector/debugger/script-parsed-for-runtime-evaluate-expected.txt b/deps/v8/test/inspector/debugger/script-parsed-for-runtime-evaluate-expected.txt index 1e86252c4f..cc91a65dec 100644 --- a/deps/v8/test/inspector/debugger/script-parsed-for-runtime-evaluate-expected.txt +++ b/deps/v8/test/inspector/debugger/script-parsed-for-runtime-evaluate-expected.txt @@ -9,6 +9,7 @@ Runtime.evaluate with valid expression hasSourceURL : true hash : 9D04F7335D1661503EAB9AF3EACAF92020803F34 isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -25,6 +26,7 @@ Runtime.evaluate with syntax error executionContextId : <executionContextId> hasSourceURL : true hash : 9BCA34A10E5386925E74C1716C857BEB02821E15 + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -42,6 +44,7 @@ Runtime.callFunctionOn with valid functionDeclaration hasSourceURL : false hash : 9D04CEA1B54DF92A01A0498543D429DC872EBA18 isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -58,6 +61,7 @@ Runtime.callFunctionOn with syntax error executionContextId : <executionContextId> hasSourceURL : false hash : 9D04D83251E2B7F64CB5762843D429DC872EBA18 + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -75,6 +79,7 @@ Runtime.compileScript with valid expression hasSourceURL : false hash : 9D04F733E4E4F1BA4CB5762843D429DC872EBA18 isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -91,6 +96,7 @@ Runtime.compileScript with syntax error executionContextId : <executionContextId> hasSourceURL : false hash : FF746120E4E4F1BA4CB5762843D429DC872EBA18 + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 diff --git a/deps/v8/test/inspector/debugger/set-script-source-exception-expected.txt b/deps/v8/test/inspector/debugger/set-script-source-exception-expected.txt index 03624e989c..376c11d0b3 100644 --- a/deps/v8/test/inspector/debugger/set-script-source-exception-expected.txt +++ b/deps/v8/test/inspector/debugger/set-script-source-exception-expected.txt @@ -4,7 +4,7 @@ Running test: testIncorrectScriptId { error : { code : -32000 - message : Uncaught Script not found + message : No script with given id found } id : <messageId> } diff --git a/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate-expected.txt b/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate-expected.txt new file mode 100644 index 0000000000..d77870e737 --- /dev/null +++ b/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate-expected.txt @@ -0,0 +1,5 @@ +Paused on 'debugger;' +f() returns 1 +g() returns 2 +f() returns 1 +g() throws EvalError diff --git a/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate.js b/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate.js new file mode 100644 index 0000000000..18ea6fba27 --- /dev/null +++ b/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate.js @@ -0,0 +1,56 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --ignition + +InspectorTest.addScript(` +function testFunction() +{ + var o = 0; + function f() { return 1; } + function g() { o = 2; return o; } + debugger; +} +//# sourceURL=foo.js`); + +Protocol.Debugger.enable(); + +Protocol.Debugger.oncePaused().then(debuggerPaused); + +Protocol.Runtime.evaluate({ "expression": "setTimeout(testFunction, 0)" }); + +var topFrameId; + +function debuggerPaused(messageObject) +{ + InspectorTest.log("Paused on 'debugger;'"); + + topFrameId = messageObject.params.callFrames[0].callFrameId; + Protocol.Debugger.evaluateOnCallFrame({ callFrameId: topFrameId, expression: "f()"}).then(evaluatedFirst); +} + +function evaluatedFirst(response) +{ + InspectorTest.log("f() returns " + response.result.result.value); + Protocol.Debugger.evaluateOnCallFrame({ callFrameId: topFrameId, expression: "g()"}).then(evaluatedSecond); +} + +function evaluatedSecond(response) +{ + InspectorTest.log("g() returns " + response.result.result.value); + Protocol.Debugger.evaluateOnCallFrame({ callFrameId: topFrameId, expression: "f()", throwOnSideEffect: true}).then(evaluatedThird); +} + +function evaluatedThird(response) +{ + InspectorTest.log("f() returns " + response.result.result.value); + Protocol.Debugger.evaluateOnCallFrame({ callFrameId: topFrameId, expression: "g()", throwOnSideEffect: true}).then(evaluatedFourth); + InspectorTest.completeTest(); +} + +function evaluatedFourth(response) +{ + InspectorTest.log("g() throws " + response.result.result.className); + InspectorTest.completeTest(); +} diff --git a/deps/v8/test/inspector/debugger/step-into-next-script-expected.txt b/deps/v8/test/inspector/debugger/step-into-next-script-expected.txt new file mode 100644 index 0000000000..e779d06771 --- /dev/null +++ b/deps/v8/test/inspector/debugger/step-into-next-script-expected.txt @@ -0,0 +1,83 @@ +Debugger breaks in next script after stepOut from previous one. + +Running test: testStepOut +test (foo.js:12:2) +(anonymous) (:0:0) + +(anonymous) (:0:5) + +(anonymous) (timeout1.js:0:0) + +foo (timeout2.js:1:12) + +(anonymous) (timeout3.js:0:0) + + +Running test: testStepOver +(anonymous) (:0:0) + +test (foo.js:12:2) +(anonymous) (:0:0) + +test (foo.js:13:0) +(anonymous) (:0:0) + +(anonymous) (:0:5) + +(anonymous) (timeout1.js:0:0) + +(anonymous) (timeout1.js:0:8) + +(anonymous) (timeout1.js:0:34) + +foo (timeout2.js:1:12) + +foo (timeout2.js:2:2) + +foo (timeout2.js:3:0) + +(anonymous) (timeout3.js:0:0) + +(anonymous) (timeout3.js:0:8) + +(anonymous) (timeout3.js:0:34) + + +Running test: testStepInto +(anonymous) (:0:0) + +test (foo.js:9:2) +(anonymous) (:0:0) + +test (foo.js:10:2) +(anonymous) (:0:0) + +test (foo.js:11:2) +(anonymous) (:0:0) + +test (foo.js:12:2) +(anonymous) (:0:0) + +test (foo.js:13:0) +(anonymous) (:0:0) + +(anonymous) (:0:5) + +(anonymous) (timeout1.js:0:0) + +(anonymous) (timeout1.js:0:8) + +(anonymous) (timeout1.js:0:34) + +foo (timeout2.js:1:12) + +foo (timeout2.js:2:2) + +foo (timeout2.js:3:0) + +(anonymous) (timeout3.js:0:0) + +(anonymous) (timeout3.js:0:8) + +(anonymous) (timeout3.js:0:34) + diff --git a/deps/v8/test/inspector/debugger/step-into-next-script.js b/deps/v8/test/inspector/debugger/step-into-next-script.js new file mode 100644 index 0000000000..b51ce012d8 --- /dev/null +++ b/deps/v8/test/inspector/debugger/step-into-next-script.js @@ -0,0 +1,51 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Debugger breaks in next script after stepOut from previous one.'); + +InspectorTest.addScript(` +function test() { + setTimeout('var a = 1;//# sourceURL=timeout1.js', 0); + setTimeout(foo, 0); + setTimeout('var a = 3;//# sourceURL=timeout3.js', 0); + debugger; +} +//# sourceURL=foo.js`, 7, 26); + +InspectorTest.addScript(` +function foo() { + return 42; +} +//# sourceURL=timeout2.js`) + +InspectorTest.setupScriptMap(); +var stepAction; +Protocol.Debugger.onPaused(message => { + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.log(''); + Protocol.Debugger[stepAction](); +}); +Protocol.Debugger.enable() +InspectorTest.runTestSuite([ + function testStepOut(next) { + stepAction = 'stepOut'; + Protocol.Runtime.evaluate({ expression: 'test()' }) + .then(() => InspectorTest.waitPendingTasks()) + .then(next); + }, + + function testStepOver(next) { + stepAction = 'stepOver'; + Protocol.Runtime.evaluate({ expression: 'test()' }) + .then(() => InspectorTest.waitPendingTasks()) + .then(next); + }, + + function testStepInto(next) { + stepAction = 'stepInto'; + Protocol.Runtime.evaluate({ expression: 'test()' }) + .then(() => InspectorTest.waitPendingTasks()) + .then(next); + } +]); diff --git a/deps/v8/test/inspector/debugger/stepping-with-blackboxed-ranges.js b/deps/v8/test/inspector/debugger/stepping-with-blackboxed-ranges.js index 0a97e5dc35..65b694b566 100644 --- a/deps/v8/test/inspector/debugger/stepping-with-blackboxed-ranges.js +++ b/deps/v8/test/inspector/debugger/stepping-with-blackboxed-ranges.js @@ -90,10 +90,15 @@ function setIncorrectRanges(scriptId, response) function setMixedSourceRanges(scriptId) { Protocol.Debugger.onPaused(runAction); - Protocol.Debugger.setBlackboxedRanges({ - scriptId: scriptId, - positions: [ { lineNumber: 8, columnNumber: 0 }, { lineNumber: 15, columnNumber: 0 } ] // blackbox ranges for mixed.js - }).then(runAction); + Protocol.Debugger + .setBlackboxedRanges({ + scriptId: scriptId, + positions: [ + {lineNumber: 6, columnNumber: 0}, + {lineNumber: 14, columnNumber: 0} + ] // blackbox ranges for mixed.js + }) + .then(runAction); } var actions = [ "stepOut", "print", "stepOut", "print", "stepOut", "print", diff --git a/deps/v8/test/inspector/debugger/wasm-get-breakable-locations-expected.txt b/deps/v8/test/inspector/debugger/wasm-get-breakable-locations-expected.txt new file mode 100644 index 0000000000..736117bf97 --- /dev/null +++ b/deps/v8/test/inspector/debugger/wasm-get-breakable-locations-expected.txt @@ -0,0 +1,87 @@ +Running testFunction... +Script nr 0 parsed. URL: v8://test/setup +Script nr 1 parsed. URL: v8://test/runTestFunction +Script nr 2 parsed. URL: wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0 +This is a wasm script (nr 0). +Script nr 3 parsed. URL: wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1 +This is a wasm script (nr 1). +Querying breakable locations for all wasm scripts now... +Requesting all breakable locations in wasm script 0 +4 breakable location(s): +[0] 2:2 || >nop +[1] 3:2 || >i32.const 12 +[2] 4:2 || >set_local 0 +[3] 5:0 || >end +Requesting breakable locations in lines [0,3) +1 breakable location(s): +[0] 2:2 || >nop +Requesting breakable locations in lines [4,6) +2 breakable location(s): +[0] 4:2 || >set_local 0 +[1] 5:0 || >end +Requesting all breakable locations in wasm script 1 +7 breakable location(s): +[0] 1:2 || >get_local 0 +[1] 2:2 || >if +[2] 3:4 || >block +[3] 4:6 || >call 0 +[4] 5:4 || >end +[5] 6:2 || >end +[6] 7:0 || >end +Requesting breakable locations in lines [0,3) +2 breakable location(s): +[0] 1:2 || >get_local 0 +[1] 2:2 || >if +Requesting breakable locations in lines [4,6) +2 breakable location(s): +[0] 4:6 || >call 0 +[1] 5:4 || >end +Setting a breakpoint on each breakable location... +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:2:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:3:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:4:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:5:0 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:1:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:2:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:3:4 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:4:6 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:5:4 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:6:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:7:0 +Success! +Running wasm code... +Missing breakpoints: 11 +Script nr 4 parsed. URL: v8://test/runWasm +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:1:2 +Missing breakpoints: 10 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:2:2 +Missing breakpoints: 9 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:3:4 +Missing breakpoints: 8 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:4:6 +Missing breakpoints: 7 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:2:2 +Missing breakpoints: 6 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:3:2 +Missing breakpoints: 5 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:4:2 +Missing breakpoints: 4 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:5:0 +Missing breakpoints: 3 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:5:4 +Missing breakpoints: 2 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:6:2 +Missing breakpoints: 1 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:7:0 +Missing breakpoints: 0 +Finished! diff --git a/deps/v8/test/inspector/debugger/wasm-get-breakable-locations.js b/deps/v8/test/inspector/debugger/wasm-get-breakable-locations.js new file mode 100644 index 0000000000..f947161b5e --- /dev/null +++ b/deps/v8/test/inspector/debugger/wasm-get-breakable-locations.js @@ -0,0 +1,208 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +var builder = new WasmModuleBuilder(); + +// clang-format off +var func_idx = builder.addFunction('helper', kSig_v_v) + .addLocals({i32_count: 1}) + .addBody([ + kExprNop, + kExprI32Const, 12, + kExprSetLocal, 0, + ]).index; + +builder.addFunction('main', kSig_v_i) + .addBody([ + kExprGetLocal, 0, + kExprIf, kWasmStmt, + kExprBlock, kWasmStmt, + kExprCallFunction, func_idx, + kExprEnd, + kExprEnd + ]).exportAs('main'); +// clang-format on + +var module_bytes = builder.toArray(); + +function testFunction(bytes) { + var buffer = new ArrayBuffer(bytes.length); + var view = new Uint8Array(buffer); + for (var i = 0; i < bytes.length; i++) { + view[i] = bytes[i] | 0; + } + + var module = new WebAssembly.Module(buffer); + // Set global variable. + instance = new WebAssembly.Instance(module); +} + +var evalWithUrl = (code, url) => Protocol.Runtime.evaluate( + {'expression': code + '\n//# sourceURL=v8://test/' + url}); + +var setupCode = testFunction.toString() + ';\nvar module_bytes = ' + + JSON.stringify(module_bytes) + ';\nvar instance;'; + +Protocol.Debugger.enable(); +Protocol.Debugger.onScriptParsed(handleScriptParsed); +InspectorTest.log('Running testFunction...'); +evalWithUrl(setupCode, 'setup') + .then(() => evalWithUrl('testFunction(module_bytes)', 'runTestFunction')) + .then(getBreakableLocationsForAllWasmScripts) + .then(setAllBreakableLocations) + .then(() => InspectorTest.log('Running wasm code...')) + .then(() => (evalWithUrl('instance.exports.main(1)', 'runWasm'), 0)) + .then(waitForAllPauses) + .then(() => InspectorTest.log('Finished!')) + .then(InspectorTest.completeTest); + +var allBreakableLocations = []; + +var urls = {}; +var numScripts = 0; +var wasmScripts = []; +function handleScriptParsed(messageObject) { + var scriptId = messageObject.params.scriptId; + var url = messageObject.params.url; + urls[scriptId] = url; + InspectorTest.log('Script nr ' + numScripts + ' parsed. URL: ' + url); + ++numScripts; + + if (url.startsWith('wasm://')) { + InspectorTest.log('This is a wasm script (nr ' + wasmScripts.length + ').'); + wasmScripts.push(scriptId); + } +} + +function printFailure(message) { + if (!message.result) { + InspectorTest.logMessage(message); + } + return message; +} + +function printBreakableLocations(message, expectedScriptId, source) { + var lines = source.split('\n'); + var locations = message.result.locations; + InspectorTest.log(locations.length + ' breakable location(s):'); + for (var i = 0; i < locations.length; ++i) { + if (locations[i].scriptId != expectedScriptId) { + InspectorTest.log( + 'SCRIPT ID MISMATCH!! ' + locations[i].scriptId + ' != ' + + expectedScriptId); + } + var line = '<illegal line number>'; + if (locations[i].lineNumber < lines.length) { + line = lines[locations[i].lineNumber]; + if (locations[i].columnNumber < line.length) { + line = line.substr(0, locations[i].columnNumber) + '>' + + line.substr(locations[i].columnNumber); + } + } + InspectorTest.log( + '[' + i + '] ' + locations[i].lineNumber + ':' + + locations[i].columnNumber + ' || ' + line); + } +} + +function checkGetBreakableLocations(wasmScriptNr) { + InspectorTest.log( + 'Requesting all breakable locations in wasm script ' + wasmScriptNr); + var scriptId = wasmScripts[wasmScriptNr]; + var source; + return Protocol.Debugger.getScriptSource({scriptId: scriptId}) + .then(msg => source = msg.result.scriptSource) + .then( + () => Protocol.Debugger.getPossibleBreakpoints( + {start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}})) + .then(printFailure) + .then(msg => (allBreakableLocations.push(...msg.result.locations), msg)) + .then(msg => printBreakableLocations(msg, scriptId, source)) + .then( + () => InspectorTest.log( + 'Requesting breakable locations in lines [0,3)')) + .then(() => Protocol.Debugger.getPossibleBreakpoints({ + start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}, + end: {lineNumber: 3, columnNumber: 0, scriptId: scriptId} + })) + .then(printFailure) + .then(msg => printBreakableLocations(msg, scriptId, source)) + .then( + () => InspectorTest.log( + 'Requesting breakable locations in lines [4,6)')) + .then(() => Protocol.Debugger.getPossibleBreakpoints({ + start: {lineNumber: 4, columnNumber: 0, scriptId: scriptId}, + end: {lineNumber: 6, columnNumber: 0, scriptId: scriptId} + })) + .then(printFailure) + .then(msg => printBreakableLocations(msg, scriptId, source)); +} + +function getBreakableLocationsForAllWasmScripts() { + InspectorTest.log('Querying breakable locations for all wasm scripts now...'); + var promise = Promise.resolve(); + for (var wasmScriptNr = 0; wasmScriptNr < wasmScripts.length; + ++wasmScriptNr) { + promise = promise.then(checkGetBreakableLocations.bind(null, wasmScriptNr)); + } + return promise; +} + +function locationMatches(loc1, loc2) { + return loc1.scriptId == loc2.scriptId && loc1.lineNumber == loc2.lineNumber && + loc1.columnNumber == loc2.columnNumber; +} + +function locationStr(loc) { + return urls[loc.scriptId] + ':' + loc.lineNumber + ':' + loc.columnNumber; +} + +function setBreakpoint(loc) { + InspectorTest.log('Setting at ' + locationStr(loc)); + function check(msg) { + if (locationMatches(loc, msg.result.actualLocation)) { + InspectorTest.log("Success!"); + } else { + InspectorTest.log("Mismatch!"); + InspectorTest.logMessage(msg); + } + } + return Protocol.Debugger.setBreakpoint({'location': loc}) + .then(printFailure) + .then(check); +} + +function setAllBreakableLocations() { + InspectorTest.log('Setting a breakpoint on each breakable location...'); + var promise = Promise.resolve(); + for (var loc of allBreakableLocations) { + promise = promise.then(setBreakpoint.bind(null, loc)); + } + return promise; +} + +function removePausedLocation(msg) { + var topLocation = msg.params.callFrames[0].location; + InspectorTest.log('Stopped at ' + locationStr(topLocation)); + for (var i = 0; i < allBreakableLocations.length; ++i) { + if (locationMatches(topLocation, allBreakableLocations[i])) { + allBreakableLocations.splice(i, 1); + --i; + } + } +} + +function waitForAllPauses() { + InspectorTest.log('Missing breakpoints: ' + allBreakableLocations.length); + if (allBreakableLocations.length == 0) return; + return Protocol.Debugger.oncePaused() + .then(removePausedLocation) + .then(Protocol.Debugger.resume()) + .then(waitForAllPauses); +} diff --git a/deps/v8/test/inspector/debugger/wasm-stepping-expected.txt b/deps/v8/test/inspector/debugger/wasm-stepping-expected.txt new file mode 100644 index 0000000000..922d51aa49 --- /dev/null +++ b/deps/v8/test/inspector/debugger/wasm-stepping-expected.txt @@ -0,0 +1,83 @@ +Installing code an global variable. +Calling instantiate function. +Waiting for two wasm scripts to be parsed. +Ignoring script with url v8://test/callInstantiate +Got wasm script: wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0 +Requesting source for wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0... +Got wasm script: wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1 +Requesting source for wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1... +func $wasm_A + nop + nop +end + +func $wasm_B (param i32) + loop + get_local 0 + if + get_local 0 + i32.const 1 + i32.sub + set_local 0 + call 0 + br 1 + end + end +end + +Setting breakpoint on line 7 (on the setlocal before the call), url wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1 +{ + columnNumber : 6 + lineNumber : 7 + scriptId : <scriptId> +} +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:7:6: >set_local 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:8:6: >call 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:1:2: >nop +Step action: stepOver +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:2:2: >nop +Step action: stepOut +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:9:6: >br 1 +Step action: stepOut +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:7:6: >set_local 0 +Step action: stepOver +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:8:6: >call 0 +Step action: stepOver +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:9:6: >br 1 +Step action: resume +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:7:6: >set_local 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:8:6: >call 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:1:2: >nop +Step action: stepOut +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:9:6: >br 1 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:1:2: >loop +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:2:4: >get_local 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:3:4: >if +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:4:6: >get_local 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:5:6: >i32.const 1 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:6:6: >i32.sub +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:7:6: >set_local 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:8:6: >call 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:1:2: >nop +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:2:2: >nop +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:3:0: >end +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:9:6: >br 1 +Step action: resume +exports.main returned! +Finished! diff --git a/deps/v8/test/inspector/debugger/wasm-stepping.js b/deps/v8/test/inspector/debugger/wasm-stepping.js new file mode 100644 index 0000000000..8cf14d361c --- /dev/null +++ b/deps/v8/test/inspector/debugger/wasm-stepping.js @@ -0,0 +1,160 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +var builder = new WasmModuleBuilder(); + +var func_a_idx = + builder.addFunction('wasm_A', kSig_v_v).addBody([kExprNop, kExprNop]).index; + +// wasm_B calls wasm_A <param0> times. +builder.addFunction('wasm_B', kSig_v_i) + .addBody([ + // clang-format off + kExprLoop, kWasmStmt, // while + kExprGetLocal, 0, // - + kExprIf, kWasmStmt, // if <param0> != 0 + kExprGetLocal, 0, // - + kExprI32Const, 1, // - + kExprI32Sub, // - + kExprSetLocal, 0, // decrease <param0> + kExprCallFunction, func_a_idx, // - + kExprBr, 1, // continue + kExprEnd, // - + kExprEnd, // break + // clang-format on + ]) + .exportAs('main'); + +var module_bytes = builder.toArray(); + +function instantiate(bytes) { + var buffer = new ArrayBuffer(bytes.length); + var view = new Uint8Array(buffer); + for (var i = 0; i < bytes.length; ++i) { + view[i] = bytes[i] | 0; + } + + var module = new WebAssembly.Module(buffer); + // Set global variable. + instance = new WebAssembly.Instance(module); +} + +var evalWithUrl = (code, url) => Protocol.Runtime.evaluate( + {'expression': code + '\n//# sourceURL=v8://test/' + url}); + +Protocol.Debugger.onPaused(handlePaused); +var wasm_B_scriptId; +var step_actions = [ + 'stepInto', // == stepOver, to call instruction + 'stepInto', // into call to wasm_A + 'stepOver', // over first nop + 'stepOut', // out of wasm_A + 'stepOut', // out of wasm_B, stop on breakpoint again + 'stepOver', // to call + 'stepOver', // over call + 'resume', // to next breakpoint (third iteration) + 'stepInto', // to call + 'stepInto', // into wasm_A + 'stepOut', // out to wasm_B + // now step 9 times, until we are in wasm_A again. + 'stepInto', 'stepInto', 'stepInto', 'stepInto', 'stepInto', 'stepInto', + 'stepInto', 'stepInto', 'stepInto', + // 3 more times, back to wasm_B. + 'stepInto', 'stepInto', 'stepInto', + // then just resume. + 'resume' +]; +var sources = {}; +var urls = {}; +var afterTwoSourcesCallback; + +Protocol.Debugger.enable() + .then(() => InspectorTest.log('Installing code an global variable.')) + .then( + () => evalWithUrl('var instance;\n' + instantiate.toString(), 'setup')) + .then(() => InspectorTest.log('Calling instantiate function.')) + .then( + () => + (evalWithUrl( + 'instantiate(' + JSON.stringify(module_bytes) + ')', + 'callInstantiate'), + 0)) + .then(waitForTwoWasmScripts) + .then( + () => InspectorTest.log( + 'Setting breakpoint on line 7 (on the setlocal before the call), url ' + + urls[wasm_B_scriptId])) + .then( + () => Protocol.Debugger.setBreakpoint( + {'location': {'scriptId': wasm_B_scriptId, 'lineNumber': 7}})) + .then(printFailure) + .then(msg => InspectorTest.logMessage(msg.result.actualLocation)) + .then(() => evalWithUrl('instance.exports.main(4)', 'runWasm')) + .then(() => InspectorTest.log('exports.main returned!')) + .then(() => InspectorTest.log('Finished!')) + .then(InspectorTest.completeTest); + +function printFailure(message) { + if (!message.result) { + InspectorTest.logMessage(message); + } + return message; +} + +function waitForTwoWasmScripts() { + var num = 0; + InspectorTest.log('Waiting for two wasm scripts to be parsed.'); + var promise = new Promise(fulfill => gotBothSources = fulfill); + function waitForMore() { + if (num == 2) return promise; + Protocol.Debugger.onceScriptParsed() + .then(handleNewScript) + .then(waitForMore); + } + function handleNewScript(msg) { + var url = msg.params.url; + if (!url.startsWith('wasm://')) { + InspectorTest.log('Ignoring script with url ' + url); + return; + } + num += 1; + var scriptId = msg.params.scriptId; + urls[scriptId] = url; + InspectorTest.log('Got wasm script: ' + url); + if (url.substr(-2) == '-1') wasm_B_scriptId = scriptId; + InspectorTest.log('Requesting source for ' + url + '...'); + Protocol.Debugger.getScriptSource({scriptId: scriptId}) + .then(printFailure) + .then(msg => sources[scriptId] = msg.result.scriptSource) + .then(InspectorTest.log) + .then(() => Object.keys(sources).length == 2 ? gotBothSources() : 0); + } + waitForMore(); + return promise; +} + +function printPauseLocation(scriptId, lineNr, columnNr) { + var lines = sources[scriptId].split('\n'); + var line = '<illegal line number>'; + if (lineNr < lines.length) { + line = lines[lineNr]; + if (columnNr < line.length) { + line = line.substr(0, columnNr) + '>' + line.substr(columnNr); + } + } + InspectorTest.log( + 'Paused at ' + urls[scriptId] + ':' + lineNr + ':' + columnNr + ': ' + + line); +} + +function handlePaused(msg) { + var loc = msg.params.callFrames[0].location; + printPauseLocation(loc.scriptId, loc.lineNumber, loc.columnNumber); + var action = step_actions.shift(); + InspectorTest.log('Step action: ' + action); + Protocol.Debugger[action](); +} diff --git a/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause-expected.txt b/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause-expected.txt new file mode 100644 index 0000000000..2d2e5532b3 --- /dev/null +++ b/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause-expected.txt @@ -0,0 +1,2 @@ +Checks that takeHeapSnapshot uses empty accessing_context for access checks. +Successfully finished diff --git a/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause.js b/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause.js new file mode 100644 index 0000000000..e36b11558d --- /dev/null +++ b/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause.js @@ -0,0 +1,24 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Checks that takeHeapSnapshot uses empty accessing_context for access \ +checks.'); + +InspectorTest.addScript(` +function testFunction() { + var array = [ createObjectWithStrictCheck() ]; + debugger; +} +//# sourceURL=test.js`); + +Protocol.Debugger.onScriptParsed(message => { + Protocol.HeapProfiler.takeHeapSnapshot({ reportProgress: false }) + .then(() => Protocol.Debugger.resume()); +}); + +Protocol.Debugger.enable(); +Protocol.HeapProfiler.enable(); +Protocol.Runtime.evaluate({ expression: 'testFunction()' }) + .then(() => InspectorTest.log('Successfully finished')) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/inspector-impl.cc b/deps/v8/test/inspector/inspector-impl.cc index f1d62afbad..3b04440372 100644 --- a/deps/v8/test/inspector/inspector-impl.cc +++ b/deps/v8/test/inspector/inspector-impl.cc @@ -138,7 +138,13 @@ v8::Local<v8::Context> InspectorClientImpl::ensureDefaultContextInGroup(int) { return context_.Get(isolate_); } +void InspectorClientImpl::setCurrentTimeMSForTest(double time) { + current_time_ = time; + current_time_set_for_test_ = true; +} + double InspectorClientImpl::currentTimeMS() { + if (current_time_set_for_test_) return current_time_; return v8::base::OS::TimeCurrentMillis(); } diff --git a/deps/v8/test/inspector/inspector-impl.h b/deps/v8/test/inspector/inspector-impl.h index f94bef1599..5da332bb27 100644 --- a/deps/v8/test/inspector/inspector-impl.h +++ b/deps/v8/test/inspector/inspector-impl.h @@ -27,6 +27,12 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient { static v8_inspector::V8Inspector* InspectorFromContext( v8::Local<v8::Context> context); + static v8_inspector::V8InspectorSession* SessionFromContext( + v8::Local<v8::Context> context); + + void setCurrentTimeMSForTest(double time); + + v8_inspector::V8InspectorSession* session() const { return session_.get(); } private: // V8InspectorClient implementation. @@ -36,9 +42,6 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient { void runMessageLoopOnPause(int context_group_id) override; void quitMessageLoopOnPause() override; - static v8_inspector::V8InspectorSession* SessionFromContext( - v8::Local<v8::Context> context); - friend class SendMessageToBackendTask; friend class ConnectTask; @@ -54,6 +57,9 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient { TaskRunner* task_runner_; FrontendChannel* frontend_channel_; + bool current_time_set_for_test_ = false; + double current_time_ = 0.0; + DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl); }; diff --git a/deps/v8/test/inspector/inspector-test.cc b/deps/v8/test/inspector/inspector-test.cc index 286d685d21..b3dbcb4f52 100644 --- a/deps/v8/test/inspector/inspector-test.cc +++ b/deps/v8/test/inspector/inspector-test.cc @@ -54,7 +54,10 @@ class UtilsExtension : public v8::Extension { "native function quit();" "native function setlocale();" "native function load();" - "native function compileAndRunWithOrigin();") {} + "native function compileAndRunWithOrigin();" + "native function setCurrentTimeMSForTest();" + "native function schedulePauseOnNextStatement();" + "native function cancelPauseOnNextStatement();") {} virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( v8::Isolate* isolate, v8::Local<v8::String> name) { v8::Local<v8::Context> context = isolate->GetCurrentContext(); @@ -88,6 +91,28 @@ class UtilsExtension : public v8::Extension { .FromJust()) { return v8::FunctionTemplate::New(isolate, UtilsExtension::CompileAndRunWithOrigin); + } else if (name->Equals(context, v8::String::NewFromUtf8( + isolate, "setCurrentTimeMSForTest", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New(isolate, + UtilsExtension::SetCurrentTimeMSForTest); + } else if (name->Equals(context, + v8::String::NewFromUtf8( + isolate, "schedulePauseOnNextStatement", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New( + isolate, UtilsExtension::SchedulePauseOnNextStatement); + } else if (name->Equals(context, v8::String::NewFromUtf8( + isolate, "cancelPauseOnNextStatement", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New( + isolate, UtilsExtension::CancelPauseOnNextStatement); } return v8::Local<v8::FunctionTemplate>(); } @@ -96,8 +121,13 @@ class UtilsExtension : public v8::Extension { backend_runner_ = runner; } + static void set_inspector_client(InspectorClientImpl* client) { + inspector_client_ = client; + } + private: static TaskRunner* backend_runner_; + static InspectorClientImpl* inspector_client_; static void Print(const v8::FunctionCallbackInfo<v8::Value>& args) { for (int i = 0; i < args.Length(); i++) { @@ -168,21 +198,58 @@ class UtilsExtension : public v8::Extension { static void CompileAndRunWithOrigin( const v8::FunctionCallbackInfo<v8::Value>& args) { - if (args.Length() != 4 || !args[0]->IsString() || !args[1]->IsString() || - !args[2]->IsInt32() || !args[3]->IsInt32()) { + if (args.Length() != 5 || !args[0]->IsString() || !args[1]->IsString() || + !args[2]->IsInt32() || !args[3]->IsInt32() || !args[4]->IsBoolean()) { fprintf(stderr, "Internal error: compileAndRunWithOrigin(source, name, line, " - "column)."); + "column, is_module)."); Exit(); } backend_runner_->Append(new ExecuteStringTask( ToVector(args[0].As<v8::String>()), args[1].As<v8::String>(), - args[2].As<v8::Int32>(), args[3].As<v8::Int32>(), nullptr, nullptr)); + args[2].As<v8::Int32>(), args[3].As<v8::Int32>(), + args[4].As<v8::Boolean>(), nullptr, nullptr)); + } + + static void SetCurrentTimeMSForTest( + const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 1 || !args[0]->IsNumber()) { + fprintf(stderr, "Internal error: setCurrentTimeMSForTest(time)."); + Exit(); + } + inspector_client_->setCurrentTimeMSForTest( + args[0].As<v8::Number>()->Value()); + } + + static void SchedulePauseOnNextStatement( + const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString()) { + fprintf( + stderr, + "Internal error: schedulePauseOnNextStatement('reason', 'details')."); + Exit(); + } + v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>()); + v8_inspector::StringView reason_view(reason.start(), reason.length()); + v8::internal::Vector<uint16_t> details = ToVector(args[1].As<v8::String>()); + v8_inspector::StringView details_view(details.start(), details.length()); + inspector_client_->session()->schedulePauseOnNextStatement(reason_view, + details_view); + } + + static void CancelPauseOnNextStatement( + const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 0) { + fprintf(stderr, "Internal error: cancelPauseOnNextStatement()."); + Exit(); + } + inspector_client_->session()->cancelPauseOnNextStatement(); } }; TaskRunner* UtilsExtension::backend_runner_ = nullptr; +InspectorClientImpl* UtilsExtension::inspector_client_ = nullptr; class SetTimeoutTask : public AsyncTask { public: @@ -247,19 +314,29 @@ class SetTimeoutExtension : public v8::Extension { task.reset(new ExecuteStringTask( ToVector(args[0].As<v8::String>()), v8::String::Empty(isolate), v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0), - "setTimeout", inspector)); + v8::Boolean::New(isolate, false), "setTimeout", inspector)); } TaskRunner::FromContext(context)->Append(task.release()); } }; +bool StrictAccessCheck(v8::Local<v8::Context> accessing_context, + v8::Local<v8::Object> accessed_object, + v8::Local<v8::Value> data) { + CHECK(accessing_context.IsEmpty()); + return accessing_context.IsEmpty(); +} + class InspectorExtension : public v8::Extension { public: InspectorExtension() : v8::Extension("v8_inspector/inspector", "native function attachInspector();" "native function detachInspector();" - "native function setMaxAsyncTaskStacks();") {} + "native function setMaxAsyncTaskStacks();" + "native function breakProgram();" + "native function createObjectWithStrictCheck();" + "native function callWithScheduledBreak();") {} virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( v8::Isolate* isolate, v8::Local<v8::String> name) { @@ -283,6 +360,27 @@ class InspectorExtension : public v8::Extension { .FromJust()) { return v8::FunctionTemplate::New( isolate, InspectorExtension::SetMaxAsyncTaskStacks); + } else if (name->Equals(context, + v8::String::NewFromUtf8(isolate, "breakProgram", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New(isolate, + InspectorExtension::BreakProgram); + } else if (name->Equals(context, v8::String::NewFromUtf8( + isolate, "createObjectWithStrictCheck", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New( + isolate, InspectorExtension::CreateObjectWithStrictCheck); + } else if (name->Equals(context, v8::String::NewFromUtf8( + isolate, "callWithScheduledBreak", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New( + isolate, InspectorExtension::CallWithScheduledBreak); } return v8::Local<v8::FunctionTemplate>(); } @@ -326,6 +424,61 @@ class InspectorExtension : public v8::Extension { v8_inspector::SetMaxAsyncTaskStacksForTest( inspector, args[0].As<v8::Int32>()->Value()); } + + static void BreakProgram(const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString()) { + fprintf(stderr, "Internal error: breakProgram('reason', 'details')."); + Exit(); + } + v8_inspector::V8InspectorSession* session = + InspectorClientImpl::SessionFromContext( + args.GetIsolate()->GetCurrentContext()); + CHECK(session); + + v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>()); + v8_inspector::StringView reason_view(reason.start(), reason.length()); + v8::internal::Vector<uint16_t> details = ToVector(args[1].As<v8::String>()); + v8_inspector::StringView details_view(details.start(), details.length()); + session->breakProgram(reason_view, details_view); + } + + static void CreateObjectWithStrictCheck( + const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 0) { + fprintf(stderr, "Internal error: createObjectWithStrictCheck()."); + Exit(); + } + v8::Local<v8::ObjectTemplate> templ = + v8::ObjectTemplate::New(args.GetIsolate()); + templ->SetAccessCheckCallback(&StrictAccessCheck); + args.GetReturnValue().Set( + templ->NewInstance(args.GetIsolate()->GetCurrentContext()) + .ToLocalChecked()); + } + + static void CallWithScheduledBreak( + const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 3 || !args[0]->IsFunction() || !args[1]->IsString() || + !args[2]->IsString()) { + fprintf(stderr, "Internal error: breakProgram('reason', 'details')."); + Exit(); + } + v8_inspector::V8InspectorSession* session = + InspectorClientImpl::SessionFromContext( + args.GetIsolate()->GetCurrentContext()); + CHECK(session); + + v8::internal::Vector<uint16_t> reason = ToVector(args[1].As<v8::String>()); + v8_inspector::StringView reason_view(reason.start(), reason.length()); + v8::internal::Vector<uint16_t> details = ToVector(args[2].As<v8::String>()); + v8_inspector::StringView details_view(details.start(), details.length()); + session->schedulePauseOnNextStatement(reason_view, details_view); + v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); + v8::MaybeLocal<v8::Value> result; + result = args[0].As<v8::Function>()->Call(context, context->Global(), 0, + nullptr); + session->cancelPauseOnNextStatement(); + } }; v8::Local<v8::String> ToString(v8::Isolate* isolate, @@ -364,10 +517,10 @@ class FrontendChannelImpl : public InspectorClientImpl::FrontendChannel { v8::Local<v8::String> result = v8::String::Concat(prefix, message_string); result = v8::String::Concat(result, suffix); - frontend_task_runner_->Append( - new ExecuteStringTask(ToVector(result), v8::String::Empty(isolate), - v8::Integer::New(isolate, 0), - v8::Integer::New(isolate, 0), nullptr, nullptr)); + frontend_task_runner_->Append(new ExecuteStringTask( + ToVector(result), v8::String::Empty(isolate), + v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0), + v8::Boolean::New(isolate, false), nullptr, nullptr)); } private: @@ -415,6 +568,7 @@ int main(int argc, char* argv[]) { InspectorClientImpl inspector_client(&backend_runner, &frontend_channel, &ready_semaphore); ready_semaphore.Wait(); + UtilsExtension::set_inspector_client(&inspector_client); task_runners.push_back(&frontend_runner); task_runners.push_back(&backend_runner); diff --git a/deps/v8/test/inspector/inspector.status b/deps/v8/test/inspector/inspector.status index 511c405c2b..e79510d2d6 100644 --- a/deps/v8/test/inspector/inspector.status +++ b/deps/v8/test/inspector/inspector.status @@ -4,6 +4,11 @@ [ +[ALWAYS, { + # Test is failing on V8 Linux - arm64 - sim - nosnap - debug. + 'debugger/pause-on-oom': [SKIP], +}], # ALWAYS + ############################################################################## ['variant == asm_wasm', { '*': [SKIP], diff --git a/deps/v8/test/inspector/protocol-test.js b/deps/v8/test/inspector/protocol-test.js index 37e6447f79..d62c2e0c29 100644 --- a/deps/v8/test/inspector/protocol-test.js +++ b/deps/v8/test/inspector/protocol-test.js @@ -20,7 +20,8 @@ Protocol = new Proxy({}, { var eventName = match[2]; eventName = eventName.charAt(0).toLowerCase() + eventName.slice(1); if (match[1]) - return (args) => InspectorTest._waitForEventPromise(`${agentName}.${eventName}`, args || {}); + return () => InspectorTest._waitForEventPromise( + `${agentName}.${eventName}`); else return (listener) => { InspectorTest._eventHandler[`${agentName}.${eventName}`] = listener }; } @@ -112,6 +113,21 @@ InspectorTest.logCallFrames = function(callFrames) } } +InspectorTest.logAsyncStackTrace = function(asyncStackTrace) +{ + while (asyncStackTrace) { + if (asyncStackTrace.promiseCreationFrame) { + var frame = asyncStackTrace.promiseCreationFrame; + InspectorTest.log(`-- ${asyncStackTrace.description} (${frame.url + }:${frame.lineNumber}:${frame.columnNumber})--`); + } else { + InspectorTest.log(`-- ${asyncStackTrace.description} --`); + } + InspectorTest.logCallFrames(asyncStackTrace.callFrames); + asyncStackTrace = asyncStackTrace.parent; + } +} + InspectorTest.completeTest = function() { Protocol.Debugger.disable().then(() => quit()); @@ -119,13 +135,17 @@ InspectorTest.completeTest = function() InspectorTest.completeTestAfterPendingTimeouts = function() { - Protocol.Runtime.evaluate({ - expression: "new Promise(resolve => setTimeout(resolve, 0))", - awaitPromise: true }).then(InspectorTest.completeTest); + InspectorTest.waitPendingTasks().then(InspectorTest.completeTest); +} + +InspectorTest.waitPendingTasks = function() +{ + return Protocol.Runtime.evaluate({ expression: "new Promise(r => setTimeout(r, 0))//# sourceURL=wait-pending-tasks.js", awaitPromise: true }); } -InspectorTest.addScript = (string, lineOffset, columnOffset) => compileAndRunWithOrigin(string, "", lineOffset || 0, columnOffset || 0); -InspectorTest.addScriptWithUrl = (string, url) => compileAndRunWithOrigin(string, url, 0, 0); +InspectorTest.addScript = (string, lineOffset, columnOffset) => compileAndRunWithOrigin(string, "", lineOffset || 0, columnOffset || 0, false); +InspectorTest.addScriptWithUrl = (string, url) => compileAndRunWithOrigin(string, url, 0, 0, false); +InspectorTest.addModule = (string, url, lineOffset, columnOffset) => compileAndRunWithOrigin(string, url, lineOffset || 0, columnOffset || 0, true); InspectorTest.startDumpingProtocolMessages = function() { @@ -213,6 +233,8 @@ InspectorTest._dispatchMessage = function(messageObject) var eventHandler = InspectorTest._eventHandler[eventName]; if (InspectorTest._scriptMap && eventName === "Debugger.scriptParsed") InspectorTest._scriptMap.set(messageObject.params.scriptId, JSON.parse(JSON.stringify(messageObject.params))); + if (eventName === "Debugger.scriptParsed" && messageObject.params.url === "wait-pending-tasks.js") + return; if (eventHandler) eventHandler(messageObject); } diff --git a/deps/v8/test/inspector/runtime/console-methods-expected.txt b/deps/v8/test/inspector/runtime/console-methods-expected.txt new file mode 100644 index 0000000000..100789a773 --- /dev/null +++ b/deps/v8/test/inspector/runtime/console-methods-expected.txt @@ -0,0 +1,648 @@ +Checks console methods +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : debug + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 9 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : debug + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : error + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 10 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : error + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : info + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 11 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : info + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : log + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 12 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : log + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : warn + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 13 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : warning + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : dir + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 14 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : dir + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : dirxml + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 15 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : dirxml + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + className : Array + description : Array(2) + objectId : <objectId> + preview : { + description : Array(2) + overflow : false + properties : [ + [0] : { + name : 0 + subtype : array + type : object + valuePreview : { + description : Array(2) + overflow : false + properties : [ + [0] : { + name : 0 + type : number + value : 1 + } + [1] : { + name : 1 + type : number + value : 2 + } + ] + subtype : array + type : object + } + } + [1] : { + name : 1 + subtype : array + type : object + valuePreview : { + description : Array(2) + overflow : false + properties : [ + [0] : { + name : 0 + type : number + value : 3 + } + [1] : { + name : 1 + type : number + value : 4 + } + ] + subtype : array + type : object + } + } + ] + subtype : array + type : object + } + subtype : array + type : object + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 16 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : table + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : trace + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 17 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : trace + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : console.trace + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 18 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : trace + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : console.group + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 19 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : startGroup + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : console.groupEnd + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 20 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : endGroup + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : console.groupCollapsed + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 21 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : startGroupCollapsed + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : clear + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 22 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : clear + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : console.clear + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 23 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : clear + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : count: 1 + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 24 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : count + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : 1 + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 12 + functionName : foo + lineNumber : 26 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 2 + functionName : testFunction + lineNumber : 28 + scriptId : <scriptId> + url : test.js + } + [2] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : count + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : 2 + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 12 + functionName : foo + lineNumber : 26 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 2 + functionName : testFunction + lineNumber : 29 + scriptId : <scriptId> + url : test.js + } + [2] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : count + } +} diff --git a/deps/v8/test/inspector/runtime/console-methods.js b/deps/v8/test/inspector/runtime/console-methods.js new file mode 100644 index 0000000000..f6fb20758a --- /dev/null +++ b/deps/v8/test/inspector/runtime/console-methods.js @@ -0,0 +1,36 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Checks console methods'); + +InspectorTest.addScript(` +function testFunction() { + console.debug('debug'); + console.error('error'); + console.info('info'); + console.log('log'); + console.warn('warn'); + console.dir('dir'); + console.dirxml('dirxml'); + console.table([[1,2],[3,4]]); + console.trace('trace'); + console.trace(); + console.group(); + console.groupEnd(); + console.groupCollapsed(); + console.clear('clear'); + console.clear(); + console.count('count'); + function foo() { + console.count(); + } + foo(); + foo(); +} +//# sourceURL=test.js`, 7, 26); + +Protocol.Runtime.onConsoleAPICalled(InspectorTest.logMessage); +Protocol.Runtime.enable(); +Protocol.Runtime.evaluate({ expression: 'testFunction()' }) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/runtime/console-time-end-format-expected.txt b/deps/v8/test/inspector/runtime/console-time-end-format-expected.txt new file mode 100644 index 0000000000..92fa158d2b --- /dev/null +++ b/deps/v8/test/inspector/runtime/console-time-end-format-expected.txt @@ -0,0 +1,29 @@ +Checks format of console.timeEnd output + +Running test: zero +js: 0ms +timeEnd: 0ms + +Running test: verySmall +js: 1e-15ms +timeEnd: 1e-15ms + +Running test: small +js: 0.001ms +timeEnd: 0.001ms + +Running test: regular +js: 1.2345ms +timeEnd: 1.2345ms + +Running test: big +js: 10000.2345ms +timeEnd: 10000.2345ms + +Running test: veryBig +js: 1000000000000000.2ms +timeEnd: 1000000000000000.2ms + +Running test: huge +js: 1e+42ms +timeEnd: 1e+42ms diff --git a/deps/v8/test/inspector/runtime/console-time-end-format.js b/deps/v8/test/inspector/runtime/console-time-end-format.js new file mode 100644 index 0000000000..77e7b55831 --- /dev/null +++ b/deps/v8/test/inspector/runtime/console-time-end-format.js @@ -0,0 +1,45 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Checks format of console.timeEnd output'); + +Protocol.Runtime.enable(); +Protocol.Runtime.onConsoleAPICalled(message => { + InspectorTest.log(message.params.args[0].value); +}); + +InspectorTest.runTestSuite([ + function zero(next) { + checkInterval(0.0).then(next); + }, + function verySmall(next) { + checkInterval(1e-15).then(next); + }, + function small(next) { + checkInterval(0.001).then(next); + }, + function regular(next) { + checkInterval(1.2345).then(next); + }, + function big(next) { + checkInterval(10000.2345).then(next); + }, + function veryBig(next) { + checkInterval(1e+15 + 0.2345).then(next); + }, + function huge(next) { + checkInterval(1e+42).then(next); + } +]); + +function checkInterval(time) { + setCurrentTimeMSForTest(0.0); + return Protocol.Runtime.evaluate({ + expression: `console.log('js: ' + ${time} + 'ms')`}) + .then(() => Protocol.Runtime.evaluate({ + expression: 'console.time(\'timeEnd\')'})) + .then(() => setCurrentTimeMSForTest(time)) + .then(() => Protocol.Runtime.evaluate({ + expression: 'console.timeEnd(\'timeEnd\')'})); +} diff --git a/deps/v8/test/inspector/runtime/es6-module-expected.txt b/deps/v8/test/inspector/runtime/es6-module-expected.txt new file mode 100644 index 0000000000..421d88c4c3 --- /dev/null +++ b/deps/v8/test/inspector/runtime/es6-module-expected.txt @@ -0,0 +1,240 @@ +Checks basic ES6 modules support. +{ + method : Debugger.scriptParsed + params : { + endColumn : 17 + endLine : 5 + executionContextId : <executionContextId> + hasSourceURL : false + hash : 9C014F7249BAFA12B91017817AD15091D01A9155 + isLiveEdit : false + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module1 + } +} +{ + method : Debugger.scriptParsed + params : { + endColumn : 17 + endLine : 5 + executionContextId : <executionContextId> + hasSourceURL : false + hash : 443A2FA24A6112E6B9101781E6A19B56BDC396D4 + isLiveEdit : false + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module2 + } +} +{ + method : Debugger.scriptParsed + params : { + endColumn : 0 + endLine : 9 + executionContextId : <executionContextId> + hasSourceURL : false + hash : 54D834614FBF9B389082DAE06CD3EFC499BEBF13 + isLiveEdit : false + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module3 + } +} +console.log(module1) +foo (module1:2:10) +(anonymous) (module3:3:12) + +console.log(42) +(anonymous) (module3:3:8) + +console.log(module2) +foo (module2:2:10) +(anonymous) (module3:4:12) + +console.log(239) +(anonymous) (module3:4:8) + +{ + method : Debugger.paused + params : { + callFrames : [ + [0] : { + callFrameId : <callFrameId> + functionLocation : { + columnNumber : 0 + lineNumber : 0 + scriptId : <scriptId> + } + functionName : + location : { + columnNumber : 0 + lineNumber : 7 + scriptId : <scriptId> + } + scopeChain : [ + [0] : { + endLocation : { + columnNumber : 0 + lineNumber : 8 + scriptId : <scriptId> + } + object : { + className : Object + description : Object + objectId : <objectId> + type : object + } + startLocation : { + columnNumber : 0 + lineNumber : 0 + scriptId : <scriptId> + } + type : module + } + [1] : { + object : { + className : global + description : global + objectId : <objectId> + type : object + } + type : global + } + ] + this : { + type : undefined + } + } + ] + hitBreakpoints : [ + ] + reason : other + } +} +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : foo1 + value : { + className : Function + description : function foo() { console.log('module1'); return 42; } + objectId : <objectId> + type : function + } + writable : true + } + [1] : { + configurable : true + enumerable : true + isOwn : true + name : foo2 + value : { + className : Function + description : function foo() { console.log('module2'); return 239; } + objectId : <objectId> + type : function + } + writable : true + } + [2] : { + configurable : true + enumerable : true + isOwn : true + name : a1 + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + [3] : { + configurable : true + enumerable : true + isOwn : true + name : a2 + value : { + description : 2 + type : number + value : 2 + } + writable : true + } + ] + } +} +{ + method : Debugger.scriptFailedToParse + params : { + endColumn : 1 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : false + hash : FF746120E4E4F1BA4CB5762843D429DC872EBA18 + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module4 + } +} +{ + method : Runtime.exceptionThrown + params : { + exceptionDetails : { + columnNumber : 0 + exception : { + className : SyntaxError + description : SyntaxError: Unexpected token } + objectId : <objectId> + preview : { + description : SyntaxError: Unexpected token } + overflow : false + properties : [ + [0] : { + name : stack + type : string + value : SyntaxError: Unexpected token } + } + [1] : { + name : message + type : string + value : Unexpected token } + } + ] + subtype : error + type : object + } + subtype : error + type : object + } + exceptionId : <exceptionId> + executionContextId : <executionContextId> + lineNumber : 0 + scriptId : <scriptId> + stackTrace : { + callFrames : [ + ] + } + text : Uncaught SyntaxError: Unexpected token } + url : module4 + } + timestamp : <timestamp> + } +} diff --git a/deps/v8/test/inspector/runtime/es6-module.js b/deps/v8/test/inspector/runtime/es6-module.js new file mode 100644 index 0000000000..e4e468ee5d --- /dev/null +++ b/deps/v8/test/inspector/runtime/es6-module.js @@ -0,0 +1,61 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Checks basic ES6 modules support.'); + +var module1 = ` +export function foo() { + console.log('module1'); + return 42; +} +export let a1 = 1`; + +var module2 = ` +export function foo() { + console.log('module2'); + return 239; +} +export let a2 = 2`; + +var module3 = ` +import { foo as foo1 } from 'module1'; +import { foo as foo2 } from 'module2'; +console.log(foo1()); +console.log(foo2()); +import { a1 } from 'module1'; +import { a2 } from 'module2'; +debugger; +`; + +var module4 = '}'; + +InspectorTest.setupScriptMap(); +// We get scriptParsed events for modules .. +Protocol.Debugger.onScriptParsed(InspectorTest.logMessage); +// .. scriptFailed to parse for modules with syntax error .. +Protocol.Debugger.onScriptFailedToParse(InspectorTest.logMessage); +// .. API messages from modules contain correct stack trace .. +Protocol.Runtime.onConsoleAPICalled(message => { + InspectorTest.log(`console.log(${message.params.args[0].value})`); + InspectorTest.logCallFrames(message.params.stackTrace.callFrames); + InspectorTest.log(''); +}); +// .. we could break inside module and scope contains correct list of variables .. +Protocol.Debugger.onPaused(message => { + InspectorTest.logMessage(message); + Protocol.Runtime.getProperties({ objectId: message.params.callFrames[0].scopeChain[0].object.objectId}) + .then(InspectorTest.logMessage) + .then(() => Protocol.Debugger.resume()); +}); +// .. we process uncaught errors from modules correctly. +Protocol.Runtime.onExceptionThrown(InspectorTest.logMessage); + +Protocol.Runtime.enable(); +Protocol.Debugger.enable() + .then(() => InspectorTest.addModule(module1, "module1")) + .then(() => InspectorTest.addModule(module2, "module2")) + .then(() => InspectorTest.addModule(module3, "module3")) + .then(() => InspectorTest.addModule(module4, "module4")) + .then(() => InspectorTest.waitPendingTasks()) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/runtime/internal-properties-entries-expected.txt b/deps/v8/test/inspector/runtime/internal-properties-entries-expected.txt new file mode 100644 index 0000000000..d395067efe --- /dev/null +++ b/deps/v8/test/inspector/runtime/internal-properties-entries-expected.txt @@ -0,0 +1,691 @@ +Checks internal [[Entries]] in Runtime.getProperties output + +Running test: maps +expression: new Map([[1,2],[3,4]]) +[ + [0] : { + key : 1 + value : 2 + } + [1] : { + key : 3 + value : 4 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : {1 => 2} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : true + enumerable : true + isOwn : true + name : 1 + value : { + className : Object + description : {3 => 4} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [2] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 2 + type : number + value : 2 + } + writable : true + } + ] + } +} +expression: new Map() +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} + +Running test: mapIterators +expression: new Map([[1,2],[3,4]]).entries() +[ + [0] : { + key : 1 + value : 2 + } + [1] : { + key : 3 + value : 4 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : {1 => 2} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : true + enumerable : true + isOwn : true + name : 1 + value : { + className : Object + description : {3 => 4} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [2] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 2 + type : number + value : 2 + } + writable : true + } + ] + } +} +expression: it = new Map([[1,2],[3,4]]).entries(); it.next(); it +[ + [0] : { + key : 3 + value : 4 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : {3 => 4} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Map([[1,2],[3,4]]).keys(); it.next(); it +[ + [0] : { + value : 3 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 3 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Map([[1,2],[3,4]]).values(); it.next(); it +[ + [0] : { + value : 4 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 4 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Map([[1,2],[3,4]]).entries(); it.next(); it.next(); it +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} + +Running test: sets +expression: new Set([1,2]) +[ + [0] : { + value : 1 + } + [1] : { + value : 2 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 1 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : true + enumerable : true + isOwn : true + name : 1 + value : { + className : Object + description : 2 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [2] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 2 + type : number + value : 2 + } + writable : true + } + ] + } +} +expression: new Set() +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} + +Running test: setIterators +expression: new Set([1,2]).values() +[ + [0] : { + value : 1 + } + [1] : { + value : 2 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 1 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : true + enumerable : true + isOwn : true + name : 1 + value : { + className : Object + description : 2 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [2] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 2 + type : number + value : 2 + } + writable : true + } + ] + } +} +expression: it = new Set([1,2]).values(); it.next(); it +[ + [0] : { + value : 2 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 2 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Set([1,2]).keys(); it.next(); it +[ + [0] : { + value : 2 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 2 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Set([1,2]).entries(); it.next(); it +[ + [0] : { + value : 2 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 2 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Set([1,2]).values(); it.next(); it.next(); it +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} + +Running test: weakMaps +expression: new WeakMap() +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} +expression: new WeakMap([[{ a: 2 }, 42]]) +[ + [0] : { + key : { + a : 2 + } + value : 42 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : {Object => 42} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} + +Running test: weakSets +expression: new WeakSet() +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} +expression: new WeakSet([{a:2}]) +[ + [0] : { + value : { + a : 2 + } + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : Object + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} diff --git a/deps/v8/test/inspector/runtime/internal-properties-entries.js b/deps/v8/test/inspector/runtime/internal-properties-entries.js new file mode 100644 index 0000000000..2e49c92b34 --- /dev/null +++ b/deps/v8/test/inspector/runtime/internal-properties-entries.js @@ -0,0 +1,65 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Checks internal [[Entries]] in Runtime.getProperties output'); + +Protocol.Runtime.enable(); + +InspectorTest.runTestSuite([ + function maps(next) { + checkExpression('new Map([[1,2],[3,4]])') + .then(() => checkExpression('new Map()')) + .then(next); + }, + + function mapIterators(next) { + checkExpression('new Map([[1,2],[3,4]]).entries()') + .then(() => checkExpression('it = new Map([[1,2],[3,4]]).entries(); it.next(); it')) + .then(() => checkExpression('it = new Map([[1,2],[3,4]]).keys(); it.next(); it')) + .then(() => checkExpression('it = new Map([[1,2],[3,4]]).values(); it.next(); it')) + .then(() => checkExpression('it = new Map([[1,2],[3,4]]).entries(); it.next(); it.next(); it')) + .then(next); + }, + + function sets(next) { + checkExpression('new Set([1,2])') + .then(() => checkExpression('new Set()')) + .then(next); + }, + + function setIterators(next) { + checkExpression('new Set([1,2]).values()') + .then(() => checkExpression('it = new Set([1,2]).values(); it.next(); it')) + .then(() => checkExpression('it = new Set([1,2]).keys(); it.next(); it')) + .then(() => checkExpression('it = new Set([1,2]).entries(); it.next(); it')) + .then(() => checkExpression('it = new Set([1,2]).values(); it.next(); it.next(); it')) + .then(next); + }, + + function weakMaps(next) { + checkExpression('new WeakMap()') + .then(() => checkExpression('new WeakMap([[{ a: 2 }, 42]])')) + .then(next); + }, + + function weakSets(next) { + checkExpression('new WeakSet()') + .then(() => checkExpression('new WeakSet([{a:2}])')) + .then(next); + } +]); + +function checkExpression(expression) +{ + InspectorTest.log(`expression: ${expression}`); + var entriesObjectId; + return Protocol.Runtime.evaluate({ expression: expression }) + .then(message => Protocol.Runtime.getProperties({ objectId: message.result.result.objectId })) + .then(message => message.result.internalProperties.filter(p => p.name === '[[Entries]]')[0]) + .then(entries => entriesObjectId = entries.value.objectId) + .then(() => Protocol.Runtime.callFunctionOn({ objectId: entriesObjectId, functionDeclaration: 'function f() { return this; }', returnByValue: true })) + .then(message => InspectorTest.logMessage(message.result.result.value)) + .then(() => Protocol.Runtime.getProperties({ objectId: entriesObjectId, ownProperties: true })) + .then(message => InspectorTest.logMessage(message)); +} diff --git a/deps/v8/test/inspector/runtime/internal-properties-expected.txt b/deps/v8/test/inspector/runtime/internal-properties-expected.txt new file mode 100644 index 0000000000..deee4cfdbd --- /dev/null +++ b/deps/v8/test/inspector/runtime/internal-properties-expected.txt @@ -0,0 +1,576 @@ +Checks internal properties in Runtime.getProperties output + +Running test: generatorFunction +expression: (function* foo() { yield 1 }) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[FunctionLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 14 + lineNumber : 0 + scriptId : <scriptId> + } + } + } + [1] : { + name : [[IsGenerator]] + value : { + type : boolean + value : true + } + } + [2] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[1] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } + ] + } +} + +Running test: regularFunction +expression: (function foo() {}) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[FunctionLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 13 + lineNumber : 0 + scriptId : <scriptId> + } + } + } + [1] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[1] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } + ] + } +} + +Running test: boxedObjects +expression: new Number(239) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PrimitiveValue]] + value : { + description : 239 + type : number + value : 239 + } + } + ] + } +} +expression: new Boolean(false) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PrimitiveValue]] + value : { + type : boolean + value : false + } + } + ] + } +} +expression: new String('abc') +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PrimitiveValue]] + value : { + type : string + value : abc + } + } + ] + } +} +expression: Object(Symbol(42)) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PrimitiveValue]] + value : { + description : Symbol(42) + objectId : <objectId> + type : symbol + } + } + ] + } +} + +Running test: promise +expression: Promise.resolve(42) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PromiseStatus]] + value : { + type : string + value : resolved + } + } + [1] : { + name : [[PromiseValue]] + value : { + description : 42 + type : number + value : 42 + } + } + ] + } +} +expression: new Promise(() => undefined) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PromiseStatus]] + value : { + type : string + value : pending + } + } + [1] : { + name : [[PromiseValue]] + value : { + type : undefined + } + } + ] + } +} + +Running test: generatorObject +expression: gen1 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : suspended + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 13 + lineNumber : 8 + scriptId : <scriptId> + } + } + } + [4] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[2] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } + ] + } +} +expression: gen1.next();gen1 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : suspended + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 2 + lineNumber : 9 + scriptId : <scriptId> + } + } + } + [4] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[2] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } + ] + } +} +expression: gen1.next();gen1 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : closed + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 13 + lineNumber : 8 + scriptId : <scriptId> + } + } + } + [4] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[2] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } + ] + } +} + +Running test: generatorObjectDebuggerDisabled +expression: gen2 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : suspended + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 13 + lineNumber : 8 + scriptId : <scriptId> + } + } + } + ] + } +} +expression: gen2.next();gen2 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : suspended + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 2 + lineNumber : 9 + scriptId : <scriptId> + } + } + } + ] + } +} +expression: gen2.next();gen2 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : closed + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 13 + lineNumber : 8 + scriptId : <scriptId> + } + } + } + ] + } +} + +Running test: iteratorObject +expression: (new Map([[1,2]])).entries() +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[IteratorHasMore]] + value : { + type : boolean + value : true + } + } + [1] : { + name : [[IteratorIndex]] + value : { + description : 0 + type : number + value : 0 + } + } + [2] : { + name : [[IteratorKind]] + value : { + type : string + value : entries + } + } + [3] : { + name : [[Entries]] + value : { + className : Array + description : Array(1) + objectId : <objectId> + subtype : array + type : object + } + } + ] + } +} +expression: (new Set([[1,2]])).entries() +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[IteratorHasMore]] + value : { + type : boolean + value : true + } + } + [1] : { + name : [[IteratorIndex]] + value : { + description : 0 + type : number + value : 0 + } + } + [2] : { + name : [[IteratorKind]] + value : { + type : string + value : entries + } + } + [3] : { + name : [[Entries]] + value : { + className : Array + description : Array(1) + objectId : <objectId> + subtype : array + type : object + } + } + ] + } +} diff --git a/deps/v8/test/inspector/runtime/internal-properties.js b/deps/v8/test/inspector/runtime/internal-properties.js new file mode 100644 index 0000000000..86fe96ab1c --- /dev/null +++ b/deps/v8/test/inspector/runtime/internal-properties.js @@ -0,0 +1,70 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +print('Checks internal properties in Runtime.getProperties output'); + +InspectorTest.addScript(` +function* foo() { + yield 1; +} +var gen1 = foo(); +var gen2 = foo(); +//# sourceURL=test.js`, 7, 26); + +Protocol.Runtime.enable(); +Protocol.Debugger.enable(); + +InspectorTest.runTestSuite([ + function generatorFunction(next) { + checkExpression('(function* foo() { yield 1 })').then(next); + }, + + function regularFunction(next) { + checkExpression('(function foo() {})').then(next); + }, + + function boxedObjects(next) { + checkExpression('new Number(239)') + .then(() => checkExpression('new Boolean(false)')) + .then(() => checkExpression('new String(\'abc\')')) + .then(() => checkExpression('Object(Symbol(42))')) + .then(next); + }, + + function promise(next) { + checkExpression('Promise.resolve(42)') + .then(() => checkExpression('new Promise(() => undefined)')) + .then(next); + }, + + function generatorObject(next) { + checkExpression('gen1') + .then(() => checkExpression('gen1.next();gen1')) + .then(() => checkExpression('gen1.next();gen1')) + .then(next); + }, + + function generatorObjectDebuggerDisabled(next) { + Protocol.Debugger.disable() + .then(() => checkExpression('gen2')) + .then(() => checkExpression('gen2.next();gen2')) + .then(() => checkExpression('gen2.next();gen2')) + .then(next); + }, + + function iteratorObject(next) { + checkExpression('(new Map([[1,2]])).entries()') + .then(() => checkExpression('(new Set([[1,2]])).entries()')) + .then(next); + } +]); + +function checkExpression(expression) +{ + InspectorTest.log(`expression: ${expression}`); + return Protocol.Runtime.evaluate({ expression: expression }) + .then(message => Protocol.Runtime.getProperties({ objectId: message.result.result.objectId })) + .then(message => { delete message.result.result; return message; }) + .then(InspectorTest.logMessage); +} diff --git a/deps/v8/test/inspector/runtime/protocol-works-with-different-locale-expected.txt b/deps/v8/test/inspector/runtime/protocol-works-with-different-locale-expected.txt index d526d5d447..ee70e94c2a 100644 --- a/deps/v8/test/inspector/runtime/protocol-works-with-different-locale-expected.txt +++ b/deps/v8/test/inspector/runtime/protocol-works-with-different-locale-expected.txt @@ -1,3 +1,4 @@ + Running test: consoleLogWithDefaultLocale { method : Runtime.consoleAPICalled @@ -34,14 +35,14 @@ set locale to fr_CA.UTF-8 (has comma as separator) args : [ [0] : { type : string - value : a: x.xms + value : a: 0.001ms } ] executionContextId : <executionContextId> stackTrace : { callFrames : [ [0] : { - columnNumber : 27 + columnNumber : 8 functionName : lineNumber : 0 scriptId : <scriptId> @@ -50,7 +51,7 @@ set locale to fr_CA.UTF-8 (has comma as separator) ] } timestamp : <timestamp> - type : debug + type : timeEnd } } @@ -117,14 +118,14 @@ set locale to fr_CA.UTF-8 (has comma as separator) args : [ [0] : { type : string - value : a: x.xms + value : a: 0.001ms } ] executionContextId : <executionContextId> stackTrace : { callFrames : [ [0] : { - columnNumber : 27 + columnNumber : 8 functionName : lineNumber : 0 scriptId : <scriptId> @@ -133,6 +134,6 @@ set locale to fr_CA.UTF-8 (has comma as separator) ] } timestamp : <timestamp> - type : debug + type : timeEnd } } diff --git a/deps/v8/test/inspector/runtime/protocol-works-with-different-locale.js b/deps/v8/test/inspector/runtime/protocol-works-with-different-locale.js index 381dfab31e..27be5ed905 100644 --- a/deps/v8/test/inspector/runtime/protocol-works-with-different-locale.js +++ b/deps/v8/test/inspector/runtime/protocol-works-with-different-locale.js @@ -4,7 +4,7 @@ Protocol.Runtime.enable(); -Protocol.Runtime.onConsoleAPICalled(dumpConsoleApiCalled); +Protocol.Runtime.onConsoleAPICalled(InspectorTest.logMessage); InspectorTest.runTestSuite([ function consoleLogWithDefaultLocale(next) { @@ -14,7 +14,11 @@ InspectorTest.runTestSuite([ function consoleTimeWithCommaAsSeparator(next) { InspectorTest.log("set locale to fr_CA.UTF-8 (has comma as separator)"); setlocale("fr_CA.UTF-8"); - Protocol.Runtime.evaluate({ expression: "console.time(\"a\"); console.timeEnd(\"a\")"}).then(next); + setCurrentTimeMSForTest(0.0); + Protocol.Runtime.evaluate({ expression: "console.time(\"a\");"}) + .then(() => setCurrentTimeMSForTest(0.001)) + .then(() => Protocol.Runtime.evaluate({ expression: "console.timeEnd(\"a\");"})) + .then(next); }, function consoleLogWithCommaAsSeparator(next) { @@ -27,14 +31,10 @@ InspectorTest.runTestSuite([ InspectorTest.log("set locale to fr_CA.UTF-8 (has comma as separator)"); setlocale("fr_CA.UTF-8"); Protocol.Runtime.evaluate({ expression: "console.log(239) "}) - .then(() => Protocol.Runtime.evaluate({ expression: "console.time(\"a\"); console.timeEnd(\"a\")"})) + .then(() => setCurrentTimeMSForTest(0.0)) + .then(() => Protocol.Runtime.evaluate({ expression: "console.time(\"a\");"})) + .then(() => setCurrentTimeMSForTest(0.001)) + .then(() => Protocol.Runtime.evaluate({ expression: "console.timeEnd(\"a\");"})) .then(next); } ]); - -function dumpConsoleApiCalled(message) { - var firstArg = message.params.args[0]; - if (firstArg.type === "string") - firstArg.value = firstArg.value.replace(/[0-9]+/g, "x"); - InspectorTest.logMessage(message); -} diff --git a/deps/v8/test/inspector/task-runner.cc b/deps/v8/test/inspector/task-runner.cc index 14270177f0..4bfd784900 100644 --- a/deps/v8/test/inspector/task-runner.cc +++ b/deps/v8/test/inspector/task-runner.cc @@ -22,6 +22,13 @@ void ReportUncaughtException(v8::Isolate* isolate, fprintf(stderr, "Unhandle exception: %s\n", message.data()); } +v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) { + v8::internal::Vector<uint16_t> buffer = + v8::internal::Vector<uint16_t>::New(str->Length()); + str->Write(buffer.start(), 0, str->Length()); + return buffer; +} + } // namespace TaskRunner::TaskRunner(v8::ExtensionConfiguration* extensions, @@ -101,6 +108,19 @@ void TaskRunner::Terminate() { process_queue_semaphore_.Signal(); } +void TaskRunner::RegisterModule(v8::internal::Vector<uint16_t> name, + v8::Local<v8::Module> module) { + modules_[name] = v8::Global<v8::Module>(isolate_, module); +} + +v8::MaybeLocal<v8::Module> TaskRunner::ModuleResolveCallback( + v8::Local<v8::Context> context, v8::Local<v8::String> specifier, + v8::Local<v8::Module> referrer) { + std::string str = *v8::String::Utf8Value(specifier); + TaskRunner* runner = TaskRunner::FromContext(context); + return runner->modules_[ToVector(specifier)].Get(runner->isolate_); +} + TaskRunner::Task* TaskRunner::GetNext(bool only_protocol) { for (;;) { if (is_terminated_.Value()) return nullptr; @@ -125,17 +145,6 @@ TaskRunner* TaskRunner::FromContext(v8::Local<v8::Context> context) { context->GetAlignedPointerFromEmbedderData(kTaskRunnerIndex)); } -namespace { - -v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) { - v8::internal::Vector<uint16_t> buffer = - v8::internal::Vector<uint16_t>::New(str->Length()); - str->Write(buffer.start(), 0, str->Length()); - return buffer; -} - -} // namespace - AsyncTask::AsyncTask(const char* task_name, v8_inspector::V8Inspector* inspector) : inspector_(task_name ? inspector : nullptr) { @@ -157,20 +166,18 @@ void AsyncTask::Run(v8::Isolate* isolate, ExecuteStringTask::ExecuteStringTask( const v8::internal::Vector<uint16_t>& expression, v8::Local<v8::String> name, v8::Local<v8::Integer> line_offset, - v8::Local<v8::Integer> column_offset, const char* task_name, - v8_inspector::V8Inspector* inspector) + v8::Local<v8::Integer> column_offset, v8::Local<v8::Boolean> is_module, + const char* task_name, v8_inspector::V8Inspector* inspector) : AsyncTask(task_name, inspector), expression_(expression), name_(ToVector(name)), line_offset_(line_offset.As<v8::Int32>()->Value()), - column_offset_(column_offset.As<v8::Int32>()->Value()) {} + column_offset_(column_offset.As<v8::Int32>()->Value()), + is_module_(is_module->Value()) {} ExecuteStringTask::ExecuteStringTask( const v8::internal::Vector<const char>& expression) - : AsyncTask(nullptr, nullptr), - expression_utf8_(expression), - line_offset_(0), - column_offset_(0) {} + : AsyncTask(nullptr, nullptr), expression_utf8_(expression) {} void ExecuteStringTask::AsyncRun(v8::Isolate* isolate, const v8::Global<v8::Context>& context) { @@ -188,7 +195,14 @@ void ExecuteStringTask::AsyncRun(v8::Isolate* isolate, v8::Local<v8::Integer> column_offset = v8::Integer::New(isolate, column_offset_); - v8::ScriptOrigin origin(name, line_offset, column_offset); + v8::ScriptOrigin origin( + name, line_offset, column_offset, + /* resource_is_shared_cross_origin */ v8::Local<v8::Boolean>(), + /* script_id */ v8::Local<v8::Integer>(), + /* source_map_url */ v8::Local<v8::Value>(), + /* resource_is_opaque */ v8::Local<v8::Boolean>(), + /* is_wasm */ v8::Local<v8::Boolean>(), + v8::Boolean::New(isolate, is_module_)); v8::Local<v8::String> source; if (expression_.length()) { source = v8::String::NewFromTwoByte(isolate, expression_.start(), @@ -203,10 +217,28 @@ void ExecuteStringTask::AsyncRun(v8::Isolate* isolate, } v8::ScriptCompiler::Source scriptSource(source, origin); - v8::Local<v8::Script> script; - if (!v8::ScriptCompiler::Compile(local_context, &scriptSource) - .ToLocal(&script)) - return; - v8::MaybeLocal<v8::Value> result; - result = script->Run(local_context); + if (!is_module_) { + v8::Local<v8::Script> script; + if (!v8::ScriptCompiler::Compile(local_context, &scriptSource) + .ToLocal(&script)) + return; + v8::MaybeLocal<v8::Value> result; + if (inspector_) + inspector_->willExecuteScript(local_context, + script->GetUnboundScript()->GetId()); + result = script->Run(local_context); + if (inspector_) inspector_->didExecuteScript(local_context); + } else { + v8::Local<v8::Module> module; + if (!v8::ScriptCompiler::CompileModule(isolate, &scriptSource) + .ToLocal(&module)) { + return; + } + if (!module->Instantiate(local_context, &TaskRunner::ModuleResolveCallback)) + return; + v8::Local<v8::Value> result; + if (!module->Evaluate(local_context).ToLocal(&result)) return; + TaskRunner* runner = TaskRunner::FromContext(local_context); + runner->RegisterModule(name_, module); + } } diff --git a/deps/v8/test/inspector/task-runner.h b/deps/v8/test/inspector/task-runner.h index 045bba0d25..73d0f0430e 100644 --- a/deps/v8/test/inspector/task-runner.h +++ b/deps/v8/test/inspector/task-runner.h @@ -5,6 +5,8 @@ #ifndef V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ #define V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ +#include <map> + #include "include/v8-inspector.h" #include "include/v8-platform.h" #include "include/v8.h" @@ -14,6 +16,16 @@ #include "src/locked-queue-inl.h" #include "src/vector.h" +struct VectorCompare { + bool operator()(const v8::internal::Vector<uint16_t>& lhs, + const v8::internal::Vector<uint16_t>& rhs) const { + for (int i = 0; i < lhs.length() && i < rhs.length(); ++i) { + if (lhs[i] != rhs[i]) return lhs[i] < rhs[i]; + } + return false; + } +}; + class TaskRunner : public v8::base::Thread { public: class Task { @@ -42,6 +54,12 @@ class TaskRunner : public v8::base::Thread { void Terminate(); + void RegisterModule(v8::internal::Vector<uint16_t> name, + v8::Local<v8::Module> module); + static v8::MaybeLocal<v8::Module> ModuleResolveCallback( + v8::Local<v8::Context> context, v8::Local<v8::String> specifier, + v8::Local<v8::Module> referrer); + private: void InitializeContext(); Task* GetNext(bool only_protocol); @@ -60,6 +78,10 @@ class TaskRunner : public v8::base::Thread { v8::internal::LockedQueue<Task*> deffered_queue_; v8::base::Semaphore process_queue_semaphore_; + std::map<v8::internal::Vector<uint16_t>, v8::Global<v8::Module>, + VectorCompare> + modules_; + int nested_loop_count_; v8::base::AtomicNumber<int> is_terminated_; @@ -77,7 +99,7 @@ class AsyncTask : public TaskRunner::Task { virtual void AsyncRun(v8::Isolate* isolate, const v8::Global<v8::Context>& context) = 0; - private: + protected: v8_inspector::V8Inspector* inspector_; }; @@ -86,7 +108,8 @@ class ExecuteStringTask : public AsyncTask { ExecuteStringTask(const v8::internal::Vector<uint16_t>& expression, v8::Local<v8::String> name, v8::Local<v8::Integer> line_offset, - v8::Local<v8::Integer> column_offset, const char* task_name, + v8::Local<v8::Integer> column_offset, + v8::Local<v8::Boolean> is_module, const char* task_name, v8_inspector::V8Inspector* inspector); explicit ExecuteStringTask( const v8::internal::Vector<const char>& expression); @@ -99,8 +122,9 @@ class ExecuteStringTask : public AsyncTask { v8::internal::Vector<uint16_t> expression_; v8::internal::Vector<const char> expression_utf8_; v8::internal::Vector<uint16_t> name_; - int32_t line_offset_; - int32_t column_offset_; + int32_t line_offset_ = 0; + int32_t column_offset_ = 0; + bool is_module_ = false; DISALLOW_COPY_AND_ASSIGN(ExecuteStringTask); }; diff --git a/deps/v8/test/inspector/testcfg.py b/deps/v8/test/inspector/testcfg.py index 6995669a15..fc498aa113 100644 --- a/deps/v8/test/inspector/testcfg.py +++ b/deps/v8/test/inspector/testcfg.py @@ -71,7 +71,7 @@ class InspectorProtocolTestSuite(testsuite.TestSuite): def ExpIterator(): for line in expected_lines: - if line.startswith("#") or not line.strip(): continue + if not line.strip(): continue yield line.strip() def ActIterator(lines): diff --git a/deps/v8/test/intl/number-format/check-digit-ranges.js b/deps/v8/test/intl/number-format/check-digit-ranges.js index 322785cbf9..50f0437d59 100644 --- a/deps/v8/test/intl/number-format/check-digit-ranges.js +++ b/deps/v8/test/intl/number-format/check-digit-ranges.js @@ -39,6 +39,8 @@ assertThrows('Intl.NumberFormat(undefined, {minimumFractionDigits: -1})'); assertThrows('Intl.NumberFormat(undefined, {maximumFractionDigits: 21})'); assertThrows('Intl.NumberFormat(undefined, {minimumSignificantDigits: 0})'); +assertThrows('Intl.NumberFormat(undefined, {minimumSignificantDigits: 22})'); +assertThrows('Intl.NumberFormat(undefined, {maximumSignificantDigits: 0})'); assertThrows('Intl.NumberFormat(undefined, {maximumSignificantDigits: 22})'); assertThrows('Intl.NumberFormat(undefined, ' + '{minimumSignificantDigits: 5, maximumSignificantDigits: 2})'); diff --git a/deps/v8/test/js-perf-test/JSTests.json b/deps/v8/test/js-perf-test/JSTests.json index 7b100413da..79aa6ccd0d 100644 --- a/deps/v8/test/js-perf-test/JSTests.json +++ b/deps/v8/test/js-perf-test/JSTests.json @@ -274,6 +274,59 @@ {"name": "Object.hasOwnProperty--el-str"}, {"name": "Object.hasOwnProperty--NE-el"} ] + }, + { + "name": "TypedArrays", + "path": ["TypedArrays"], + "results_regexp": "^TypedArrays\\-%s\\(Score\\): (.+)$", + "tests": [ + { + "name": "CopyWithin", + "main": "run.js", + "test_flags": ["copywithin"] + }, + { + "name": "Constructor", + "main": "run.js", + "test_flags": ["constructor"] + }, + { + "name": "Constructor--Future", + "flags": ["--future"], + "results_regexp": "^TypedArrays\\-Constructor\\(Score\\): (.+)$", + "main": "run.js", + "test_flags": ["constructor"] + }, + { + "name": "ConstructWithBuffer", + "main": "run.js", + "test_flags": ["construct-buffer"] + }, + { + "name": "ConstructWithBuffer--Future", + "flags": ["--future"], + "results_regexp": "^TypedArrays\\-ConstructWithBuffer\\(Score\\): (.+)$", + "main": "run.js", + "test_flags": ["construct-buffer"] + }, + { + "name": "ConstructArrayLike", + "main": "run.js", + "test_flags": ["construct-arraylike"] + }, + { + "name": "ConstructArrayLike--Future", + "flags": ["--future"], + "results_regexp": "^TypedArrays\\-ConstructArrayLike\\(Score\\): (.+)$", + "main": "run.js", + "test_flags": ["construct-arraylike"] + }, + { + "name": "Sort", + "main": "run.js", + "test_flags": ["sort"] + } + ] } ] } diff --git a/deps/v8/test/js-perf-test/SixSpeed.json b/deps/v8/test/js-perf-test/SixSpeed.json index ffd38e3b42..4789ff77f5 100644 --- a/deps/v8/test/js-perf-test/SixSpeed.json +++ b/deps/v8/test/js-perf-test/SixSpeed.json @@ -8,47 +8,124 @@ "total": true, "resources": ["base.js"], "tests": [ - { + { "name": "Array pattern destructuring", - "path": ["SixSpeed/array_destructuring"], - "main": "run.js", - "resources": [ - "run.js", - "array_destructuring.js" - ], + "path": ["SixSpeed"], "results_regexp": "^%s\\(Score\\): (.+)$", "tests": [ - {"name": "ArrayDestructuring-ES5"}, - {"name": "ArrayDestructuring-ES6"} + { + "name": "ES5", + "main": "run.js", + "test_flags": ["array_destructuring/es5"] + }, + { + "name": "ES6", + "main": "run.js", + "test_flags": ["array_destructuring/es6"] + } ] }, { "name": "Computed property names in object literals", - "path": ["SixSpeed/object_literals"], - "main": "run.js", - "resources": [ - "run.js", - "object_literals.js" - ], + "path": ["SixSpeed"], + "results_regexp": "^%s\\(Score\\): (.+)$", + "tests": [ + { + "name": "ES5", + "main": "run.js", + "test_flags": ["object_literals/es5"] + }, + { + "name": "ES6", + "main": "run.js", + "test_flags": ["object_literals/es6"] + } + ] + }, + { + "name": "Defaults", + "path": ["SixSpeed"], "results_regexp": "^%s\\(Score\\): (.+)$", "tests": [ - {"name": "ObjectLiterals-ES5"}, - {"name": "ObjectLiterals-ES6"} + { + "name": "ES5", + "main": "run.js", + "test_flags": ["defaults/es5"] + }, + { + "name": "ES6", + "main": "run.js", + "test_flags": ["defaults/es6"] + } ] }, { "name": "Spread", - "path": ["SixSpeed/spread"], - "main": "run.js", - "resources": [ - "run.js", - "spread.js" - ], + "path": ["SixSpeed"], + "flags": ["--future"], + "results_regexp": "^%s\\(Score\\): (.+)$", + "tests": [ + { + "name": "ES5", + "main": "run.js", + "test_flags": ["spread/es5"] + }, + { + "name": "Babel", + "main": "run.js", + "test_flags": ["spread/babel"] + }, + { + "name": "ES6", + "main": "run.js", + "test_flags": ["spread/es6"] + } + ] + }, + { + "name": "SuperSpread", + "path": ["SixSpeed"], + "flags": ["--future"], + "results_regexp": "^%s\\(Score\\): (.+)$", + "tests": [ + { + "name": "ES5", + "main": "run.js", + "test_flags": ["super_spread/es5"] + }, + { + "name": "Babel", + "main": "run.js", + "test_flags": ["super_spread/babel"] + }, + { + "name": "ES6", + "main": "run.js", + "test_flags": ["super_spread/es6"] + } + ] + }, + { + "name": "SpreadLiteral", + "path": ["SixSpeed"], + "flags": ["--future"], "results_regexp": "^%s\\(Score\\): (.+)$", "tests": [ - {"name": "Spread-ES5"}, - {"name": "Spread-Traceur"}, - {"name": "Spread-ES6"} + { + "name": "ES5", + "main": "run.js", + "test_flags": ["spread_literal/es5"] + }, + { + "name": "Babel", + "main": "run.js", + "test_flags": ["spread_literal/babel"] + }, + { + "name": "ES6", + "main": "run.js", + "test_flags": ["spread_literal/es6"] + } ] } ] diff --git a/deps/v8/test/js-perf-test/SixSpeed/array_destructuring/array_destructuring.js b/deps/v8/test/js-perf-test/SixSpeed/array_destructuring/array_destructuring.js deleted file mode 100644 index f4a1d53f5c..0000000000 --- a/deps/v8/test/js-perf-test/SixSpeed/array_destructuring/array_destructuring.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This benchmark is based on the six-speed benchmark build output. -// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> - - -new BenchmarkSuite('ArrayDestructuring-ES5', [1000], [ - new Benchmark('ES5', false, false, 0, ES5), -]); - -new BenchmarkSuite('ArrayDestructuring-ES6', [1000], [ - new Benchmark('ES6', false, false, 0, ES6), -]); - -// ---------------------------------------------------------------------------- -// Benchmark: ES5 -// ---------------------------------------------------------------------------- - -function ES5() { - "use strict"; - var data = [1, 2, 3]; - var c = data[0]; - return c; -} - - -// ---------------------------------------------------------------------------- -// Benchmark: ES6 -// ---------------------------------------------------------------------------- - -function ES6() { - "use strict"; - var data = [1, 2, 3]; - var [c] = data; - return c; -} diff --git a/deps/v8/test/js-perf-test/SixSpeed/array_destructuring/es5.js b/deps/v8/test/js-perf-test/SixSpeed/array_destructuring/es5.js new file mode 100644 index 0000000000..e95144d02f --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/array_destructuring/es5.js @@ -0,0 +1,17 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES5', [1000], [ + new Benchmark('ES5', false, false, 0, ES5), +]); + +function ES5() { + "use strict"; + var data = [1, 2, 3]; + var c = data[0]; + return c; +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/array_destructuring/es6.js b/deps/v8/test/js-perf-test/SixSpeed/array_destructuring/es6.js new file mode 100644 index 0000000000..2ff0c9baab --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/array_destructuring/es6.js @@ -0,0 +1,17 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES6', [1000], [ + new Benchmark('ES6', false, false, 0, ES6), +]); + +function ES6() { + "use strict"; + var data = [1, 2, 3]; + var [c] = data; + return c; +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/defaults/es5.js b/deps/v8/test/js-perf-test/SixSpeed/defaults/es5.js new file mode 100644 index 0000000000..91abf4170b --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/defaults/es5.js @@ -0,0 +1,23 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES5', [1000], [ + new Benchmark('ES5', false, false, 0, ES5), +]); + +function ES5() { + "use strict"; + function fn(arg, other) { + arg = arg === undefined ? 1 : arg; + other = other === undefined ? 3 : other; + return other; + } + + fn(); + fn(2); + fn(2, 4); +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/defaults/es6.js b/deps/v8/test/js-perf-test/SixSpeed/defaults/es6.js new file mode 100644 index 0000000000..70d4343250 --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/defaults/es6.js @@ -0,0 +1,21 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES6', [1000], [ + new Benchmark('ES6', false, false, 0, ES6), +]); + +function ES6() { + "use strict"; + function fn(arg = 1, other = 3) { + return other; + } + + fn(); + fn(2); + fn(2, 4); +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/object_literals/es5.js b/deps/v8/test/js-perf-test/SixSpeed/object_literals/es5.js new file mode 100644 index 0000000000..39155de484 --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/object_literals/es5.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES5', [1000], [ + new Benchmark('ES5', false, false, 0, ES5), +]); + +function ES5() { + "use strict"; + var name = 'foo'; + var ret = {}; + ret[name] = 'bar'; + return ret; +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/object_literals/es6.js b/deps/v8/test/js-perf-test/SixSpeed/object_literals/es6.js new file mode 100644 index 0000000000..09311f24f8 --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/object_literals/es6.js @@ -0,0 +1,19 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES6', [1000], [ + new Benchmark('ES6', false, false, 0, ES6), +]); + +function ES6() { + "use strict"; + var name = 'foo'; + var ret = { + [name]: 'bar', + }; + return ret; +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/object_literals/object_literals.js b/deps/v8/test/js-perf-test/SixSpeed/object_literals/object_literals.js deleted file mode 100644 index 831e173ec2..0000000000 --- a/deps/v8/test/js-perf-test/SixSpeed/object_literals/object_literals.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This benchmark is based on the six-speed benchmark build output. -// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> - - -new BenchmarkSuite('ObjectLiterals-ES5', [1000], [ - new Benchmark('ES5', false, false, 0, ES5), -]); - -new BenchmarkSuite('ObjectLiterals-ES6', [1000], [ - new Benchmark('ES6', false, false, 0, ES6), -]); - -// ---------------------------------------------------------------------------- -// Benchmark: ES5 -// ---------------------------------------------------------------------------- - -function ES5() { - "use strict"; - var name = 'foo'; - var ret = {}; - ret[name] = 'bar'; - return ret; -} - - -// ---------------------------------------------------------------------------- -// Benchmark: ES6 -// ---------------------------------------------------------------------------- - -function ES6() { - "use strict"; - var name = 'foo'; - var ret = { - [name]: 'bar', - }; - return ret; -} diff --git a/deps/v8/test/js-perf-test/SixSpeed/object_literals/run.js b/deps/v8/test/js-perf-test/SixSpeed/object_literals/run.js deleted file mode 100644 index f8b5343f9e..0000000000 --- a/deps/v8/test/js-perf-test/SixSpeed/object_literals/run.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -load('../../base.js'); -load('object_literals.js'); - -var success = true; - -function PrintResult(name, result) { - print(name + '(Score): ' + result); -} - - -function PrintError(name, error) { - PrintResult(name, error); - success = false; -} - - -BenchmarkSuite.config.doWarmup = undefined; -BenchmarkSuite.config.doDeterministic = undefined; - -BenchmarkSuite.RunSuites({ NotifyResult: PrintResult, - NotifyError: PrintError }); diff --git a/deps/v8/test/js-perf-test/SixSpeed/spread/run.js b/deps/v8/test/js-perf-test/SixSpeed/run.js index c46b29be98..272d42fa9a 100644 --- a/deps/v8/test/js-perf-test/SixSpeed/spread/run.js +++ b/deps/v8/test/js-perf-test/SixSpeed/run.js @@ -1,9 +1,9 @@ -// Copyright 2016 the V8 project authors. All rights reserved. +// Copyright 2017 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -load('../../base.js'); -load('spread.js'); +load('../base.js'); +load(arguments[0] + '.js'); var success = true; @@ -11,15 +11,12 @@ function PrintResult(name, result) { print(name + '(Score): ' + result); } - function PrintError(name, error) { PrintResult(name, error); success = false; } - -BenchmarkSuite.config.doWarmup = undefined; +BenchmarkSuite.config.doWarmup = true; BenchmarkSuite.config.doDeterministic = undefined; -BenchmarkSuite.RunSuites({ NotifyResult: PrintResult, - NotifyError: PrintError }); +BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError}); diff --git a/deps/v8/test/js-perf-test/SixSpeed/spread/babel.js b/deps/v8/test/js-perf-test/SixSpeed/spread/babel.js new file mode 100644 index 0000000000..89beae3270 --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/spread/babel.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('Babel', [1000], [ + new Benchmark('Babel', false, false, 0, Babel), +]); + +function Babel() { + "use strict"; + return Math.max.apply(Math, [1, 2, 3]); +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/spread/es5.js b/deps/v8/test/js-perf-test/SixSpeed/spread/es5.js new file mode 100644 index 0000000000..8cc0e74488 --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/spread/es5.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES5', [1000], [ + new Benchmark('ES5', false, false, 0, ES5), +]); + +function ES5() { + "use strict"; + return Math.max.apply(Math, [1, 2, 3]); +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/spread/es6.js b/deps/v8/test/js-perf-test/SixSpeed/spread/es6.js new file mode 100644 index 0000000000..6a2f1e861c --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/spread/es6.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES6', [1000], [ + new Benchmark('ES6', false, false, 0, ES6), +]); + +function ES6() { + "use strict"; + return Math.max(...[1, 2, 3]); +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/spread/spread.js b/deps/v8/test/js-perf-test/SixSpeed/spread/spread.js deleted file mode 100644 index 7c5f40b427..0000000000 --- a/deps/v8/test/js-perf-test/SixSpeed/spread/spread.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This benchmark is based on the six-speed benchmark build output. -// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> - - -new BenchmarkSuite('Spread-ES5', [1000], [ - new Benchmark('ES5', false, false, 0, ES5), -]); - -new BenchmarkSuite('Spread-Traceur', [1000], [ - new Benchmark('Traceur', false, false, 0, Traceur), -]); - -new BenchmarkSuite('Spread-ES6', [1000], [ - new Benchmark('ES6', false, false, 0, ES6), -]); - -// ---------------------------------------------------------------------------- -// Benchmark: ES5 -// ---------------------------------------------------------------------------- - -function ES5() { - "use strict"; - return Math.max.apply(Math, [1,2,3]); -} - -// ---------------------------------------------------------------------------- -// Benchmark: Traceur -// ---------------------------------------------------------------------------- - -function checkObjectCoercible(v) { - "use strict"; - if (v === null || v === undefined) { - throw new $TypeError('Value cannot be converted to an Object'); - } - return v; -} - -function spread() { - "use strict"; - var rv = [], - j = 0, - iterResult; - for (var i = 0; i < arguments.length; i++) { - var valueToSpread = checkObjectCoercible(arguments[i]); - if (typeof valueToSpread[Symbol.iterator] !== 'function') { - throw new TypeError('Cannot spread non-iterable object.'); - } - var iter = valueToSpread[Symbol.iterator](); - while (!(iterResult = iter.next()).done) { - rv[j++] = iterResult.value; - } - } - return rv; -} - -function Traceur() { - "use strict"; - var $__0; - return ($__0 = Math).max.apply($__0, spread([1, 2, 3])); -} - -// ---------------------------------------------------------------------------- -// Benchmark: ES6 -// ---------------------------------------------------------------------------- - -function ES6() { - "use strict"; - return Math.max(...[1,2,3]); -} diff --git a/deps/v8/test/js-perf-test/SixSpeed/spread_literal/babel.js b/deps/v8/test/js-perf-test/SixSpeed/spread_literal/babel.js new file mode 100644 index 0000000000..db759fc695 --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/spread_literal/babel.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('Babel', [1000], [ + new Benchmark('Babel', false, false, 0, Babel), +]); + +function Babel() { + return [1].concat([1, 2, 3]); +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/spread_literal/es5.js b/deps/v8/test/js-perf-test/SixSpeed/spread_literal/es5.js new file mode 100644 index 0000000000..33ddbf2b15 --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/spread_literal/es5.js @@ -0,0 +1,16 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES5', [1000], [ + new Benchmark('ES5', false, false, 0, ES5), +]); + +function ES5() { + var ret = [1]; + ret.push(1, 2, 3); + return ret; +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/spread_literal/es6.js b/deps/v8/test/js-perf-test/SixSpeed/spread_literal/es6.js new file mode 100644 index 0000000000..6d7ce47386 --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/spread_literal/es6.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES6', [1000], [ + new Benchmark('ES6', false, false, 0, ES6), +]); + +function ES6() { + return [1, ... [1, 2, 3]]; +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/super_spread/babel.js b/deps/v8/test/js-perf-test/SixSpeed/super_spread/babel.js new file mode 100644 index 0000000000..c736477c83 --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/super_spread/babel.js @@ -0,0 +1,75 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('Babel', [1000], [ + new Benchmark('Babel', false, false, 0, Babel), +]); + +function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError( + 'this hasn\'t been initialised - super() hasn\'t been called'); + } + return call && (typeof call === 'object' || typeof call === 'function') ? + call : + self; +} + +function _inherits(subClass, superClass) { + if (typeof superClass !== 'function' && superClass !== null) { + throw new TypeError( + 'Super expression must either be null or a function, not ' + + typeof superClass); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) + Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : + subClass.__proto__ = superClass; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function'); + } +} + +var Point = function Point(x, y) { + _classCallCheck(this, Point); + + this.x = x; + this.y = y; +}; + +var MyPoint = function(_Point) { + _inherits(MyPoint, _Point); + + function MyPoint() { + _classCallCheck(this, MyPoint); + + return _possibleConstructorReturn( + this, (MyPoint.__proto__ || Object.getPrototypeOf(MyPoint)) + .apply(this, arguments)); + } + + return MyPoint; +}(Point); + +function makePoint(x, y) { + return new MyPoint(x, y); +} + +function Babel() { + 'use strict'; + return makePoint(1, 2); +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/super_spread/es5.js b/deps/v8/test/js-perf-test/SixSpeed/super_spread/es5.js new file mode 100644 index 0000000000..7d56d94a42 --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/super_spread/es5.js @@ -0,0 +1,28 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES5', [1000], [ + new Benchmark('ES5', false, false, 0, ES5), +]); + +function Point(x, y) { + this.x = x; + this.y = y; +} + +function MyPoint() { + Point.apply(this, arguments); +} + +function makePoint(x, y) { + return new MyPoint(x, y); +} + +function ES5() { + 'use strict'; + return makePoint(1, 2); +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/super_spread/es6.js b/deps/v8/test/js-perf-test/SixSpeed/super_spread/es6.js new file mode 100644 index 0000000000..4640ff4bb3 --- /dev/null +++ b/deps/v8/test/js-perf-test/SixSpeed/super_spread/es6.js @@ -0,0 +1,28 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This benchmark is based on the six-speed benchmark build output. +// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> + +new BenchmarkSuite('ES6', [1000], [ + new Benchmark('ES6', false, false, 0, ES6), +]); + +class Point { + constructor(x, y) { + this.x = x; + this.y = y; + } +} + +class MyPoint extends Point {} + +function makePoint(x, y) { + return new MyPoint(x, y); +} + +function ES6() { + 'use strict'; + return makePoint(1, 2); +} diff --git a/deps/v8/test/js-perf-test/TypedArrays/construct-arraylike.js b/deps/v8/test/js-perf-test/TypedArrays/construct-arraylike.js new file mode 100644 index 0000000000..2ea736e7ff --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/construct-arraylike.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +new BenchmarkSuite('ConstructArrayLike', [1000], [ + new Benchmark('ConstructArrayLike', false, false, 0, constructor), +]); + +var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; + +function constructor() { + new Int32Array(arr); +} diff --git a/deps/v8/test/js-perf-test/TypedArrays/construct-buffer.js b/deps/v8/test/js-perf-test/TypedArrays/construct-buffer.js new file mode 100644 index 0000000000..2143156da9 --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/construct-buffer.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +new BenchmarkSuite('ConstructWithBuffer', [1000], [ + new Benchmark('ConstructWithBuffer', false, false, 0, constructor), +]); + +var buffer = new ArrayBuffer(64); + +function constructor() { + new Int32Array(buffer); +} diff --git a/deps/v8/test/js-perf-test/TypedArrays/constructor.js b/deps/v8/test/js-perf-test/TypedArrays/constructor.js new file mode 100644 index 0000000000..51bedc4a0b --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/constructor.js @@ -0,0 +1,11 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +new BenchmarkSuite('Constructor', [1000], [ + new Benchmark('Constructor', false, false, 0, constructor), +]); + +function constructor() { + new Int32Array(16); +} diff --git a/deps/v8/test/js-perf-test/TypedArrays/copywithin.js b/deps/v8/test/js-perf-test/TypedArrays/copywithin.js new file mode 100644 index 0000000000..fa1be802e0 --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/copywithin.js @@ -0,0 +1,32 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +new BenchmarkSuite('CopyWithin', [1000], [ + new Benchmark('CopyWithin-Large', false, false, 0, + CopyWithinLarge, CopyWithinLargeSetup, CopyWithinLargeTearDown), +]); + +var initialLargeFloat64Array = new Array(10000); +for (var i = 0; i < 5000; ++i) { + initialLargeFloat64Array[i] = i; +} +initialLargeFloat64Array = new Float64Array(initialLargeFloat64Array); +var largeFloat64Array; + +function CopyWithinLarge() { + largeFloat64Array.copyWithin(5000); +} + +function CopyWithinLargeSetup() { + largeFloat64Array = new Float64Array(initialLargeFloat64Array); +} + +function CopyWithinLargeTearDown() { + for (var i = 0; i < 5000; ++i) { + if (largeFloat64Array[i + 5000] !== i) { + throw new TypeError("Unexpected result!\n" + largeFloat64Array); + } + } + largeFloat64Array = void 0; +} diff --git a/deps/v8/test/js-perf-test/SixSpeed/array_destructuring/run.js b/deps/v8/test/js-perf-test/TypedArrays/run.js index 5988512619..2df0b2d537 100644 --- a/deps/v8/test/js-perf-test/SixSpeed/array_destructuring/run.js +++ b/deps/v8/test/js-perf-test/TypedArrays/run.js @@ -1,17 +1,16 @@ -// Copyright 2016 the V8 project authors. All rights reserved. +// Copyright 2014 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -load('../../base.js'); -load('array_destructuring.js'); +load('../base.js'); +load(arguments[0] + '.js'); var success = true; function PrintResult(name, result) { - print(name + '(Score): ' + result); + print(`TypedArrays-${name}(Score): ${result}`); } - function PrintError(name, error) { PrintResult(name, error); success = false; diff --git a/deps/v8/test/js-perf-test/TypedArrays/sort.js b/deps/v8/test/js-perf-test/TypedArrays/sort.js new file mode 100644 index 0000000000..aebc981e64 --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/sort.js @@ -0,0 +1,33 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +new BenchmarkSuite('Sort', [1000], [ + new Benchmark('Sort', false, false, 0, + sortLarge, sortLargeSetup, sortLargeTearDown), +]); + +var size = 3000; +var initialLargeFloat64Array = new Array(size); +for (var i = 0; i < size; ++i) { + initialLargeFloat64Array[i] = Math.random(); +} +initialLargeFloat64Array = new Float64Array(initialLargeFloat64Array); +var largeFloat64Array; + +function sortLarge() { + largeFloat64Array.sort(); +} + +function sortLargeSetup() { + largeFloat64Array = new Float64Array(initialLargeFloat64Array); +} + +function sortLargeTearDown() { + for (var i = 0; i < size - 1; ++i) { + if (largeFloat64Array[i] > largeFloat64Array[i+1]) { + throw new TypeError("Unexpected result!\n" + largeFloat64Array); + } + } + largeFloat64Array = void 0; +} diff --git a/deps/v8/test/message/formal-parameters-trailing-comma.js b/deps/v8/test/message/formal-parameters-trailing-comma.js index 09cdb8904b..9a248bee68 100644 --- a/deps/v8/test/message/formal-parameters-trailing-comma.js +++ b/deps/v8/test/message/formal-parameters-trailing-comma.js @@ -2,4 +2,4 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function foo(b, a, a,) { return a } +function foo(b, a, a,,) { return a } diff --git a/deps/v8/test/message/formal-parameters-trailing-comma.out b/deps/v8/test/message/formal-parameters-trailing-comma.out index 4b930eceae..5c46552628 100644 --- a/deps/v8/test/message/formal-parameters-trailing-comma.out +++ b/deps/v8/test/message/formal-parameters-trailing-comma.out @@ -1,4 +1,4 @@ -*%(basename)s:5: SyntaxError: Unexpected token ) -function foo(b, a, a,) { return a } +*%(basename)s:5: SyntaxError: Unexpected token , +function foo(b, a, a,,) { return a } ^ -SyntaxError: Unexpected token ) +SyntaxError: Unexpected token , diff --git a/deps/v8/test/message/let-lexical-declaration-destructuring-brace-in-single-statement.js b/deps/v8/test/message/let-lexical-declaration-destructuring-brace-in-single-statement.js new file mode 100644 index 0000000000..1afcc8ccc8 --- /dev/null +++ b/deps/v8/test/message/let-lexical-declaration-destructuring-brace-in-single-statement.js @@ -0,0 +1,5 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +with ({}) let {a: x} = {a: 42}; diff --git a/deps/v8/test/message/let-lexical-declaration-destructuring-brace-in-single-statement.out b/deps/v8/test/message/let-lexical-declaration-destructuring-brace-in-single-statement.out new file mode 100644 index 0000000000..352adae7cb --- /dev/null +++ b/deps/v8/test/message/let-lexical-declaration-destructuring-brace-in-single-statement.out @@ -0,0 +1,4 @@ +*%(basename)s:5: SyntaxError: Lexical declaration cannot appear in a single-statement context +with ({}) let {a: x} = {a: 42}; + ^^^ +SyntaxError: Lexical declaration cannot appear in a single-statement context diff --git a/deps/v8/test/message/let-lexical-declaration-destructuring-in-single-statement.js b/deps/v8/test/message/let-lexical-declaration-destructuring-in-single-statement.js new file mode 100644 index 0000000000..5e439fff9f --- /dev/null +++ b/deps/v8/test/message/let-lexical-declaration-destructuring-in-single-statement.js @@ -0,0 +1,5 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +with ({}) let [a] = [42]; diff --git a/deps/v8/test/message/let-lexical-declaration-destructuring-in-single-statement.out b/deps/v8/test/message/let-lexical-declaration-destructuring-in-single-statement.out new file mode 100644 index 0000000000..16c487f3d6 --- /dev/null +++ b/deps/v8/test/message/let-lexical-declaration-destructuring-in-single-statement.out @@ -0,0 +1,4 @@ +*%(basename)s:5: SyntaxError: Lexical declaration cannot appear in a single-statement context +with ({}) let [a] = [42]; + ^^^ +SyntaxError: Lexical declaration cannot appear in a single-statement context diff --git a/deps/v8/test/message/let-lexical-declaration-in-single-statement.js b/deps/v8/test/message/let-lexical-declaration-in-single-statement.js new file mode 100644 index 0000000000..037937d594 --- /dev/null +++ b/deps/v8/test/message/let-lexical-declaration-in-single-statement.js @@ -0,0 +1,5 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +with ({}) let a = []; diff --git a/deps/v8/test/message/let-lexical-declaration-in-single-statement.out b/deps/v8/test/message/let-lexical-declaration-in-single-statement.out new file mode 100644 index 0000000000..29680d8fd8 --- /dev/null +++ b/deps/v8/test/message/let-lexical-declaration-in-single-statement.out @@ -0,0 +1,4 @@ +*%(basename)s:5: SyntaxError: Lexical declaration cannot appear in a single-statement context +with ({}) let a = []; + ^^^ +SyntaxError: Lexical declaration cannot appear in a single-statement context diff --git a/deps/v8/test/mjsunit/allocation-site-info.js b/deps/v8/test/mjsunit/allocation-site-info.js index 8325ab791c..ba4ae17cf0 100644 --- a/deps/v8/test/mjsunit/allocation-site-info.js +++ b/deps/v8/test/mjsunit/allocation-site-info.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --expose-gc -// Flags: --noalways-opt +// Flags: --crankshaft --no-always-opt var elements_kind = { fast_smi_only : 'fast smi only elements', @@ -350,7 +350,7 @@ assertOptimized(instanceof_check); // to be monomorphic on first call. Only after crankshafting do we introduce // realmBArray. This should deopt the method. %DeoptimizeFunction(instanceof_check); - %ClearFunctionTypeFeedback(instanceof_check); + %ClearFunctionFeedback(instanceof_check); instanceof_check(Array); instanceof_check(Array); %OptimizeFunctionOnNextCall(instanceof_check); diff --git a/deps/v8/test/mjsunit/arguments-deopt.js b/deps/v8/test/mjsunit/arguments-deopt.js new file mode 100644 index 0000000000..0cf3c0455c --- /dev/null +++ b/deps/v8/test/mjsunit/arguments-deopt.js @@ -0,0 +1,90 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --turbo + +(function MaterializeStrictArguments() { + "use strict" + + function f(x, y) { + return x + y; + } + + function test() { + %DeoptimizeNow(); + return f.apply(null, arguments); + } + + assertEquals(test(1, 2), 3); + assertEquals(test(1, 2, 3), 3); + + %OptimizeFunctionOnNextCall(test); + assertEquals(test(1, 2), 3); + %OptimizeFunctionOnNextCall(test); + assertEquals(test(1, 2, 3), 3); +})(); + +(function MaterializeSloppyArguments() { + function f(x, y) { + return x + y; + } + + function test() { + %DeoptimizeNow(); + return f.apply(null, arguments); + } + + assertEquals(test(1, 2), 3); + assertEquals(test(1, 2, 3), 3); + + %OptimizeFunctionOnNextCall(test); + assertEquals(test(1, 2), 3); + %OptimizeFunctionOnNextCall(test); + assertEquals(test(1, 2, 3), 3); +})(); + +(function MaterializeStrictOverwrittenArguments() { + "use strict" + + function f(x, y) { + return x + y; + } + + function test(a, b) { + a = 4; + %DeoptimizeNow(); + return f.apply(null, arguments); + } + + assertEquals(test(1, 2), 3); + assertEquals(test(1, 2, 3), 3); + + %OptimizeFunctionOnNextCall(test); + assertEquals(test(1, 2), 3); + %OptimizeFunctionOnNextCall(test); + assertEquals(test(1, 2, 3), 3); +})(); + +(function MaterializeSloppyOverwrittenArguments() { + function f(x, y) { + return x + y; + } + + function test(a, b) { + a = 4; + %DeoptimizeNow(); + return f.apply(null, arguments); + } + + test(1, 2); + test(3, 4, 5); + + assertEquals(test(1, 2), 6); + assertEquals(test(1, 2, 3), 6); + + %OptimizeFunctionOnNextCall(test); + assertEquals(test(1, 2), 6); + %OptimizeFunctionOnNextCall(test); + assertEquals(test(1, 2, 3), 6); +})(); diff --git a/deps/v8/test/mjsunit/array-bounds-check-removal.js b/deps/v8/test/mjsunit/array-bounds-check-removal.js index 7b089eed3d..17be095143 100644 --- a/deps/v8/test/mjsunit/array-bounds-check-removal.js +++ b/deps/v8/test/mjsunit/array-bounds-check-removal.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --expose-gc +// Flags: --allow-natives-syntax --expose-gc --no-always-opt var a = new Int32Array(1024); @@ -108,7 +108,7 @@ test_base(dictionary_map_array, -2, true); assertUnoptimized(test_base); // Forget about the dictionary_map_array's map. -%ClearFunctionTypeFeedback(test_base); +%ClearFunctionFeedback(test_base); test_base(a, 5, true); test_base(a, 6, true); diff --git a/deps/v8/test/mjsunit/array-constructor-feedback.js b/deps/v8/test/mjsunit/array-constructor-feedback.js index 865b8ba44f..45ea0d53e1 100644 --- a/deps/v8/test/mjsunit/array-constructor-feedback.js +++ b/deps/v8/test/mjsunit/array-constructor-feedback.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --expose-gc -// Flags: --noalways-opt +// Flags: --no-always-opt --crankshaft // Test element kind of objects. @@ -72,7 +72,7 @@ function assertKind(expected, obj, name_opt) { a[0] = 3.5; b = bar0(Array); assertKind(elements_kind.fast_double, b); - %OptimizeFunctionOnNextCall(bar0); + %OptimizeFunctionOnNextCall(bar0); b = bar0(Array); assertKind(elements_kind.fast_double, b); assertOptimized(bar0); @@ -81,18 +81,15 @@ function assertKind(expected, obj, name_opt) { assertUnoptimized(bar0) // When it's re-optimized, we should call through the full stub bar0(Array); - %OptimizeFunctionOnNextCall(bar0); + %OptimizeFunctionOnNextCall(bar0); b = bar0(Array); - // This only makes sense to test if we allow crankshafting - if (4 != %GetOptimizationStatus(bar0)) { - // We also lost our ability to record kind feedback, as the site - // is megamorphic now. - assertKind(elements_kind.fast_smi_only, b); - assertOptimized(bar0); - b[0] = 3.5; - c = bar0(Array); - assertKind(elements_kind.fast_smi_only, c); - } + // We also lost our ability to record kind feedback, as the site + // is megamorphic now. + assertKind(elements_kind.fast_smi_only, b); + assertOptimized(bar0); + b[0] = 3.5; + c = bar0(Array); + assertKind(elements_kind.fast_smi_only, c); })(); @@ -106,7 +103,7 @@ function assertKind(expected, obj, name_opt) { a[0] = "a string"; a = bar(10); assertKind(elements_kind.fast, a); - %OptimizeFunctionOnNextCall(bar); + %OptimizeFunctionOnNextCall(bar); a = bar(10); assertKind(elements_kind.fast, a); assertOptimized(bar); @@ -124,7 +121,7 @@ function assertKind(expected, obj, name_opt) { barn(1, 2, 3); barn(1, 2, 3); - %OptimizeFunctionOnNextCall(barn); + %OptimizeFunctionOnNextCall(barn); barn(1, 2, 3); assertOptimized(barn); a = barn(1, "oops", 3); @@ -141,17 +138,14 @@ function assertKind(expected, obj, name_opt) { } a = bar(); bar(); - %OptimizeFunctionOnNextCall(bar); + %OptimizeFunctionOnNextCall(bar); b = bar(); - // This only makes sense to test if we allow crankshafting - if (4 != %GetOptimizationStatus(bar)) { - assertOptimized(bar); - %DebugPrint(3); - b[0] = 3.5; - c = bar(); - assertKind(elements_kind.fast_smi_only, c); - assertOptimized(bar); - } + assertOptimized(bar); + %DebugPrint(3); + b[0] = 3.5; + c = bar(); + assertKind(elements_kind.fast_smi_only, c); + assertOptimized(bar); })(); @@ -161,7 +155,7 @@ function assertKind(expected, obj, name_opt) { function bar() { return new Array(); } bar(); bar(); - %OptimizeFunctionOnNextCall(bar); + %OptimizeFunctionOnNextCall(bar); a = bar(); assertTrue(a instanceof Array); @@ -180,7 +174,7 @@ function assertKind(expected, obj, name_opt) { function bar(len) { return new Array(len); } bar(0); bar(0); - %OptimizeFunctionOnNextCall(bar); + %OptimizeFunctionOnNextCall(bar); a = bar(0); assertOptimized(bar); assertFalse(isHoley(a)); @@ -192,10 +186,8 @@ function assertKind(expected, obj, name_opt) { a = bar(0); assertOptimized(bar); // Crankshafted functions don't use mementos, so feedback still - // indicates a packed array is desired. (unless --nocrankshaft is in use). - if (4 != %GetOptimizationStatus(bar)) { - assertFalse(isHoley(a)); - } + // indicates a packed array is desired. + assertFalse(isHoley(a)); })(); // Test: Make sure that crankshaft continues with feedback for large arrays. diff --git a/deps/v8/test/mjsunit/array-feedback.js b/deps/v8/test/mjsunit/array-feedback.js index 4eb922c2f7..c585920df1 100644 --- a/deps/v8/test/mjsunit/array-feedback.js +++ b/deps/v8/test/mjsunit/array-feedback.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --expose-gc -// Flags: --noalways-opt +// Flags: --crankshaft --no-always-opt var elements_kind = { fast_smi_only : 'fast smi only elements', diff --git a/deps/v8/test/mjsunit/array-functions-prototype-misc.js b/deps/v8/test/mjsunit/array-functions-prototype-misc.js index a2c1410837..7ff5d4f2f5 100644 --- a/deps/v8/test/mjsunit/array-functions-prototype-misc.js +++ b/deps/v8/test/mjsunit/array-functions-prototype-misc.js @@ -31,7 +31,7 @@ * should work on other objects too, so we test that too. */ -var LARGE = 4000000; +var LARGE = 400000; var VERYLARGE = 4000000000; // Nicer for firefox 1.5. Unless you uncomment the following two lines, diff --git a/deps/v8/test/mjsunit/array-literal-feedback.js b/deps/v8/test/mjsunit/array-literal-feedback.js index ed9c4e879e..d27f089c22 100644 --- a/deps/v8/test/mjsunit/array-literal-feedback.js +++ b/deps/v8/test/mjsunit/array-literal-feedback.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --expose-gc -// Flags: --noalways-opt +// Flags: --crankshaft --no-always-opt var elements_kind = { fast_smi_only : 'fast smi only elements', diff --git a/deps/v8/test/mjsunit/array-literal-transitions.js b/deps/v8/test/mjsunit/array-literal-transitions.js index 1af02d8d2f..ce46cb7a7c 100644 --- a/deps/v8/test/mjsunit/array-literal-transitions.js +++ b/deps/v8/test/mjsunit/array-literal-transitions.js @@ -25,7 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --expose-gc --ignition-osr +// Flags: --allow-natives-syntax --expose-gc --ignition-osr --no-always-opt +// Flags: --crankshaft // IC and Crankshaft support for smi-only elements in dynamic array literals. function get(foo) { return foo; } // Used to generate dynamic values. @@ -188,9 +189,7 @@ assertEquals(foo, array[2]); (function literals_after_osr() { var color = [0]; - // Trigger OSR, if optimization is not disabled. - if (%GetOptimizationStatus(literals_after_osr) != 4) { - while (%GetOptimizationCount(literals_after_osr) == 0) {} - } + // Trigger OSR. + while (%GetOptimizationCount(literals_after_osr) == 0) {} return [color[0]]; })(); diff --git a/deps/v8/test/mjsunit/array-methods-read-only-length.js b/deps/v8/test/mjsunit/array-methods-read-only-length.js index 2943b162c9..7de580d074 100644 --- a/deps/v8/test/mjsunit/array-methods-read-only-length.js +++ b/deps/v8/test/mjsunit/array-methods-read-only-length.js @@ -91,9 +91,9 @@ function testRemove(a, mode) { %OptimizeFunctionOnNextCall(splice); check(splice); - %ClearFunctionTypeFeedback(pop); - %ClearFunctionTypeFeedback(shift); - %ClearFunctionTypeFeedback(splice); + %ClearFunctionFeedback(pop); + %ClearFunctionFeedback(shift); + %ClearFunctionFeedback(splice); } for (var i = 0; i < 3; i++) { diff --git a/deps/v8/test/mjsunit/array-push5.js b/deps/v8/test/mjsunit/array-push5.js index 83339a21e0..4d75dc8b7c 100644 --- a/deps/v8/test/mjsunit/array-push5.js +++ b/deps/v8/test/mjsunit/array-push5.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt var v = 0; diff --git a/deps/v8/test/mjsunit/array-shift4.js b/deps/v8/test/mjsunit/array-shift4.js index 669b11a054..aa0c546233 100644 --- a/deps/v8/test/mjsunit/array-shift4.js +++ b/deps/v8/test/mjsunit/array-shift4.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft // Inlining shift with holey smi arrays shouldn't deopt just because it // encounters the hole on the copy step. diff --git a/deps/v8/test/mjsunit/array-sort.js b/deps/v8/test/mjsunit/array-sort.js index fdd2333d7c..ddfeffe4a2 100644 --- a/deps/v8/test/mjsunit/array-sort.js +++ b/deps/v8/test/mjsunit/array-sort.js @@ -480,6 +480,29 @@ function TestSortOnProxy() { } TestSortOnProxy(); +function TestSortOnNonExtensible() { + { + var arr = [1,,2]; + Object.preventExtensions(arr); + assertThrows(() => arr.sort(), TypeError); + assertEquals(arr, [1,,2]); + } + { + var arr = [1,,undefined]; + Object.preventExtensions(arr); + assertThrows(() => arr.sort(), TypeError); + assertFalse(arr.hasOwnProperty(1)); + assertEquals(arr, [1,,undefined]); + } + { + var arr = [1,undefined,2]; + Object.preventExtensions(arr); + arr.sort(); + assertEquals(arr, [1,2,undefined]); + } +} +TestSortOnNonExtensible(); + // Test special prototypes (function testSortSpecialPrototypes() { diff --git a/deps/v8/test/mjsunit/array-store-and-grow.js b/deps/v8/test/mjsunit/array-store-and-grow.js index 5ac95e9b3a..4de7a376e3 100644 --- a/deps/v8/test/mjsunit/array-store-and-grow.js +++ b/deps/v8/test/mjsunit/array-store-and-grow.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt // Verifies that the KeyedStoreIC correctly handles out-of-bounds stores // to an array that grow it by a single element. Test functions are @@ -205,7 +205,7 @@ assertEquals(0.5, array_store_1([], 0, 0.5)); assertOptimized(grow_store); grow_store(a,2048,1); assertUnoptimized(grow_store); - %ClearFunctionTypeFeedback(grow_store); + %ClearFunctionFeedback(grow_store); })(); @@ -228,7 +228,7 @@ assertEquals(0.5, array_store_1([], 0, 0.5)); // Should be a polymorphic grow stub. If not a grow stub it will deopt. f(new Array("hi"), 1, 3); assertOptimized(f); - %ClearFunctionTypeFeedback(f); + %ClearFunctionFeedback(f); })(); @@ -252,5 +252,5 @@ assertEquals(0.5, array_store_1([], 0, 0.5)); // An attempt to grow should cause deopt f(new Array("hi"), 1, 3); assertUnoptimized(f); - %ClearFunctionTypeFeedback(f); + %ClearFunctionFeedback(f); })(); diff --git a/deps/v8/test/mjsunit/asm/asm-validation.js b/deps/v8/test/mjsunit/asm/asm-validation.js index 3dfd18caef..364ecd64d3 100644 --- a/deps/v8/test/mjsunit/asm/asm-validation.js +++ b/deps/v8/test/mjsunit/asm/asm-validation.js @@ -413,3 +413,86 @@ function assertValidAsm(func) { Module(); assertFalse(%IsAsmWasmCode(Module)); })(); + +(function TestConditionalReturn() { + function Module() { + 'use asm'; + function foo(a, b) { + a = +a; + b = +b; + // Allowed, despite not matching the spec, as emscripten emits this in + // practice. + return a == b ? +a : +b; + } + return foo; + } + var m = Module(); + assertEquals(4, m(4, 4)); + assertEquals(5, m(4, 5)); + assertEquals(4, m(5, 4)); + assertValidAsm(Module); +})(); + +(function TestMismatchedConditionalReturn() { + function Module() { + 'use asm'; + function foo(a, b) { + a = +a; + return a == 0.0 ? 0 : +a; + } + return foo; + } + Module(); + assertFalse(% IsAsmWasmCode(Module)); +})(); + +(function TestBadIntConditionalReturn() { + function Module() { + 'use asm'; + function foo(a, b) { + a = a | 0; + b = b | 0; + // Disallowed because signature must be signed, but these will be int. + return 1 ? a : b; + } + return foo; + } + Module(); + assertFalse(% IsAsmWasmCode(Module)); +})(); + +(function TestBadSignedConditionalReturn() { + function Module() { + 'use asm'; + function foo(a, b) { + a = a | 0; + b = b | 0; + // Disallowed because conditional yields int, even when both sides + // are signed. + return 1 ? a | 0 : b | 0; + } + return foo; + } + Module(); + assertFalse(% IsAsmWasmCode(Module)); +})(); + +(function TestAsmIsRegular() { + function Module() { + 'use asm'; + var g = 123; + function foo() { + return g | 0; + } + return {x: foo}; + } + var o = Module(); + assertValidAsm(Module); + assertFalse(o instanceof WebAssembly.Instance); + assertTrue(o instanceof Object); + assertTrue(o.__proto__ === Object.prototype); + o.x = 5; + assertTrue(typeof o.x === 'number'); + assertTrue(o.__single_function__ === undefined); + assertTrue(o.__foreign_init__ === undefined); +})(); diff --git a/deps/v8/test/mjsunit/asm/do-while-false.js b/deps/v8/test/mjsunit/asm/do-while-false.js index ba906a0ab3..e4cf375b01 100644 --- a/deps/v8/test/mjsunit/asm/do-while-false.js +++ b/deps/v8/test/mjsunit/asm/do-while-false.js @@ -41,11 +41,11 @@ function Module() { function d6(a) { a = a | 0; do { - if (a == 0) return 120; - if (a == 1) break; - if (a == 2) return 122; - if (a == 3) continue; - if (a == 4) return 124; + if ((a | 0) == 0) return 120; + if ((a | 0) == 1) break; + if ((a | 0) == 2) return 122; + if ((a | 0) == 3) continue; + if ((a | 0) == 4) return 124; } while(false); return 125; } diff --git a/deps/v8/test/mjsunit/asm/do-while.js b/deps/v8/test/mjsunit/asm/do-while.js index 214be6458f..0c0824da11 100644 --- a/deps/v8/test/mjsunit/asm/do-while.js +++ b/deps/v8/test/mjsunit/asm/do-while.js @@ -5,17 +5,17 @@ function Module(stdlib, foreign, buffer) { "use asm"; function f(i) { - var j; i = i|0; + var j = 0; do { - if (i > 0) { - j = i != 0; + if ((i | 0) > 0) { + j = (i | 0) != 0; i = (i - 1) | 0; } else { j = 0; } } while (j); - return i; + return i | 0; } return {f:f}; } diff --git a/deps/v8/test/mjsunit/asm/float32array-negative-offset.js b/deps/v8/test/mjsunit/asm/float32array-negative-offset.js index 524bdc840c..2f753bea8f 100644 --- a/deps/v8/test/mjsunit/asm/float32array-negative-offset.js +++ b/deps/v8/test/mjsunit/asm/float32array-negative-offset.js @@ -12,8 +12,7 @@ var m = (function Module(stdlib, foreign, heap) { var MEM32 = new stdlib.Float32Array(heap); function load(i) { i = i|0; - i = +MEM32[i >> 2]; - return i; + return +MEM32[i >> 2]; } function store(i, v) { i = i|0; @@ -22,8 +21,7 @@ var m = (function Module(stdlib, foreign, heap) { } function load8(i) { i = i|0; - i = +MEM32[i + 8 >> 2]; - return i; + return +MEM32[i + 8 >> 2]; } function store8(i, v) { i = i|0; diff --git a/deps/v8/test/mjsunit/asm/float32array-outofbounds.js b/deps/v8/test/mjsunit/asm/float32array-outofbounds.js index 8709b706c9..e4062160e6 100644 --- a/deps/v8/test/mjsunit/asm/float32array-outofbounds.js +++ b/deps/v8/test/mjsunit/asm/float32array-outofbounds.js @@ -7,8 +7,7 @@ function Module(stdlib, foreign, heap) { var MEM32 = new stdlib.Float32Array(heap); function load(i) { i = i|0; - i = +MEM32[i >> 2]; - return i; + return +MEM32[i >> 2]; } function store(i, v) { i = i|0; diff --git a/deps/v8/test/mjsunit/asm/float32array-store-div.js b/deps/v8/test/mjsunit/asm/float32array-store-div.js index 78224f962b..45f3fd5f21 100644 --- a/deps/v8/test/mjsunit/asm/float32array-store-div.js +++ b/deps/v8/test/mjsunit/asm/float32array-store-div.js @@ -6,8 +6,9 @@ function Module(stdlib, foreign, heap) { "use asm"; var MEM32 = new stdlib.Float32Array(heap); function foo(i) { - MEM32[0] = (i >>> 0) / 2; - return MEM32[0]; + i = i | 0; + MEM32[0] = +(i >>> 0) / 2.; + return +MEM32[0]; } return { foo: foo }; } diff --git a/deps/v8/test/mjsunit/asm/float64array-negative-offset.js b/deps/v8/test/mjsunit/asm/float64array-negative-offset.js index 154bd82cd3..76be0ced01 100644 --- a/deps/v8/test/mjsunit/asm/float64array-negative-offset.js +++ b/deps/v8/test/mjsunit/asm/float64array-negative-offset.js @@ -12,8 +12,7 @@ var m = (function Module(stdlib, foreign, heap) { var MEM64 = new stdlib.Float64Array(heap); function load(i) { i = i|0; - i = +MEM64[i >> 3]; - return i; + return +MEM64[i >> 3]; } function store(i, v) { i = i|0; @@ -22,8 +21,7 @@ var m = (function Module(stdlib, foreign, heap) { } function load8(i) { i = i|0; - i = +MEM64[i + 8 >> 3]; - return i; + return +MEM64[i + 8 >> 3]; } function store8(i, v) { i = i|0; diff --git a/deps/v8/test/mjsunit/asm/float64array-outofbounds.js b/deps/v8/test/mjsunit/asm/float64array-outofbounds.js index 106d8e4821..049421c596 100644 --- a/deps/v8/test/mjsunit/asm/float64array-outofbounds.js +++ b/deps/v8/test/mjsunit/asm/float64array-outofbounds.js @@ -7,8 +7,7 @@ function Module(stdlib, foreign, heap) { var MEM64 = new stdlib.Float64Array(heap); function load(i) { i = i|0; - i = +MEM64[i >> 3]; - return i; + return +MEM64[i >> 3]; } function store(i, v) { i = i|0; diff --git a/deps/v8/test/mjsunit/asm/float64array-store-div.js b/deps/v8/test/mjsunit/asm/float64array-store-div.js index 10b0011fbc..0af2ffc28a 100644 --- a/deps/v8/test/mjsunit/asm/float64array-store-div.js +++ b/deps/v8/test/mjsunit/asm/float64array-store-div.js @@ -6,8 +6,9 @@ function Module(stdlib, foreign, heap) { "use asm"; var MEM64 = new stdlib.Float64Array(heap); function foo(i) { - MEM64[0] = (i >>> 0) / 2; - return MEM64[0]; + i = i | 0; + MEM64[0] = +(i >>> 0) / 2.; + return +MEM64[0]; } return { foo: foo }; } diff --git a/deps/v8/test/mjsunit/asm/float64mul.js b/deps/v8/test/mjsunit/asm/float64mul.js index 9cd9582327..366f784c2e 100644 --- a/deps/v8/test/mjsunit/asm/float64mul.js +++ b/deps/v8/test/mjsunit/asm/float64mul.js @@ -10,7 +10,7 @@ function Module(stdlib, foreign, heap) { } function f2(i) { i = +i; - return +(-1 * i); + return +(-1. * i); } function f3(i) { i = +i; diff --git a/deps/v8/test/mjsunit/asm/if-cloning.js b/deps/v8/test/mjsunit/asm/if-cloning.js index 99d4edc67a..cd9ab9634d 100644 --- a/deps/v8/test/mjsunit/asm/if-cloning.js +++ b/deps/v8/test/mjsunit/asm/if-cloning.js @@ -7,7 +7,7 @@ var if0 = (function Module() { function if0(i, j) { i = i|0; j = j|0; - if (i == 0 ? j == 0 : 0) return 1; + if ((i | 0) == 0 ? (j | 0) == 0 : 0) return 1; return 0; } return {if0: if0}; @@ -23,7 +23,7 @@ var if1 = (function Module() { function if1(i, j) { i = i|0; j = j|0; - if (i == 0 ? j == 0 : 1) return 0; + if ((i | 0) == 0 ? (j | 0) == 0 : 1) return 0; return 1; } return {if1: if1}; diff --git a/deps/v8/test/mjsunit/asm/if-folding.js b/deps/v8/test/mjsunit/asm/if-folding.js index 80070ee6ee..e0017e2d12 100644 --- a/deps/v8/test/mjsunit/asm/if-folding.js +++ b/deps/v8/test/mjsunit/asm/if-folding.js @@ -18,41 +18,55 @@ function Module() { function if2() { if (0) return 15; else return 16; + return 0; // needed for validation } function if3() { if (1) return 17; else return 18; + return 0; // needed for validation } function if4() { - return 1 ? 19 : 20; + return (1 ? 19 : 20) | 0; } function if5() { - return 0 ? 21 : 22; + return (0 ? 21 : 22) | 0; } function if6() { - var x = 0 ? 23 : 24; - return x; + var x = 0; + x = 0 ? 23 : 24; + return x | 0; } function if7() { - if (0) { var x = 0 ? 25 : 26; } - else { var x = 0 ? 27 : 28; } - return x; + var x = 0; + if (0) { + x = 0 ? 25 : 26; + } else { + x = 0 ? 27 : 28; + } + return x | 0; } function if8() { + var x = 0; if (0) { - if (0) { var x = 0 ? 29 : 30; } - else { var x = 0 ? 31 : 32; } + if (0) { + x = 0 ? 29 : 30; + } else { + x = 0 ? 31 : 32; + } } else { - if (0) { var x = 0 ? 33 : 34; } - else { var x = 0 ? 35 : 36; } + if (0) { + x = 0 ? 33 : 34; + } else { + x = 0 ? 35 : 36; + } } - return x; + return x | 0; } return {if0: if0, if1: if1, if2: if2, if3: if3, if4: if4, if5: if5, if6: if6, if7: if7, if8: if8 }; @@ -70,25 +84,33 @@ assertEquals(28, m.if7()); assertEquals(36, m.if8()); -function Spec(a,b,c) { +function Spec0(stdlib, foreign, heap) { "use asm"; - var xx = a | 0; - var yy = b | 0; - var zz = c | 0; + var xx = foreign.a | 0; + var yy = foreign.b | 0; + var zz = foreign.c | 0; function f() { + var x = 0; if (xx) { - if (yy) { var x = zz ? 29 : 30; } - else { var x = zz ? 31 : 32; } + if (yy) { + x = zz ? 29 : 30; + } else { + x = zz ? 31 : 32; + } } else { - if (yy) { var x = zz ? 33 : 34; } - else { var x = zz ? 35 : 36; } + if (yy) { + x = zz ? 33 : 34; + } else { + x = zz ? 35 : 36; + } } - return x; + return x | 0; } return {f: f}; } +var Spec = (a, b, c) => Spec0(this, {a: a, b: b, c: c}); assertEquals(36, Spec(0,0,0).f()); assertEquals(35, Spec(0,0,1).f()); diff --git a/deps/v8/test/mjsunit/asm/if-reduction.js b/deps/v8/test/mjsunit/asm/if-reduction.js index b0dcc13842..420d9d38ec 100644 --- a/deps/v8/test/mjsunit/asm/if-reduction.js +++ b/deps/v8/test/mjsunit/asm/if-reduction.js @@ -6,65 +6,84 @@ function Module() { "use asm"; function if0() { - var x = 0 ? 11 : 12; - return (x == 11) | 0; + var x = 0; + x = 0 ? 11 : 12; + return ((x | 0) == 11) | 0; } function if1() { - var x = 1 ? 13 : 14; - return (x == 13) | 0; + var x = 0; + x = 1 ? 13 : 14; + return ((x | 0) == 13) | 0; } function if2() { - var x = 0 ? 15 : 16; - return (x != 15) | 0; + var x = 0; + x = 0 ? 15 : 16; + return ((x | 0) != 15) | 0; } function if3() { - var x = 1 ? 17 : 18; - return (x != 17) | 0; + var x = 0; + x = 1 ? 17 : 18; + return ((x | 0) != 17) | 0; } function if4() { - var x = 0 ? 19 : 20; - var y = (x == 19) ? 21 : 22; - return y; + var x = 0; + var y = 0; + x = 0 ? 19 : 20; + y = ((x | 0) == 19) ? 21 : 22; + return y | 0; } function if5() { - var x = 1 ? 23 : 24; - var y = (x == 23) ? 25 : 26; - return y; + var x = 0; + var y = 0; + x = 1 ? 23 : 24; + y = ((x | 0) == 23) ? 25 : 26; + return y | 0; } function if6() { - var x = 0 ? 27 : 28; - var y = (x == 27) ? 29 : 30; - var z = (y == 29) ? 31 : 32; - return z; + var x = 0; + var y = 0; + var z = 0; + x = 0 ? 27 : 28; + y = ((x | 0) == 27) ? 29 : 30; + z = ((y | 0) == 29) ? 31 : 32; + return z | 0; } function if7() { - var x = 1 ? 33 : 34; - var y = (x == 33) ? 35 : 36; - var z = (y == 35) ? 37 : 38; - var w = (z == 37) ? 39 : 40; - return w; + var x = 0; + var y = 0; + var z = 0; + var w = 0; + x = 1 ? 33 : 34; + y = ((x | 0) == 33) ? 35 : 36; + z = ((y | 0) == 35) ? 37 : 38; + w = ((z | 0) == 37) ? 39 : 40; + return w | 0; } function if8() { + var w = 0; + var x = 0; + var y = 0; + var z = 0; if (0) { - var x = 0 ? 43 : 44; - var y = (x == 43) ? 45 : 46; - var z = (y == 45) ? 47 : 48; - var w = (z == 47) ? 49 : 50; + x = 0 ? 43 : 44; + y = ((x | 0) == 43) ? 45 : 46; + z = ((y | 0) == 45) ? 47 : 48; + w = ((z | 0) == 47) ? 49 : 50; } else { - var x = 1 ? 53 : 54; - var y = (x == 53) ? 55 : 56; - var z = (y == 55) ? 57 : 58; - var w = (z == 57) ? 59 : 60; + x = 1 ? 53 : 54; + y = ((x | 0) == 53) ? 55 : 56; + z = ((y | 0) == 55) ? 57 : 58; + w = ((z | 0) == 57) ? 59 : 60; } - return w; + return w | 0; } return {if0: if0, if1: if1, if2: if2, if3: if3, if4: if4, if5: if5, if6: if6, if7: if7, if8: if8 }; @@ -82,28 +101,33 @@ assertEquals(39, m.if7()); assertEquals(59, m.if8()); -function Spec(a,b) { +function Spec0(stdlib, foreign, heap) { "use asm"; - var xx = a | 0; - var yy = b | 0; + var xx = foreign.a | 0; + var yy = foreign.b | 0; function f() { + var x = 0; + var y = 0; + var z = 0; + var w = 0; if (xx) { - var x = yy ? 43 : 44; - var y = (x == 43) ? 45 : 46; - var z = (y == 45) ? 47 : 48; - var w = (z == 47) ? 49 : 50; + x = yy ? 43 : 44; + y = ((x | 0) == 43) ? 45 : 46; + z = ((y | 0) == 45) ? 47 : 48; + w = ((z | 0) == 47) ? 49 : 50; } else { - var x = yy ? 53 : 54; - var y = (x == 53) ? 55 : 56; - var z = (y == 55) ? 57 : 58; - var w = (z == 57) ? 59 : 60; + x = yy ? 53 : 54; + y = ((x | 0) == 53) ? 55 : 56; + z = ((y | 0) == 55) ? 57 : 58; + w = ((z | 0) == 57) ? 59 : 60; } - return w; + return w | 0; } return {f: f}; } +var Spec = (a, b, c) => Spec0(this, {a: a, b: b, c: c}); assertEquals(60, Spec(0,0).f()); assertEquals(59, Spec(0,1).f()); diff --git a/deps/v8/test/mjsunit/asm/if-tonumber.js b/deps/v8/test/mjsunit/asm/if-tonumber.js index dd3f73b2c2..f604fbcef8 100644 --- a/deps/v8/test/mjsunit/asm/if-tonumber.js +++ b/deps/v8/test/mjsunit/asm/if-tonumber.js @@ -10,8 +10,8 @@ function Module(stdlib, foreign, heap) { "use asm"; function foo(i) { i = i|0; - if (i > 0) { - i = i == 1; + if ((i | 0) > 0) { + i = (i | 0) == 1; } else { i = 1; } diff --git a/deps/v8/test/mjsunit/asm/infinite-loops-taken.js b/deps/v8/test/mjsunit/asm/infinite-loops-taken.js index 8a3f91a67a..5ac3769e9e 100644 --- a/deps/v8/test/mjsunit/asm/infinite-loops-taken.js +++ b/deps/v8/test/mjsunit/asm/infinite-loops-taken.js @@ -7,6 +7,7 @@ function counter(x) { return (function() { if (x-- == 0) throw error;}); } +// TODO(asm): This module is not valid asm.js. function Module() { "use asm"; diff --git a/deps/v8/test/mjsunit/asm/int16array-negative-offset.js b/deps/v8/test/mjsunit/asm/int16array-negative-offset.js index 5d33115ad8..ff452fac6f 100644 --- a/deps/v8/test/mjsunit/asm/int16array-negative-offset.js +++ b/deps/v8/test/mjsunit/asm/int16array-negative-offset.js @@ -13,7 +13,7 @@ var m = (function Module(stdlib, foreign, heap) { function load(i) { i = i|0; i = MEM16[i >> 1]|0; - return i; + return i | 0; } function store(i, v) { i = i|0; @@ -23,7 +23,7 @@ var m = (function Module(stdlib, foreign, heap) { function load8(i) { i = i|0; i = MEM16[i + 8 >> 1]|0; - return i; + return i | 0; } function store8(i, v) { i = i|0; diff --git a/deps/v8/test/mjsunit/asm/int16array-outofbounds.js b/deps/v8/test/mjsunit/asm/int16array-outofbounds.js index 7982c0046a..8cad86efb5 100644 --- a/deps/v8/test/mjsunit/asm/int16array-outofbounds.js +++ b/deps/v8/test/mjsunit/asm/int16array-outofbounds.js @@ -8,19 +8,22 @@ function Module(stdlib, foreign, heap) { function load(i) { i = i|0; i = MEM16[i >> 1] | 0; - return i; + return i | 0; } function loadm1() { - return MEM16[-1] | 0; + var i = -1 << 1; + return MEM16[i >> 1] | 0; + return 0; } function store(i, v) { - i = i|0; - v = v|0; + i = i | 0; + v = v | 0; MEM16[i >> 1] = v; } function storem1(v) { - v = v|0; - MEM16[-1] = v; + v = v | 0; + var i = -1 << 1; + MEM16[i >> 1] = v; } return {load: load, loadm1: loadm1, store: store, storem1: storem1}; } diff --git a/deps/v8/test/mjsunit/asm/int32-div.js b/deps/v8/test/mjsunit/asm/int32-div.js index b4d0fef401..bfc4924474 100644 --- a/deps/v8/test/mjsunit/asm/int32-div.js +++ b/deps/v8/test/mjsunit/asm/int32-div.js @@ -6,19 +6,19 @@ function Module(stdlib, foreign, heap) { "use asm"; function f1(i) { i = i|0; - return i / 3 | 0; + return (i | 0) / 3 | 0; } function f2(i) { i = i|0; - return i / 13 | 0; + return (i | 0) / 13 | 0; } function f3(i) { i = i|0; - return i / 1024 | 0; + return (i | 0) / 1024 | 0; } function f4(i) { i = i|0; - return i / 3733331 | 0; + return (i | 0) / 3733331 | 0; } return { f1: f1, f2: f2, f3: f3, f4: f4 }; } diff --git a/deps/v8/test/mjsunit/asm/int32-mod.js b/deps/v8/test/mjsunit/asm/int32-mod.js index b3a7c0ecf4..141bd0282f 100644 --- a/deps/v8/test/mjsunit/asm/int32-mod.js +++ b/deps/v8/test/mjsunit/asm/int32-mod.js @@ -6,19 +6,19 @@ function Module(stdlib, foreign, heap) { "use asm"; function f1(i) { i = i|0; - return i % 3; + return ((i | 0) % 3) | 0; } function f2(i) { i = i|0; - return i % 9; + return ((i | 0) % 9) | 0; } function f3(i) { i = i|0; - return i % 1024; + return ((i | 0) % 1024) | 0; } function f4(i) { i = i|0; - return i % 3133335; + return ((i | 0) % 3133335) | 0; } return { f1: f1, f2: f2, f3: f3, f4: f4 }; } @@ -26,8 +26,8 @@ function Module(stdlib, foreign, heap) { var m = Module(this, {}, new ArrayBuffer(1024)); for (var i = -2147483648; i < 2147483648; i += 3999773) { - assertEquals(i % 3, m.f1(i)); - assertEquals(i % 9, m.f2(i)); - assertEquals(i % 1024, m.f3(i)); - assertEquals(i % 3133335, m.f4(i)); + assertEquals((i % 3) | 0, m.f1(i)); + assertEquals((i % 9) | 0, m.f2(i)); + assertEquals((i % 1024) | 0, m.f3(i)); + assertEquals((i % 3133335) | 0, m.f4(i)); } diff --git a/deps/v8/test/mjsunit/asm/int32-mul.js b/deps/v8/test/mjsunit/asm/int32-mul.js index c5af8a03ad..4c5e38668a 100644 --- a/deps/v8/test/mjsunit/asm/int32-mul.js +++ b/deps/v8/test/mjsunit/asm/int32-mul.js @@ -6,19 +6,19 @@ function Module(stdlib, foreign, heap) { "use asm"; function f1(i) { i = i|0; - return i * 3 | 0; + return (i | 0) * 3 | 0; } function f2(i) { i = i|0; - return i * 7 | 0; + return (i | 0) * 7 | 0; } function f3(i) { i = i|0; - return i * 1024 | 0; + return (i | 0) * 1024 | 0; } function f4(i) { i = i|0; - return i * 3333339 | 0; + return (i | 0) * 333339 | 0; } return { f1: f1, f2: f2, f3: f3, f4: f4 }; } @@ -29,5 +29,5 @@ for (var i = -2147483648; i < 2147483648; i += 3999771) { assertEquals(i * 3 | 0, m.f1(i)); assertEquals(i * 7 | 0, m.f2(i)); assertEquals(i * 1024 | 0, m.f3(i)); - assertEquals(i * 3333339 | 0, m.f4(i)); + assertEquals(i * 333339 | 0, m.f4(i)); } diff --git a/deps/v8/test/mjsunit/asm/int32-tmod.js b/deps/v8/test/mjsunit/asm/int32-tmod.js index 0e294d3412..1e7495e302 100644 --- a/deps/v8/test/mjsunit/asm/int32-tmod.js +++ b/deps/v8/test/mjsunit/asm/int32-tmod.js @@ -6,23 +6,23 @@ function Module(stdlib, foreign, heap) { "use asm"; function f0(i) { i = i|0; - return i % 2 | 0; + return (i | 0) % 2 | 0; } function f1(i) { i = i|0; - return i % 3 | 0; + return (i | 0) % 3 | 0; } function f2(i) { i = i|0; - return i % 9 | 0; + return (i | 0) % 9 | 0; } function f3(i) { i = i|0; - return i % 1024 | 0; + return (i | 0) % 1024 | 0; } function f4(i) { i = i|0; - return i % 3333339 | 0; + return (i | 0) % 3333339 | 0; } return { f0: f0, f1: f1, f2: f2, f3: f3, f4: f4 }; } diff --git a/deps/v8/test/mjsunit/asm/int32-udiv.js b/deps/v8/test/mjsunit/asm/int32-udiv.js index 9c67d6f076..6eccca251d 100644 --- a/deps/v8/test/mjsunit/asm/int32-udiv.js +++ b/deps/v8/test/mjsunit/asm/int32-udiv.js @@ -5,20 +5,20 @@ function Module(stdlib, foreign, heap) { "use asm"; function f1(i) { - i = i>>>0; - return i / 3 | 0; + i = i | 0; + return (i >>> 0) / 3 | 0; } function f2(i) { - i = i>>>0; - return i / 17 | 0; + i = i | 0; + return (i >>> 0) / 17 | 0; } function f3(i) { - i = i>>>0; - return i / 1024 | 0; + i = i | 0; + return (i >>> 0) / 1024 | 0; } function f4(i) { - i = i>>>0; - return i / 3343330 | 0; + i = i | 0; + return (i >>> 0) / 3343330 | 0; } return { f1: f1, f2: f2, f3: f3, f4: f4 }; } diff --git a/deps/v8/test/mjsunit/asm/int32-umod.js b/deps/v8/test/mjsunit/asm/int32-umod.js index 2268966250..8a96aefdab 100644 --- a/deps/v8/test/mjsunit/asm/int32-umod.js +++ b/deps/v8/test/mjsunit/asm/int32-umod.js @@ -5,20 +5,20 @@ function Module(stdlib, foreign, heap) { "use asm"; function f1(i) { - i = i>>>0; - return i % 3; + i = i | 0; + return (i >>> 0) % 3 | 0; } function f2(i) { - i = i>>>0; - return i % 11; + i = i | 0; + return (i >>> 0) % 11 | 0; } function f3(i) { - i = i>>>0; - return i % 1024; + i = i | 0; + return (i >>> 0) % 1024 | 0; } function f4(i) { - i = i>>>0; - return i % 3333337; + i = i | 0; + return (i >>> 0) % 3333337 | 0; } return { f1: f1, f2: f2, f3: f3, f4: f4 }; } diff --git a/deps/v8/test/mjsunit/asm/int32array-constant-key.js b/deps/v8/test/mjsunit/asm/int32array-constant-key.js index bb5b65062e..49eabccb9a 100644 --- a/deps/v8/test/mjsunit/asm/int32array-constant-key.js +++ b/deps/v8/test/mjsunit/asm/int32array-constant-key.js @@ -6,28 +6,34 @@ function Module(stdlib, foreign, heap) { "use asm"; var MEM32 = new stdlib.Int32Array(heap); function loadm4194304() { - return MEM32[-4194304]; + var i = -4194304 << 2; + return MEM32[i >> 2] | 0; } function loadm0() { - return MEM32[-0]; + return MEM32[-0] | 0; } function load0() { - return MEM32[0]; + return MEM32[0] | 0; } function load4() { - return MEM32[4]; + return MEM32[4] | 0; } function storem4194304(v) { - MEM32[-4194304] = v; + v = v | 0; + var i = -4194304 << 2; + MEM32[i >> 2] = v; } function storem0(v) { + v = v | 0; MEM32[-0] = v; } function store0(v) { - MEM32[0] = v; + v = v | 0; + MEM32[0 >> 2] = v; } function store4(v) { - MEM32[4] = v; + v = v | 0; + MEM32[(4 << 2) >> 2] = v; } return { loadm4194304: loadm4194304, storem4194304: storem4194304, loadm0: loadm0, storem0: storem0, load0: load0, store0: store0, @@ -36,27 +42,27 @@ function Module(stdlib, foreign, heap) { var m = Module(this, {}, new ArrayBuffer(4)); -assertEquals(undefined, m.loadm4194304()); +assertEquals(0, m.loadm4194304()); assertEquals(0, m.loadm0()); assertEquals(0, m.load0()); -assertEquals(undefined, m.load4()); +assertEquals(0, m.load4()); m.storem4194304(123456789); -assertEquals(undefined, m.loadm4194304()); +assertEquals(0, m.loadm4194304()); assertEquals(0, m.loadm0()); assertEquals(0, m.load0()); -assertEquals(undefined, m.load4()); +assertEquals(0, m.load4()); m.storem0(987654321); -assertEquals(undefined, m.loadm4194304()); +assertEquals(0, m.loadm4194304()); assertEquals(987654321, m.loadm0()); assertEquals(987654321, m.load0()); -assertEquals(undefined, m.load4()); +assertEquals(0, m.load4()); m.store0(0x12345678); -assertEquals(undefined, m.loadm4194304()); +assertEquals(0, m.loadm4194304()); assertEquals(0x12345678, m.loadm0()); assertEquals(0x12345678, m.load0()); -assertEquals(undefined, m.load4()); +assertEquals(0, m.load4()); m.store4(43); -assertEquals(undefined, m.loadm4194304()); +assertEquals(0, m.loadm4194304()); assertEquals(0x12345678, m.loadm0()); assertEquals(0x12345678, m.load0()); -assertEquals(undefined, m.load4()); +assertEquals(0, m.load4()); diff --git a/deps/v8/test/mjsunit/asm/int32array-negative-offset.js b/deps/v8/test/mjsunit/asm/int32array-negative-offset.js index d1a8efa671..690af8e668 100644 --- a/deps/v8/test/mjsunit/asm/int32array-negative-offset.js +++ b/deps/v8/test/mjsunit/asm/int32array-negative-offset.js @@ -13,7 +13,7 @@ var m = (function Module(stdlib, foreign, heap) { function load(i) { i = i|0; i = MEM32[i >> 2]|0; - return i; + return i | 0; } function store(i, v) { i = i|0; @@ -23,7 +23,7 @@ var m = (function Module(stdlib, foreign, heap) { function load8(i) { i = i|0; i = MEM32[i + 8 >> 2]|0; - return i; + return i | 0; } function store8(i, v) { i = i|0; diff --git a/deps/v8/test/mjsunit/asm/int32array-outofbounds.js b/deps/v8/test/mjsunit/asm/int32array-outofbounds.js index ba7043dea3..8fafb0d371 100644 --- a/deps/v8/test/mjsunit/asm/int32array-outofbounds.js +++ b/deps/v8/test/mjsunit/asm/int32array-outofbounds.js @@ -8,7 +8,7 @@ function Module(stdlib, foreign, heap) { function load(i) { i = i|0; i = MEM32[i >> 2] | 0; - return i; + return i | 0; } function store(i, v) { i = i|0; diff --git a/deps/v8/test/mjsunit/asm/int32array-unaligned.js b/deps/v8/test/mjsunit/asm/int32array-unaligned.js index 698ec5e312..6fdf5585e0 100644 --- a/deps/v8/test/mjsunit/asm/int32array-unaligned.js +++ b/deps/v8/test/mjsunit/asm/int32array-unaligned.js @@ -8,7 +8,7 @@ function Module(stdlib, foreign, heap) { function load(i) { i = i|0; i = MEM32[i >> 2] | 0; - return i; + return i | 0; } function store(i, v) { i = i|0; diff --git a/deps/v8/test/mjsunit/asm/int32div.js b/deps/v8/test/mjsunit/asm/int32div.js index f5d24331ed..8bb9adaa87 100644 --- a/deps/v8/test/mjsunit/asm/int32div.js +++ b/deps/v8/test/mjsunit/asm/int32div.js @@ -12,13 +12,15 @@ function Int32Div(divisor) { name += "minus_"; } name += Math.abs(divisor); - var m = eval("function Module(stdlib, foreign, heap) {\n" - + " \"use asm\";\n" - + " function " + name + "(dividend) {\n" - + " return ((dividend | 0) / " + divisor + ") | 0;\n" - + " }\n" - + " return { f: " + name + "}\n" - + "}; Module"); + var m = eval( + 'function Module(stdlib, foreign, heap) {\n' + + ' "use asm";\n' + + ' function ' + name + '(dividend) {\n' + + ' dividend = dividend | 0;\n' + + ' return ((dividend | 0) / ' + divisor + ') | 0;\n' + + ' }\n' + + ' return { f: ' + name + '}\n' + + '}; Module'); return m(stdlib, foreign, heap).f; } diff --git a/deps/v8/test/mjsunit/asm/int32mod-constant.js b/deps/v8/test/mjsunit/asm/int32mod-constant.js index fdbdc5de10..27a13a778e 100644 --- a/deps/v8/test/mjsunit/asm/int32mod-constant.js +++ b/deps/v8/test/mjsunit/asm/int32mod-constant.js @@ -12,13 +12,15 @@ function Int32Mod(divisor) { name += "minus_"; } name += Math.abs(divisor); - var m = eval("function Module(stdlib, foreign, heap) {\n" - + " \"use asm\";\n" - + " function " + name + "(dividend) {\n" - + " return ((dividend | 0) % " + divisor + ") | 0;\n" - + " }\n" - + " return { f: " + name + "}\n" - + "}; Module"); + var m = eval( + 'function Module(stdlib, foreign, heap) {\n' + + ' "use asm";\n' + + ' function ' + name + '(dividend) {\n' + + ' dividend = dividend | 0;\n' + + ' return ((dividend | 0) % ' + divisor + ') | 0;\n' + + ' }\n' + + ' return { f: ' + name + '}\n' + + '}; Module'); return m(stdlib, foreign, heap).f; } diff --git a/deps/v8/test/mjsunit/asm/int32mod.js b/deps/v8/test/mjsunit/asm/int32mod.js index 22fa81384d..44513e3292 100644 --- a/deps/v8/test/mjsunit/asm/int32mod.js +++ b/deps/v8/test/mjsunit/asm/int32mod.js @@ -11,7 +11,7 @@ var mod = (function Module(stdlib, foreign, heap) { function mod(dividend, divisor) { dividend = dividend|0; divisor = divisor|0; - return (dividend % divisor) | 0; + return ((dividend | 0) % (divisor | 0)) | 0; } return { mod: mod }; })(stdlib, foreign, heap).mod; diff --git a/deps/v8/test/mjsunit/asm/int32modb.js b/deps/v8/test/mjsunit/asm/int32modb.js index 5081b49ae5..f8c034279b 100644 --- a/deps/v8/test/mjsunit/asm/int32modb.js +++ b/deps/v8/test/mjsunit/asm/int32modb.js @@ -11,7 +11,7 @@ var mod = (function Module(stdlib, foreign, heap) { function mod(dividend, divisor) { dividend = dividend|0; divisor = divisor|0; - return (dividend % divisor) | 0; + return ((dividend | 0) % (divisor | 0)) | 0; } return { mod: mod }; })(stdlib, foreign, heap).mod; diff --git a/deps/v8/test/mjsunit/asm/int8array-negative-offset.js b/deps/v8/test/mjsunit/asm/int8array-negative-offset.js index 47dbc1bfea..a2088e1b12 100644 --- a/deps/v8/test/mjsunit/asm/int8array-negative-offset.js +++ b/deps/v8/test/mjsunit/asm/int8array-negative-offset.js @@ -13,7 +13,7 @@ var m = (function Module(stdlib, foreign, heap) { function load(i) { i = i|0; i = MEM8[i >> 0]|0; - return i; + return i | 0; } function store(i, v) { i = i|0; @@ -23,7 +23,7 @@ var m = (function Module(stdlib, foreign, heap) { function load8(i) { i = i|0; i = MEM8[i + 8 >> 0]|0; - return i; + return i | 0; } function store8(i, v) { i = i|0; diff --git a/deps/v8/test/mjsunit/asm/load-elimination.js b/deps/v8/test/mjsunit/asm/load-elimination.js index cdc996222e..fff722d017 100644 --- a/deps/v8/test/mjsunit/asm/load-elimination.js +++ b/deps/v8/test/mjsunit/asm/load-elimination.js @@ -10,12 +10,13 @@ var heap = new ArrayBuffer(64 * 1024 * 1024); var foo = (function(stdlib, foreign, heap) { "use asm"; - var M16 = new Int16Array(heap); - var M32 = new Int32Array(heap); + var M16 = new stdlib.Int16Array(heap); + var M32 = new stdlib.Int32Array(heap); function foo() { + var i = 0; M32[0] = 0x12341234; - var i = M32[0]; - return M16[0]; + i = M32[0] | 0; + return M16[0] | 0; } return foo; })(stdlib, foreign, heap); diff --git a/deps/v8/test/mjsunit/asm/math-abs.js b/deps/v8/test/mjsunit/asm/math-abs.js index 6387749e03..bf7c7d07ea 100644 --- a/deps/v8/test/mjsunit/asm/math-abs.js +++ b/deps/v8/test/mjsunit/asm/math-abs.js @@ -15,14 +15,14 @@ function Module(stdlib) { // g: unsigned -> double function g(a) { - a = a>>>0; - return +abs(a); + a = a | 0; + return +abs(+(a >>> 0)); } // h: signed -> double function h(a) { a = a|0; - return +abs(a); + return +abs(+(a | 0)); } return { f: f, g: g, h: h }; diff --git a/deps/v8/test/mjsunit/asm/math-ceil.js b/deps/v8/test/mjsunit/asm/math-ceil.js index edb94937ba..d458eba057 100644 --- a/deps/v8/test/mjsunit/asm/math-ceil.js +++ b/deps/v8/test/mjsunit/asm/math-ceil.js @@ -10,7 +10,7 @@ function Module(stdlib) { // f: double -> float function f(a) { a = +a; - return ceil(a); + return +ceil(a); } return { f: f }; diff --git a/deps/v8/test/mjsunit/asm/math-clz32.js b/deps/v8/test/mjsunit/asm/math-clz32.js index 42dcf46575..54a42389e4 100644 --- a/deps/v8/test/mjsunit/asm/math-clz32.js +++ b/deps/v8/test/mjsunit/asm/math-clz32.js @@ -10,8 +10,8 @@ var f = (function Module(stdlib) { var clz32 = stdlib.Math.clz32; function f(a) { - a = a >>> 0; - return clz32(a)|0; + a = a | 0; + return clz32(a >>> 0) | 0; } return f; diff --git a/deps/v8/test/mjsunit/asm/math-floor.js b/deps/v8/test/mjsunit/asm/math-floor.js index e8c3f341bb..18a5a0b2c3 100644 --- a/deps/v8/test/mjsunit/asm/math-floor.js +++ b/deps/v8/test/mjsunit/asm/math-floor.js @@ -9,8 +9,8 @@ function Module(stdlib) { // f: double -> float function f(a) { - a = +a; - return floor(a); + a = +a + return +floor(a); } return { f: f }; diff --git a/deps/v8/test/mjsunit/asm/redundancy1.js b/deps/v8/test/mjsunit/asm/redundancy1.js index c7e0e37453..a3e3339bed 100644 --- a/deps/v8/test/mjsunit/asm/redundancy1.js +++ b/deps/v8/test/mjsunit/asm/redundancy1.js @@ -7,15 +7,15 @@ function module(stdlib, foreign, heap) { "use asm"; function foo(i) { - var j = 0; i = i|0; - if (i < 0) { + var j = 0; + if ((i | 0) < 0) { j = i+1|0; } - if (i > 0) { + if ((i | 0) > 0) { j = i+1|0; } - return j; + return j | 0; } return { foo: foo }; } diff --git a/deps/v8/test/mjsunit/asm/redundancy2.js b/deps/v8/test/mjsunit/asm/redundancy2.js index 95a55b533e..25e9a77828 100644 --- a/deps/v8/test/mjsunit/asm/redundancy2.js +++ b/deps/v8/test/mjsunit/asm/redundancy2.js @@ -7,9 +7,9 @@ function module(stdlib, foreign, heap) { "use asm"; function foo(i) { - var j = 0; i = i|0; - switch (i) { + var j = 0; + switch (i | 0) { case 0: j = i+1|0; break; @@ -20,10 +20,10 @@ function module(stdlib, foreign, heap) { j = i; break; } - return j; + return j | 0; } return { foo: foo }; } var foo = module(this, {}, new ArrayBuffer(64*1024)).foo; -print(foo(1)); +assertEquals(2, foo(2)); diff --git a/deps/v8/test/mjsunit/asm/regress-674089.js b/deps/v8/test/mjsunit/asm/regress-674089.js new file mode 100644 index 0000000000..ea862d7116 --- /dev/null +++ b/deps/v8/test/mjsunit/asm/regress-674089.js @@ -0,0 +1,16 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --validate-asm --ignition-staging --lazy-inner-functions + +function outer() { + "use asm"; + function inner() { + switch (1) { + case 0: + break foo; + } + } +} +outer(); diff --git a/deps/v8/test/mjsunit/asm/regress-681707.js b/deps/v8/test/mjsunit/asm/regress-681707.js new file mode 100644 index 0000000000..9c352eaf40 --- /dev/null +++ b/deps/v8/test/mjsunit/asm/regress-681707.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --validate-asm + +var foo = (function(stdlib) { + "use asm"; + var bar = (stdlib[0]); + function foo() { return bar ("lala"); } + return foo; +})(this); + +try { + nop(foo); + foo(); +} catch (e) { +} diff --git a/deps/v8/test/mjsunit/asm/switch.js b/deps/v8/test/mjsunit/asm/switch.js index 5cb6329e43..d02e661eeb 100644 --- a/deps/v8/test/mjsunit/asm/switch.js +++ b/deps/v8/test/mjsunit/asm/switch.js @@ -11,11 +11,12 @@ var switch1 = (function(stdlib, foreign, heap) { "use asm"; function switch1(i) { i = i|0; - switch (i) { + switch (i | 0) { case 0: return 1; case 1: return 2; default: return i|0; } + return i | 0; } return { switch1: switch1 }; })(stdlib, foreign, heap).switch1; @@ -32,7 +33,7 @@ var switch2 = (function(stdlib, foreign, heap) { function switch2(i) { i = i|0; var j = 0; - switch (i) { + switch (i | 0) { case 0: j = 1; break; case 1: j = 2; break; case 2: j = 3; break; @@ -56,7 +57,7 @@ var switch3 = (function(stdlib, foreign, heap) { function switch3(i) { i = i|0; var j = 0; - switch (i) { + switch (i | 0) { case 0: case 1: j = 1; break; case 2: @@ -85,7 +86,7 @@ var switch4 = (function(stdlib, foreign, heap) { "use asm"; function switch4(i) { i = i|0; - switch (i) { + switch (i | 0) { case -1: case 1: return 0; @@ -105,6 +106,7 @@ var switch4 = (function(stdlib, foreign, heap) { default: return 4; } + return 0; // needed for validation } return { switch4: switch4 }; })(stdlib, foreign, heap).switch4; diff --git a/deps/v8/test/mjsunit/asm/uint32-less-than-shift.js b/deps/v8/test/mjsunit/asm/uint32-less-than-shift.js index 7384e21ebd..fb201bb5f0 100644 --- a/deps/v8/test/mjsunit/asm/uint32-less-than-shift.js +++ b/deps/v8/test/mjsunit/asm/uint32-less-than-shift.js @@ -7,7 +7,8 @@ function Module(stdlib, foreign, heap) { function foo1(i1) { i1 = i1 | 0; - var i10 = i1 >> 5; + var i10 = 0; + i10 = (i1 >> 5) | 0; if (i10 >>> 0 < 5) { return 1; } else { @@ -18,7 +19,8 @@ function Module(stdlib, foreign, heap) { function foo2(i1) { i1 = i1 | 0; - var i10 = i1 / 32 | 0; + var i10 = 0; + i10 = ((i1 | 0) / 32) | 0; if (i10 >>> 0 < 5) { return 1; } else { @@ -29,7 +31,8 @@ function Module(stdlib, foreign, heap) { function foo3(i1) { i1 = i1 | 0; - var i10 = (i1 + 32 | 0) / 32 | 0; + var i10 = 0; + i10 = (i1 + 32 | 0) / 32 | 0; if (i10 >>> 0 < 5) { return 1; } else { diff --git a/deps/v8/test/mjsunit/asm/uint32div.js b/deps/v8/test/mjsunit/asm/uint32div.js index dcbb73bfa9..04b31a6dbb 100644 --- a/deps/v8/test/mjsunit/asm/uint32div.js +++ b/deps/v8/test/mjsunit/asm/uint32div.js @@ -9,13 +9,15 @@ var heap = new ArrayBuffer(64 * 1024); function Uint32Div(divisor) { var name = "div_"; name += divisor; - var m = eval("function Module(stdlib, foreign, heap) {\n" - + " \"use asm\";\n" - + " function " + name + "(dividend) {\n" - + " return ((dividend >>> 0) / " + divisor + ") >>> 0;\n" - + " }\n" - + " return { f: " + name + "}\n" - + "}; Module"); + var m = eval( + 'function Module(stdlib, foreign, heap) {\n' + + ' "use asm";\n' + + ' function ' + name + '(dividend) {\n' + + ' dividend = dividend | 0;\n' + + ' return ((dividend >>> 0) / ' + divisor + ') | 0;\n' + + ' }\n' + + ' return { f: ' + name + '}\n' + + '}; Module'); return m(stdlib, foreign, heap).f; } @@ -24,13 +26,15 @@ for (var i in divisors) { var divisor = divisors[i]; var div = Uint32Div(divisor); for (var dividend = 0; dividend < 4294967296; dividend += 3999773) { - assertEquals((dividend / divisor) >>> 0, div(dividend)); + assertEquals((dividend / divisor) | 0, div(dividend)); } } var div = (function(stdlib, foreign, heap) { "use asm"; function div(dividend, divisor) { + dividend = dividend | 0; + divisor = divisor | 0; return (dividend >>> 0) / (divisor >>> 0) | 0; } return {div: div}; diff --git a/deps/v8/test/mjsunit/asm/uint32mod-constant.js b/deps/v8/test/mjsunit/asm/uint32mod-constant.js index 4ba94dad20..562dcd11f9 100644 --- a/deps/v8/test/mjsunit/asm/uint32mod-constant.js +++ b/deps/v8/test/mjsunit/asm/uint32mod-constant.js @@ -9,13 +9,15 @@ var heap = new ArrayBuffer(64 * 1024); function Uint32Mod(divisor) { var name = "mod_"; name += divisor; - var m = eval("function Module(stdlib, foreign, heap) {\n" - + " \"use asm\";\n" - + " function " + name + "(dividend) {\n" - + " return ((dividend >>> 0) % " + divisor + ") >>> 0;\n" - + " }\n" - + " return { f: " + name + "}\n" - + "}; Module"); + var m = eval( + 'function Module(stdlib, foreign, heap) {\n' + + ' "use asm";\n' + + ' function ' + name + '(dividend) {\n' + + ' dividend = dividend | 0;\n' + + ' return ((dividend >>> 0) % ' + divisor + ') | 0;\n' + + ' }\n' + + ' return { f: ' + name + '}\n' + + '}; Module'); return m(stdlib, foreign, heap).f; } @@ -24,6 +26,6 @@ for (var i in divisors) { var divisor = divisors[i]; var mod = Uint32Mod(divisor); for (var dividend = 0; dividend < 4294967296; dividend += 3999773) { - assertEquals((dividend % divisor) >>> 0, mod(dividend)); + assertEquals((dividend % divisor) | 0, mod(dividend)); } } diff --git a/deps/v8/test/mjsunit/asm/uint32mod.js b/deps/v8/test/mjsunit/asm/uint32mod.js index fa40507c7f..137e64d7f9 100644 --- a/deps/v8/test/mjsunit/asm/uint32mod.js +++ b/deps/v8/test/mjsunit/asm/uint32mod.js @@ -9,9 +9,9 @@ var heap = new ArrayBuffer(64 * 1024); var mod = (function Module(stdlib, foreign, heap) { "use asm"; function mod(dividend, divisor) { - dividend = dividend >>> 0; - divisor = divisor >>> 0; - return (dividend % divisor) >>> 0; + dividend = dividend | 0; + divisor = divisor | 0; + return ((dividend >>> 0) % (divisor >>> 0)) | 0; } return { mod: mod }; })(stdlib, foreign, heap).mod; @@ -20,6 +20,6 @@ var divisors = [0, 1, 3, 4, 10, 42, 64, 100, 1024, 2147483647, 4294967295]; for (var i in divisors) { var divisor = divisors[i]; for (var dividend = 0; dividend < 4294967296; dividend += 3999773) { - assertEquals((dividend % divisor) >>> 0, mod(dividend, divisor)); + assertEquals((dividend % divisor) | 0, mod(dividend, divisor)); } } diff --git a/deps/v8/test/mjsunit/asm/uint8array-outofbounds.js b/deps/v8/test/mjsunit/asm/uint8array-outofbounds.js index 179efa4ba8..a4ab6bb4f0 100644 --- a/deps/v8/test/mjsunit/asm/uint8array-outofbounds.js +++ b/deps/v8/test/mjsunit/asm/uint8array-outofbounds.js @@ -8,7 +8,7 @@ function Module(stdlib, foreign, heap) { function load(i) { i = i|0; i = MEM8[i] | 0; - return i; + return i | 0; } function store(i, v) { i = i|0; diff --git a/deps/v8/test/mjsunit/asm/word32and.js b/deps/v8/test/mjsunit/asm/word32and.js index 6c41f882a1..392dba3c84 100644 --- a/deps/v8/test/mjsunit/asm/word32and.js +++ b/deps/v8/test/mjsunit/asm/word32and.js @@ -8,13 +8,15 @@ var heap = new ArrayBuffer(64 * 1024); function Word32And(rhs) { var name = "and_0x" + Number(rhs).toString(16); - var m = eval("function Module(stdlib, foreign, heap) {\n" - + " \"use asm\";\n" - + " function " + name + "(lhs) {\n" - + " return (lhs | 0) & 0x" + Number(rhs).toString(16) + ";\n" - + " }\n" - + " return { f: " + name + "}\n" - + "}; Module"); + var m = eval( + 'function Module(stdlib, foreign, heap) {\n' + + ' "use asm";\n' + + ' function ' + name + '(lhs) {\n' + + ' lhs = lhs | 0;\n' + + ' return (lhs & 0x' + Number(rhs).toString(16) + ') | 0;\n' + + ' }\n' + + ' return { f: ' + name + '}\n' + + '}; Module'); return m(stdlib, foreign, heap).f; } diff --git a/deps/v8/test/mjsunit/asm/word32ror.js b/deps/v8/test/mjsunit/asm/word32ror.js index 9535bdee8a..6891cd124f 100644 --- a/deps/v8/test/mjsunit/asm/word32ror.js +++ b/deps/v8/test/mjsunit/asm/word32ror.js @@ -11,7 +11,7 @@ var rol = (function Module(stdlib, foreign, heap) { function rol(x, y) { x = x | 0; y = y | 0; - return (x << y) | (x >>> (32 - y)); + return (x << y) | (x >>> (32 - y)) | 0; } return { rol: rol }; })(stdlib, foreign, heap).rol; @@ -26,7 +26,7 @@ var ror = (function Module(stdlib, foreign, heap) { function ror(x, y) { x = x | 0; y = y | 0; - return (x << (32 - y)) | (x >>> y); + return (x << (32 - y)) | (x >>> y) | 0; } return { ror: ror }; })(stdlib, foreign, heap).ror; diff --git a/deps/v8/test/mjsunit/asm/zero-extend.js b/deps/v8/test/mjsunit/asm/zero-extend.js index a1f9da65a2..3e34aac88b 100644 --- a/deps/v8/test/mjsunit/asm/zero-extend.js +++ b/deps/v8/test/mjsunit/asm/zero-extend.js @@ -10,8 +10,8 @@ var foreign = {} var zext8 = (function Module(stdlib, foreign, heap) { "use asm"; function zext8(i) { - i = i|0; - return i & 0xff; + i = i | 0; + return (i & 0xff) | 0; } return { zext8: zext8 }; })(stdlib, foreign, buffer).zext8; @@ -25,8 +25,8 @@ assertEquals(0xff, zext8(0xff)); var zext16 = (function Module(stdlib, foreign, heap) { "use asm"; function zext16(i) { - i = i|0; - return i & 0xffff; + i = i | 0; + return (i & 0xffff) | 0; } return { zext16: zext16 }; })(stdlib, foreign, buffer).zext16; diff --git a/deps/v8/test/mjsunit/assert-opt-and-deopt.js b/deps/v8/test/mjsunit/assert-opt-and-deopt.js index 19502f3354..c4f15cec08 100644 --- a/deps/v8/test/mjsunit/assert-opt-and-deopt.js +++ b/deps/v8/test/mjsunit/assert-opt-and-deopt.js @@ -44,18 +44,6 @@ function OptTracker() { } /** - * The possible optimization states of a function. Must be in sync with the - * return values of Runtime_GetOptimizationStatus() in runtime.cc! - * @enum {int} - */ -OptTracker.OptimizationState = { - YES: 1, - NO: 2, - ALWAYS: 3, - NEVER: 4 -}; - -/** * Always call this at the beginning of your test, once for each function * that you later want to track de/optimizations for. It is necessary because * tests are sometimes executed several times in a row, and you want to @@ -94,12 +82,10 @@ OptTracker.prototype.AssertIsOptimized = function(func, expect_optimized) { if (this.DisableAsserts_(func)) { return; } - var raw_optimized = %GetOptimizationStatus(func); - if (expect_optimized) { - assertEquals(OptTracker.OptimizationState.YES, raw_optimized); - } else { - assertEquals(OptTracker.OptimizationState.NO, raw_optimized); - } + var opt_status = %GetOptimizationStatus(func); + assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0); + assertEquals(expect_optimized, + (opt_status & V8OptimizationStatus.kOptimized) !== 0); } /** @@ -119,7 +105,8 @@ OptTracker.prototype.GetOptCount_ = function(func) { */ OptTracker.prototype.GetDeoptCount_ = function(func) { var count = this.GetOptCount_(func); - if (%GetOptimizationStatus(func) == OptTracker.OptimizationState.YES) { + var opt_status = %GetOptimizationStatus(func); + if ((opt_status & V8OptimizationStatus.kOptimized) !== 0) { count -= 1; } return count; @@ -129,15 +116,9 @@ OptTracker.prototype.GetDeoptCount_ = function(func) { * @private */ OptTracker.prototype.DisableAsserts_ = function(func) { - switch(%GetOptimizationStatus(func)) { - case OptTracker.OptimizationState.YES: - case OptTracker.OptimizationState.NO: - return false; - case OptTracker.OptimizationState.ALWAYS: - case OptTracker.OptimizationState.NEVER: - return true; - } - return true; + var opt_status = %GetOptimizationStatus(func); + return (opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0 || + (opt_status & V8OptimizationStatus.kNeverOptimize) !== 0; } // (End of class OptTracker.) diff --git a/deps/v8/test/mjsunit/code-coverage-ad-hoc.js b/deps/v8/test/mjsunit/code-coverage-ad-hoc.js new file mode 100644 index 0000000000..9289c2152a --- /dev/null +++ b/deps/v8/test/mjsunit/code-coverage-ad-hoc.js @@ -0,0 +1,74 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --no-always-opt + +// Test code coverage without explicitly activating it upfront. + +function GetCoverage(source) { + for (var script of %DebugCollectCoverage()) { + if (script.script.source == source) return script; + } + return undefined; +} + +function TestCoverage(name, source, expectation) { + source = source.trim(); + eval(source); + var coverage = GetCoverage(source); + var result = JSON.stringify(coverage); + print(result); + assertEquals(JSON.stringify(expectation), result, name + " failed"); +} + +TestCoverage( +"call simple function twice", +` +function f() {} +f(); +f(); +`, +[{"start":0,"end":25,"count":1}, + {"start":0,"end":15,"count":2}] +); + +TestCoverage( +"call arrow function twice", +` +var f = () => 1; +f(); +f(); +`, +[{"start":0,"end":26,"count":1}, + {"start":8,"end":15,"count":2}] +); + +TestCoverage( +"call nested function", +` +function f() { + function g() {} + g(); + g(); +} +f(); +f(); +`, +[{"start":0,"end":58,"count":1}, + {"start":0,"end":48,"count":2}, + {"start":17,"end":32,"count":4}] +); + +TestCoverage( +"call recursive function", +` +function fib(x) { + if (x < 2) return 1; + return fib(x-1) + fib(x-2); +} +fib(5); +`, +[{"start":0,"end":80,"count":1}, + {"start":0,"end":72,"count":15}] +); diff --git a/deps/v8/test/mjsunit/code-coverage-precise.js b/deps/v8/test/mjsunit/code-coverage-precise.js new file mode 100644 index 0000000000..03015f9202 --- /dev/null +++ b/deps/v8/test/mjsunit/code-coverage-precise.js @@ -0,0 +1,68 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --no-always-opt + +// Test precise code coverage. + +function GetCoverage(source) { + for (var script of %DebugCollectCoverage()) { + if (script.script.source == source) return script; + } + return undefined; +} + +function TestCoverage(name, source, expectation) { + source = source.trim(); + eval(source); + %CollectGarbage("collect dead objects"); + var coverage = GetCoverage(source); + var result = JSON.stringify(coverage); + print(result); + assertEquals(JSON.stringify(expectation), result, name + " failed"); +} + +// Without precise coverage enabled, we lose coverage data to the GC. +TestCoverage( +"call an IIFE", +` +(function f() {})(); +`, +undefined // The IIFE has been garbage-collected. +); + +TestCoverage( +"call locally allocated function", +` +for (var i = 0; i < 10; i++) { + let f = () => 1; + i += f(); +} +`, +undefined +); + +// This does not happen with precise coverage enabled. +%DebugTogglePreciseCoverage(true); + +TestCoverage( +"call an IIFE", +` +(function f() {})(); +`, +[{"start":0,"end":20,"count":1},{"start":1,"end":16,"count":1}] +); + +TestCoverage( +"call locally allocated function", +` +for (var i = 0; i < 10; i++) { + let f = () => 1; + i += f(); +} +`, +[{"start":0,"end":63,"count":1},{"start":41,"end":48,"count":5}] +); + +%DebugTogglePreciseCoverage(false); diff --git a/deps/v8/test/mjsunit/compiler/alloc-object.js b/deps/v8/test/mjsunit/compiler/alloc-object.js index 0e593a49b3..5876134342 100644 --- a/deps/v8/test/mjsunit/compiler/alloc-object.js +++ b/deps/v8/test/mjsunit/compiler/alloc-object.js @@ -53,7 +53,7 @@ function test(construct) { assertEquals(5, o.y); assertEquals(6, o.z); %DeoptimizeFunction(test_helper); - %ClearFunctionTypeFeedback(test_helper); + %ClearFunctionFeedback(test_helper); } function finalize_slack_tracking(construct) { diff --git a/deps/v8/test/mjsunit/compiler/concurrent-invalidate-transition-map.js b/deps/v8/test/mjsunit/compiler/concurrent-invalidate-transition-map.js index ab7d6d50ee..5d3c73b4e6 100644 --- a/deps/v8/test/mjsunit/compiler/concurrent-invalidate-transition-map.js +++ b/deps/v8/test/mjsunit/compiler/concurrent-invalidate-transition-map.js @@ -27,6 +27,7 @@ // Flags: --track-fields --track-double-fields --allow-natives-syntax // Flags: --concurrent-recompilation --block-concurrent-recompilation +// Flags: --no-always-opt if (!%IsConcurrentRecompilationSupported()) { print("Concurrent recompilation is disabled. Skipping this test."); @@ -41,6 +42,9 @@ function new_object() { } function add_field(obj) { + // Assign twice to make the field non-constant. + // TODO(ishell): update test once constant field tracking is done. + obj.c = 0; obj.c = 3; } var obj1 = new_object(); @@ -61,4 +65,4 @@ assertUnoptimized(add_field, "no sync"); // Sync with background thread to conclude optimization that bailed out. assertUnoptimized(add_field, "sync"); // Clear type info for stress runs. -%ClearFunctionTypeFeedback(add_field); +%ClearFunctionFeedback(add_field); diff --git a/deps/v8/test/mjsunit/compiler/concurrent-proto-change.js b/deps/v8/test/mjsunit/compiler/concurrent-proto-change.js index 3abf292c92..0a016ac3ca 100644 --- a/deps/v8/test/mjsunit/compiler/concurrent-proto-change.js +++ b/deps/v8/test/mjsunit/compiler/concurrent-proto-change.js @@ -25,8 +25,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --no-always-opt // Flags: --concurrent-recompilation --block-concurrent-recompilation +// Flags: --no-always-opt if (!%IsConcurrentRecompilationSupported()) { print("Concurrent recompilation is disabled. Skipping this test."); @@ -55,4 +56,4 @@ assertUnoptimized(f, "no sync"); assertUnoptimized(f, "sync"); assertEquals(2, f(o)); //Clear type info for stress runs. -%ClearFunctionTypeFeedback(f); +%ClearFunctionFeedback(f); diff --git a/deps/v8/test/mjsunit/compiler/deopt-inlined-from-call.js b/deps/v8/test/mjsunit/compiler/deopt-inlined-from-call.js index 24d73546f6..db9eb96824 100644 --- a/deps/v8/test/mjsunit/compiler/deopt-inlined-from-call.js +++ b/deps/v8/test/mjsunit/compiler/deopt-inlined-from-call.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --noalways-opt +// Flags: --allow-natives-syntax --crankshaft --no-always-opt var global = this; diff --git a/deps/v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js b/deps/v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js index 51faef0952..493d88a421 100644 --- a/deps/v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js +++ b/deps/v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft (function() { function foo(x, y) { return x << y; } diff --git a/deps/v8/test/mjsunit/compiler/deopt-string-outofbounds.js b/deps/v8/test/mjsunit/compiler/deopt-string-outofbounds.js index 2a9f6a1c38..ef85eee2b2 100644 --- a/deps/v8/test/mjsunit/compiler/deopt-string-outofbounds.js +++ b/deps/v8/test/mjsunit/compiler/deopt-string-outofbounds.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt var s = "12345"; diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis-15.js b/deps/v8/test/mjsunit/compiler/escape-analysis-15.js new file mode 100644 index 0000000000..4ebd0f7887 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/escape-analysis-15.js @@ -0,0 +1,19 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --turbo --turbo-escape --turbo-experimental --no-turbo-load-elimination + +function f(i) { + var o1 = {a: 1, b: 2}; + var o2 = {a: 1, b: 3}; + var o3 = {a: o2.b}; + o3.a = ""; + o2.a = o1; + if (i == 4) return o3; +} +for (var i = 0; i < 100; ++i){ + f(i%5) +} +%OptimizeFunctionOnNextCall(f); +f(false); diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis-representation.js b/deps/v8/test/mjsunit/compiler/escape-analysis-representation.js index 8e21a36b40..127d92ea7d 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis-representation.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis-representation.js @@ -60,7 +60,7 @@ function test(value_track, value_break) { access(value_track, value_break(), deopt); // Clear type feedback of the access function for next run. - %ClearFunctionTypeFeedback(access); + %ClearFunctionFeedback(access); // Also make sure the initial map of the constructor is reset. constructor.prototype = {}; diff --git a/deps/v8/test/mjsunit/compiler/increment-typefeedback.js b/deps/v8/test/mjsunit/compiler/increment-typefeedback.js index 798959296c..dca488b13f 100644 --- a/deps/v8/test/mjsunit/compiler/increment-typefeedback.js +++ b/deps/v8/test/mjsunit/compiler/increment-typefeedback.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function f(x) { x++; diff --git a/deps/v8/test/mjsunit/compiler/inline-accessors.js b/deps/v8/test/mjsunit/compiler/inline-accessors.js index a4cf7ae8c1..90e0263b42 100644 --- a/deps/v8/test/mjsunit/compiler/inline-accessors.js +++ b/deps/v8/test/mjsunit/compiler/inline-accessors.js @@ -78,8 +78,8 @@ function TryGetter(context, getter, obj, expected, expectException) { assertEquals(7, exception.stack.split('\n').length); } %DeoptimizeFunction(context); - %ClearFunctionTypeFeedback(context); - %ClearFunctionTypeFeedback(getter); + %ClearFunctionFeedback(context); + %ClearFunctionFeedback(getter); } function TestGetterInAllContexts(getter, obj, expected, expectException) { @@ -239,8 +239,8 @@ function TrySetter(context, setter, obj, expectException, value, expected) { assertEquals(7, exception.stack.split('\n').length); } %DeoptimizeFunction(context); - %ClearFunctionTypeFeedback(context); - %ClearFunctionTypeFeedback(setter); + %ClearFunctionFeedback(context); + %ClearFunctionFeedback(setter); } function TestSetterInAllContexts(setter, obj, expectException) { diff --git a/deps/v8/test/mjsunit/compiler/inline-arguments.js b/deps/v8/test/mjsunit/compiler/inline-arguments.js index 1337ab237a..1579926e24 100644 --- a/deps/v8/test/mjsunit/compiler/inline-arguments.js +++ b/deps/v8/test/mjsunit/compiler/inline-arguments.js @@ -253,9 +253,9 @@ test_toarr(toarr2); %DeoptimizeFunction(outer); %DeoptimizeFunction(middle); %DeoptimizeFunction(inner); - %ClearFunctionTypeFeedback(outer); - %ClearFunctionTypeFeedback(middle); - %ClearFunctionTypeFeedback(inner); + %ClearFunctionFeedback(outer); + %ClearFunctionFeedback(middle); + %ClearFunctionFeedback(inner); } for (var a = 1; a <= 3; a++) { diff --git a/deps/v8/test/mjsunit/compiler/inline-construct.js b/deps/v8/test/mjsunit/compiler/inline-construct.js index fa784cfc99..aea1bb4848 100644 --- a/deps/v8/test/mjsunit/compiler/inline-construct.js +++ b/deps/v8/test/mjsunit/compiler/inline-construct.js @@ -53,8 +53,8 @@ function TestInlinedConstructor(constructor, closure) { assertEquals(4, counter.value); %DeoptimizeFunction(closure); - %ClearFunctionTypeFeedback(closure); - %ClearFunctionTypeFeedback(constructor); + %ClearFunctionFeedback(closure); + %ClearFunctionFeedback(constructor); } function value_context(constructor, val, deopt, counter) { diff --git a/deps/v8/test/mjsunit/compiler/inline-function-apply.js b/deps/v8/test/mjsunit/compiler/inline-function-apply.js index 6b761f4df8..12238e1c53 100644 --- a/deps/v8/test/mjsunit/compiler/inline-function-apply.js +++ b/deps/v8/test/mjsunit/compiler/inline-function-apply.js @@ -76,11 +76,11 @@ assertEquals("ABC", A(1,2)); %DeoptimizeFunction(A); - %ClearFunctionTypeFeedback(A); + %ClearFunctionFeedback(A); %DeoptimizeFunction(B); - %ClearFunctionTypeFeedback(B); + %ClearFunctionFeedback(B); %DeoptimizeFunction(C); - %ClearFunctionTypeFeedback(C); + %ClearFunctionFeedback(C); } for (var a = 1; a <= 3; a++) { diff --git a/deps/v8/test/mjsunit/compiler/inlined-array-pop-opt.js b/deps/v8/test/mjsunit/compiler/inlined-array-pop-opt.js index c1301489e7..8263fc2f37 100644 --- a/deps/v8/test/mjsunit/compiler/inlined-array-pop-opt.js +++ b/deps/v8/test/mjsunit/compiler/inlined-array-pop-opt.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft (function() { function foo(a) { return a.pop(); } diff --git a/deps/v8/test/mjsunit/compiler/inlined-call.js b/deps/v8/test/mjsunit/compiler/inlined-call.js index f296b08798..97f2514387 100644 --- a/deps/v8/test/mjsunit/compiler/inlined-call.js +++ b/deps/v8/test/mjsunit/compiler/inlined-call.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft var global = this; diff --git a/deps/v8/test/mjsunit/compiler/integral32-add-sub.js b/deps/v8/test/mjsunit/compiler/integral32-add-sub.js index 2dd370c9dd..2aab6e0f2e 100644 --- a/deps/v8/test/mjsunit/compiler/integral32-add-sub.js +++ b/deps/v8/test/mjsunit/compiler/integral32-add-sub.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft (function() { function foo(x) { diff --git a/deps/v8/test/mjsunit/compiler/literals.js b/deps/v8/test/mjsunit/compiler/literals.js index 3bda9fc472..49de2e10f2 100644 --- a/deps/v8/test/mjsunit/compiler/literals.js +++ b/deps/v8/test/mjsunit/compiler/literals.js @@ -71,6 +71,10 @@ assertThrows('"\\u111G"'); assertEquals("\\x1G", /\x1G/.source); assertEquals("\\u111G", /\u111G/.source); +// Test that octal literals continue to be forbidden in template even +// when followed by a string containing an octal literal. +assertThrows('`\\1`\n"\\1"'); + // Test some materialized array literals. assertEquals([1,2,3,4], eval('[1,2,3,4]')); assertEquals([[1,2],3,4], eval('[[1,2],3,4]')); diff --git a/deps/v8/test/mjsunit/compiler/manual-concurrent-recompile.js b/deps/v8/test/mjsunit/compiler/manual-concurrent-recompile.js index 66245ef073..cd1861185d 100644 --- a/deps/v8/test/mjsunit/compiler/manual-concurrent-recompile.js +++ b/deps/v8/test/mjsunit/compiler/manual-concurrent-recompile.js @@ -27,6 +27,7 @@ // Flags: --allow-natives-syntax --expose-gc // Flags: --concurrent-recompilation --block-concurrent-recompilation +// Flags: --crankshaft --no-always-opt if (!%IsConcurrentRecompilationSupported()) { print("Concurrent recompilation is disabled. Skipping this test."); diff --git a/deps/v8/test/mjsunit/compiler/opt-next-call-turbo.js b/deps/v8/test/mjsunit/compiler/opt-next-call-turbo.js index d4beff9f6e..39f29c9e5c 100644 --- a/deps/v8/test/mjsunit/compiler/opt-next-call-turbo.js +++ b/deps/v8/test/mjsunit/compiler/opt-next-call-turbo.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo-filter=* +// Flags: --allow-natives-syntax --crankshaft --turbo-filter=* function foo() { with ({ value:"fooed" }) { return value; } diff --git a/deps/v8/test/mjsunit/compiler/opt-next-call.js b/deps/v8/test/mjsunit/compiler/opt-next-call.js index 3d7e74f626..f1ae5bda09 100644 --- a/deps/v8/test/mjsunit/compiler/opt-next-call.js +++ b/deps/v8/test/mjsunit/compiler/opt-next-call.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function foo() { return "fooed"; diff --git a/deps/v8/test/mjsunit/compiler/optimized-float32array-length.js b/deps/v8/test/mjsunit/compiler/optimized-float32array-length.js index eed8922c07..6fde8d6daf 100644 --- a/deps/v8/test/mjsunit/compiler/optimized-float32array-length.js +++ b/deps/v8/test/mjsunit/compiler/optimized-float32array-length.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft var a = new Float32Array(1); function len(a) { return a.length; } diff --git a/deps/v8/test/mjsunit/compiler/optimized-float64array-length.js b/deps/v8/test/mjsunit/compiler/optimized-float64array-length.js index f6a3d77677..13a7539054 100644 --- a/deps/v8/test/mjsunit/compiler/optimized-float64array-length.js +++ b/deps/v8/test/mjsunit/compiler/optimized-float64array-length.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft var a = new Float64Array(1); function len(a) { return a.length; } diff --git a/deps/v8/test/mjsunit/compiler/optimized-int32array-length.js b/deps/v8/test/mjsunit/compiler/optimized-int32array-length.js index 250d523cc9..cd1b7a775a 100644 --- a/deps/v8/test/mjsunit/compiler/optimized-int32array-length.js +++ b/deps/v8/test/mjsunit/compiler/optimized-int32array-length.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft var a = new Int32Array(1); function len(a) { return a.length; } diff --git a/deps/v8/test/mjsunit/compiler/optimized-uint32array-length.js b/deps/v8/test/mjsunit/compiler/optimized-uint32array-length.js index d389370a4f..fe56e68cb5 100644 --- a/deps/v8/test/mjsunit/compiler/optimized-uint32array-length.js +++ b/deps/v8/test/mjsunit/compiler/optimized-uint32array-length.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft var a = new Uint32Array(1); function len(a) { return a.length; } diff --git a/deps/v8/test/mjsunit/compiler/regress-5320.js b/deps/v8/test/mjsunit/compiler/regress-5320.js index 2e30a7b4f5..7e76ee735f 100644 --- a/deps/v8/test/mjsunit/compiler/regress-5320.js +++ b/deps/v8/test/mjsunit/compiler/regress-5320.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function OptimizeTruncatingBinaryOp(func) { func(42, -2); diff --git a/deps/v8/test/mjsunit/compiler/regress-675704.js b/deps/v8/test/mjsunit/compiler/regress-675704.js new file mode 100644 index 0000000000..788f92e530 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-675704.js @@ -0,0 +1,26 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function foo(a) { + this.a = a; + // Note that any call would do, it doesn't need to be %MaxSmi() + this.x = this.a + %MaxSmi(); +} + +function g(x) { + new foo(2); + + if (x) { + for (var i = 0.1; i < 1.1; i++) { + new foo(i); + } + } +} + +g(false); +g(false); +%OptimizeFunctionOnNextCall(g); +g(true); diff --git a/deps/v8/test/mjsunit/compiler/regress-strict-equals-mixed-feedback.js b/deps/v8/test/mjsunit/compiler/regress-strict-equals-mixed-feedback.js index cf41617096..6c429d9386 100644 --- a/deps/v8/test/mjsunit/compiler/regress-strict-equals-mixed-feedback.js +++ b/deps/v8/test/mjsunit/compiler/regress-strict-equals-mixed-feedback.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function bar(x, y) { return x === y; diff --git a/deps/v8/test/mjsunit/compiler/shift-shr.js b/deps/v8/test/mjsunit/compiler/shift-shr.js index 52cd370e42..c52ad43ac5 100644 --- a/deps/v8/test/mjsunit/compiler/shift-shr.js +++ b/deps/v8/test/mjsunit/compiler/shift-shr.js @@ -24,3 +24,32 @@ assertEquals(0, test_shr(1)); for (var i = 5; i >= -5; i--) { assertEquals(0, test_shr(i)); } + + +(function () { + function foo(x, b, array) { + var y; + x = x >>> 0; + b ? (y = x | 0) : (y = x); + return array[y]; + } + + foo(111, true, new Array(42)); + foo(111, true, new Array(42)); + %OptimizeFunctionOnNextCall(foo); + foo(-111, true, new Array(42)); +})(); + +(function () { + function foo(x, b, array) { + var y; + x = x >>> 0; + b ? (y = x | 0) : (y = x); + return array[y]; + } + + foo(111, true, new Array(42)); + foo(111, true, new Array(42)); + %OptimizeFunctionOnNextCall(foo); + foo(111, true, new Array(42)); +})(); diff --git a/deps/v8/test/mjsunit/compiler/uint8-clamped-array.js b/deps/v8/test/mjsunit/compiler/uint8-clamped-array.js index 66274d54d1..17a0ad400e 100644 --- a/deps/v8/test/mjsunit/compiler/uint8-clamped-array.js +++ b/deps/v8/test/mjsunit/compiler/uint8-clamped-array.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft (function() { function foo(a, v) { diff --git a/deps/v8/test/mjsunit/concurrent-initial-prototype-change.js b/deps/v8/test/mjsunit/concurrent-initial-prototype-change.js index 6c9a9f4d56..4a7241c84f 100644 --- a/deps/v8/test/mjsunit/concurrent-initial-prototype-change.js +++ b/deps/v8/test/mjsunit/concurrent-initial-prototype-change.js @@ -27,7 +27,7 @@ // Flags: --allow-natives-syntax // Flags: --concurrent-recompilation --block-concurrent-recompilation -// Flags: --nostress-opt +// Flags: --nostress-opt --no-always-opt // --nostress-opt is in place because this particular optimization // (guaranteeing that the Array prototype chain has no elements) is @@ -64,4 +64,4 @@ assertUnoptimized(f1, "no sync"); // due to map dependency. assertUnoptimized(f1, "sync"); //Clear type info for stress runs. -%ClearFunctionTypeFeedback(f1); +%ClearFunctionFeedback(f1); diff --git a/deps/v8/test/mjsunit/const-field-tracking.js b/deps/v8/test/mjsunit/const-field-tracking.js new file mode 100644 index 0000000000..ab1dbc1b23 --- /dev/null +++ b/deps/v8/test/mjsunit/const-field-tracking.js @@ -0,0 +1,268 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --crankshaft --no-always-opt + +var global = this; + +// TODO(ishell): update the test once const->mutable migration does not +// create a new map. +var IS_INPLACE_MAP_MODIFICATION_SUPPORTED = false; + +var unique_id = 0; +// Creates a function with unique SharedFunctionInfo to ensure the feedback +// vector is unique for each test case. +function MakeFunctionWithUniqueSFI(...args) { + assertTrue(args.length > 0); + var body = `/* Unique comment: ${unique_id++} */ ` + args.pop(); + return new Function(...args, body); +} + + +// +// Load constant field from constant object directly. +// +function TestLoadFromConstantFieldOfAConstantObject(the_value, other_value) { + function A(v) { this.v = v; } + function O() { this.a = new A(the_value); } + var the_object = new O(); + + // Ensure that {the_object.a}'s map is not stable to complicate compiler's + // life. + new A(the_value).blah = 0; + + // Ensure that constant tracking is enabled for {contant_object}. + delete global.constant_object; + global.constant_object = the_object; + assertEquals(the_object, constant_object); + + assertTrue(%HasFastProperties(the_object)); + + // {constant_object} is known to the compiler via global property cell + // tracking. + var load = MakeFunctionWithUniqueSFI("return constant_object.a.v;"); + load(); + load(); + %OptimizeFunctionOnNextCall(load); + assertEquals(the_value, load()); + assertOptimized(load); + if (IS_INPLACE_MAP_MODIFICATION_SUPPORTED) { + var a = new A(other_value); + assertTrue(%HaveSameMap(a, the_object.a)); + // Make constant field mutable by assigning another value + // to some other instance of A. + new A(the_value).v = other_value; + assertTrue(%HaveSameMap(a, new A(the_value))); + assertTrue(%HaveSameMap(a, the_object.a)); + assertUnoptimized(load); + assertEquals(the_value, load()); + } else { + var a = new A(other_value); + assertTrue(%HaveSameMap(a, the_object.a)); + // Make constant field mutable by assigning another value + // to some other instance of A. + new A(the_value).v = other_value; + assertOptimized(load); + assertTrue(!%HaveSameMap(a, new A(the_value))); + + assertTrue(%HaveSameMap(a, the_object.a)); + // Ensure the {the_object.a} migrated to an up-to date version of a map + // by loading a property through IC. + assertEquals(the_value, the_object.a.v); + assertTrue(!%HaveSameMap(a, the_object.a)); + assertOptimized(load); + + // Now attempt to call load should deoptimize because of failed map check. + assertEquals(the_value, load()); + } + assertUnoptimized(load); + assertEquals(the_value, load()); +} + +// Test constant tracking with Smi value. +(function() { + var the_value = 42; + var other_value = 153; + TestLoadFromConstantFieldOfAConstantObject(the_value, other_value); +})(); + +// Test constant tracking with double value. +(function() { + var the_value = 0.9; + var other_value = 0.42; + TestLoadFromConstantFieldOfAConstantObject(the_value, other_value); +})(); + +// Test constant tracking with function value. +(function() { + var the_value = function V() {}; + var other_value = function W() {}; + TestLoadFromConstantFieldOfAConstantObject(the_value, other_value); +})(); + +// Test constant tracking with heap object value. +(function() { + function V() {} + var the_value = new V(); + var other_value = new V(); + TestLoadFromConstantFieldOfAConstantObject(the_value, other_value); +})(); + + +// +// Load constant field from a prototype. +// +function TestLoadFromConstantFieldOfAPrototype(the_value, other_value) { + function Proto() { this.v = the_value; } + var the_prototype = new Proto(); + + function O() {} + O.prototype = the_prototype; + var the_object = new O(); + + // Ensure O.prototype is in fast mode by loading from its field. + function warmup() { return new O().v; } + warmup(); warmup(); warmup(); + assertTrue(%HasFastProperties(O.prototype)); + + // The parameter object is not constant but all the values have the same + // map and therefore the compiler knows the prototype object and can + // optimize load of "v". + var load = MakeFunctionWithUniqueSFI("o", "return o.v;"); + load(new O()); + load(new O()); + %OptimizeFunctionOnNextCall(load); + assertEquals(the_value, load(new O())); + assertOptimized(load); + if (IS_INPLACE_MAP_MODIFICATION_SUPPORTED) { + // Invalidation of mutability should trigger deoptimization with a + // "field-owner" reason. + the_prototype.v = other_value; + } else { + // Invalidation of mutability should trigger deoptimization with a + // "prototype-check" (stability) reason. + the_prototype.v = other_value; + } + assertUnoptimized(load); +} + +// Test constant tracking with Smi value. +(function() { + var the_value = 42; + var other_value = 153; + TestLoadFromConstantFieldOfAPrototype(the_value, other_value); +})(); + +// Test constant tracking with double value. +(function() { + var the_value = 0.9; + var other_value = 0.42; + TestLoadFromConstantFieldOfAPrototype(the_value, other_value); +})(); + +// Test constant tracking with function value. +(function() { + var the_value = function V() {}; + var other_value = function W() {}; + TestLoadFromConstantFieldOfAPrototype(the_value, other_value); +})(); + +// Test constant tracking with heap object value. +(function() { + function V() {} + var the_value = new V(); + var other_value = new V(); + TestLoadFromConstantFieldOfAPrototype(the_value, other_value); +})(); + + +// +// Store to constant field of a constant object. +// +function TestStoreToConstantFieldOfConstantObject(the_value, other_value) { + function A(v) { this.v = v; } + function O() { this.a = new A(the_value); } + var the_object = new O(); + + // Ensure that {the_object.a}'s map is not stable to complicate compiler's + // life. + new A(the_value).blah = 0; + + // Ensure that constant tracking is enabled for {contant_object}. + delete global.constant_object; + global.constant_object = the_object; + assertEquals(the_object, constant_object); + + assertTrue(%HasFastProperties(the_object)); + + // {constant_object} is known to the compiler via global property cell + // tracking. + var store = MakeFunctionWithUniqueSFI("v", "constant_object.a.v = v;"); + store(the_value); + store(the_value); + %OptimizeFunctionOnNextCall(store); + store(the_value); + assertEquals(the_value, constant_object.a.v); + assertOptimized(store); + // Storing of the same value does not deoptimize. + store(the_value); + assertEquals(the_value, constant_object.a.v); + assertOptimized(store); + + if (IS_INPLACE_MAP_MODIFICATION_SUPPORTED) { + var a = new A(other_value); + + if (typeof the_value == "function" || typeof the_value == "object") { + // For heap object fields "field-owner" dependency is installed for + // any access of the field, therefore making constant field mutable by + // assigning other value to some other instance of A should already + // trigger deoptimization. + assertTrue(%HaveSameMap(a, the_object.a)); + new A(the_value).v = other_value; + assertTrue(%HaveSameMap(a, new A(the_value))); + assertTrue(%HaveSameMap(a, the_object.a)); + assertUnoptimized(store); + } else { + assertOptimized(store); + } + // Storing other value deoptimizes because of failed value check. + store(other_value); + assertUnoptimized(store); + assertEquals(other_value, constant_object.a.v); + } else { + // Storing other value deoptimizes because of failed value check. + store(other_value); + assertUnoptimized(store); + assertEquals(other_value, constant_object.a.v); + } +} + +// Test constant tracking with Smi values. +(function() { + var the_value = 42; + var other_value = 153; + TestStoreToConstantFieldOfConstantObject(the_value, other_value); +})(); + +// Test constant tracking with double values. +(function() { + var the_value = 0.9; + var other_value = 0.42 + TestStoreToConstantFieldOfConstantObject(the_value, other_value); +})(); + +// Test constant tracking with function values. +(function() { + var the_value = function V() {}; + var other_value = function W() {}; + TestStoreToConstantFieldOfConstantObject(the_value, other_value); +})(); + +// Test constant tracking with heap object values. +(function() { + function V() {} + var the_value = new V(); + var other_value = new V(); + TestStoreToConstantFieldOfConstantObject(the_value, other_value); +})(); diff --git a/deps/v8/test/mjsunit/constant-folding-2.js b/deps/v8/test/mjsunit/constant-folding-2.js index 3f82c2fa43..e9bea0aab5 100644 --- a/deps/v8/test/mjsunit/constant-folding-2.js +++ b/deps/v8/test/mjsunit/constant-folding-2.js @@ -26,7 +26,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --nodead-code-elimination --fold-constants --allow-natives-syntax --nostress-opt +// Flags: --nodead-code-elimination --fold-constants +// Flags: --allow-natives-syntax --nostress-opt --crankshaft function test(f) { f(); diff --git a/deps/v8/test/mjsunit/date-parse.js b/deps/v8/test/mjsunit/date-parse.js index e623827df7..62dddfd1c2 100644 --- a/deps/v8/test/mjsunit/date-parse.js +++ b/deps/v8/test/mjsunit/date-parse.js @@ -245,9 +245,9 @@ var testCasesES5Misc = [ ['2000-01T08:00:00.099Z', 946713600099], ['2000-01T08:00:00.999Z', 946713600999], ['2000-01T00:00:00.001-08:00', 946713600001], - ['2000-01-01T24:00', 946771200000], - ['2000-01-01T24:00:00', 946771200000], - ['2000-01-01T24:00:00.000', 946771200000], + ['2000-01-01T24:00Z', 946771200000], + ['2000-01-01T24:00:00Z', 946771200000], + ['2000-01-01T24:00:00.000Z', 946771200000], ['2000-01-01T24:00:00.000Z', 946771200000]]; var testCasesES5MiscNegative = [ @@ -261,6 +261,31 @@ var testCasesES5MiscNegative = [ '2000-01-01T24:00:00.001', '2000-01-01T24:00:00.999Z']; +// TODO(littledan): This is an hack that could break in historically +// changing timezones that happened on this day, but allows us to +// check the date value for local times. +var localOffset = new Date('2000-01-01').getTimezoneOffset()*1000*60; + +// Sanity check which is even more of a hack: in the timezones where +// these tests are likely to be run, the offset is nonzero because +// dates which don't include Z are in the local timezone. +if (this.Intl && + ["America/Los_Angeles", "Europe/Berlin", "Europe/Madrid"].indexOf( + Intl.DateTimeFormat().resolvedOptions().timeZone) != -1) { + assertTrue(localOffset != 0); +} + +var testCasesES2016TZ = [ + // If the timezone is absent and time is present, use local time + ['2000-01-02T00:00', 946771200000 + localOffset], + ['2000-01-02T00:00:00', 946771200000 + localOffset], + ['2000-01-02T00:00:00.000', 946771200000 + localOffset], + // If timezone is absent and time is absent, use UTC + ['2000-01-02', 946771200000], + ['2000-01-02', 946771200000], + ['2000-01-02', 946771200000], +]; + // Run all the tests. testCasesUT.forEach(testDateParse); @@ -282,6 +307,7 @@ testCasesES5MiscNegative.forEach(function (s) { assertTrue(isNaN(Date.parse(s)), s + " is not NaN."); }); +testCasesES2016TZ.forEach(testDateParseMisc); // Test that we can parse our own date format. // (Dates from 1970 to ~2070 with 150h steps.) diff --git a/deps/v8/test/mjsunit/date.js b/deps/v8/test/mjsunit/date.js index 244a04202c..b7d78bbec7 100644 --- a/deps/v8/test/mjsunit/date.js +++ b/deps/v8/test/mjsunit/date.js @@ -193,110 +193,112 @@ assertEquals(-8640000000000000, Date.UTC(1970, 0, 1 - 100000001, 24)); // Parsing ES5 ISO-8601 dates. -// When TZ is omitted, it defaults to 'Z' meaning UTC. +// When TZ is omitted, it defaults to the local timezone if there is +// no time, and to UTC if a time is provided. This file tests the +// "timezone present" case; timezone absent is tested by test/mjsunit/date-parse.js // Check epoch. assertEquals(0, Date.parse("1970-01-01T00:00:00.000+00:00")); assertEquals(0, Date.parse("1970-01-01T00:00:00.000-00:00")); assertEquals(0, Date.parse("1970-01-01T00:00:00.000Z")); -assertEquals(0, Date.parse("1970-01-01T00:00:00.000")); -assertEquals(0, Date.parse("1970-01-01T00:00:00")); -assertEquals(0, Date.parse("1970-01-01T00:00")); -assertEquals(0, Date.parse("1970-01-01")); +assertEquals(0, Date.parse("1970-01-01T00:00:00.000Z")); +assertEquals(0, Date.parse("1970-01-01T00:00:00Z")); +assertEquals(0, Date.parse("1970-01-01T00:00Z")); +assertEquals(0, Date.parse("1970-01-01Z")); assertEquals(0, Date.parse("1970-01T00:00:00.000+00:00")); assertEquals(0, Date.parse("1970-01T00:00:00.000-00:00")); assertEquals(0, Date.parse("1970-01T00:00:00.000Z")); -assertEquals(0, Date.parse("1970-01T00:00:00.000")); -assertEquals(0, Date.parse("1970-01T00:00:00")); -assertEquals(0, Date.parse("1970-01T00:00")); -assertEquals(0, Date.parse("1970-01")); +assertEquals(0, Date.parse("1970-01T00:00:00.000Z")); +assertEquals(0, Date.parse("1970-01T00:00:00Z")); +assertEquals(0, Date.parse("1970-01T00:00Z")); +assertEquals(0, Date.parse("1970-01Z")); assertEquals(0, Date.parse("1970T00:00:00.000+00:00")); assertEquals(0, Date.parse("1970T00:00:00.000-00:00")); assertEquals(0, Date.parse("1970T00:00:00.000Z")); -assertEquals(0, Date.parse("1970T00:00:00.000")); -assertEquals(0, Date.parse("1970T00:00:00")); -assertEquals(0, Date.parse("1970T00:00")); -assertEquals(0, Date.parse("1970")); +assertEquals(0, Date.parse("1970T00:00:00.000Z")); +assertEquals(0, Date.parse("1970T00:00:00Z")); +assertEquals(0, Date.parse("1970T00:00Z")); +assertEquals(0, Date.parse("1970Z")); assertEquals(0, Date.parse("+001970-01-01T00:00:00.000+00:00")); assertEquals(0, Date.parse("+001970-01-01T00:00:00.000-00:00")); assertEquals(0, Date.parse("+001970-01-01T00:00:00.000Z")); -assertEquals(0, Date.parse("+001970-01-01T00:00:00.000")); -assertEquals(0, Date.parse("+001970-01-01T00:00:00")); -assertEquals(0, Date.parse("+001970-01-01T00:00")); -assertEquals(0, Date.parse("+001970-01-01")); +assertEquals(0, Date.parse("+001970-01-01T00:00:00.000Z")); +assertEquals(0, Date.parse("+001970-01-01T00:00:00Z")); +assertEquals(0, Date.parse("+001970-01-01T00:00Z")); +assertEquals(0, Date.parse("+001970-01-01Z")); assertEquals(0, Date.parse("+001970-01T00:00:00.000+00:00")); assertEquals(0, Date.parse("+001970-01T00:00:00.000-00:00")); assertEquals(0, Date.parse("+001970-01T00:00:00.000Z")); -assertEquals(0, Date.parse("+001970-01T00:00:00.000")); -assertEquals(0, Date.parse("+001970-01T00:00:00")); -assertEquals(0, Date.parse("+001970-01T00:00")); -assertEquals(0, Date.parse("+001970-01")); +assertEquals(0, Date.parse("+001970-01T00:00:00.000Z")); +assertEquals(0, Date.parse("+001970-01T00:00:00Z")); +assertEquals(0, Date.parse("+001970-01T00:00Z")); +assertEquals(0, Date.parse("+001970-01Z")); assertEquals(0, Date.parse("+001970T00:00:00.000+00:00")); assertEquals(0, Date.parse("+001970T00:00:00.000-00:00")); assertEquals(0, Date.parse("+001970T00:00:00.000Z")); -assertEquals(0, Date.parse("+001970T00:00:00.000")); -assertEquals(0, Date.parse("+001970T00:00:00")); -assertEquals(0, Date.parse("+001970T00:00")); -assertEquals(0, Date.parse("+001970")); +assertEquals(0, Date.parse("+001970T00:00:00.000Z")); +assertEquals(0, Date.parse("+001970T00:00:00Z")); +assertEquals(0, Date.parse("+001970T00:00Z")); +assertEquals(0, Date.parse("+001970Z")); // Check random date. assertEquals(70671003500, Date.parse("1972-03-28T23:50:03.500+01:00")); assertEquals(70674603500, Date.parse("1972-03-28T23:50:03.500Z")); -assertEquals(70674603500, Date.parse("1972-03-28T23:50:03.500")); -assertEquals(70674603000, Date.parse("1972-03-28T23:50:03")); -assertEquals(70674600000, Date.parse("1972-03-28T23:50")); -assertEquals(70588800000, Date.parse("1972-03-28")); +assertEquals(70674603500, Date.parse("1972-03-28T23:50:03.500Z")); +assertEquals(70674603000, Date.parse("1972-03-28T23:50:03Z")); +assertEquals(70674600000, Date.parse("1972-03-28T23:50Z")); +assertEquals(70588800000, Date.parse("1972-03-28Z")); assertEquals(68338203500, Date.parse("1972-03T23:50:03.500+01:00")); assertEquals(68341803500, Date.parse("1972-03T23:50:03.500Z")); -assertEquals(68341803500, Date.parse("1972-03T23:50:03.500")); -assertEquals(68341803000, Date.parse("1972-03T23:50:03")); -assertEquals(68341800000, Date.parse("1972-03T23:50")); -assertEquals(68256000000, Date.parse("1972-03")); +assertEquals(68341803500, Date.parse("1972-03T23:50:03.500Z")); +assertEquals(68341803000, Date.parse("1972-03T23:50:03Z")); +assertEquals(68341800000, Date.parse("1972-03T23:50Z")); +assertEquals(68256000000, Date.parse("1972-03Z")); assertEquals(63154203500, Date.parse("1972T23:50:03.500+01:00")); assertEquals(63157803500, Date.parse("1972T23:50:03.500Z")); -assertEquals(63157803500, Date.parse("1972T23:50:03.500")); -assertEquals(63157803000, Date.parse("1972T23:50:03")); -assertEquals(63072000000, Date.parse("1972")); +assertEquals(63157803500, Date.parse("1972T23:50:03.500Z")); +assertEquals(63157803000, Date.parse("1972T23:50:03Z")); +assertEquals(63072000000, Date.parse("1972Z")); assertEquals(70671003500, Date.parse("+001972-03-28T23:50:03.500+01:00")); assertEquals(70674603500, Date.parse("+001972-03-28T23:50:03.500Z")); -assertEquals(70674603500, Date.parse("+001972-03-28T23:50:03.500")); -assertEquals(70674603000, Date.parse("+001972-03-28T23:50:03")); -assertEquals(70674600000, Date.parse("+001972-03-28T23:50")); -assertEquals(70588800000, Date.parse("+001972-03-28")); +assertEquals(70674603500, Date.parse("+001972-03-28T23:50:03.500Z")); +assertEquals(70674603000, Date.parse("+001972-03-28T23:50:03Z")); +assertEquals(70674600000, Date.parse("+001972-03-28T23:50Z")); +assertEquals(70588800000, Date.parse("+001972-03-28Z")); assertEquals(68338203500, Date.parse("+001972-03T23:50:03.500+01:00")); assertEquals(68341803500, Date.parse("+001972-03T23:50:03.500Z")); -assertEquals(68341803500, Date.parse("+001972-03T23:50:03.500")); -assertEquals(68341803000, Date.parse("+001972-03T23:50:03")); -assertEquals(68341800000, Date.parse("+001972-03T23:50")); -assertEquals(68256000000, Date.parse("+001972-03")); +assertEquals(68341803500, Date.parse("+001972-03T23:50:03.500Z")); +assertEquals(68341803000, Date.parse("+001972-03T23:50:03Z")); +assertEquals(68341800000, Date.parse("+001972-03T23:50Z")); +assertEquals(68256000000, Date.parse("+001972-03Z")); assertEquals(63154203500, Date.parse("+001972T23:50:03.500+01:00")); assertEquals(63157803500, Date.parse("+001972T23:50:03.500Z")); -assertEquals(63157803500, Date.parse("+001972T23:50:03.500")); -assertEquals(63157803000, Date.parse("+001972T23:50:03")); -assertEquals(63072000000, Date.parse("+001972")); +assertEquals(63157803500, Date.parse("+001972T23:50:03.500Z")); +assertEquals(63157803000, Date.parse("+001972T23:50:03Z")); +assertEquals(63072000000, Date.parse("+001972Z")); // Ensure that ISO-years in the range 00-99 aren't translated to the range // 1950..2049. -assertEquals(-60904915200000, Date.parse("0040-01-01")); -assertEquals(-60273763200000, Date.parse("0060-01-01")); -assertEquals(-62167219200000, Date.parse("0000-01-01")); -assertEquals(-62167219200000, Date.parse("+000000-01-01")); +assertEquals(-60904915200000, Date.parse("0040-01-01T00:00Z")); +assertEquals(-60273763200000, Date.parse("0060-01-01T00:00Z")); +assertEquals(-62167219200000, Date.parse("0000-01-01T00:00Z")); +assertEquals(-62167219200000, Date.parse("+000000-01-01T00:00Z")); // Test negative years. -assertEquals(-63429523200000, Date.parse("-000040-01-01")); -assertEquals(-64060675200000, Date.parse("-000060-01-01")); -assertEquals(-124397510400000, Date.parse("-001972-01-01")); +assertEquals(-63429523200000, Date.parse("-000040-01-01Z")); +assertEquals(-64060675200000, Date.parse("-000060-01-01Z")); +assertEquals(-124397510400000, Date.parse("-001972-01-01Z")); // Check time-zones. assertEquals(70674603500, Date.parse("1972-03-28T23:50:03.500Z")); diff --git a/deps/v8/test/mjsunit/deopt-minus-zero.js b/deps/v8/test/mjsunit/deopt-minus-zero.js index 835494cfcf..47d46cd0f4 100644 --- a/deps/v8/test/mjsunit/deopt-minus-zero.js +++ b/deps/v8/test/mjsunit/deopt-minus-zero.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --expose-gc +// Flags: --allow-natives-syntax --expose-gc --crankshaft function mul (a, b) { return a * b; diff --git a/deps/v8/test/mjsunit/deopt-with-fp-regs.js b/deps/v8/test/mjsunit/deopt-with-fp-regs.js index 10e3d9abb3..7591f0358d 100644 --- a/deps/v8/test/mjsunit/deopt-with-fp-regs.js +++ b/deps/v8/test/mjsunit/deopt-with-fp-regs.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt deopt_trigger = 0; side_effect = 0; @@ -81,10 +81,10 @@ test(10.0, 20.0, 30.0, 40.0, 50.0, 1.5); test(10.0, 20.0, 30.0, 40.0, 50.0, 1.5); %OptimizeFunctionOnNextCall(test); test(10.0, 20.0, 30.0, 40.0, 50.0, 1.5); -assertTrue(2 != %GetOptimizationStatus(test)); +assertOptimized(test); // By deleting the field we are forcing the code to deopt when the field is // read on next execution. delete deopt_trigger; test(10.0, 20.0, 30.0, 40.0, 50.0, 1.5); -assertTrue(1 != %GetOptimizationStatus(test)); +assertUnoptimized(test); diff --git a/deps/v8/test/mjsunit/deserialize-optimize-inner.js b/deps/v8/test/mjsunit/deserialize-optimize-inner.js index 72df32018a..bbd3875b55 100644 --- a/deps/v8/test/mjsunit/deserialize-optimize-inner.js +++ b/deps/v8/test/mjsunit/deserialize-optimize-inner.js @@ -3,6 +3,7 @@ // found in the LICENSE file. // Flags: --allow-natives-syntax --cache=code --no-lazy --serialize-inner +// Flags: --crankshaft function f(x, y) { return x + y; } diff --git a/deps/v8/test/mjsunit/div-mul-minus-one.js b/deps/v8/test/mjsunit/div-mul-minus-one.js index 5ade61492d..c7643ae262 100644 --- a/deps/v8/test/mjsunit/div-mul-minus-one.js +++ b/deps/v8/test/mjsunit/div-mul-minus-one.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function div(g) { return (g/-1) ^ 1 diff --git a/deps/v8/test/mjsunit/double-equals.js b/deps/v8/test/mjsunit/double-equals.js index 40d9a76b48..5f8bea380e 100644 --- a/deps/v8/test/mjsunit/double-equals.js +++ b/deps/v8/test/mjsunit/double-equals.js @@ -25,8 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-simd - /** * This test uses assert{True,False}(... == ...) instead of * assertEquals(..., ...) to not rely on the details of the @@ -242,9 +240,3 @@ testEqual(s, s); testEqual(Object(s), s); testEqual(new Wrapper(s), s); testNotEqual(Object(s), Object(s)); - -var simd = SIMD.Float32x4(1, 2, 3, 4); -testEqual(simd, simd); -testEqual(Object(simd), simd); -testEqual(new Wrapper(simd), simd); -testNotEqual(Object(simd), Object(simd)); diff --git a/deps/v8/test/mjsunit/elements-kind.js b/deps/v8/test/mjsunit/elements-kind.js index 4da8a9dc60..5ff5116ae2 100644 --- a/deps/v8/test/mjsunit/elements-kind.js +++ b/deps/v8/test/mjsunit/elements-kind.js @@ -159,7 +159,7 @@ function test_wrapper() { // The test is called in a wrapper function to eliminate the transition learning // feedback of AllocationSites. test_wrapper(); -%ClearFunctionTypeFeedback(test_wrapper); +%ClearFunctionFeedback(test_wrapper); %NeverOptimizeFunction(construct_smis); diff --git a/deps/v8/test/mjsunit/elements-transition-hoisting.js b/deps/v8/test/mjsunit/elements-transition-hoisting.js index 9f229d2e17..db5b24f6a0 100644 --- a/deps/v8/test/mjsunit/elements-transition-hoisting.js +++ b/deps/v8/test/mjsunit/elements-transition-hoisting.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax -// Flags: --nostress-opt +// Flags: --nostress-opt --crankshaft // Ensure that ElementsKind transitions in various situations are hoisted (or // not hoisted) correctly, don't change the semantics programs and don't trigger @@ -53,7 +53,7 @@ function test_wrapper() { testDoubleConversion4(new Array(5)); testDoubleConversion4(new Array(5)); assertOptimized(testDoubleConversion4); - %ClearFunctionTypeFeedback(testDoubleConversion4); + %ClearFunctionFeedback(testDoubleConversion4); // Make sure that non-element related map checks that are not preceded by // transitions in a loop still get hoisted in a way that doesn't generate a @@ -79,7 +79,7 @@ function test_wrapper() { testExactMapHoisting(new Array(5)); testExactMapHoisting(new Array(5)); assertOptimized(testExactMapHoisting); - %ClearFunctionTypeFeedback(testExactMapHoisting); + %ClearFunctionFeedback(testExactMapHoisting); // Make sure that non-element related map checks do NOT get hoisted if they // depend on an elements transition before them and it's not possible to hoist @@ -111,7 +111,7 @@ function test_wrapper() { testExactMapHoisting2(new Array(5)); // Temporarily disabled - see bug 2176. // assertOptimized(testExactMapHoisting2); - %ClearFunctionTypeFeedback(testExactMapHoisting2); + %ClearFunctionFeedback(testExactMapHoisting2); // Make sure that non-element related map checks do get hoisted if they use // the transitioned map for the check and all transitions that they depend @@ -140,7 +140,7 @@ function test_wrapper() { testExactMapHoisting3(new Array(5)); testExactMapHoisting3(new Array(5)); assertOptimized(testExactMapHoisting3); - %ClearFunctionTypeFeedback(testExactMapHoisting3); + %ClearFunctionFeedback(testExactMapHoisting3); function testDominatingTransitionHoisting1(a) { var object = new Object(); @@ -167,7 +167,7 @@ function test_wrapper() { // above the access, causing a deopt. We should update the type of access // rather than forbid hoisting the transition. assertOptimized(testDominatingTransitionHoisting1); - %ClearFunctionTypeFeedback(testDominatingTransitionHoisting1); + %ClearFunctionFeedback(testDominatingTransitionHoisting1); */ function testHoistingWithSideEffect(a) { @@ -188,7 +188,7 @@ function test_wrapper() { testHoistingWithSideEffect(new Array(5)); testHoistingWithSideEffect(new Array(5)); assertOptimized(testHoistingWithSideEffect); - %ClearFunctionTypeFeedback(testHoistingWithSideEffect); + %ClearFunctionFeedback(testHoistingWithSideEffect); function testStraightLineDupeElinination(a,b,c,d,e,f) { var count = 3; @@ -227,10 +227,10 @@ function test_wrapper() { testStraightLineDupeElinination(new Array(5),0,0,0,0,0); testStraightLineDupeElinination(new Array(5),0,0,0,0,0); assertOptimized(testStraightLineDupeElinination); - %ClearFunctionTypeFeedback(testStraightLineDupeElinination); + %ClearFunctionFeedback(testStraightLineDupeElinination); } // The test is called in a test wrapper that has type feedback cleared to // prevent the influence of allocation-sites, which learn from transitions. test_wrapper(); -%ClearFunctionTypeFeedback(test_wrapper); +%ClearFunctionFeedback(test_wrapper); diff --git a/deps/v8/test/mjsunit/elements-transition.js b/deps/v8/test/mjsunit/elements-transition.js index f6a8188e2f..7365ed7014 100644 --- a/deps/v8/test/mjsunit/elements-transition.js +++ b/deps/v8/test/mjsunit/elements-transition.js @@ -92,7 +92,7 @@ function test(test_double, test_object, set, length) { function run_test(test_double, test_object, set, length) { test(test_double, test_object, set, length); - %ClearFunctionTypeFeedback(test); + %ClearFunctionFeedback(test); } run_test(false, false, function(a,i,v){ a[i] = v; }, 20); diff --git a/deps/v8/test/mjsunit/ensure-growing-store-learns.js b/deps/v8/test/mjsunit/ensure-growing-store-learns.js index e64fe93921..659ff0d66e 100644 --- a/deps/v8/test/mjsunit/ensure-growing-store-learns.js +++ b/deps/v8/test/mjsunit/ensure-growing-store-learns.js @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - // Flags: --allow-natives-syntax --noverify-heap --noenable-slow-asserts +// Flags: --allow-natives-syntax --noverify-heap --noenable-slow-asserts +// Flags: --crankshaft --no-always-opt - // --noverify-heap and --noenable-slow-asserts are set because the test is too - // slow with it on. +// --noverify-heap and --noenable-slow-asserts are set because the test is too +// slow with it on. - // Ensure that keyed stores work, and optimized functions learn if the - // store required change to dictionary mode. Verify that stores that grow - // the array into large object space don't cause a deopt. +// Ensure that keyed stores work, and optimized functions learn if the +// store required change to dictionary mode. Verify that stores that grow +// the array into large object space don't cause a deopt. (function() { var a = []; @@ -42,7 +43,7 @@ // Clearing feedback for the StoreIC in foo is important for runs with // flag --stress-opt. - %ClearFunctionTypeFeedback(foo); + %ClearFunctionFeedback(foo); })(); @@ -60,27 +61,24 @@ %OptimizeFunctionOnNextCall(foo2); foo2(a, 40); - // This test is way too slow without crankshaft. - if (4 != %GetOptimizationStatus(foo2)) { - assertOptimized(foo2); - assertTrue(%HasFastSmiElements(a)); + assertOptimized(foo2); + assertTrue(%HasFastSmiElements(a)); - // Grow a large array into large object space through the keyed store - // without deoptimizing. Grow by 10s. If we set elements too sparsely, the - // array will convert to dictionary mode. - a = new Array(99999); - assertTrue(%HasFastSmiElements(a)); - for (var i = 0; i < 263000; i += 10) { - foo2(a, i); - } - - // Verify that we are over 1 page in size, and foo2 remains optimized. - // This means we've smoothly transitioned to allocating in large object - // space. - assertTrue(%HasFastSmiElements(a)); - assertTrue(a.length * 4 > (1024 * 1024)); - assertOptimized(foo2); + // Grow a large array into large object space through the keyed store + // without deoptimizing. Grow by 10s. If we set elements too sparsely, the + // array will convert to dictionary mode. + a = new Array(99999); + assertTrue(%HasFastSmiElements(a)); + for (var i = 0; i < 263000; i += 10) { + foo2(a, i); } - %ClearFunctionTypeFeedback(foo2); + // Verify that we are over 1 page in size, and foo2 remains optimized. + // This means we've smoothly transitioned to allocating in large object + // space. + assertTrue(%HasFastSmiElements(a)); + assertTrue(a.length * 4 > (1024 * 1024)); + assertOptimized(foo2); + + %ClearFunctionFeedback(foo2); })(); diff --git a/deps/v8/test/mjsunit/es6/array-iterator-turbo.js b/deps/v8/test/mjsunit/es6/array-iterator-turbo.js index c1b8d32072..39c46575a6 100644 --- a/deps/v8/test/mjsunit/es6/array-iterator-turbo.js +++ b/deps/v8/test/mjsunit/es6/array-iterator-turbo.js @@ -2,25 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --turbo --turbo-escape --allow-natives-syntax +// Flags: --turbo --turbo-escape --allow-natives-syntax --no-always-opt "use strict"; -const kDeoptimized = 2; -const kTurbofanned = 7; -const kInterpreted = 8; - -function GetOptimizationStatus(fn) { - let status = %GetOptimizationStatus(fn); - switch (status) { - case kInterpreted: // Treat interpreted frames as unoptimized - status = kDeoptimized; - break; - } - - return status; -} - let global = this; let tests = { FastElementsKind() { @@ -118,15 +103,27 @@ let tests = { // TODO(bmeurer): FAST_HOLEY_DOUBLE_ELEMENTS maps generally deopt when // a hole is encountered. Test should be fixed once that is corrected. - let status = /HOLEY_DOUBLE/.test(key) ? kDeoptimized : kTurbofanned; + let expect_deopt = /HOLEY_DOUBLE/.test(key); - assertEquals(status, GetOptimizationStatus(fn), key); + if (expect_deopt) { + assertUnoptimized(fn, '', key); + } else { + assertOptimized(fn, '', key); + } assertEquals(expected, fn(array), key); - assertEquals(status, GetOptimizationStatus(fn), key); + if (expect_deopt) { + assertUnoptimized(fn, '', key); + } else { + assertOptimized(fn, '', key); + } - // Check no deopt when another arra with the same map is used + // Check no deopt when another array with the same map is used assertTrue(%HaveSameMap(array, array2), key); - assertEquals(status, GetOptimizationStatus(fn), key); + if (expect_deopt) { + assertUnoptimized(fn, '', key); + } else { + assertOptimized(fn, '', key); + } assertEquals(expected2, fn(array2), key); // CheckMaps bailout @@ -134,7 +131,7 @@ let tests = { [1, 2, 3], 2, { enumerable: false, configurable: false, get() { return 7; } }); fn(newArray); - assertEquals(kDeoptimized, GetOptimizationStatus(fn), key); + assertUnoptimized(fn, '', key); } }, @@ -222,12 +219,12 @@ let tests = { %OptimizeFunctionOnNextCall(sum); assertEquals(expected, sum(array), key); - assertEquals(kTurbofanned, GetOptimizationStatus(sum), key); + assertOptimized(sum, '', key); // Not deoptimized when called on typed array of same type / map assertTrue(%HaveSameMap(array, array2)); assertEquals(expected2, sum(array2), key); - assertEquals(kTurbofanned, GetOptimizationStatus(sum), key); + assertOptimized(sum, '', key); // Throw when detached let clone = new array.constructor(array); diff --git a/deps/v8/test/mjsunit/es6/block-let-crankshaft-sloppy.js b/deps/v8/test/mjsunit/es6/block-let-crankshaft-sloppy.js index b5e81f7850..d06153ed8a 100644 --- a/deps/v8/test/mjsunit/es6/block-let-crankshaft-sloppy.js +++ b/deps/v8/test/mjsunit/es6/block-let-crankshaft-sloppy.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft // Check that the following functions are optimizable. var functions = [ f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, @@ -478,5 +478,5 @@ for (var i=0; i<10; i++) { f(12); g(12); -assertTrue(%GetOptimizationStatus(f) != 2); -assertTrue(%GetOptimizationStatus(g) != 2); +assertOptimized(f); +assertOptimized(g); diff --git a/deps/v8/test/mjsunit/es6/block-let-crankshaft.js b/deps/v8/test/mjsunit/es6/block-let-crankshaft.js index 9cfdf847fc..99a8b52968 100644 --- a/deps/v8/test/mjsunit/es6/block-let-crankshaft.js +++ b/deps/v8/test/mjsunit/es6/block-let-crankshaft.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft "use strict"; @@ -480,5 +480,5 @@ for (var i=0; i<10; i++) { f(12); g(12); -assertTrue(%GetOptimizationStatus(f) != 2); -assertTrue(%GetOptimizationStatus(g) != 2); +assertOptimized(f); +assertOptimized(g); diff --git a/deps/v8/test/mjsunit/es6/block-scoping-sloppy.js b/deps/v8/test/mjsunit/es6/block-scoping-sloppy.js index f5c5a6326b..29eadb17d1 100644 --- a/deps/v8/test/mjsunit/es6/block-scoping-sloppy.js +++ b/deps/v8/test/mjsunit/es6/block-scoping-sloppy.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft // Test functionality of block scopes. // Hoisting of var declarations. @@ -40,7 +40,7 @@ function f1() { for (var j = 0; j < 5; ++j) f1(); %OptimizeFunctionOnNextCall(f1); f1(); -assertTrue(%GetOptimizationStatus(f1) != 2); +assertOptimized(f1); // Dynamic lookup in and through block contexts. function f2(one) { diff --git a/deps/v8/test/mjsunit/es6/block-scoping.js b/deps/v8/test/mjsunit/es6/block-scoping.js index 0308edde96..ec13592977 100644 --- a/deps/v8/test/mjsunit/es6/block-scoping.js +++ b/deps/v8/test/mjsunit/es6/block-scoping.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft // Test functionality of block scopes. "use strict"; @@ -42,7 +42,7 @@ function f1() { for (var j = 0; j < 5; ++j) f1(); %OptimizeFunctionOnNextCall(f1); f1(); -assertTrue(%GetOptimizationStatus(f1) != 2); +assertOptimized(f1); // Dynamic lookup in and through block contexts. function f2(one) { diff --git a/deps/v8/test/mjsunit/es6/call-with-spread-modify-array-iterator.js b/deps/v8/test/mjsunit/es6/call-with-spread-modify-array-iterator.js new file mode 100644 index 0000000000..a68e2960f6 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/call-with-spread-modify-array-iterator.js @@ -0,0 +1,37 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function modifyArrayIterator() { + 'use strict'; + + function maxWithZero(...args) { + return Math.max(0, ...args); + } + + function testMax(x, y) { + return maxWithZero(x, y); + } + + testMax(1, 2); + testMax(1, 2); + % OptimizeFunctionOnNextCall(testMax); + var r = testMax(1, 2); + + assertEquals(2, r); + + Object.defineProperty(Array.prototype, Symbol.iterator, { + value: function* + () { + yield 3; + yield 4; + }, + configurable: true + }); + + var r2 = testMax(1, 2); + + assertEquals(4, r2); +})(); diff --git a/deps/v8/test/mjsunit/es6/call-with-spread-modify-next.js b/deps/v8/test/mjsunit/es6/call-with-spread-modify-next.js new file mode 100644 index 0000000000..d206a14d35 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/call-with-spread-modify-next.js @@ -0,0 +1,42 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function modifyNext() { + 'use strict'; + + var a = []; + var ai = a[Symbol.iterator](); + + var original_next = ai.__proto__['next']; + + function maxWithZero(...args) { + return Math.max(0, ...args); + } + + function testMax(x, y) { + return maxWithZero(x, y); + } + + testMax(1, 2); + testMax(1, 2); + % OptimizeFunctionOnNextCall(testMax); + var r = testMax(1, 2); + + assertEquals(2, r); + + var called = 0; + Object.defineProperty(ai.__proto__, 'next', { + get: function() { + called++; + return original_next; + } + }); + + var r2 = testMax(1, 2); + + assertEquals(3, called); + assertEquals(2, r2); +})(); diff --git a/deps/v8/test/mjsunit/es6/call-with-spread.js b/deps/v8/test/mjsunit/es6/call-with-spread.js new file mode 100644 index 0000000000..e372e416d0 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/call-with-spread.js @@ -0,0 +1,113 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function() { + 'use strict'; + + function testBaselineAndOpt(func) { + func(-1, -2); + func(-1, -2); + % OptimizeFunctionOnNextCall(func); + return func(-1, -2); + } + + // Rest parameters + + function RestMax(...args) { + return Math.max(...args); + } + + var r = testBaselineAndOpt(function(x, y) { + return RestMax(x, y); + }); + assertEquals(r, -1); + + function RestMaxWithZero(...args) { + return Math.max(0, ...args); + } + + var r = testBaselineAndOpt(function(x, y) { + return RestMaxWithZero(x, y); + }); + assertEquals(r, 0); + + function RestMaxOneArg(x, ...args) { + return Math.max(-10, ...args); + } + + r = testBaselineAndOpt(function(x, y) { + return RestMaxOneArg(x, y); + }); + assertEquals(r, -2); + + // Strict Arguments Object + + function ArgumentsMax() { + return Math.max(...arguments); + } + + var r = testBaselineAndOpt(function(x, y) { + return ArgumentsMax(x, y); + }); + assertEquals(r, -1); + + function ArgumentsMaxWithZero() { + return Math.max(0, ...arguments); + } + + var r = testBaselineAndOpt(function(x, y) { + return ArgumentsMaxWithZero(x, y); + }); + assertEquals(r, 0); + + function ArgumentsMaxOneArg(x) { + return Math.max(-10, ...arguments); + } + + var r = testBaselineAndOpt(function(x, y) { + return ArgumentsMaxOneArg(x, y); + }); + assertEquals(r, -1); + +})(); + +(function() { + function testBaselineAndOpt(func) { + func(-1, -2); + func(-1, -2); + % OptimizeFunctionOnNextCall(func); + return func(-1, -2); + } + + // Sloppy Arguments Object + + function ArgumentsMax() { + return Math.max(...arguments); + } + + var r = testBaselineAndOpt(function(x, y) { + return ArgumentsMax(x, y); + }); + assertEquals(r, -1); + + function ArgumentsMaxWithZero() { + return Math.max(0, ...arguments); + } + + var r = testBaselineAndOpt(function(x, y) { + return ArgumentsMaxWithZero(x, y); + }); + assertEquals(r, 0); + + function ArgumentsMaxOneArg(x) { + return Math.max(-10, ...arguments); + } + + var r = testBaselineAndOpt(function(x, y) { + return ArgumentsMaxOneArg(x, y); + }); + assertEquals(r, -1); +})(); diff --git a/deps/v8/test/mjsunit/es6/promises.js b/deps/v8/test/mjsunit/es6/promises.js index 0af7a882e7..6e20d684ff 100644 --- a/deps/v8/test/mjsunit/es6/promises.js +++ b/deps/v8/test/mjsunit/es6/promises.js @@ -34,6 +34,9 @@ var defineProperty = Object.defineProperty; var numberPrototype = Number.prototype; var symbolIterator = Symbol.iterator; +function assertUnreachable() { + %AbortJS("Failure: unreachable"); +} (function() { // Test before clearing global (fails otherwise) @@ -982,7 +985,7 @@ function assertAsyncDone(iteration) { var promise = new Promise(function(res) { resolve = res; }); resolve({ then() { thenCalled = true; throw new Error(); } }); assertLater(function() { return thenCalled; }, "resolve-with-thenable"); -}); +})(); (function() { var calledWith; diff --git a/deps/v8/test/mjsunit/es6/reflect-construct.js b/deps/v8/test/mjsunit/es6/reflect-construct.js index 4661b4093b..9de5158005 100644 --- a/deps/v8/test/mjsunit/es6/reflect-construct.js +++ b/deps/v8/test/mjsunit/es6/reflect-construct.js @@ -17,6 +17,30 @@ })(); +(function testReflectConstructArg1NonConstructor() { + try { + Reflect.construct(() => {}, []); + } catch (e) { + assertInstanceof(e, TypeError); + assertEquals("() => {} is not a constructor", e.message); + return; + } + assertUnreachable("Exception expected"); +})(); + + +(function testReflectConstructArg3NonConstructor() { + try { + Reflect.construct(function() {}, [], () => {}); + } catch (e) { + assertInstanceof(e, TypeError); + assertEquals("() => {} is not a constructor", e.message); + return; + } + assertUnreachable("Exception expected"); +})(); + + (function testReflectConstructBasic() { function Constructor() { "use strict"; } assertInstanceof(Reflect.construct(Constructor, []), Constructor); diff --git a/deps/v8/test/mjsunit/es6/regress/regress-5929-1.js b/deps/v8/test/mjsunit/es6/regress/regress-5929-1.js new file mode 100644 index 0000000000..94e143fa77 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/regress/regress-5929-1.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var buf = new ArrayBuffer(0x10000); +var arr = new Uint8Array(buf).fill(55); +var tmp = {}; +tmp[Symbol.toPrimitive] = function () { + %ArrayBufferNeuter(arr.buffer); + return 50; +} +arr.copyWithin(tmp); diff --git a/deps/v8/test/mjsunit/es6/spread-call-new-class.js b/deps/v8/test/mjsunit/es6/spread-call-new-class.js index de88cff5d1..9ec8660918 100644 --- a/deps/v8/test/mjsunit/es6/spread-call-new-class.js +++ b/deps/v8/test/mjsunit/es6/spread-call-new-class.js @@ -88,3 +88,82 @@ assertEquals(["extra", 1, 2, 3], c.baseArgs); assertEquals([1, 2, 3], c.childArgs); })(); + +(function testArgumentsObjectStrict() { + "use strict"; + class Base { + constructor(...args) { + this.baseArgs = args; + } + method() { return this.baseArgs; } + } + + class Child extends Base { + constructor() { + super(...arguments); + this.childArgs = arguments; + } + } + + class Child2 extends Base { + constructor() { + super("extra", ...arguments); + this.childArgs = arguments; + } + } + + var c = new Child(...[1, 2, 3]); + assertInstanceof(c, Child); + assertInstanceof(c, Base); + assertEquals([1, 2, 3], c.method()); + assertEquals([1, 2, 3], c.baseArgs); + assertFalse(Array.__proto__ === c.childArgs.__proto__); + assertEquals([1, 2, 3], Array.prototype.slice.call(c.childArgs)); + + c = new Child2(...[1, 2, 3]); + assertInstanceof(c, Child2); + assertInstanceof(c, Base); + assertEquals(["extra", 1, 2, 3], c.method()); + assertEquals(["extra", 1, 2, 3], c.baseArgs); + assertFalse(Array.__proto__ === c.childArgs.__proto__); + assertEquals([1, 2, 3], Array.prototype.slice.call(c.childArgs)); +})(); + +(function testArgumentsObjectSloppy() { + class Base { + constructor(...args) { + this.baseArgs = args; + } + method() { return this.baseArgs; } + } + + class Child extends Base { + constructor() { + super(...arguments); + this.childArgs = arguments; + } + } + + class Child2 extends Base { + constructor() { + super("extra", ...arguments); + this.childArgs = arguments; + } + } + + var c = new Child(...[1, 2, 3]); + assertInstanceof(c, Child); + assertInstanceof(c, Base); + assertEquals([1, 2, 3], c.method()); + assertEquals([1, 2, 3], c.baseArgs); + assertFalse(Array.__proto__ === c.childArgs.__proto__); + assertEquals([1, 2, 3], Array.prototype.slice.call(c.childArgs)); + + c = new Child2(...[1, 2, 3]); + assertInstanceof(c, Child2); + assertInstanceof(c, Base); + assertEquals(["extra", 1, 2, 3], c.method()); + assertEquals(["extra", 1, 2, 3], c.baseArgs); + assertFalse(Array.__proto__ === c.childArgs.__proto__); + assertEquals([1, 2, 3], Array.prototype.slice.call(c.childArgs)); +})(); diff --git a/deps/v8/test/mjsunit/es6/spread-call.js b/deps/v8/test/mjsunit/es6/spread-call.js index de38f129cd..33d55a815f 100644 --- a/deps/v8/test/mjsunit/es6/spread-call.js +++ b/deps/v8/test/mjsunit/es6/spread-call.js @@ -49,6 +49,9 @@ return sum; } + assertThrows(function() { + sum(...0); + }, TypeError); assertEquals(void 0, sum(..."")); assertEquals(void 0, sum(...[])); assertEquals(void 0, sum(...new Set)); @@ -201,6 +204,9 @@ return sum; } + assertThrows(function() { + sum(...0); + }, TypeError); assertEquals(void 0, sum(..."")); assertEquals(void 0, sum(...[])); assertEquals(void 0, sum(...new Set)); diff --git a/deps/v8/test/mjsunit/es6/super-with-spread-modify-array-iterator.js b/deps/v8/test/mjsunit/es6/super-with-spread-modify-array-iterator.js new file mode 100644 index 0000000000..70ce9ca159 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/super-with-spread-modify-array-iterator.js @@ -0,0 +1,51 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function modifyArrayIterator() { + 'use strict'; + + class Point { + constructor(x, y) { + this.x = x; + this.y = y; + } + } + + class RestPoint extends Point { + constructor(...args) { + super(...args); + } + } + + function testRestPoint(x, y) { + return new RestPoint(x, y); + } + testRestPoint(1, 2); + testRestPoint(1, 2); + % OptimizeFunctionOnNextCall(testRestPoint); + var r = testRestPoint(1, 2); + + assertInstanceof(r, RestPoint); + assertInstanceof(r, Point); + assertEquals(1, r.x); + assertEquals(2, r.y); + + Object.defineProperty(Array.prototype, Symbol.iterator, { + value: function* + () { + yield 3; + yield 4; + }, + configurable: true + }); + + var r2 = testRestPoint(1, 2); + + assertInstanceof(r2, RestPoint); + assertInstanceof(r2, Point); + assertEquals(3, r2.x); + assertEquals(4, r2.y); +})(); diff --git a/deps/v8/test/mjsunit/es6/super-with-spread-modify-next.js b/deps/v8/test/mjsunit/es6/super-with-spread-modify-next.js new file mode 100644 index 0000000000..8ae0d6c589 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/super-with-spread-modify-next.js @@ -0,0 +1,56 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function modifyNext() { + 'use strict'; + + class Point { + constructor(x, y) { + this.x = x; + this.y = y; + } + } + + class ArgumentsPoint extends Point { + constructor() { + super(...arguments); + } + } + + var a = []; + var ai = a[Symbol.iterator](); + + var original_next = ai.__proto__['next']; + + function testArgumentsPoint(x, y) { + return new ArgumentsPoint(x, y); + } + testArgumentsPoint(1, 2); + testArgumentsPoint(1, 2); + % OptimizeFunctionOnNextCall(testArgumentsPoint); + var r = testArgumentsPoint(1, 2); + + assertInstanceof(r, ArgumentsPoint); + assertInstanceof(r, Point); + assertEquals(r.x, 1); + assertEquals(r.y, 2); + + var called = 0; + Object.defineProperty(ai.__proto__, 'next', { + get: function() { + called++; + return original_next; + } + }); + + var r2 = testArgumentsPoint(1, 2); + + assertEquals(3, called); + assertInstanceof(r2, ArgumentsPoint); + assertInstanceof(r2, Point); + assertEquals(r2.x, 1); + assertEquals(r2.y, 2); +})(); diff --git a/deps/v8/test/mjsunit/es6/super-with-spread.js b/deps/v8/test/mjsunit/es6/super-with-spread.js new file mode 100644 index 0000000000..260704f7a4 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/super-with-spread.js @@ -0,0 +1,88 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function() { + 'use strict'; + + class Point { + constructor(x, y) { + this.x = x; + this.y = y; + } + } + + function testBaselineAndOpt(func) { + func(1, 2); + func(1, 2); + % OptimizeFunctionOnNextCall(func); + return func(1, 2); + } + + class RestPoint extends Point { + constructor(...args) { + super(...args); + } + } + var r = testBaselineAndOpt(function(x, y) { + return new RestPoint(x, y); + }); + assertInstanceof(r, RestPoint); + assertInstanceof(r, Point); + assertEquals(r.x, 1); + assertEquals(r.y, 2); + + class RestExtraPoint extends Point { + constructor(...args) { + super(-1, 0, ...args); + } + } + r = testBaselineAndOpt(function(x, y) { + return new RestExtraPoint(x, y); + }); + assertInstanceof(r, RestExtraPoint); + assertInstanceof(r, Point); + assertEquals(r.x, -1); + assertEquals(r.y, 0); + + class ArgumentsPoint extends Point { + constructor() { + super(...arguments); + } + } + r = testBaselineAndOpt(function(x, y) { + return new ArgumentsPoint(x, y); + }); + assertInstanceof(r, ArgumentsPoint); + assertInstanceof(r, Point); + assertEquals(r.x, 1); + assertEquals(r.y, 2); + + class ArgumentsExtraPoint extends Point { + constructor() { + super(1, 2, ...arguments); + } + } + r = testBaselineAndOpt(function(x, y) { + return new ArgumentsExtraPoint(x, y); + }); + assertInstanceof(r, ArgumentsExtraPoint); + assertInstanceof(r, Point); + assertEquals(r.x, 1); + assertEquals(r.y, 2); + + class LiteralPoint extends Point { + constructor() { + super(...[3, 4]); + } + } + r = testBaselineAndOpt(function(x, y) { + return new LiteralPoint(x, y); + }); + assertInstanceof(r, LiteralPoint); + assertInstanceof(r, Point); + assertEquals(r.x, 3); + assertEquals(r.y, 4); +})(); diff --git a/deps/v8/test/mjsunit/es6/typedarray-copywithin.js b/deps/v8/test/mjsunit/es6/typedarray-copywithin.js index ad5a0df563..1e63508393 100644 --- a/deps/v8/test/mjsunit/es6/typedarray-copywithin.js +++ b/deps/v8/test/mjsunit/es6/typedarray-copywithin.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --allow-natives-syntax + var typedArrayConstructors = [ Uint8Array, Int8Array, @@ -171,3 +173,75 @@ CheckEachTypedArray(function copyWithinNullEnd(constructor) { assertArrayEquals([1, 2, 3, 4, 5], new constructor([1, 2, 3, 4, 5]).copyWithin(0, 3, null)); }); + + +CheckEachTypedArray(function copyWithinMinusInfinityTarget(constructor) { + var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + var expected = [6, 7, 8, 9, 10, 6, 7, 8, 9, 10]; + + assertArrayEquals(expected, arr.copyWithin(-Infinity, 5)); + assertEquals(10, arr.length); +}); + + +CheckEachTypedArray(function copyWithinPositiveInfinityTarget(constructor) { + var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + var expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + + assertArrayEquals(expected, arr.copyWithin(+Infinity, 5)); + assertEquals(10, arr.length); +}); + + +CheckEachTypedArray(function copyWithinMinusInfinityStart(constructor) { + var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + var expected = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]; + + assertArrayEquals(expected, arr.copyWithin(5, -Infinity)); + assertEquals(10, arr.length); +}); + + +CheckEachTypedArray(function copyWithinPositiveInfinityStart(constructor) { + var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + var expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + + assertArrayEquals(expected, arr.copyWithin(5, +Infinity)); + assertEquals(10, arr.length); +}); + + +CheckEachTypedArray(function copyWithinMinusInfinityEnd(constructor) { + var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + var expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + + assertArrayEquals(expected, arr.copyWithin(5, 0, -Infinity)); + assertEquals(10, arr.length); +}); + + +CheckEachTypedArray(function copyWithinPositiveInfinityEnd(constructor) { +var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + var expected = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]; + + assertArrayEquals(expected, arr.copyWithin(5, 0, +Infinity)); + assertEquals(10, arr.length); +}); + +CheckEachTypedArray(function parametersNotCalledIfDetached(constructor) { + var tmp = { + [Symbol.toPrimitive]() { + assertUnreachable("Parameter should not be processed when " + + "array.[[ViewedArrayBuffer]] is neutered."); + return 0; + } + }; + + var array = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + %ArrayBufferNeuter(array.buffer); + + // TODO(caitp): this should throw due to being invoked on a TypedArray with a + // detached buffer (per v8:4648). + array.copyWithin(tmp, tmp, tmp); + assertEquals(0, array.length, "array.[[ViewedArrayBuffer]] is detached"); +}); diff --git a/deps/v8/test/mjsunit/es6/typedarray-sort.js b/deps/v8/test/mjsunit/es6/typedarray-sort.js index 4fb8469075..9051a775d0 100644 --- a/deps/v8/test/mjsunit/es6/typedarray-sort.js +++ b/deps/v8/test/mjsunit/es6/typedarray-sort.js @@ -52,4 +52,12 @@ for (var constructor of typedArrayConstructors) { assertEquals(a.length, 1); // Method doesn't work on other objects assertThrows(function() { a.sort.call([]); }, TypeError); + + // Do not touch elements out of byte offset + var buf = new ArrayBuffer(constructor.BYTES_PER_ELEMENT * 3); + var a = new constructor(buf, constructor.BYTES_PER_ELEMENT); + var b = new constructor(buf); + b[0] = 3; b[1] = 2; b[2] = 1; + a.sort(); + assertArrayLikeEquals(a, [1, 2], constructor); } diff --git a/deps/v8/test/mjsunit/es7/array-includes.js b/deps/v8/test/mjsunit/es7/array-includes.js index 3981797a7c..4170a1cf31 100644 --- a/deps/v8/test/mjsunit/es7/array-includes.js +++ b/deps/v8/test/mjsunit/es7/array-includes.js @@ -316,6 +316,7 @@ assertFalse(Array.prototype.includes.call(arrayLikeWithTraps, "c", 2.1)); assertFalse(Array.prototype.includes.call(arrayLikeWithTraps, "c", +Infinity)); + assertFalse(["a", "b", "c"].includes("a", +Infinity)); assertTrue(["a", "b", "c"].includes("a", -Infinity)); assertTrue(["a", "b", "c"].includes("c", 2.9)); assertTrue(["a", "b", "c"].includes("c", NaN)); diff --git a/deps/v8/test/mjsunit/es7/regress/regress-5986.js b/deps/v8/test/mjsunit/es7/regress/regress-5986.js new file mode 100644 index 0000000000..ca157f8026 --- /dev/null +++ b/deps/v8/test/mjsunit/es7/regress/regress-5986.js @@ -0,0 +1,29 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax +var array = [1.7, 1.7, 1.7]; +var mutator = { + [Symbol.toPrimitive]() { + Object.defineProperties(array, { + 0: { get() { } }, + 1: { get() { } }, + 2: { get() { } }, + }); + return 0; + } +}; + +assertTrue(array.includes(undefined, mutator)); + +function search(array, searchElement, startIndex) { + return array.includes(searchElement, startIndex); +} + +array = [1.7, 1.7, 1.7]; +var not_mutator = { [Symbol.toPrimitive]() { return 0; } }; +assertFalse(search(array, undefined, not_mutator)); +assertFalse(search(array, undefined, not_mutator)); +%OptimizeFunctionOnNextCall(search); +assertTrue(search(array, undefined, mutator)); diff --git a/deps/v8/test/mjsunit/es8/async-await-basic.js b/deps/v8/test/mjsunit/es8/async-await-basic.js index 41da67f7cd..ba11798aac 100644 --- a/deps/v8/test/mjsunit/es8/async-await-basic.js +++ b/deps/v8/test/mjsunit/es8/async-await-basic.js @@ -390,3 +390,175 @@ async function gaga() { while (i-- > 0) { await 42 } } assertDoesNotThrow(gaga); + + +{ + let log = []; + async function foo() { + try { + Promise.resolve().then(() => log.push("a")) + } finally { + log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["b", "a", "c"], log); +} + +{ + let log = []; + async function foo() { + try { + return Promise.resolve().then(() => log.push("a")) + } finally { + log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["b", "a", "c"], log); +} + +{ + let log = []; + async function foo() { + try { + return await Promise.resolve().then(() => log.push("a")) + } finally { + log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["a", "b", "c"], log); +} + + +{ + let log = []; + async function foo() { + try { + Promise.resolve().then().then(() => log.push("a")) + } finally { + log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["b", "c", "a"], log); +} + +{ + let log = []; + async function foo() { + try { + return Promise.resolve().then().then(() => log.push("a")) + } finally { + log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["b", "a", "c"], log); +} + +{ + let log = []; + async function foo() { + try { + return await Promise.resolve().then().then(() => log.push("a")) + } finally { + log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["a", "b", "c"], log); +} + + +{ + let log = []; + async function foo() { + try { + Promise.resolve().then(() => log.push("a")) + } finally { + return log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["b", "a", "c"], log); +} + +{ + let log = []; + async function foo() { + try { + return Promise.resolve().then(() => log.push("a")) + } finally { + return log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["b", "a", "c"], log); +} + +{ + let log = []; + async function foo() { + try { + return await Promise.resolve().then(() => log.push("a")) + } finally { + return log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["a", "b", "c"], log); +} + + +{ + let log = []; + async function foo() { + try { + Promise.resolve().then().then(() => log.push("a")) + } finally { + return log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["b", "c", "a"], log); +} + +{ + let log = []; + async function foo() { + try { + return Promise.resolve().then().then(() => log.push("a")) + } finally { + return log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["b", "c", "a"], log); +} + +{ + let log = []; + async function foo() { + try { + return await Promise.resolve().then().then(() => log.push("a")) + } finally { + return log.push("b"); + } + } + foo().then(() => log.push("c")); + %RunMicrotasks(); + assertEquals(["a", "b", "c"], log); +} diff --git a/deps/v8/test/mjsunit/es8/async-await-no-constructor.js b/deps/v8/test/mjsunit/es8/async-await-no-constructor.js index 7a2b2b2921..e954e2ac57 100644 --- a/deps/v8/test/mjsunit/es8/async-await-no-constructor.js +++ b/deps/v8/test/mjsunit/es8/async-await-no-constructor.js @@ -24,4 +24,4 @@ async function bar() { foo(); bar(); %RunMicrotasks(); -assertEquals(1, count); +assertEquals(2, count); diff --git a/deps/v8/test/mjsunit/external-array.js b/deps/v8/test/mjsunit/external-array.js index 108b9f2e68..78f27809b7 100644 --- a/deps/v8/test/mjsunit/external-array.js +++ b/deps/v8/test/mjsunit/external-array.js @@ -301,7 +301,7 @@ function run_test(test_func, array, expected_result) { } assertEquals(expected_result, sum); %DeoptimizeFunction(test_func); - %ClearFunctionTypeFeedback(test_func); + %ClearFunctionFeedback(test_func); } function run_bounds_test(test_func, array, expected_result) { @@ -350,7 +350,7 @@ for (var t = 0; t < types.length; t++) { %OptimizeFunctionOnNextCall(run_bounds_test); run_bounds_test(a); %DeoptimizeFunction(run_bounds_test); - %ClearFunctionTypeFeedback(run_bounds_test); + %ClearFunctionFeedback(run_bounds_test); } function array_load_set_smi_check(a) { @@ -369,7 +369,7 @@ for (var t = 0; t < types.length; t++) { array_load_set_smi_check2(a); array_load_set_smi_check2(0); %DeoptimizeFunction(array_load_set_smi_check2); - %ClearFunctionTypeFeedback(array_load_set_smi_check2); + %ClearFunctionFeedback(array_load_set_smi_check2); } // Check handling of undefined in 32- and 64-bit external float arrays. @@ -647,8 +647,8 @@ function do_tagged_index_external_array_test(constructor) { %OptimizeFunctionOnNextCall(boo); boo(t_array, 0, 15); assertEquals(15, goo(t_array, 0)); - %ClearFunctionTypeFeedback(goo); - %ClearFunctionTypeFeedback(boo); + %ClearFunctionFeedback(goo); + %ClearFunctionFeedback(boo); } do_tagged_index_external_array_test(Int8Array); @@ -667,8 +667,8 @@ assertEquals(1, goo(built_in_array, 0)); %OptimizeFunctionOnNextCall(boo); boo(built_in_array, 0, 11); assertEquals(11, goo(built_in_array, 0)); -%ClearFunctionTypeFeedback(goo); -%ClearFunctionTypeFeedback(boo); +%ClearFunctionFeedback(goo); +%ClearFunctionFeedback(boo); built_in_array = new Array(1.5, 2, 3, 4, 5, 6); assertEquals(1.5, goo(built_in_array, 0)); @@ -677,8 +677,8 @@ assertEquals(1.5, goo(built_in_array, 0)); %OptimizeFunctionOnNextCall(boo); boo(built_in_array, 0, 2.5); assertEquals(2.5, goo(built_in_array, 0)); -%ClearFunctionTypeFeedback(goo); -%ClearFunctionTypeFeedback(boo); +%ClearFunctionFeedback(goo); +%ClearFunctionFeedback(boo); // Check all int range edge cases function checkRange() { diff --git a/deps/v8/test/mjsunit/extra-commas.js b/deps/v8/test/mjsunit/extra-commas.js index 6fed04c0de..02d25df4ed 100644 --- a/deps/v8/test/mjsunit/extra-commas.js +++ b/deps/v8/test/mjsunit/extra-commas.js @@ -38,9 +38,9 @@ function assertSyntaxError(x) { assertSyntaxError("f(,)"); -assertSyntaxError("f(1,)"); -assertSyntaxError("f(1,2,)"); +assertSyntaxError("f(1,,)"); +assertSyntaxError("f(1,2,,)"); assertSyntaxError("function f(,) {}"); -assertSyntaxError("function f(1,) {}"); -assertSyntaxError("function f(1,2,) {}"); +assertSyntaxError("function f(1,,) {}"); +assertSyntaxError("function f(1,2,,) {}"); diff --git a/deps/v8/test/mjsunit/fast-element-smi-check.js b/deps/v8/test/mjsunit/fast-element-smi-check.js index 3083d5fe74..09b2d6ac9e 100644 --- a/deps/v8/test/mjsunit/fast-element-smi-check.js +++ b/deps/v8/test/mjsunit/fast-element-smi-check.js @@ -46,7 +46,7 @@ test_load_set_smi_2(a); test_load_set_smi_2(a); test_load_set_smi_2(0); %DeoptimizeFunction(test_load_set_smi_2); -%ClearFunctionTypeFeedback(test_load_set_smi_2); +%ClearFunctionFeedback(test_load_set_smi_2); var b = new Object(); @@ -67,4 +67,4 @@ test_load_set_smi_4(b); test_load_set_smi_4(b); test_load_set_smi_4(0); %DeoptimizeFunction(test_load_set_smi_4); -%ClearFunctionTypeFeedback(test_load_set_smi_4); +%ClearFunctionFeedback(test_load_set_smi_4); diff --git a/deps/v8/test/mjsunit/field-type-tracking.js b/deps/v8/test/mjsunit/field-type-tracking.js index b4901f34c3..e6b19b9bbc 100644 --- a/deps/v8/test/mjsunit/field-type-tracking.js +++ b/deps/v8/test/mjsunit/field-type-tracking.js @@ -3,10 +3,14 @@ // found in the LICENSE file. // Flags: --allow-natives-syntax --nostress-opt --track-field-types +// Flags: --crankshaft --no-always-opt (function() { var o = { text: "Hello World!" }; function A() { + // Assign twice to make the field non-constant. + // TODO(ishell): update test once constant field tracking is done. + this.a = {text: 'foo'}; this.a = o; } function readA(x) { @@ -107,6 +111,9 @@ (function() { function Foo(x) { this.x = x; } + // TODO(ishell): update test once constant field tracking is done. + var f0 = new Foo({x: 0}); + f0.x = {x: 0}; // make Foo.x non-constant here. var f1 = new Foo({x: 1}); var f2 = new Foo({x: 2}); var f3 = new Foo({x: 3}); @@ -143,7 +150,9 @@ function baz(f, y) { f.y = y; } baz(f1, {y: 9}); baz(f2, {y: 9}); + baz(f2, {y: 9}); %OptimizeFunctionOnNextCall(baz); + baz(f2, {y: 9}); baz(f3, {a: -1}); assertUnoptimized(baz); })(); diff --git a/deps/v8/test/mjsunit/getters-on-elements.js b/deps/v8/test/mjsunit/getters-on-elements.js index 7f2c98b2e7..e6c526a80e 100644 --- a/deps/v8/test/mjsunit/getters-on-elements.js +++ b/deps/v8/test/mjsunit/getters-on-elements.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --max-opt-count=100 --noalways-opt -// Flags: --nocollect-maps +// Flags: --nocollect-maps --crankshaft // We specify max-opt-count because we opt/deopt the same function many // times. @@ -70,7 +70,7 @@ if (standalone) { %OptimizeFunctionOnNextCall(name); } clearFunctionTypeFeedback = function(name) { - %ClearFunctionTypeFeedback(name); + %ClearFunctionFeedback(name); } deoptimizeFunction = function(name) { %DeoptimizeFunction(name); diff --git a/deps/v8/test/mjsunit/harmony/async-from-sync-iterator.js b/deps/v8/test/mjsunit/harmony/async-from-sync-iterator.js new file mode 100644 index 0000000000..9ca33c995d --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/async-from-sync-iterator.js @@ -0,0 +1,670 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --harmony-async-iteration --allow-natives-syntax + +let testFailed = false; +let testFailure; + +function assertThrowsAsync(run, errorType, message) { + var actual; + var hadValue = false; + var hadError = false; + var promise = run(); + + if (typeof promise !== "object" || typeof promise.then !== "function") { + throw new MjsUnitAssertionError( + "Expected " + run.toString() + + " to return a Promise, but it returned " + PrettyPrint(promise)); + } + + promise.then(function(value) { hadValue = true; actual = value; }, + function(error) { hadError = true; actual = error; }); + + assertFalse(hadValue || hadError); + + %RunMicrotasks(); + + if (!hadError) { + throw new MjsUnitAssertionError( + "Expected " + run + "() to throw " + errorType.name + + ", but did not throw."); + } + if (!(actual instanceof errorType)) + throw new MjsUnitAssertionError( + "Expected " + run + "() to throw " + errorType.name + + ", but threw '" + actual + "'"); + if (message !== void 0 && actual.message !== message) + throw new MjsUnitAssertionError( + "Expected " + run + "() to throw '" + message + "', but threw '" + + actual.message + "'"); +}; + +function resolveLater(value) { + return new Promise(function(resolve) { + Promise.resolve().then(function() { + resolve(value); + }); + }); +} + +function rejectLater(value) { + return new Promise(function(resolve, reject) { + Promise.resolve().then(function() { + reject(value); + }); + }); +} + +const kNext = 1; +const kThrow = 2; +const kReturn = 4; +const kNextThrows = kNext | 8; +const kReturnThrows = kReturn | 16; +const kThrowNormal = kThrow | 32; +const kNextUnchanged = kNext | 64; +const kReturnUnchanged = kReturn | 128; +const kThrowUnchanged = kThrow | 256; +function sync(array, features, log) { + // `log` is a required parameter + if (log === void 0) %AbortJS("`log` is undefined"); + + let i = 0; + let methods = { + next(sent) { + let done = i >= array.length; + let value = array[i]; + log.push({ method: "next", sent, value, done }); + if ((features & kNextThrows) === kNextThrows) throw sent; + if ((features & kNextUnchanged) === kNextUnchanged) return sent; + i++; + return { value, done }; + }, + throw(sent) { + let done = i >= array.length; + log.push({ method: "throw", sent, done }); + if ((features & kThrowNormal) === kThrowNormal) + return { value: sent, done }; + if ((features & kThrowUnchanged) === kThrowUnchanged) return sent; + throw sent; + }, + return(sent) { + let done = true; + log.push({ method: "return", sent, done }); + if ((features & kReturnThrows) === kReturnThrows) throw sent; + if ((features & kReturnUnchanged) === kReturnUnchanged) return sent; + return { value: sent, done }; + } + }; + return { + [Symbol.iterator]() { return this; }, + next: (features & kNext) ? methods.next : undefined, + throw: (features & kThrow) ? methods.throw : undefined, + return: (features & kReturn) ? methods.return : undefined + }; +} + +class MyError extends Error {}; + +(async function AsyncFromSyncWithGenerator() { + function* gen() { + yield "sync value"; + try { + yield new Promise(function(resolve) { + resolve("async value"); + }); + } catch (error) { + throw error; + } + assertUnreachable("generator is closed"); + } + let iter = %CreateAsyncFromSyncIterator(gen()); + + // [Async-from-Sync Iterator] wraps sync iterator values in a Promise + let promise = iter.next(); + assertInstanceof(promise, Promise); + let iter_result = await promise; + assertEquals({ value: "sync value", done: false }, iter_result); + + // [Async-from-Sync Iterator] will wait for resolution of Promise values + promise = iter.next(); + assertInstanceof(promise, Promise); + iter_result = await promise; + assertEquals({ value: "async value", done: false }, iter_result); + + // [Async-from-Sync Iterator].throw delegates to .throw() method of sync + // iterator. + promise = iter.throw(new MyError("Error#1")); + assertInstanceof(promise, Promise); + try { + await promise; + assertUnreachable("promise should be rejected"); + } catch (e) { + // If assertUnreachable failed, rethrow + if (e instanceof MjsUnitAssertionError) throw e; + assertInstanceof(e, MyError); + assertEquals("Error#1", e.message); + } + + // Generator is closed, subsequent calls to .next() will not resume. + promise = iter.next("floof"); + iter_result = await promise; + assertEquals({ value: undefined, done: true }, iter_result); + + promise = iter.return("generator closed"); + assertInstanceof(promise, Promise); + iter_result = await promise; + assertEquals({ value: "generator closed", done: true }, iter_result); + + // .next(), .return() and .throw() delegate to sync iterator methods, without + // keeping track of the state of the generator. + promise = iter.next("unused"); + assertInstanceof(promise, Promise); + iter_result = await promise; + assertEquals({ value: undefined, done: true }, iter_result); + + promise = iter.throw(new MyError("Error#2")); + assertInstanceof(promise, Promise); + try { + await promise; + assertUnreachable("promise should be rejected"); + } catch (e) { + // If assertUnreachable failed, rethrow + if (e instanceof MjsUnitAssertionError) throw e; + assertInstanceof(e, MyError); + assertEquals("Error#2", e.message); + } + + promise = iter.return("return-after-completed"); + assertInstanceof(promise, Promise); + iter_result = await promise; + assertEquals({ value: "return-after-completed", done: true }, iter_result); +})().catch(function(error) { + testFailed = true; + testFailure = error; +}); + +%RunMicrotasks(); +if (testFailed) { + throw testFailure; +} + + +(async function AsyncFromSyncOrderOfOperations() { + let log = []; + iter = %CreateAsyncFromSyncIterator(sync(["sync-value"], 0, log)); + + try { + await iter.next(); + assertUnreachable("Iterator.next() method is not optional"); + } catch (e) { + assertInstanceof(e, TypeError); + assertEquals([], log); + } + + log = []; + iter = %CreateAsyncFromSyncIterator(sync(["sync-value"], kNext, log)); + assertEquals({ value: "sync-value", done: false }, await iter.next("a")); + assertEquals([ + { + method: "next", + sent: "a", + value: "sync-value", + done: false + } + ], log); + + log = []; + let asyncValue = resolveLater("async-value"); + iter = %CreateAsyncFromSyncIterator(sync([asyncValue], kNext, log)); + assertEquals({ value: "async-value", done: false }, await iter.next("b")); + assertEquals([ + { + method: "next", + sent: "b", + value: asyncValue, + done: false + } + ], log); + + // If [sync_iterator].next() produces a rejected Promise or an exception is + // thrown, Promise is rejected with thrown/rejected value. + log = []; + asyncValue = rejectLater("Boo!"); + iter = %CreateAsyncFromSyncIterator(sync([asyncValue], kNext, log)); + try { + await iter.next('c'); + assertUnreachable('Expected `iter.next(\'c\') to throw, but did not throw'); + } catch (e) { + assertEquals("Boo!", e); + assertEquals([ + { + method: 'next', + sent: 'c', + value: asyncValue, + done: false + } + ], log); + } + + log = []; + iter = %CreateAsyncFromSyncIterator(sync(['sync-value'], kNextThrows, log)); + try { + await iter.next('Boo!'); + assertUnreachable('Expected `iter.next(\'c\') to throw, but did not throw'); + } catch (e) { + assertEquals("Boo!", e); + assertEquals([ + { + method: 'next', + sent: 'Boo!', + value: 'sync-value', + done: false + } + ], log); + } + + + // [Async-from-Sync Iterator].next() will be rejected with a TypeError if + // Type([sync_iterator].next()) is not Object. + log = []; + iter = %CreateAsyncFromSyncIterator(sync(['sync-value'], kNextUnchanged, + log)); + try { + await iter.next('not-a-JSReceiver'); + assertUnreachable('Expected `iter.next(\'not-a-JSReceiver\')` to ' + + 'throw, but did not throw') + } catch (e) { + assertEquals(e.constructor, TypeError); + } + + assertEquals([ + { + method: 'next', + sent: 'not-a-JSReceiver', + value: 'sync-value', + done: false + } + ], log); + + // If [sync_iterator] does not have a .return() method, return a Promise + // resolved with the value `{ value: <<sent value>>, done: true }`. + log = []; + iter = %CreateAsyncFromSyncIterator(sync(['sync-return'], kNext, log)); + assertEquals({ + value: 'd', + done: true + }, await iter.return('d')); + + // [Async-from-Sync Iterator] merely delegates, and does not keep track of + // whether [sync_iterator] is completed or not. + assertEquals({ + value: 'sync-return', + done: false + }, await iter.next('e')); + + assertEquals([ + { + method: 'next', + sent: 'e', + value: 'sync-return', + done: false + } + ], log); + + // If [sync_iterator] does have a .return() method, return a Promise + // fulfilled with the iterator result of [sync_iterator].return(). + log = []; + iter = %CreateAsyncFromSyncIterator(sync(['sync-return'], + kNext|kReturn, log)); + assertEquals({ + value: 'f', + done: true + }, await iter.return('f')); + + // [Async-from-Sync Iterator] merely delegates, and does not keep track of + // whether [sync_iterator] is completed or not. + assertEquals({ + value: 'sync-return', + done: false + }, await iter.next('g')); + + assertEquals([ + { + method: 'return', + sent: 'f', + done: true + }, + { + method: 'next', + sent: 'g', + value: 'sync-return', + done: false + } + ], log); + + // If [sync_iterator].return() produces a rejected Promise or an exception is + // thrown, Promise is rejected with thrown/rejected value. + log = []; + iter = %CreateAsyncFromSyncIterator(sync(['sync-value'], kNext|kReturnThrows, + log)); + try { + await iter.return('Boo!!'); + assertUnreachable('Expected `iter.return(\'Boo!!\')` to throw, but did ' + + 'not throw'); + } catch (e) { + assertEquals("Boo!!", e); + } + + // [Async-from-Sync Iterator] merely delegates, and does not keep track of + // whether [sync_iterator] is completed or not. + assertEquals({ value: 'sync-value', done: false }, await iter.next('h')); + assertEquals([ + { + method: 'return', + sent: 'Boo!!', + done: true + }, + { + method: 'next', + sent: 'h', + value: 'sync-value', + done: false + } + ], log); + + + log = []; + iter = %CreateAsyncFromSyncIterator(sync(['sync-value'], kNext|kReturn, log)); + + let rejection = Promise.reject('Boo!!'); + try { + await iter.return(rejection); + assertUnreachable('Expected `iter.return(Promise.reject(\'Boo!!\'))` to ' + + 'throw, but did not throw'); + } catch (e) { + assertEquals('Boo!!', e); + } + + // [Async-from-Sync Iterator] merely delegates, and does not keep track of + // whether [sync_iterator] is completed or not. + assertEquals({ value: 'sync-value', done: false }, await iter.next('i')); + assertEquals([ + { + method: 'return', + sent: rejection, + done: true + }, + { + method: 'next', + sent: 'i', + value: 'sync-value', + done: false + } + ], log); + + // [Async-from-Sync Iterator].return() will be rejected with a TypeError if + // Type([sync_iterator].return()) is not Object. + log = []; + iter = %CreateAsyncFromSyncIterator(sync(['sync-value'], + kNext|kReturnUnchanged, log)); + try { + await iter.return('not-a-JSReceiver'); + assertUnreachable('Expected `iter.return(\'not-a-JSReceiver\')` to ' + + 'throw, but did not throw') + } catch (e) { + assertEquals(e.constructor, TypeError); + } + + // [Async-from-Sync Iterator] merely delegates, and does not keep track of + // whether [sync_iterator] is completed or not. + assertEquals({ value: 'sync-value', done: false }, await iter.next('j')); + assertEquals([ + { + method: 'return', + sent: 'not-a-JSReceiver', + done: true + }, + { + method: 'next', + sent: 'j', + value: 'sync-value', + done: false + } + ], log); + + // If [sync_iterator] does not have a .throw method, return a Promise rejected + // with the sent value. + log = []; + iter = %CreateAsyncFromSyncIterator(sync(['sync-value'], kNext, log)); + try { + await iter.throw('Boo!!'); + assertUnreachable('Expected iter.throw(\'Boo!!\') to throw, but did not ' + + 'throw'); + } catch (e) { + assertEquals('Boo!!', e); + } + + // [Async-from-Sync Iterator] merely delegates, and does not keep track of + // whether [sync_iterator] is completed or not. + assertEquals({ value: 'sync-value', done: false }, await iter.next('k')); + assertEquals([ + { + method: 'next', + sent: 'k', + value: 'sync-value', + done: false + } + ], log); + + + log = []; + iter = %CreateAsyncFromSyncIterator(sync(['sync-value'], kNext|kThrow, log)); + try { + await iter.throw('Boo!!'); + assertUnreachable('Expected iter.throw(\'Boo!!\') to throw, but did not ' + + 'throw'); + } catch (e) { + assertEquals('Boo!!', e); + } + + // [Async-from-Sync Iterator] merely delegates, and does not keep track of + // whether [sync_iterator] is completed or not. + assertEquals({ value: 'sync-value', done: false }, await iter.next('l')); + assertEquals([ + { + method: 'throw', + sent: 'Boo!!', + done: false + }, + { + method: 'next', + sent: 'l', + value: 'sync-value', + done: false + } + ], log); + + // If [sync_iterator].throw() returns a resolved Promise or a Completion + // with [[Type]] "normal" or "return", return a resolved Promise + log = []; + iter = %CreateAsyncFromSyncIterator(sync(['sync-value'], kNext|kThrowNormal, + log)); + assertEquals({ + value: 'Boo!!', + done: false + }, await iter.throw('Boo!!')); + + // [Async-from-Sync Iterator] merely delegates, and does not keep track of + // whether [sync_iterator] is completed or not. + assertEquals({ value: 'sync-value', done: false }, await iter.next('m')); + assertEquals([ + { + method: 'throw', + sent: 'Boo!!', + done: false + }, + { + method: 'next', + sent: 'm', + value: 'sync-value', + done: false + } + ], log); + + // [Async-from-Sync Iterator].throw() will be rejected with a TypeError if + // Type([sync_iterator].throw()) is not Object. + log = []; + iter = %CreateAsyncFromSyncIterator(sync(['sync-value'], + kNext|kThrowUnchanged, log)); + try { + await iter.throw('not-a-JSReceiver'); + assertUnreachable('Expected `iter.throw(\'not-a-JSReceiver\')` to ' + + 'throw, but did not throw') + } catch (e) { + assertEquals(e.constructor, TypeError); + } + + // [Async-from-Sync Iterator] merely delegates, and does not keep track of + // whether [sync_iterator] is completed or not. + assertEquals({ value: 'sync-value', done: false }, await iter.next('n')); + assertEquals([ + { + method: 'throw', + sent: 'not-a-JSReceiver', + done: false + }, + { + method: 'next', + sent: 'n', + value: 'sync-value', + done: false + } + ], log); + + // Let nextValue be IteratorValue(nextResult). + // IfAbruptRejectPromise(nextValue, promiseCapability).) + iter = %CreateAsyncFromSyncIterator({ + next() { return { get value() { throw "BadValue!" }, done: false }; } + }); + try { + await iter.next(); + assertUnreachable('Expected `iter.next()` to throw, but did not throw'); + } catch (e) { + assertEquals('BadValue!', e); + } + + // Let nextDone be IteratorComplete(nextResult). + // IfAbruptRejectPromise(nextDone, promiseCapability). + iter = %CreateAsyncFromSyncIterator({ + next() { return { value: undefined, get done() { throw "BadValue!" } }; } + }); + try { + await iter.next(); + assertUnreachable('Expected `iter.next()` to throw, but did not throw'); + } catch (e) { + assertEquals('BadValue!', e); + } + + // IfAbruptRejectPromise(returnResult, promiseCapability). + // Let returnValue be IteratorValue(returnResult). + iter = %CreateAsyncFromSyncIterator({ + return() { return { get value() { throw "BadValue!" }, done: false }; } + }); + try { + await iter.return(); + assertUnreachable('Expected `iter.return()` to throw, but did not throw'); + } catch (e) { + assertEquals('BadValue!', e); + } + + // IfAbruptRejectPromise(returnValue, promiseCapability). + // Let returnDone be IteratorComplete(returnResult). + iter = %CreateAsyncFromSyncIterator({ + return() { return { value: undefined, get done() { throw "BadValue!" } }; } + }); + try { + await iter.return(); + assertUnreachable('Expected `iter.return()` to throw, but did not throw'); + } catch (e) { + assertEquals('BadValue!', e); + } + + // IfAbruptRejectPromise(throwResult, promiseCapability). + // Let throwValue be IteratorValue(throwResult). + iter = %CreateAsyncFromSyncIterator({ + throw() { return { get value() { throw "BadValue!" }, done: false }; } + }); + try { + await iter.throw(); + assertUnreachable('Expected `iter.throw()` to throw, but did not throw'); + } catch (e) { + assertEquals('BadValue!', e); + } + + // IfAbruptRejectPromise(throwValue, promiseCapability). + // Let throwDone be IteratorComplete(throwResult). + iter = %CreateAsyncFromSyncIterator({ + throw() { return { value: undefined, get done() { throw "BadValue!" } }; } + }); + try { + await iter.throw(); + assertUnreachable('Expected `iter.throw()` to throw, but did not throw'); + } catch (e) { + assertEquals('BadValue!', e); + } +})().catch(function(error) { + testFailed = true; + testFailure = error; +}); + +%RunMicrotasks(); +if (testFailed) { + throw testFailure; +} + +(function ExtractedAsyncFromSyncIteratorMethods() { + // Async-from-Sync iterator methods can be extracted via function.caller. + // TODO(caitp): test extracted `throw` method using yield* in async generator. + let extractor = [0, 1, 2, 3, 4,5,6,7,8,9]; + let extractedNext; + let extractedReturn; + + extractor[Symbol.iterator] = function() { + let it = [][Symbol.iterator].call(extractor); + let origNext = it.next, origThrow = it.throw, origReturn = it.return; + function extractNext() { + extractedNext = extractNext.caller; + return origNext; + } + function extractReturn() { + extractedReturn = extractReturn.caller; + return origReturn; + } + Object.defineProperties(it, { + "next": { get: extractNext, configurable: true }, + "return": { get: extractReturn, configurable: true } + }); + return it; + }; + + async function f() { + let i; + let it = extractor[Symbol.iterator](); + for await (let x of it) break; + for await (let x of it) return "x"; + } + + // Cycle through `f` to extract iterator methods + f().catch(function() { %AbortJS("No error should have occurred"); }); + %RunMicrotasks(); + + assertEquals(typeof extractedNext, "function"); + assertThrowsAsync(() => extractedNext.call(undefined), TypeError); + assertThrowsAsync(() => extractedNext.call(1), TypeError); + + assertEquals(typeof extractedReturn, "function"); + assertThrowsAsync(() => extractedReturn.call(undefined), TypeError); + assertThrowsAsync(() => extractedReturn.call(1), TypeError); +})(); diff --git a/deps/v8/test/mjsunit/harmony/atomics.js b/deps/v8/test/mjsunit/harmony/atomics.js index e608df3342..840d00e78b 100644 --- a/deps/v8/test/mjsunit/harmony/atomics.js +++ b/deps/v8/test/mjsunit/harmony/atomics.js @@ -386,6 +386,15 @@ function clearArray(sab) { })(); (function TestIsLockFree() { + // Various invalid cases. + var valueOf = {valueOf: function(){ return 3;}}; + var toString = {toString: function(){ return '3';}}; + var invalid = [3.14, 'foo', Infinity, NaN, false, undefined, valueOf, + toString]; + invalid.forEach(function(v) { + assertEquals(false, Atomics.isLockFree(v), JSON.stringify(v)); + }); + // For all platforms we support, 1, 2 and 4 bytes should be lock-free. assertEquals(true, Atomics.isLockFree(1)); assertEquals(true, Atomics.isLockFree(2)); diff --git a/deps/v8/test/mjsunit/harmony/do-expressions.js b/deps/v8/test/mjsunit/harmony/do-expressions.js index 38b68b6ed7..5adf1545a5 100644 --- a/deps/v8/test/mjsunit/harmony/do-expressions.js +++ b/deps/v8/test/mjsunit/harmony/do-expressions.js @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-do-expressions --allow-natives-syntax +// Flags: --harmony-do-expressions --allow-natives-syntax --no-always-opt +// Flags: --crankshaft function returnValue(v) { return v; } function MyError() {} diff --git a/deps/v8/test/mjsunit/harmony/for-await-of.js b/deps/v8/test/mjsunit/harmony/for-await-of.js new file mode 100644 index 0000000000..efcfdab2ea --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/for-await-of.js @@ -0,0 +1,1264 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --harmony-async-iteration --allow-natives-syntax + +let testFailed = false; +let testFailure; +(async function() { + const kNext = 1; + const kThrow = 2; + const kReturn = 4; + const kReturnPrimitive = kReturn | 32; + + function async(iterable, features = kNext, log = []) { + // Helper to turn a synchronous iterable into an asynchronous iterable, + // without using the [Async-from-Sync Iterator]. + let it = iterable[Symbol.iterator](); + let methods = { + next(sentValue) { + return new Promise(function(resolve, reject) { + let {value, done} = it.next(sentValue); + Promise.resolve(value).then(function(value) { + log.push('.next() -> resolved ' + value); + resolve({value, done}); + }, function(value) { + log.push('.next() -> rejected ' + value); + reject(value); + }); + }); + }, + + throw(sentValue) { + return new Promise(function(resolve, reject) { + let throwMethod = it.throw; + if (typeof throwMethod !== 'function') { + log.push('.throw(' + sentValue + ')'); + return reject(sentValue); + } + + let {value, done} = throwMethod.call(it, sentValue); + Promise.resolve(value).then(function(value) { + log.push('.throw() -> resolved ' + value); + resolve({ value, done }); + }, function(value) { + log.push('.throw() -> rejected ' + value); + reject(value); + }); + }); + }, + + return(sentValue) { + return new Promise(function(resolve, reject) { + let returnMethod = it.return; + if (typeof returnMethod !== 'function') { + log.push('.return(' + sentValue + ')'); + if ((features & kReturnPrimitive) === kReturnPrimitive) + return resolve(sentValue); + return resolve({value: sentValue, done: true}); + } + + let {value, done} = returnMethod.call(it, sentValue); + Promise.resolve(value).then(function(value) { + log.push('.return() -> resolved ' + value); + if ((features & kReturnPrimitive) === kReturnPrimitive) + return resolve(value); + resolve({ value, done }); + }, function(value) { + log.push('.return() -> rejected ' + value); + reject(value); + }); + }); + } + }; + + + return { + [Symbol.asyncIterator]() { + log.push('[Symbol.asyncIterator]()') + return this; + }, + + next: (features & kNext) ? methods.next : undefined, + throw: (features & kThrow) ? methods.throw : undefined, + return: (features & kReturn) ? methods.return : undefined + }; + } + + let testDone; + let test; + async function testBindingIdentifierVarDeclarationStatement() { + let sum = 0; + testDone = false; + for await (var value of async([100, 200, 300, 400, 500])) sum += value; + testDone = true; + return sum; + } + + test = testBindingIdentifierVarDeclarationStatement(); + assertFalse(testDone); + assertEquals(1500, await test); + assertTrue(testDone); + + async function testBindingIdentifierVarDeclarationBlockStatement() { + let sum = 0; + testDone = false; + for await (var value of async([100, 200, 300, 400, 500])) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + sum += value; + } + testDone = true; + return sum; + } + + test = testBindingIdentifierVarDeclarationBlockStatement(); + assertFalse(testDone); + assertEquals(1500, await test); + assertTrue(testDone); + + async function testObjectBindingPatternVarDeclarationStatement() { + let sum = 0, keys = []; + let collection = [ + {key: 'first', value: 10}, {key: undefined, value: 20}, {value: 30}, + {key: 'last', value: 40} + ]; + testDone = false; + for await (var {key = 'unknown', value} of async(collection)) + keys.push(key), sum += value; + testDone = true; + return {keys, sum}; + } + + test = testObjectBindingPatternVarDeclarationStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + async function testObjectBindingPatternVarDeclarationBlockStatement() { + let sum = 0, keys = []; + let collection = [ + {key: 'first', value: 10}, {key: undefined, value: 20}, {value: 30}, + {key: 'last', value: 40} + ]; + testDone = false; + for await (var {key = 'unknown', value} of async(collection)) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + keys.push(key); + sum += value; + } + testDone = true; + return {keys, sum}; + } + + test = testObjectBindingPatternVarDeclarationBlockStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + async function testArrayBindingPatternVarDeclarationStatement() { + let sum = 0, keys = []; + let collection = [['first', 10], [undefined, 20], [, 30], ['last', 40]]; + testDone = false; + for await (var [key = 'unknown', value] of async(collection)) + keys.push(key), sum += value; + testDone = true; + return {keys, sum}; + } + + test = testArrayBindingPatternVarDeclarationStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + async function testArrayBindingPatternVarDeclarationBlockStatement() { + let sum = 0, keys = []; + let collection = [['first', 10], [undefined, 20], [, 30], ['last', 40]]; + testDone = false; + for await (var [key = 'unknown', value] of async(collection)) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + keys.push(key); + sum += value; + } + testDone = true; + return {keys, sum}; + } + + test = testArrayBindingPatternVarDeclarationBlockStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + // -------------------------------------------------------------------------- + + async function testBindingIdentifierLetDeclarationStatement() { + let sum = 0; + testDone = false; + for await (let value of async([100, 200, 300, 400, 500])) sum += value; + testDone = true; + return sum; + } + + test = testBindingIdentifierLetDeclarationStatement(); + assertFalse(testDone); + assertEquals(1500, await test); + assertTrue(testDone); + + async function testBindingIdentifierLetDeclarationBlockStatement() { + let sum = 0; + testDone = false; + for await (let value of async([100, 200, 300, 400, 500])) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + sum += value; + } + testDone = true; + return sum; + } + + test = testBindingIdentifierLetDeclarationBlockStatement(); + assertFalse(testDone); + assertEquals(1500, await test); + assertTrue(testDone); + + async function testObjectBindingPatternLetDeclarationStatement() { + let sum = 0, keys = []; + let collection = [ + {key: 'first', value: 10}, {key: undefined, value: 20}, {value: 30}, + {key: 'last', value: 40} + ]; + testDone = false; + for await (let {key = 'unknown', value} of async(collection)) + keys.push(key), sum += value; + testDone = true; + return {keys, sum}; + } + + test = testObjectBindingPatternLetDeclarationStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + async function testObjectBindingPatternLetDeclarationBlockStatement() { + let sum = 0, keys = []; + let collection = [ + {key: 'first', value: 10}, {key: undefined, value: 20}, {value: 30}, + {key: 'last', value: 40} + ]; + testDone = false; + for await (let {key = 'unknown', value} of async(collection)) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + keys.push(key); + sum += value; + } + testDone = true; + return {keys, sum}; + } + + let threwEarly = false; + test = testObjectBindingPatternLetDeclarationBlockStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + async function testObjectBindingPatternTDZLetDeclarationStatement() { + // See https://codereview.chromium.org/1218543003 + let sum = 0; + testDone = false; + let value = { value: 1 }; + try { + for await (let {value} of async([value])) sum += value; + } catch (error) { + threwEarly = true; + throw { sum, error, toString() { return 'TestError' } }; + } + } + + test = testObjectBindingPatternTDZLetDeclarationStatement(); + assertTrue(threwEarly, 'Async function promise should be rejected'); + try { + await test; + } catch (e) { + assertEquals('TestError', e.toString()); + assertEquals(0, e.sum); + assertInstanceof(e.error, ReferenceError); + testDone = true; + } + assertTrue(testDone, 'Awaited promise should be rejected'); + + async function testObjectBindingPatternTDZLetDeclarationBlockStatement() { + // See https://codereview.chromium.org/1218543003 + let sum = 0; + testDone = false; + let value = { value: 1 }; + try { + for await (let {value} of async([value])) { + sum += value; + } + } catch (error) { + threwEarly = true; + throw { sum, error, toString() { return 'TestError' } }; + } + } + + threwEarly = false; + test = testObjectBindingPatternTDZLetDeclarationBlockStatement(); + assertTrue(threwEarly, 'Async function promise should be rejected'); + try { + await test; + } catch (e) { + assertEquals('TestError', e.toString()); + assertEquals(0, e.sum); + assertInstanceof(e.error, ReferenceError); + testDone = true; + } + assertTrue(testDone, 'Awaited promise should be rejected'); + + async function testArrayBindingPatternLetDeclarationStatement() { + let sum = 0, keys = []; + let collection = [['first', 10], [undefined, 20], [, 30], ['last', 40]]; + testDone = false; + for await (let [key = 'unknown', value] of async(collection)) + keys.push(key), sum += value; + testDone = true; + return {keys, sum}; + } + + test = testArrayBindingPatternLetDeclarationStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + async function testArrayBindingPatternLetDeclarationBlockStatement() { + let sum = 0, keys = []; + let collection = [['first', 10], [undefined, 20], [, 30], ['last', 40]]; + testDone = false; + for await (let [key = 'unknown', value] of async(collection)) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + keys.push(key); + sum += value; + } + testDone = true; + return {keys, sum}; + } + + test = testArrayBindingPatternLetDeclarationBlockStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + async function testArrayBindingPatternTDZLetDeclarationStatement() { + // See https://codereview.chromium.org/1218543003 + let sum = 0; + testDone = false; + let value = [1]; + try { + for await (let [value] of async([value])) sum += value; + } catch (error) { + threwEarly = true; + throw { sum, error, toString() { return 'TestError' } }; + } + } + + threwEarly = false; + test = testArrayBindingPatternTDZLetDeclarationStatement(); + assertTrue(threwEarly, 'Async function promise should be rejected'); + try { + await test; + } catch (e) { + assertEquals('TestError', e.toString()); + assertEquals(0, e.sum); + assertInstanceof(e.error, ReferenceError); + testDone = true; + } + assertTrue(testDone, 'Awaited promise should be rejected'); + + async function testArrayBindingPatternTDZLetDeclarationBlockStatement() { + // See https://codereview.chromium.org/1218543003 + let sum = 0; + testDone = false; + let value = [1]; + try { + for await (let [value] of async([value])) { + sum += value; + } + } catch (error) { + threwEarly = true; + throw { sum, error, toString() { return 'TestError' } }; + } + } + + threwEarly = false; + test = testArrayBindingPatternTDZLetDeclarationBlockStatement(); + assertTrue(threwEarly, 'Async function promise should be rejected'); + try { + await test; + } catch (e) { + assertEquals('TestError', e.toString()); + assertEquals(0, e.sum); + assertInstanceof(e.error, ReferenceError); + testDone = true; + } + assertTrue(testDone, 'Awaited promise should be rejected'); + + // -------------------------------------------------------------------------- + + async function testBindingIdentifierConstDeclarationStatement() { + let sum = 0; + testDone = false; + for await (let value of async([100, 200, 300, 400, 500])) sum += value; + testDone = true; + return sum; + } + + test = testBindingIdentifierConstDeclarationStatement(); + assertFalse(testDone); + assertEquals(1500, await test); + assertTrue(testDone); + + async function testBindingIdentifierConstDeclarationBlockStatement() { + let sum = 0; + testDone = false; + for await (const value of async([100, 200, 300, 400, 500])) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + sum += value; + } + testDone = true; + return sum; + } + + test = testBindingIdentifierConstDeclarationBlockStatement(); + assertFalse(testDone); + assertEquals(1500, await test); + assertTrue(testDone); + + async function testObjectBindingPatternConstDeclarationStatement() { + let sum = 0, keys = []; + let collection = [ + {key: 'first', value: 10}, {key: undefined, value: 20}, {value: 30}, + {key: 'last', value: 40} + ]; + testDone = false; + for await (const {key = 'unknown', value} of async(collection)) + keys.push(key), sum += value; + testDone = true; + return {keys, sum}; + } + + test = testObjectBindingPatternConstDeclarationStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + async function testObjectBindingPatternConstDeclarationBlockStatement() { + let sum = 0, keys = []; + let collection = [ + {key: 'first', value: 10}, {key: undefined, value: 20}, {value: 30}, + {key: 'last', value: 40} + ]; + testDone = false; + for await (const {key = 'unknown', value} of async(collection)) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + keys.push(key); + sum += value; + } + testDone = true; + return {keys, sum}; + } + + test = testObjectBindingPatternConstDeclarationBlockStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + async function testObjectBindingPatternTDZConstDeclarationStatement() { + // See https://codereview.chromium.org/1218543003 + let sum = 0; + testDone = false; + const value = { value: 1 }; + try { + for await (const {value} of async([value])) sum += value; + } catch (error) { + threwEarly = true; + throw { sum, error, toString() { return 'TestError' } }; + } + } + + threwEarly = false; + test = testObjectBindingPatternTDZConstDeclarationStatement(); + assertTrue(threwEarly, 'Async function promise should be rejected'); + try { + await test; + } catch (e) { + assertEquals('TestError', e.toString()); + assertEquals(0, e.sum); + assertInstanceof(e.error, ReferenceError); + testDone = true; + } + assertTrue(testDone, 'Awaited promise should be rejected'); + + async function testObjectBindingPatternTDZConstDeclarationBlockStatement() { + // See https://codereview.chromium.org/1218543003 + let sum = 0; + testDone = false; + const value = { value: 1 }; + try { + for await (const {value} of async([value])) { + sum += value; + } + } catch (error) { + threwEarly = true; + throw { sum, error, toString() { return 'TestError' } }; + } + } + + threwEarly = false; + test = testObjectBindingPatternTDZConstDeclarationBlockStatement(); + assertTrue(threwEarly, 'Async function promise should be rejected'); + try { + await test; + } catch (e) { + assertEquals('TestError', e.toString()); + assertEquals(0, e.sum); + assertInstanceof(e.error, ReferenceError); + testDone = true; + } + assertTrue(testDone, 'Awaited promise should be rejected'); + + async function testArrayBindingPatternConstDeclarationStatement() { + let sum = 0, keys = []; + let collection = [['first', 10], [undefined, 20], [, 30], ['last', 40]]; + testDone = false; + for await (const [key = 'unknown', value] of async(collection)) + keys.push(key), sum += value; + testDone = true; + return {keys, sum}; + } + + test = testArrayBindingPatternConstDeclarationStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + async function testArrayBindingPatternConstDeclarationBlockStatement() { + let sum = 0, keys = []; + let collection = [['first', 10], [undefined, 20], [, 30], ['last', 40]]; + testDone = false; + for await (const [key = 'unknown', value] of async(collection)) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + keys.push(key); + sum += value; + } + testDone = true; + return {keys, sum}; + } + + test = testArrayBindingPatternLetDeclarationBlockStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 100}, await test); + assertTrue(testDone); + + async function testArrayBindingPatternTDZConstDeclarationStatement() { + // See https://codereview.chromium.org/1218543003 + let sum = 0; + testDone = false; + const value = [1]; + try { + for await (const [value] of async([value])) sum += value; + } catch (error) { + threwEarly = true; + throw { sum, error, toString() { return 'TestError' } }; + } + } + + threwEarly = false; + test = testArrayBindingPatternTDZConstDeclarationStatement(); + assertTrue(threwEarly, 'Async function promise should be rejected'); + try { + await test; + } catch (e) { + assertEquals('TestError', e.toString()); + assertEquals(0, e.sum); + assertInstanceof(e.error, ReferenceError); + testDone = true; + } + assertTrue(testDone, 'Awaited promise should be rejected'); + + async function testArrayBindingPatternTDZConstDeclarationBlockStatement() { + // See https://codereview.chromium.org/1218543003 + let sum = 0; + testDone = false; + const value = [1]; + try { + for await (const [value] of async([value])) { + sum += value; + } + } catch (error) { + threwEarly = true; + throw { sum, error, toString() { return 'TestError' } }; + } + } + + threwEarly = false; + test = testArrayBindingPatternTDZConstDeclarationBlockStatement(); + assertTrue(threwEarly, 'Async function promise should be rejected'); + try { + await test; + } catch (e) { + assertEquals('TestError', e.toString()); + assertEquals(0, e.sum); + assertInstanceof(e.error, ReferenceError); + testDone = true; + } + assertTrue(testDone, 'Awaited promise should be rejected'); + + // -------------------------------------------------------------------------- + + async function testBindingIdentifierLHSStatement() { + let sum = 0; + let value; + testDone = false; + for await (value of async([100, 200, 300, 400, 500])) sum += value; + testDone = true; + return sum; + } + + test = testBindingIdentifierLHSStatement(); + assertFalse(testDone); + assertEquals(1500, await test); + assertTrue(testDone); + + async function testBindingIdentifierLHSBlockStatement() { + let sum = 0; + let value; + testDone = false; + for await (value of async([100, 200, 300, 400, 500])) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + sum += value; + } + testDone = true; + return sum; + } + + test = testBindingIdentifierLHSStatement(); + assertFalse(testDone); + assertEquals(1500, await test); + assertTrue(testDone); + + async function testObjectBindingPatternLHSStatement() { + let sum = 0; + let keys = []; + let value; + let key; + let collection = [ + {key: 'first', value: 1}, {key: undefined, value: 2}, {value: 3}, + {key: 'last', value: 4} + ]; + testDone = false; + for await ({key = 'unknown', value} of async(collection)) + keys.push(key), sum += value; + testDone = true; + return {keys, sum}; + } + + test = testObjectBindingPatternLHSStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 10}, await test); + assertTrue(testDone); + + async function testObjectBindingPatternLHSBlockStatement() { + let sum = 0; + let keys = []; + let value; + let key; + let collection = [ + {key: 'first', value: 1}, {key: undefined, value: 2}, {value: 3}, + {key: 'last', value: 4} + ]; + testDone = false; + for await ({key = 'unknown', value} of async(collection)) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + keys.push(key); + sum += value; + } + testDone = true; + return {keys, sum}; + } + + test = testObjectBindingPatternLHSBlockStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 10}, await test); + assertTrue(testDone); + + async function testArrayBindingPatternLHSStatement() { + let sum = 0; + let keys = []; + let value; + let key; + let collection = [['first', 1], [undefined, 2], [, 3], ['last', 4]]; + testDone = false; + for await ([key = 'unknown', value] of async(collection)) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + keys.push(key); + sum += value; + } + testDone = true; + return {keys, sum}; + } + + test = testArrayBindingPatternLHSStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 10}, await test); + assertTrue(testDone); + + async function testArrayBindingPatternLHSBlockStatement() { + let sum = 0; + let keys = []; + let value; + let key; + let collection = [ + {key: 'first', value: 1}, {key: undefined, value: 2}, {value: 3}, + {key: 'last', value: 4} + ]; + testDone = false; + for await ({key = 'unknown', value} of async(collection)) { + 'use strict'; + let strict = (function() { return this === undefined; })(); + assertFalse(strict); + keys.push(key); + sum += value; + } + testDone = true; + return {keys, sum}; + } + + test = testArrayBindingPatternLHSBlockStatement(); + assertFalse(testDone); + assertEquals( + {keys: ['first', 'unknown', 'unknown', 'last'], sum: 10}, await test); + assertTrue(testDone); + + // -------------------------------------------------------------------------- + + async function testBreakStatementReturnMethodNotPresent() { + let log = []; + let collection = [1, 2, 3, 4, 5]; + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(collection, kNext, log)) { + sum += x; + if (++i === 3) break; + } + testDone = true; + return { sum, log }; + } + + test = testBreakStatementReturnMethodNotPresent(); + assertFalse(testDone); + assertEquals({sum: 6, log: ['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.next() -> resolved 3']}, + await test); + assertTrue(testDone); + + async function testBreakStatementReturnMethodPresent() { + let log = []; + let collection = [1, 2, 3, 4, 5]; + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(collection, kNext|kReturn, log)) { + sum += x; + if (++i === 2) break; + } + testDone = true; + return { sum, log }; + } + + test = testBreakStatementReturnMethodPresent(); + assertFalse(testDone); + assertEquals({sum: 3, log: ['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.return(undefined)']}, + await test); + assertTrue(testDone); + + async function testBreakStatementReturnMethodAwaitIterResult() { + let log = []; + let collection = [1, 2, 3, 4, 5]; + let sync_iter = collection[Symbol.iterator](); + sync_iter.return = function() { + return { + value: new Promise(function(resolve, reject) { + Promise.resolve().then(function() { + resolve('break!'); + }); + }), + done: true + }; + }; + + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(sync_iter, kNext|kReturn, log)) { + sum += x; + if (++i === 2) break; + } + testDone = true; + return { sum, log }; + } + + test = testBreakStatementReturnMethodAwaitIterResult(); + assertFalse(testDone); + assertEquals({sum: 3, + log: ['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.return() -> resolved break!' ]}, + await test); + assertTrue(testDone); + + async function testBreakStatementReturnMethodAwaitRejection(log) { + let collection = [1, 2, 3, 4, 5]; + let sync_iter = collection[Symbol.iterator](); + let sum = 0; + sync_iter.return = function() { + return { + value: new Promise(function(resolve, reject) { + Promise.resolve().then(function() { + reject('break! ' + sum); + }); + }), + done: true + }; + }; + + let i = 0; + testDone = false; + for await (var x of async(sync_iter, kNext|kReturn, log)) { + sum += x; + if (++i === 2) break; + } + return { sum, log }; + } + + let log = []; + test = testBreakStatementReturnMethodAwaitRejection(log); + assertFalse(testDone); + try { + await test; + } catch (e) { + assertEquals(log, ['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.return() -> rejected break! 3']); + assertEquals('break! 3', e); + testDone = true; + } + assertTrue(testDone, 'Promise should be rejected'); + + async function testBreakStatementReturnMethodPrimitiveValue(log) { + let collection = [1, 2, 3, 4, 5]; + let sync_iter = collection[Symbol.iterator](); + sync_iter.return = function() { + return { value: 'break! primitive!', done: true }; + } + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(sync_iter, kNext|kReturnPrimitive, log)) { + sum += x; + if (++i === 2) break; + } + return { sum, log }; + } + log = []; + test = testBreakStatementReturnMethodPrimitiveValue(log); + assertFalse(testDone); + try { + await test; + } catch (e) { + assertEquals(['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.return() -> resolved break! primitive!'], + log); + assertInstanceof(e, TypeError); + testDone = true; + } + assertTrue(testDone, 'Promise should be rejected'); + + async function testReturnStatementReturnMethodNotPresent() { + let log = []; + let collection = [1, 2, 3, 4, 5]; + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(collection, kNext, log)) { + sum += x; + if (++i === 3) { + testDone = true; + return { sum, log }; + } + } + } + + test = testReturnStatementReturnMethodNotPresent(); + assertFalse(testDone); + assertEquals({sum: 6, log: ['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.next() -> resolved 3']}, + await test); + assertTrue(testDone); + + async function testReturnStatementReturnMethodPresent() { + let log = []; + let collection = [1, 2, 3, 4, 5]; + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(collection, kNext|kReturn, log)) { + sum += x; + if (++i === 2) { + testDone = true; + return { sum, log }; + } + } + } + + test = testReturnStatementReturnMethodPresent(); + assertFalse(testDone); + assertEquals({sum: 3, log: ['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.return(undefined)']}, + await test); + assertTrue(testDone); + + async function testReturnStatementReturnMethodAwaitIterResult() { + let log = []; + let collection = [1, 2, 3, 4, 5]; + let sync_iter = collection[Symbol.iterator](); + sync_iter.return = function() { + return { + value: new Promise(function(resolve, reject) { + Promise.resolve().then(function() { + testDone = true; + resolve('return!'); + }); + }), + done: true + }; + }; + + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(sync_iter, kNext|kReturn, log)) { + sum += x; + if (++i === 2) return { sum, log }; + } + } + + test = testReturnStatementReturnMethodAwaitIterResult(); + assertFalse(testDone); + assertEquals({sum: 3, + log: ['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.return() -> resolved return!' ]}, + await test); + assertTrue(testDone); + + async function testReturnStatementReturnMethodAwaitRejection(log) { + let collection = [1, 2, 3, 4, 5]; + let sync_iter = collection[Symbol.iterator](); + let sum = 0; + sync_iter.return = function() { + return { + value: new Promise(function(resolve, reject) { + Promise.resolve().then(function() { + reject('return! ' + sum); + }); + }), + done: true + }; + }; + + let i = 0; + testDone = false; + for await (var x of async(sync_iter, kNext|kReturn, log)) { + sum += x; + if (++i === 2) return { sum, log }; + } + } + + log = []; + test = testReturnStatementReturnMethodAwaitRejection(log); + assertFalse(testDone); + try { + await test; + } catch (e) { + assertEquals('return! 3', e); + assertEquals(['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.return() -> rejected return! 3'], + log); + testDone = true; + } + assertTrue(testDone, 'Promise should be rejected'); + + async function testReturnStatementReturnMethodPrimitiveValue(log) { + let collection = [1, 2, 3, 4, 5]; + let sync_iter = collection[Symbol.iterator](); + sync_iter.return = function() { + return { value: 'return! primitive!', done: true }; + } + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(sync_iter, kNext|kReturnPrimitive, log)) { + sum += x; + if (++i === 2) break; + } + return { sum, log }; + } + log = []; + test = testReturnStatementReturnMethodPrimitiveValue(log); + assertFalse(testDone); + try { + await test; + } catch (e) { + assertEquals(['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.return() -> resolved return! primitive!'], + log); + assertInstanceof(e, TypeError); + testDone = true; + } + assertTrue(testDone, 'Promise should be rejected'); + + async function testThrowStatementReturnMethodNotPresent() { + let log = []; + let collection = [1, 2, 3, 4, 5]; + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(collection, kNext|kThrow, log)) { + sum += x; + if (++i === 3) { + throw { sum, log, toString() { return 'TestError'; } }; + } + } + return { sum, log }; + } + + test = testThrowStatementReturnMethodNotPresent(); + assertFalse(testDone); + try { + await test; + } catch (e) { + assertEquals('TestError', e.toString()); + assertEquals(6, e.sum); + assertEquals(['[Symbol.asyncIterator]()', '.next() -> resolved 1', + '.next() -> resolved 2', '.next() -> resolved 3' + ], e.log); + testDone = true; + } + assertTrue(testDone, 'Awaited Promise should be rejected'); + + async function testThrowStatementReturnMethodPresent() { + let log = []; + let collection = [1, 2, 3, 4, 5]; + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(collection, kNext|kThrow|kReturn, log)) { + sum += x; + if (++i === 2) { + throw { sum, log, toString() { return 'TestError2'; } }; + } + } + return { sum, log }; + } + + test = testThrowStatementReturnMethodPresent(); + assertFalse(testDone); + try { + await test; + } catch (e) { + assertEquals('TestError2', e.toString()); + assertEquals(3, e.sum); + assertEquals(['[Symbol.asyncIterator]()', '.next() -> resolved 1', + '.next() -> resolved 2', '.return(undefined)' + ], e.log); + testDone = true; + } + assertTrue(testDone, 'Awaited Promise should be rejected'); + + async function testThrowStatementReturnMethodAwaitIterResult(log) { + let collection = [1, 2, 3, 4, 5]; + let sync_iter = collection[Symbol.iterator](); + sync_iter.return = function() { + return { + value: new Promise(function(resolve, reject) { + Promise.resolve().then(function() { + testDone = true; + resolve('throw!'); + }); + }), + done: true + }; + }; + + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(sync_iter, kNext|kReturn, log)) { + sum += x; + if (++i === 2) throw 'Boo!!'; + } + } + + log = []; + test = testThrowStatementReturnMethodAwaitIterResult(log); + assertFalse(testDone); + + try { + await test; + } catch (e) { + assertEquals('Boo!!', e); + assertEquals(['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.return() -> resolved throw!' ], log); + testDone = true; + } + assertTrue(testDone, 'Awaited Promise should be rejected'); + + async function testThrowStatementReturnMethodAwaitRejection(log) { + let collection = [1, 2, 3, 4, 5]; + let sync_iter = collection[Symbol.iterator](); + let sum = 0; + sync_iter.return = function() { + return { + value: new Promise(function(resolve, reject) { + Promise.resolve().then(function() { + reject('return! ' + sum); + }); + }), + done: true + }; + }; + + let i = 0; + testDone = false; + for await (var x of async(sync_iter, kNext|kReturn, log)) { + sum += x; + if (++i === 2) throw 'Boo!!'; + } + } + + log = []; + test = testThrowStatementReturnMethodAwaitRejection(log); + assertFalse(testDone); + try { + await test; + } catch (e) { + assertEquals('Boo!!', e); + assertEquals(['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.return() -> rejected return! 3'], + log); + testDone = true; + } + assertTrue(testDone, 'Promise should be rejected'); + + async function testThrowStatementReturnMethodPrimitiveValue(log) { + let collection = [1, 2, 3, 4, 5]; + let sync_iter = collection[Symbol.iterator](); + sync_iter.return = function() { + return { value: 'return! primitive!', done: true }; + } + let sum = 0; + let i = 0; + testDone = false; + for await (var x of async(sync_iter, kNext|kReturnPrimitive, log)) { + sum += x; + if (++i === 2) throw 'Boo!!'; + } + } + log = []; + test = testThrowStatementReturnMethodPrimitiveValue(log); + assertFalse(testDone); + try { + await test; + } catch (e) { + assertEquals(['[Symbol.asyncIterator]()', + '.next() -> resolved 1', + '.next() -> resolved 2', + '.return() -> resolved return! primitive!'], + log); + + // AsyncIteratorClose does not require Throw completions to be of type + // Object + assertEquals('Boo!!', e); + testDone = true; + } + assertTrue(testDone, 'Promise should be rejected'); +})().catch(function(error) { + testFailed = true; + testFailure = error; +}); + +%RunMicrotasks(); + +if (testFailed) { + throw testFailure; +} diff --git a/deps/v8/test/mjsunit/harmony/function-tostring.js b/deps/v8/test/mjsunit/harmony/function-tostring.js new file mode 100644 index 0000000000..949ac2282f --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/function-tostring.js @@ -0,0 +1,124 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --harmony-function-tostring + +var prefix = "/*before*/"; +var suffix = "/*after*/"; + +function checkStringRepresentation(f, source) { + assertEquals(typeof f, "function"); + assertEquals(source, f.toString()); +} + +function testDeclaration(source) { + // this eval should define a local variable f that is a function + eval(prefix + source + suffix); + checkStringRepresentation(f, source); +} +testDeclaration( "function f(){}"); +testDeclaration( "function*f(){}"); +testDeclaration("async function f(){}"); +testDeclaration( "function/*A*/ f/*B*/(/*C*/a/*D*/,/*E*/b/*G*/)/*H*/{/*I*/}"); +testDeclaration( "function/*A*/*f/*B*/(/*C*/a/*D*/,/*E*/b/*G*/)/*H*/{/*I*/}"); +testDeclaration("async/*Z*/function/*A*/ f/*B*/(/*C*/a/*D*/,/*E*/b/*G*/)/*H*/{/*I*/}"); +testDeclaration( "function \t f \n ( \r a \r\n,\n\r b ) {'\u2654'}"); +testDeclaration( "function \t *f \n ( \r a \r\n,\n\r b ) { }"); +testDeclaration( "function *\t f \n ( \r a \r\n,\n\r b ) { }"); +testDeclaration("async \t function f \n ( \r a \r\n,\n\r b ) { }"); + +function testExpression(source) { + // this eval should return a function + var f = eval("(" + prefix + source + suffix + ")"); + checkStringRepresentation(f, source); +} +testExpression( "function (){}"); +testExpression( "function f(){}"); +testExpression( "function* (){}"); +testExpression( "function*f(){}"); +testExpression("async function (){}"); +testExpression("async function f(){}"); +testExpression( "function/*A*/ /*B*/(/*C*/a/*D*/,/*E*/b/*G*/)/*H*/{/*I*/}"); +testExpression( "function/*A*/ f/*B*/(/*C*/a/*D*/,/*E*/b/*G*/)/*H*/{/*I*/}"); +testExpression( "function/*A*/* /*B*/(/*C*/a/*D*/,/*E*/b/*G*/)/*H*/{/*I*/}"); +testExpression( "function/*A*/*f/*B*/(/*C*/a/*D*/,/*E*/b/*G*/)/*H*/{/*I*/}"); +testExpression("async/*Z*/function/*A*/ f/*B*/(/*C*/a/*D*/,/*E*/b/*G*/)/*H*/{/*I*/}"); +testExpression( "function \t \n ( \r a \r\n,\n\r b ) { }"); +testExpression( "function \t f \n ( \r a \r\n,\n\r b ) { }"); +testExpression( "function \t * \n ( \r a \r\n,\n\r b ) { }"); +testExpression( "function \t *f \n ( \r a \r\n,\n\r b ) { }"); +testExpression( "function *\t \n ( \r a \r\n,\n\r b ) { }"); +testExpression( "function *\t f \n ( \r a \r\n,\n\r b ) { }"); +testExpression("async \t function \n ( \r a \r\n,\n\r b ) { }"); + +testExpression( "(/*A*/ /*B*/ /*C*/ /*D*/ /*E*/ /*F*/)/*G*/=>/*H*/0"); +testExpression( "a/*B*/ /*C*/ /*D*/ /*E*/ /*F*/ /*G*/=>/*H*/{}"); +testExpression( "(/*A*/a/*B*/ /*C*/ /*D*/ /*E*/ /*F*/)/*G*/=>/*H*/0"); +testExpression( "(/*A*/a/*B*/,/*C*/b/*D*/,/*E*/c/*F*/)/*G*/=>/*H*/{}"); +testExpression("async (/*A*/ /*B*/ /*C*/ /*D*/ /*E*/ /*F*/)/*G*/=>/*H*/0"); +testExpression("async a/*B*/ /*C*/ /*D*/ /*E*/ /*F*/ /*G*/=>/*H*/{}"); +testExpression("async (/*A*/a/*B*/ /*C*/ /*D*/ /*E*/ /*F*/)/*G*/=>/*H*/0"); +testExpression("async (/*A*/a/*B*/,/*C*/b/*D*/,/*E*/c/*F*/)/*G*/=>/*H*/{}"); + +function testSimpleMethod(source) { + // the source should define a method f + + // object method + var f = eval("({" + prefix + source + suffix + "}.f)"); + checkStringRepresentation(f, source); + + // nonstatic class method + var f = eval("new class{" + prefix + source + suffix + "}().f"); + checkStringRepresentation(f, source); + + // static class method + var f = eval("(class{static" + prefix + source + suffix + "}).f"); + checkStringRepresentation(f, source); +} +testSimpleMethod("f(){}"); +testSimpleMethod("*f(){}"); +testSimpleMethod("async f(){}"); +testSimpleMethod("f \t (){}"); +testSimpleMethod("* \tf(){}"); +testSimpleMethod("async \t f (){}"); + +function testAccessorMethod(source, getOrSet) { + // the source should define a getter or setter method + + // object method + var f = Object.getOwnPropertyDescriptor(eval("({" + prefix + source + suffix + "})"), "f")[getOrSet]; + checkStringRepresentation(f, source); + + // nonstatic class method + var f = Object.getOwnPropertyDescriptor(eval("(class{" + prefix + source + suffix + "})").prototype, "f")[getOrSet]; + + // static class method + var f = Object.getOwnPropertyDescriptor(eval("(class{static" + prefix + source + suffix + "})"), "f")[getOrSet]; + checkStringRepresentation(f, source); +} + +testAccessorMethod("get f( ){}", "get"); +testAccessorMethod("set f(a){}", "set"); +testAccessorMethod("get/*A*/f/*B*/(/*C*/ /*D*/)/*E*/{/*F*/}", "get"); +testAccessorMethod("set/*A*/f/*B*/(/*C*/a/*D*/)/*E*/{/*F*/}", "set"); + +const GeneratorFunction = function*(){}.constructor; +const AsyncFunction = async function(){}.constructor; +function testDynamicFunction(...args) { + var P = args.slice(0, args.length - 1).join(","); + var bodyText = args.length > 0 ? args[args.length - 1] : ""; + var source = " anonymous(" + P + "\n) {\n" + bodyText + "\n}"; + checkStringRepresentation( Function(...args), "function" + source); + checkStringRepresentation(GeneratorFunction(...args), "function*" + source); + checkStringRepresentation( AsyncFunction(...args), "async function" + source); +} +testDynamicFunction(); +testDynamicFunction(";"); +testDynamicFunction("return"); +testDynamicFunction("a", "return a"); +testDynamicFunction("a", "b", "return a"); +testDynamicFunction("a, b", "return a"); +testDynamicFunction("a,/*A*/b", "return a"); +testDynamicFunction("/*A*/a,b", "return a"); +testDynamicFunction("a,b", "return a/*A*/"); diff --git a/deps/v8/test/mjsunit/harmony/futex.js b/deps/v8/test/mjsunit/harmony/futex.js index 1f9474b46c..ea71be99fb 100644 --- a/deps/v8/test/mjsunit/harmony/futex.js +++ b/deps/v8/test/mjsunit/harmony/futex.js @@ -95,6 +95,20 @@ assertEquals("timed-out", Atomics.wait(i32a, 0, 0, -Infinity)); })(); +(function TestWaitNotAllowed() { + %SetAllowAtomicsWait(false); + var i32a = new Int32Array(new SharedArrayBuffer(16)); + assertThrows(function() { + Atomics.wait(i32a, 0, 0, -1); + }); + %SetAllowAtomicsWait(true); +})(); + +(function TestWakePositiveInfinity() { + var i32a = new Int32Array(new SharedArrayBuffer(16)); + Atomics.wake(i32a, 0, Number.POSITIVE_INFINITY); +})(); + //// WORKER ONLY TESTS if (this.Worker) { diff --git a/deps/v8/test/mjsunit/harmony/object-rest-basic.js b/deps/v8/test/mjsunit/harmony/object-rest-basic.js new file mode 100644 index 0000000000..f03eccdc16 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/object-rest-basic.js @@ -0,0 +1,159 @@ +// // Copyright 2016 the V8 project authors. All rights reserved. +// // Use of this source code is governed by a BSD-style license that can be +// // found in the LICENSE file. + +// Flags: --harmony-object-rest-spread +var { ...x } = { a: 1 }; +assertEquals({ a: 1 }, x); + +var { ...x } = { a: 1, b: 1 }; +assertEquals({ a: 1, b: 1 }, x); + +var { x, ...x } = { a: 1, b: 1 }; +assertEquals({ a: 1, b: 1 }, x); + +var { x = {}, ...x } = { a: 1, b: 1 }; +assertEquals({ a: 1, b: 1 }, x); + +var { y, ...x } = { y: 1, a: 1 }; +assertEquals({ a: 1 }, x); +assertEquals(1, y); + +var { z, y, ...x } = { z:1, y: 1, a: 1, b: 1 }; +assertEquals({ a: 1, b:1 }, x); +assertEquals(1, y); +assertEquals(1, z); + +({ a, ...b } = { a: 1, b: 2 }); +assertEquals(1, a); +assertEquals({ b: 2 }, b); + +var { ...x } = {}; +assertEquals({}, x); + +var key = "b"; +var { [key]: y, ...x } = { b: 1, a: 1 }; +assertEquals({ a: 1 }, x); +assertEquals(1, y); + +var key = 1; +var { [key++]: y, ...x } = { 1: 1, a: 1 }; +assertEquals({ a: 1 }, x); +assertEquals(key, 2); +assertEquals(1, y); + +var key = '1'; +var {[key]: y, ...x} = {1: 1, a: 1}; +assertEquals({a: 1}, x); +assertEquals(1, y); + +function example({a, ...rest}, { b = rest }) { + assertEquals(1, a); + assertEquals({ b: 2, c: 3}, rest); + assertEquals({ b: 2, c: 3}, b); +}; +example({ a: 1, b: 2, c: 3}, { b: undefined }); + +var x = { a: 3 }; +var y = { + set a(val) { assertUnreachable(); }, + ...x, +}; +assertEquals(y.a, 3); + +var {...y} = { + get a() { + return 1 + } +}; +assertEquals({a: 1}, y); + +var x = { + get a() { throw new Error(); }, +}; +assertThrows(() => { var { ...y } = x }); + +var p = new Proxy({}, { + ownKeys() { throw new Error(); } +}); +assertThrows(() => { var { ...y } = p }); + +var p = new Proxy({}, { + ownKeys() { [1]; }, + get() { throw new Error(); } +}); +assertThrows(() => { var { ...y } = p }); + +var p = new Proxy({}, { + ownKeys() { [1]; }, + getOwnPropertyDescriptor() { throw new Error(); } +}); +assertThrows(() => { var { ...y } = p }); + +var z = { b: 1} +var p = new Proxy(z, { + ownKeys() { return Object.keys(z); }, + get(_, prop) { return z[prop]; }, + getOwnPropertyDescriptor(_, prop) { + return Object.getOwnPropertyDescriptor(z, prop); + }, +}); +var { ...y } = p ; +assertEquals(z, y); + +var z = { b: 1} +var { ...y } = { ...z} ; +assertEquals(z, y); + +var count = 0; +class Foo { + constructor(x) { this.x = x; } + toString() { count++; return this.x.toString(); } +} +var f = new Foo(1); +var { [f] : x, ...y } = { 1: 1, 2: 2} +assertEquals(1, count); +assertEquals({2: 2}, y); + +var { 1: x, 2: y, ...z } = { 1: 1, 2: 2, 3:3 }; +assertEquals(1, x); +assertEquals(2, y); +assertEquals({ 3: 3 }, z); + +var { 1.5: x, 2: y, ...z } = { 1.5: 1, 2: 2, 3:3 }; +assertEquals(1, x); +assertEquals(2, y); +assertEquals({ 3: 3 }, z); + +(({x, ...z}) => { assertEquals({y: 1}, z); })({ x: 1, y: 1}); + +var [...{...z}] = [{ x: 1}]; +assertEquals({ 0: { x: 1} }, z); + +var {...{x}} = { x: 1}; +assertEquals(1, x); + +var {4294967297: y, ...x} = {4294967297: 1, x: 1}; +assertEquals(1, y); +assertEquals({x: 1}, x); + +var obj = { + [Symbol.toPrimitive]() { + return 1; + } +}; +var {[obj]: y, ...x} = {1: 1, x: 1}; +assertEquals(1, y); +assertEquals({x: 1}, x); + +var {[null]: y, ...x} = {null: 1, x: 1}; +assertEquals(1, y); +assertEquals({x: 1}, x); + +var {[true]: y, ...x} = {true: 1, x: 1}; +assertEquals(1, y); +assertEquals({x: 1}, x); + +var {[false]: y, ...x} = {false: 1, x: 1}; +assertEquals(1, y); +assertEquals({x: 1}, x); diff --git a/deps/v8/test/mjsunit/harmony/object-spread-basic.js b/deps/v8/test/mjsunit/harmony/object-spread-basic.js index de19805d30..8724b1af28 100644 --- a/deps/v8/test/mjsunit/harmony/object-spread-basic.js +++ b/deps/v8/test/mjsunit/harmony/object-spread-basic.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-object-spread +// Flags: --harmony-object-rest-spread var x = {a: 1}; var y = { ...x}; diff --git a/deps/v8/test/mjsunit/harmony/promise-prototype-finally.js b/deps/v8/test/mjsunit/harmony/promise-prototype-finally.js new file mode 100644 index 0000000000..eefce4b6ba --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/promise-prototype-finally.js @@ -0,0 +1,661 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --harmony-promise-finally --allow-natives-syntax + +var asyncAssertsExpected = 0; + +function assertUnreachable() { + %AbortJS("Unreachable: failure"); +} + +function assertAsyncRan() { + ++asyncAssertsExpected; +} + +function assertAsync(b, s) { + if (b) { + print(s, "succeeded"); + } else { + %AbortJS(s + " FAILED!"); + } + --asyncAssertsExpected; +} + +function assertEqualsAsync(b, s) { + if (b === s) { + print(b, "===", s, "succeeded"); + } else { + %AbortJS(b + "===" + s + " FAILED!"); + } + --asyncAssertsExpected; +} + +function assertAsyncDone(iteration) { + var iteration = iteration || 0; + %EnqueueMicrotask(function() { + if (asyncAssertsExpected === 0) + assertAsync(true, "all"); + else if ( + iteration > 10 // Shouldn't take more. + ) + assertAsync(false, "all... " + asyncAssertsExpected); + else + assertAsyncDone(iteration + 1); + }); +} + +(function() { + assertThrows( + function() { + Promise.prototype.finally.call(5); + }, + TypeError + ); +})(); + +// resolve/finally/then +(function() { + Promise.resolve(3).finally().then( + x => { + assertEqualsAsync(3, x); + }, + assertUnreachable + ); + assertAsyncRan(); +})(); + +// reject/finally/then +(function() { + Promise.reject(3).finally().then(assertUnreachable, x => { + assertEqualsAsync(3, x); + }); + assertAsyncRan(); +})(); + +// resolve/finally-return-notcallable/then +(function() { + Promise.resolve(3).finally(2).then( + x => { + assertEqualsAsync(3, x); + }, + assertUnreachable + ); + assertAsyncRan(); +})(); + +// reject/finally-return-notcallable/then +(function() { + Promise.reject(3).finally(2).then( + assertUnreachable, e => { + assertEqualsAsync(3, e); + }); + assertAsyncRan(); +})(); + +// reject/finally/catch +(function() { + Promise.reject(3).finally().catch(reason => { + assertEqualsAsync(3, reason); + }); + assertAsyncRan(); +})(); + +// reject/finally/then/catch +(function() { + Promise.reject(3).finally().then(assertUnreachable).catch(reason => { + assertEqualsAsync(3, reason); + }); + assertAsyncRan(); +})(); + +// resolve/then/finally/then +(function() { + Promise.resolve(3) + .then(x => { + assertEqualsAsync(3, x); + return x; + }) + .finally() + .then( + x => { + assertEqualsAsync(3, x); + }, + assertUnreachable + ); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/catch/finally/then +(function() { + Promise.reject(3) + .catch(x => { + assertEqualsAsync(3, x); + return x; + }) + .finally() + .then( + x => { + assertEqualsAsync(3, x); + }, + assertUnreachable + ); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// resolve/finally-throw/then +(function() { + Promise.resolve(3) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + throw 1; + }) + .then(assertUnreachable, function onRejected(reason) { + assertEqualsAsync(1, reason); + }); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/finally-throw/then +(function() { + Promise.reject(3) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + throw 1; + }) + .then(assertUnreachable, function onRejected(reason) { + assertEqualsAsync(1, reason); + }); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// resolve/finally-return/then +(function() { + Promise.resolve(3) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return 4; + }) + .then( + x => { + assertEqualsAsync(x, 3); + }, + assertUnreachable + ); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/finally-return/then +(function() { + Promise.reject(3) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return 4; + }) + .then(assertUnreachable, x => { + assertEqualsAsync(x, 3); + }); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/catch-throw/finally-throw/then +(function() { + Promise.reject(3) + .catch(e => { + assertEqualsAsync(3, e); + throw e; + }) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + throw 4; + }) + .then(assertUnreachable, function onRejected(e) { + assertEqualsAsync(4, e); + }); + assertAsyncRan(); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// resolve/then-throw/finally-throw/then +(function() { + Promise.resolve(3) + .then(e => { + assertEqualsAsync(3, e); + throw e; + }) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + throw 4; + }) + .then(assertUnreachable, function onRejected(e) { + assertEqualsAsync(4, e); + }); + assertAsyncRan(); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// resolve/finally-return-rejected-promise/then +(function() { + Promise.resolve(3) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return Promise.reject(4); + }) + .then(assertUnreachable, e => { + assertEqualsAsync(4, e); + }); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/finally-return-rejected-promise/then +(function() { + Promise.reject(3) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return Promise.reject(4); + }) + .then(assertUnreachable, e => { + assertEqualsAsync(4, e); + }); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// resolve/finally-return-resolved-promise/then +(function() { + Promise.resolve(3) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return Promise.resolve(4); + }) + .then( + x => { + assertEqualsAsync(3, x); + }, + assertUnreachable + ); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/finally-return-resolved-promise/then +(function() { + Promise.reject(3) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return Promise.resolve(4); + }) + .then(assertUnreachable, e => { + assertEqualsAsync(3, e); + }); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/finally-return-resolved-promise/then +(function() { + Promise.reject(3) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return Promise.resolve(4); + }) + .then(assertUnreachable, e => { + assertEqualsAsync(3, e); + }); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// resolve/finally-thenable-resolve/then +(function() { + var thenable = { + then: function(onResolve, onReject) { + onResolve(5); + } + }; + + Promise.resolve(5) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return thenable; + }) + .then( + x => { + assertEqualsAsync(5, x); + }, + assertUnreachable + ); + + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/finally-thenable-resolve/then +(function() { + var thenable = { + then: function(onResolve, onReject) { + onResolve(1); + } + }; + + Promise.reject(5) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return thenable; + }) + .then(assertUnreachable, e => { + assertEqualsAsync(5, e); + }); + + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/finally-thenable-reject/then +(function() { + var thenable = { + then: function(onResolve, onReject) { + onReject(1); + } + }; + + Promise.reject(5) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return thenable; + }) + .then(assertUnreachable, e => { + assertEqualsAsync(1, e); + }); + + assertAsyncRan(); + assertAsyncRan(); +})(); + +// resolve/finally-thenable-reject/then +(function() { + var thenable = { + then: function(onResolve, onReject) { + onReject(1); + } + }; + + Promise.resolve(5) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return thenable; + }) + .then(assertUnreachable, e => { + assertEqualsAsync(1, e); + }); + + assertAsyncRan(); + assertAsyncRan(); +})(); + +// resolve/finally/finally/then +(function() { + Promise.resolve(5) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + }) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + }) + .then( + x => { + assertEqualsAsync(5, x); + }, + assertUnreachable + ); + + assertAsyncRan(); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// resolve/finally-throw/finally/then +(function() { + Promise.resolve(5) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + throw 1; + }) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + }) + .then(assertUnreachable, e => { + assertEqualsAsync(1, e); + }); + + assertAsyncRan(); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// resolve/finally-return-rejected-promise/finally/then +(function() { + Promise.resolve(5) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return Promise.reject(1); + }) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + }) + .then(assertUnreachable, e => { + assertEqualsAsync(1, e); + }); + + assertAsyncRan(); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/finally/finally/then +(function() { + Promise.reject(5) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + }) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + }) + .then(assertUnreachable, e => { + assertEqualsAsync(5, e); + }); + + assertAsyncRan(); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/finally-throw/finally/then +(function() { + Promise.reject(5) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + throw 1; + }) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + }) + .then(assertUnreachable, e => { + assertEqualsAsync(1, e); + }); + + assertAsyncRan(); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/finally-return-rejected-promise/finally/then +(function() { + Promise.reject(5) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return Promise.reject(1); + }) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + }) + .then(assertUnreachable, e => { + assertEqualsAsync(1, e); + }); + + assertAsyncRan(); + assertAsyncRan(); + assertAsyncRan(); +})(); + +// resolve/finally-deferred-resolve/then +(function() { + var resolve, reject; + var deferred = new Promise((x, y) => { + resolve = x; + reject = y; + }); + Promise.resolve(1) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return deferred; + }) + .then( + x => { + assertEqualsAsync(1, x); + }, + assertUnreachable + ); + + assertAsyncRan(); + assertAsyncRan(); + + resolve(5); +})(); + +// resolve/finally-deferred-reject/then +(function() { + var resolve, reject; + var deferred = new Promise((x, y) => { + resolve = x; + reject = y; + }); + Promise.resolve(1) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + return deferred; + }) + .then(assertUnreachable, e => { + assertEqualsAsync(5, e); + }); + + assertAsyncRan(); + assertAsyncRan(); + + reject(5); +})(); + +// all/finally/then +(function() { + var resolve, reject; + var deferred = new Promise((x, y) => { + resolve = x; + reject = y; + }); + + Promise.all([deferred]) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + }) + .then( + ([x]) => { + assertEqualsAsync(1, x); + }, + assertUnreachable + ); + + assertAsyncRan(); + assertAsyncRan(); + + resolve(1); +})(); + +// race/finally/then +(function() { + var resolve, reject; + var d1 = new Promise((x, y) => { + resolve = x; + reject = y; + }); + var d2 = new Promise((x, y) => { + resolve = x; + reject = y; + }); + + Promise.race([d1, d2]) + .finally(function onFinally() { + assertEqualsAsync(0, arguments.length); + }) + .then( + x => { + assertEqualsAsync(1, x); + }, + assertUnreachable + ); + + assertAsyncRan(); + assertAsyncRan(); + + resolve(1); +})(); + +// resolve/finally-customthen/then +(function() { + class MyPromise extends Promise { + then(onFulfilled, onRejected) { + assertEqualsAsync(5, onFulfilled); + assertEqualsAsync(5, onRejected); + return super.then(onFulfilled, onRejected); + } + } + + MyPromise.resolve(3).finally(5); + + assertAsyncRan(); + assertAsyncRan(); +})(); + +// reject/finally-customthen/then +(function() { + class MyPromise extends Promise { + then(onFulfilled, onRejected) { + assertEqualsAsync(5, onFulfilled); + assertEqualsAsync(5, onRejected); + return super.then(onFulfilled, onRejected); + } + } + + MyPromise.reject(3).finally(5); + + assertAsyncRan(); + assertAsyncRan(); +})(); + +var descriptor = Object.getOwnPropertyDescriptor(Promise.prototype, 'finally'); +assertTrue(descriptor.writable); +assertTrue(descriptor.configurable); +assertFalse(descriptor.enumerable); +assertEquals("finally", Promise.prototype.finally.name); +assertEquals(1, Promise.prototype.finally.length); + +assertAsyncDone(); diff --git a/deps/v8/test/mjsunit/harmony/regexp-named-captures.js b/deps/v8/test/mjsunit/harmony/regexp-named-captures.js index ced8e4b2f6..4404bd4b14 100644 --- a/deps/v8/test/mjsunit/harmony/regexp-named-captures.js +++ b/deps/v8/test/mjsunit/harmony/regexp-named-captures.js @@ -18,15 +18,15 @@ assertThrows("/(?<ab>a)\\k<a>/u"); // Invalid reference. assertThrows("/\\k<a>(?<ab>a)/u"); // Invalid reference. // Fallback behavior in non-unicode mode. -assertThrows("/(?<>a)/"); -assertThrows("/(?<aa)/"); -assertThrows("/(?<42a>a)/"); -assertThrows("/(?<:a>a)/"); -assertThrows("/(?<a:>a)/"); -assertThrows("/(?<a>a)(?<a>a)/"); -assertThrows("/(?<a>a)(?<b>b)(?<a>a)/"); -assertThrows("/(?<a>a)\\k<ab>/"); -assertThrows("/(?<ab>a)\\k<a>/"); +assertThrows("/(?<>a)/", SyntaxError); +assertThrows("/(?<aa)/", SyntaxError); +assertThrows("/(?<42a>a)/", SyntaxError); +assertThrows("/(?<:a>a)/", SyntaxError); +assertThrows("/(?<a:>a)/", SyntaxError); +assertThrows("/(?<a>a)(?<a>a)/", SyntaxError); +assertThrows("/(?<a>a)(?<b>b)(?<a>a)/", SyntaxError); +assertThrows("/(?<a>a)\\k<ab>/", SyntaxError); +assertThrows("/(?<ab>a)\\k<a>/", SyntaxError); assertEquals(["k<a>"], "xxxk<a>xxx".match(/\k<a>/)); assertEquals(["k<a"], "xxxk<a>xxx".match(/\k<a/)); @@ -74,3 +74,25 @@ assertEquals(["bab", "b"], "bab".match(/(?<a>\k<a>\w)../u)); // Reference before group. assertEquals(["bab", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/u)); assertEquals(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u)); + +// Reference properties. +assertEquals("a", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").group.a); +assertEquals("b", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").group.b); +assertEquals(undefined, /(?<a>a)(?<b>b)\k<a>/u.exec("aba").group.c); +assertEquals(undefined, /(?<a>a)(?<b>b)\k<a>|(?<c>c)/u.exec("aba").group.c); + +// Unicode names. +assertEquals("a", /(?<π>a)/u.exec("bab").group.π); +assertEquals("a", /(?<\u{03C0}>a)/u.exec("bab").group.\u03C0); +assertEquals("a", /(?<$>a)/u.exec("bab").group.$); +assertEquals("a", /(?<_>a)/u.exec("bab").group._); +assertEquals("a", /(?<$𐒤>a)/u.exec("bab").group.$𐒤); +assertEquals("a", /(?<_\u200C>a)/u.exec("bab").group._\u200C); +assertEquals("a", /(?<_\u200D>a)/u.exec("bab").group._\u200D); +assertEquals("a", /(?<ಠ_ಠ>a)/u.exec("bab").group.ಠ_ಠ); +assertThrows('/(?<❤>a)/u', SyntaxError); +assertThrows('/(?<𐒤>a)/u', SyntaxError); // ID_Continue but not ID_Start. + +// The '__proto__' property on the groups object. +assertEquals(undefined, /(?<a>.)/u.exec("a").group.__proto__); +assertEquals("a", /(?<__proto__>a)/u.exec("a").group.__proto__); diff --git a/deps/v8/test/mjsunit/harmony/simd.js b/deps/v8/test/mjsunit/harmony/simd.js deleted file mode 100644 index a3d46159c1..0000000000 --- a/deps/v8/test/mjsunit/harmony/simd.js +++ /dev/null @@ -1,636 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-simd -// Flags: --allow-natives-syntax --expose-natives-as natives --noalways-opt - -function lanesForType(typeName) { - // The lane count follows the first 'x' in the type name, which begins with - // 'float', 'int', or 'bool'. - return Number.parseInt(typeName.substr(typeName.indexOf('x') + 1)); -} - - -// Creates an instance that has been zeroed, so it can be used for equality -// testing. -function createInstance(type) { - // Provide enough parameters for the longest type (currently 16). It's - // important that instances be consistent to better test that different SIMD - // types can't be compared and are never equal or the same in any sense. - return SIMD[type](0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); -} - - -function isValidSimdString(string, value, type, lanes) { - var simdFn = SIMD[type], - parseFn = - type.indexOf('Float') === 0 ? Number.parseFloat : Number.parseInt, - indexOfOpenParen = string.indexOf('('); - // Check prefix (e.g. SIMD.Float32x4.) - if (string.substr(0, indexOfOpenParen) !== 'SIMD.' + type) - return false; - // Remove type name (e.g. SIMD.Float32x4) and open parenthesis. - string = string.substr(indexOfOpenParen + 1); - var laneStrings = string.split(','); - if (laneStrings.length !== lanes) - return false; - for (var i = 0; i < lanes; i++) { - var fromString = parseFn(laneStrings[i]), - fromValue = simdFn.extractLane(value, i); - if (Math.abs(fromString - fromValue) > Number.EPSILON) - return false; - } - return true; -} - - -var simdTypeNames = ['Float32x4', 'Int32x4', 'Uint32x4', 'Bool32x4', - 'Int16x8', 'Uint16x8', 'Bool16x8', - 'Int8x16', 'Uint8x16', 'Bool8x16']; - -var nonSimdValues = [347, 1.275, NaN, "string", null, undefined, {}, - function() {}]; - -function checkTypeMatrix(type, fn) { - // Check against non-SIMD types. - nonSimdValues.forEach(fn); - // Check against SIMD values of a different type. - for (var i = 0; i < simdTypeNames.length; i++) { - var otherType = simdTypeNames[i]; - if (type != otherType) fn(createInstance(otherType)); - } -} - - -// Test different forms of constructor calls. -function TestConstructor(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - - assertFalse(Object === simdFn.prototype.constructor) - assertFalse(simdFn === Object.prototype.constructor) - assertSame(simdFn, simdFn.prototype.constructor) - - assertSame(simdFn, instance.__proto__.constructor) - assertSame(simdFn, Object(instance).__proto__.constructor) - assertSame(simdFn.prototype, instance.__proto__) - assertSame(simdFn.prototype, Object(instance).__proto__) -} - - -function TestType(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - var typeofString = type.charAt(0).toLowerCase() + type.slice(1); - - assertEquals(typeofString, typeof instance) - assertTrue(typeof instance === typeofString) - assertTrue(typeof Object(instance) === 'object') - assertEquals(null, %_ClassOf(instance)) - assertEquals(type, %_ClassOf(Object(instance))) -} - - -function TestPrototype(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - - assertSame(Object.prototype, simdFn.prototype.__proto__) - assertSame(simdFn.prototype, instance.__proto__) - assertSame(simdFn.prototype, Object(instance).__proto__) -} - - -function TestValueOf(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - - assertTrue(instance === Object(instance).valueOf()) - assertTrue(instance === instance.valueOf()) - assertTrue(simdFn.prototype.valueOf.call(Object(instance)) === instance) - assertTrue(simdFn.prototype.valueOf.call(instance) === instance) -} - - -function TestGet(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - - assertEquals(undefined, instance.a) - assertEquals(undefined, instance["a" + "b"]) - assertEquals(undefined, instance["" + "1"]) - assertEquals(undefined, instance[42]) -} - - -function TestToBoolean(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - - assertTrue(Boolean(Object(instance))) - assertFalse(!Object(instance)) - assertTrue(Boolean(instance).valueOf()) - assertFalse(!instance) - assertTrue(!!instance) - assertTrue(instance && true) - assertFalse(!instance && false) - assertTrue(!instance || true) - assertEquals(1, instance ? 1 : 2) - assertEquals(2, !instance ? 1 : 2) - if (!instance) assertUnreachable(); - if (instance) {} else assertUnreachable(); -} - - -function TestToString(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - - assertEquals(instance.toString(), String(instance)) - assertTrue(isValidSimdString(instance.toString(), instance, type, lanes)) - assertTrue( - isValidSimdString(Object(instance).toString(), instance, type, lanes)) - assertTrue(isValidSimdString( - simdFn.prototype.toString.call(instance), instance, type, lanes)) -} - - -function TestToNumber(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - - assertThrows(function() { Number(Object(instance)) }, TypeError) - assertThrows(function() { +Object(instance) }, TypeError) - assertThrows(function() { Number(instance) }, TypeError) - assertThrows(function() { instance + 0 }, TypeError) -} - - -function TestCoercions(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - // Test that setting a lane to value 'a' results in a lane with value 'b'. - function test(a, b) { - for (var i = 0; i < lanes; i++) { - var ainstance = simdFn.replaceLane(instance, i, a); - var lane_value = simdFn.extractLane(ainstance, i); - assertSame(b, lane_value); - } - } - - switch (type) { - case 'Float32x4': - test(0, 0); - test(-0, -0); - test(NaN, NaN); - test(null, 0); - test(undefined, NaN); - test("5.25", 5.25); - test(Number.MAX_VALUE, Infinity); - test(-Number.MAX_VALUE, -Infinity); - test(Number.MIN_VALUE, 0); - break; - case 'Int32x4': - test(Infinity, 0); - test(-Infinity, 0); - test(NaN, 0); - test(0, 0); - test(-0, 0); - test(Number.MIN_VALUE, 0); - test(-Number.MIN_VALUE, 0); - test(0.1, 0); - test(-0.1, 0); - test(1, 1); - test(1.1, 1); - test(-1, -1); - test(-1.6, -1); - test(2147483647, 2147483647); - test(2147483648, -2147483648); - test(2147483649, -2147483647); - test(4294967295, -1); - test(4294967296, 0); - test(4294967297, 1); - break; - case 'Uint32x4': - test(Infinity, 0); - test(-Infinity, 0); - test(NaN, 0); - test(0, 0); - test(-0, 0); - test(Number.MIN_VALUE, 0); - test(-Number.MIN_VALUE, 0); - test(0.1, 0); - test(-0.1, 0); - test(1, 1); - test(1.1, 1); - test(-1, 4294967295); - test(-1.6, 4294967295); - test(4294967295, 4294967295); - test(4294967296, 0); - test(4294967297, 1); - break; - case 'Int16x8': - test(Infinity, 0); - test(-Infinity, 0); - test(NaN, 0); - test(0, 0); - test(-0, 0); - test(Number.MIN_VALUE, 0); - test(-Number.MIN_VALUE, 0); - test(0.1, 0); - test(-0.1, 0); - test(1, 1); - test(1.1, 1); - test(-1, -1); - test(-1.6, -1); - test(32767, 32767); - test(32768, -32768); - test(32769, -32767); - test(65535, -1); - test(65536, 0); - test(65537, 1); - break; - case 'Uint16x8': - test(Infinity, 0); - test(-Infinity, 0); - test(NaN, 0); - test(0, 0); - test(-0, 0); - test(Number.MIN_VALUE, 0); - test(-Number.MIN_VALUE, 0); - test(0.1, 0); - test(-0.1, 0); - test(1, 1); - test(1.1, 1); - test(-1, 65535); - test(-1.6, 65535); - test(65535, 65535); - test(65536, 0); - test(65537, 1); - break; - case 'Int8x16': - test(Infinity, 0); - test(-Infinity, 0); - test(NaN, 0); - test(0, 0); - test(-0, 0); - test(Number.MIN_VALUE, 0); - test(-Number.MIN_VALUE, 0); - test(0.1, 0); - test(-0.1, 0); - test(1, 1); - test(1.1, 1); - test(-1, -1); - test(-1.6, -1); - test(127, 127); - test(128, -128); - test(129, -127); - test(255, -1); - test(256, 0); - test(257, 1); - break; - case 'Uint8x16': - test(Infinity, 0); - test(-Infinity, 0); - test(NaN, 0); - test(0, 0); - test(-0, 0); - test(Number.MIN_VALUE, 0); - test(-Number.MIN_VALUE, 0); - test(0.1, 0); - test(-0.1, 0); - test(1, 1); - test(1.1, 1); - test(-1, 255); - test(-1.6, 255); - test(255, 255); - test(256, 0); - test(257, 1); - break; - case 'Bool32x4': - case 'Bool16x8': - case 'Bool8x16': - test(true, true); - test(false, false); - test(0, false); - test(1, true); - test(0.1, true); - test(NaN, false); - test(null, false); - test("", false); - test("false", true); - break; - } -} - - -function TestEquality(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - - // Every SIMD value should equal itself, and non-strictly equal its wrapper. - assertSame(instance, instance) - assertEquals(instance, instance) - assertTrue(Object.is(instance, instance)) - assertTrue(instance === instance) - assertTrue(instance == instance) - assertFalse(instance === Object(instance)) - assertFalse(Object(instance) === instance) - assertTrue(instance == Object(instance)) - assertTrue(Object(instance) == instance) - assertTrue(instance === instance.valueOf()) - assertTrue(instance.valueOf() === instance) - assertTrue(instance == instance.valueOf()) - assertTrue(instance.valueOf() == instance) - assertFalse(Object(instance) === Object(instance)) - assertEquals(Object(instance).valueOf(), Object(instance).valueOf()) - - function notEqual(other) { - assertFalse(instance === other) - assertFalse(other === instance) - assertFalse(instance == other) - assertFalse(other == instance) - } - - // SIMD values should not be equal to instances of different types. - checkTypeMatrix(type, function(other) { - assertFalse(instance === other) - assertFalse(other === instance) - assertFalse(instance == other) - assertFalse(other == instance) - }); - - // Test that f(a, b) is the same as f(SIMD(a), SIMD(b)) for equality and - // strict equality, at every lane. - function test(a, b) { - for (var i = 0; i < lanes; i++) { - var aval = simdFn.replaceLane(instance, i, a); - var bval = simdFn.replaceLane(instance, i, b); - assertSame(a == b, aval == bval); - assertSame(a === b, aval === bval); - } - } - - switch (type) { - case 'Float32x4': - test(1, 2.5); - test(1, 1); - test(0, 0); - test(-0, +0); - test(+0, -0); - test(-0, -0); - test(0, NaN); - test(NaN, NaN); - break; - case 'Int32x4': - case 'Uint32x4': - case 'Int16x8': - case 'Uint16x8': - case 'Int8x16': - case 'Uint8x16': - test(1, 2); - test(1, 1); - test(1, -1); - break; - case 'Bool32x4': - case 'Bool16x8': - case 'Bool8x16': - test(true, false); - test(false, true); - break; - } -} - - -function TestSameValue(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - var sameValue = Object.is - var sameValueZero = function(x, y) { return %SameValueZero(x, y); } - - // SIMD values should not be the same as instances of different types. - checkTypeMatrix(type, function(other) { - assertFalse(sameValue(instance, other)); - assertFalse(sameValueZero(instance, other)); - }); - - // Test that f(a, b) is the same as f(SIMD(a), SIMD(b)) for sameValue and - // sameValueZero, at every lane. - function test(a, b) { - for (var i = 0; i < lanes; i++) { - var aval = simdFn.replaceLane(instance, i, a); - var bval = simdFn.replaceLane(instance, i, b); - assertSame(sameValue(a, b), sameValue(aval, bval)); - assertSame(sameValueZero(a, b), sameValueZero(aval, bval)); - } - } - - switch (type) { - case 'Float32x4': - test(1, 2.5); - test(1, 1); - test(0, 0); - test(-0, +0); - test(+0, -0); - test(-0, -0); - test(0, NaN); - test(NaN, NaN); - break; - case 'Int32x4': - case 'Uint32x4': - case 'Int16x8': - case 'Uint16x8': - case 'Int8x16': - case 'Uint8x16': - test(1, 2); - test(1, 1); - test(1, -1); - break; - case 'Bool32x4': - case 'Bool16x8': - case 'Bool8x16': - test(true, false); - test(false, true); - break; - } -} - - -function TestComparison(type, lanes) { - var simdFn = SIMD[type]; - var a = createInstance(type), b = createInstance(type); - - function compare(other) { - var throwFuncs = [ - function lt() { a < b; }, - function gt() { a > b; }, - function le() { a <= b; }, - function ge() { a >= b; }, - function lt_same() { a < a; }, - function gt_same() { a > a; }, - function le_same() { a <= a; }, - function ge_same() { a >= a; }, - ]; - - for (var f of throwFuncs) { - assertThrows(f, TypeError); - %OptimizeFunctionOnNextCall(f); - assertThrows(f, TypeError); - assertThrows(f, TypeError); - } - } - - // Test comparison against the same SIMD type. - compare(b); - // Test comparison against other types. - checkTypeMatrix(type, compare); -} - - -// Test SIMD value wrapping/boxing over non-builtins. -function TestCall(type, lanes) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - simdFn.prototype.getThisProto = function () { - return Object.getPrototypeOf(this); - } - assertTrue(instance.getThisProto() === simdFn.prototype) -} - - -function TestAsSetKey(type, lanes, set) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - - function test(set, key) { - assertFalse(set.has(key)); - assertFalse(set.delete(key)); - if (!(set instanceof WeakSet)) { - assertSame(set, set.add(key)); - assertTrue(set.has(key)); - assertTrue(set.delete(key)); - } else { - // SIMD values can't be used as keys in WeakSets. - assertThrows(function() { set.add(key) }); - } - assertFalse(set.has(key)); - assertFalse(set.delete(key)); - assertFalse(set.has(key)); - } - - test(set, instance); -} - - -function TestAsMapKey(type, lanes, map) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - - function test(map, key, value) { - assertFalse(map.has(key)); - assertSame(undefined, map.get(key)); - assertFalse(map.delete(key)); - if (!(map instanceof WeakMap)) { - assertSame(map, map.set(key, value)); - assertSame(value, map.get(key)); - assertTrue(map.has(key)); - assertTrue(map.delete(key)); - } else { - // SIMD values can't be used as keys in WeakMaps. - assertThrows(function() { map.set(key, value) }); - } - assertFalse(map.has(key)); - assertSame(undefined, map.get(key)); - assertFalse(map.delete(key)); - assertFalse(map.has(key)); - assertSame(undefined, map.get(key)); - } - - test(map, instance, {}); -} - - -// Test SIMD type with Harmony reflect-apply. -function TestReflectApply(type) { - var simdFn = SIMD[type]; - var instance = createInstance(type); - - function returnThis() { return this; } - function returnThisStrict() { 'use strict'; return this; } - function noop() {} - function noopStrict() { 'use strict'; } - var R = void 0; - - assertSame(SIMD[type].prototype, - Object.getPrototypeOf( - Reflect.apply(returnThis, instance, []))); - assertSame(instance, Reflect.apply(returnThisStrict, instance, [])); - - assertThrows( - function() { 'use strict'; Reflect.apply(instance); }, TypeError); - assertThrows( - function() { Reflect.apply(instance); }, TypeError); - assertThrows( - function() { Reflect.apply(noopStrict, R, instance); }, TypeError); - assertThrows( - function() { Reflect.apply(noop, R, instance); }, TypeError); -} - - -function TestSIMDTypes() { - for (var i = 0; i < simdTypeNames.length; ++i) { - var type = simdTypeNames[i], - lanes = lanesForType(type); - TestConstructor(type, lanes); - TestType(type, lanes); - TestPrototype(type, lanes); - TestValueOf(type, lanes); - TestGet(type, lanes); - TestToBoolean(type, lanes); - TestToString(type, lanes); - TestToNumber(type, lanes); - TestCoercions(type, lanes); - TestEquality(type, lanes); - TestSameValue(type, lanes); - TestComparison(type, lanes); - TestCall(type, lanes); - TestAsSetKey(type, lanes, new Set); - TestAsSetKey(type, lanes, new WeakSet); - TestAsMapKey(type, lanes, new Map); - TestAsMapKey(type, lanes, new WeakMap); - TestReflectApply(type); - } -} -TestSIMDTypes(); - -// Tests for the global SIMD object. -function TestSIMDObject() { - assertSame(typeof SIMD, 'object'); - assertSame(SIMD.constructor, Object); - assertSame(Object.getPrototypeOf(SIMD), Object.prototype); - assertSame(SIMD + "", "[object SIMD]"); - // The SIMD object is mutable. - SIMD.foo = "foo"; - assertSame(SIMD.foo, "foo"); - delete SIMD.foo; - delete SIMD.Bool8x16; - assertSame(SIMD.Bool8x16, undefined); -} -TestSIMDObject() - - -function TestStringify(expected, input) { - assertEquals(expected, JSON.stringify(input)); - assertEquals(expected, JSON.stringify(input, (key, value) => value)); - assertEquals(JSON.stringify(input, null, "="), - JSON.stringify(input, (key, value) => value, "=")); -} - -TestStringify(undefined, SIMD.Float32x4(1, 2, 3, 4)); -TestStringify('[null]', [SIMD.Float32x4(1, 2, 3, 4)]); -TestStringify('[{}]', [Object(SIMD.Float32x4(1, 2, 3, 4))]); -var simd_wrapper = Object(SIMD.Float32x4(1, 2, 3, 4)); -TestStringify('{}', simd_wrapper); -simd_wrapper.a = 1; -TestStringify('{"a":1}', simd_wrapper); diff --git a/deps/v8/test/mjsunit/harmony/symbol-async-iterator.js b/deps/v8/test/mjsunit/harmony/symbol-async-iterator.js new file mode 100644 index 0000000000..8a92add635 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/symbol-async-iterator.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --harmony-async-iteration + +assertTrue(Symbol.hasOwnProperty('asyncIterator')); +assertEquals('symbol', typeof Symbol.asyncIterator); +assertInstanceof(Object(Symbol.asyncIterator), Symbol); + +let desc = Object.getOwnPropertyDescriptor(Symbol, 'asyncIterator'); +assertFalse(desc.writable); +assertFalse(desc.enumerable); +assertFalse(desc.configurable); diff --git a/deps/v8/test/mjsunit/harmony/template-escapes.js b/deps/v8/test/mjsunit/harmony/template-escapes.js new file mode 100644 index 0000000000..fcaf8ac5bf --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/template-escapes.js @@ -0,0 +1,785 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --harmony-template-escapes + +function check({cooked, raw, exprs}) { + return function(strs, ...args) { + assertArrayEquals(cooked, strs); + assertArrayEquals(raw, strs.raw); + assertArrayEquals(exprs, args); + }; +} + +// clang-format off + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\01' + ], + 'exprs': [] +})`\01`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\01', + 'right' + ], + 'exprs': [ + 0 + ] +})`\01${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\01' + ], + 'exprs': [ + 0 + ] +})`left${0}\01`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\01', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\01${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\1' + ], + 'exprs': [] +})`\1`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\1', + 'right' + ], + 'exprs': [ + 0 + ] +})`\1${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\1' + ], + 'exprs': [ + 0 + ] +})`left${0}\1`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\1', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\1${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\xg' + ], + 'exprs': [] +})`\xg`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\xg', + 'right' + ], + 'exprs': [ + 0 + ] +})`\xg${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\xg' + ], + 'exprs': [ + 0 + ] +})`left${0}\xg`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\xg', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\xg${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\xAg' + ], + 'exprs': [] +})`\xAg`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\xAg', + 'right' + ], + 'exprs': [ + 0 + ] +})`\xAg${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\xAg' + ], + 'exprs': [ + 0 + ] +})`left${0}\xAg`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\xAg', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\xAg${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\u0' + ], + 'exprs': [] +})`\u0`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\u0', + 'right' + ], + 'exprs': [ + 0 + ] +})`\u0${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\u0' + ], + 'exprs': [ + 0 + ] +})`left${0}\u0`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\u0', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\u0${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\u0g' + ], + 'exprs': [] +})`\u0g`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\u0g', + 'right' + ], + 'exprs': [ + 0 + ] +})`\u0g${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\u0g' + ], + 'exprs': [ + 0 + ] +})`left${0}\u0g`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\u0g', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\u0g${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\u00g' + ], + 'exprs': [] +})`\u00g`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\u00g', + 'right' + ], + 'exprs': [ + 0 + ] +})`\u00g${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\u00g' + ], + 'exprs': [ + 0 + ] +})`left${0}\u00g`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\u00g', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\u00g${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\u000g' + ], + 'exprs': [] +})`\u000g`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\u000g', + 'right' + ], + 'exprs': [ + 0 + ] +})`\u000g${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\u000g' + ], + 'exprs': [ + 0 + ] +})`left${0}\u000g`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\u000g', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\u000g${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\u{}' + ], + 'exprs': [] +})`\u{}`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\u{}', + 'right' + ], + 'exprs': [ + 0 + ] +})`\u{}${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\u{}' + ], + 'exprs': [ + 0 + ] +})`left${0}\u{}`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\u{}', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\u{}${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\u{-0}' + ], + 'exprs': [] +})`\u{-0}`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\u{-0}', + 'right' + ], + 'exprs': [ + 0 + ] +})`\u{-0}${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\u{-0}' + ], + 'exprs': [ + 0 + ] +})`left${0}\u{-0}`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\u{-0}', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\u{-0}${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\u{g}' + ], + 'exprs': [] +})`\u{g}`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\u{g}', + 'right' + ], + 'exprs': [ + 0 + ] +})`\u{g}${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\u{g}' + ], + 'exprs': [ + 0 + ] +})`left${0}\u{g}`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\u{g}', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\u{g}${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\u{0' + ], + 'exprs': [] +})`\u{0`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\u{0', + 'right' + ], + 'exprs': [ + 0 + ] +})`\u{0${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\u{0' + ], + 'exprs': [ + 0 + ] +})`left${0}\u{0`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\u{0', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\u{0${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\u{\\u{0}' + ], + 'exprs': [] +})`\u{\u{0}`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\u{\\u{0}', + 'right' + ], + 'exprs': [ + 0 + ] +})`\u{\u{0}${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\u{\\u{0}' + ], + 'exprs': [ + 0 + ] +})`left${0}\u{\u{0}`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\u{\\u{0}', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\u{\u{0}${1}right`; + +check({ + 'cooked': [ + undefined + ], + 'raw': [ + '\\u{110000}' + ], + 'exprs': [] +})`\u{110000}`; + +check({ + 'cooked': [ + undefined, + 'right' + ], + 'raw': [ + '\\u{110000}', + 'right' + ], + 'exprs': [ + 0 + ] +})`\u{110000}${0}right`; + +check({ + 'cooked': [ + 'left', + undefined + ], + 'raw': [ + 'left', + '\\u{110000}' + ], + 'exprs': [ + 0 + ] +})`left${0}\u{110000}`; + +check({ + 'cooked': [ + 'left', + undefined, + 'right' + ], + 'raw': [ + 'left', + '\\u{110000}', + 'right' + ], + 'exprs': [ + 0, + 1 + ] +})`left${0}\u{110000}${1}right`; diff --git a/deps/v8/test/mjsunit/ignition/stack-trace-source-position.js b/deps/v8/test/mjsunit/ignition/stack-trace-source-position.js index ce236c398c..b82263ff30 100644 --- a/deps/v8/test/mjsunit/ignition/stack-trace-source-position.js +++ b/deps/v8/test/mjsunit/ignition/stack-trace-source-position.js @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition-filter=f // Flags: --no-turbo // TODO(yangguo): fix for turbofan @@ -16,6 +15,6 @@ function f(x) { var stack_lines = f(2).split("\n"); -assertTrue(/at f \(.*?:12:12\)/.test(stack_lines[1])); -assertTrue(/at f \(.*?:14:10\)/.test(stack_lines[2])); -assertTrue(/at f \(.*?:14:10\)/.test(stack_lines[3])); +assertTrue(/at f \(.*?:11:12\)/.test(stack_lines[1])); +assertTrue(/at f \(.*?:13:10\)/.test(stack_lines[2])); +assertTrue(/at f \(.*?:13:10\)/.test(stack_lines[3])); diff --git a/deps/v8/test/mjsunit/immutable-context-slot-inlining.js b/deps/v8/test/mjsunit/immutable-context-slot-inlining.js new file mode 100644 index 0000000000..3b278c3c25 --- /dev/null +++ b/deps/v8/test/mjsunit/immutable-context-slot-inlining.js @@ -0,0 +1,30 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function h(g) { + return g(); +} + +function f() { + var g; + for (var i = 0; i < 10; i++) { + var y = i; + if (i === 5) { + g = function() { + return y; + }; + assertEquals(5, h(g)); + assertEquals(5, h(g)); + %OptimizeFunctionOnNextCall(h); + assertEquals(5, h(g)); + } + } + return g; +} + +var myg = f(); + +assertEquals(9, h(myg)); diff --git a/deps/v8/test/mjsunit/keyed-load-hole-to-undefined.js b/deps/v8/test/mjsunit/keyed-load-hole-to-undefined.js index e9403b8c5e..9366458a5f 100644 --- a/deps/v8/test/mjsunit/keyed-load-hole-to-undefined.js +++ b/deps/v8/test/mjsunit/keyed-load-hole-to-undefined.js @@ -3,7 +3,7 @@ // found in the LICENSE file. // Flags: --allow-natives-syntax -// Flags: --nostress-opt +// Flags: --no-stress-opt --crankshaft --no-always-opt // --nostress-opt is specified because the test corrupts the "pristine" // array prototype chain by storing an element, and this is tracked diff --git a/deps/v8/test/mjsunit/keyed-load-with-string-key.js b/deps/v8/test/mjsunit/keyed-load-with-string-key.js index 43889460f6..2d5f0200d0 100644 --- a/deps/v8/test/mjsunit/keyed-load-with-string-key.js +++ b/deps/v8/test/mjsunit/keyed-load-with-string-key.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft var o = { diff --git a/deps/v8/test/mjsunit/keyed-load-with-symbol-key.js b/deps/v8/test/mjsunit/keyed-load-with-symbol-key.js index 15562be6bd..2c818a84ae 100644 --- a/deps/v8/test/mjsunit/keyed-load-with-symbol-key.js +++ b/deps/v8/test/mjsunit/keyed-load-with-symbol-key.js @@ -25,7 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt + var s = Symbol("foo"); var o = { diff --git a/deps/v8/test/mjsunit/math-floor-of-div-minus-zero.js b/deps/v8/test/mjsunit/math-floor-of-div-minus-zero.js index de0e90bcec..9a24231ae6 100644 --- a/deps/v8/test/mjsunit/math-floor-of-div-minus-zero.js +++ b/deps/v8/test/mjsunit/math-floor-of-div-minus-zero.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --nouse-inlining +// Flags: --allow-natives-syntax --nouse-inlining --crankshaft // Test for negative zero that doesn't need bail out diff --git a/deps/v8/test/mjsunit/math-imul.js b/deps/v8/test/mjsunit/math-imul.js index e88605f7d4..c24f6a3970 100644 --- a/deps/v8/test/mjsunit/math-imul.js +++ b/deps/v8/test/mjsunit/math-imul.js @@ -64,8 +64,8 @@ function TestMathImul(expected, a, b) { // Deoptimize closures and forget type feedback. %DeoptimizeFunction(imul_meth_closure); %DeoptimizeFunction(imul_func_closure); - %ClearFunctionTypeFeedback(imul_meth_closure); - %ClearFunctionTypeFeedback(imul_func_closure); + %ClearFunctionFeedback(imul_meth_closure); + %ClearFunctionFeedback(imul_func_closure); } TestMathImul(8, 2, 4); diff --git a/deps/v8/test/mjsunit/messages.js b/deps/v8/test/mjsunit/messages.js index 30abc197e9..ca9d856944 100644 --- a/deps/v8/test/mjsunit/messages.js +++ b/deps/v8/test/mjsunit/messages.js @@ -3,7 +3,6 @@ // found in the LICENSE file. // Flags: --stack-size=100 --harmony -// Flags: --harmony-simd function test(f, expected, type) { try { @@ -115,7 +114,7 @@ test(function() { var o = {}; Object.preventExtensions(o); Object.defineProperty(o, "x", { value: 1 }); -}, "Cannot define property:x, object is not extensible.", TypeError); +}, "Cannot define property x, object is not extensible", TypeError); // kFirstArgumentNotRegExp test(function() { @@ -242,7 +241,7 @@ test(function() { var o = {}; Object.freeze(o); o.a = 1; -}, "Can't add property a, object is not extensible", TypeError); +}, "Cannot add property a, object is not extensible", TypeError); // kObjectSetterExpectingFunction test(function() { @@ -320,11 +319,6 @@ test(function() { 1 + Symbol(); }, "Cannot convert a Symbol value to a number", TypeError); -// kSimdToNumber -test(function() { - 1 + SIMD.Float32x4(1, 2, 3, 4); -}, "Cannot convert a SIMD value to a number", TypeError); - // kUndefinedOrNullToObject test(function() { Array.prototype.toString.call(null); @@ -389,6 +383,11 @@ test(function() { // === RangeError === +// kInvalidOffset +test(function() { + new Uint8Array(new ArrayBuffer(1),2); +}, "Start offset 2 is outside the bounds of the buffer", RangeError); + // kArrayLengthOutOfRange test(function() { "use strict"; diff --git a/deps/v8/test/mjsunit/mjsunit.isolate b/deps/v8/test/mjsunit/mjsunit.isolate index 6ebd801eac..2474d65060 100644 --- a/deps/v8/test/mjsunit/mjsunit.isolate +++ b/deps/v8/test/mjsunit/mjsunit.isolate @@ -14,11 +14,14 @@ '../../tools/profviz/composer.js', '../../tools/splaytree.js', '../../tools/tickprocessor.js', - '../../tools/dumpcpp.js' + '../../tools/dumpcpp.js', + '../wasm-js/test/harness/wasm-constants.js', + '../wasm-js/test/harness/wasm-module-builder.js', + '../wasm-js/test/js-api/jsapi.js', ], }, 'includes': [ '../../src/d8.isolate', '../../tools/testrunner/testrunner.isolate', ], -}
\ No newline at end of file +} diff --git a/deps/v8/test/mjsunit/mjsunit.js b/deps/v8/test/mjsunit/mjsunit.js index 88d4d3677c..ec17f1d76a 100644 --- a/deps/v8/test/mjsunit/mjsunit.js +++ b/deps/v8/test/mjsunit/mjsunit.js @@ -120,6 +120,38 @@ var assertContains; // Assert that a string matches a given regex. var assertMatches; +// These bits must be in sync with bits defined in Runtime_GetOptimizationStatus +var V8OptimizationStatus = { + kIsFunction: 1 << 0, + kNeverOptimize: 1 << 1, + kAlwaysOptimize: 1 << 2, + kMaybeDeopted: 1 << 3, + kOptimized: 1 << 4, + kTurboFanned: 1 << 5, + kInterpreted: 1 << 6 +}; + +// Returns true if --no-crankshaft mode is on. +var isNeverOptimize; + +// Returns true if --always-opt mode is on. +var isAlwaysOptimize; + +// Returns true if given function in interpreted. +var isInterpreted; + +// Returns true if given function is compiled by a base-line compiler. +var isBaselined; + +// Returns true if given function is optimized. +var isOptimized; + +// Returns true if given function is compiled by Crankshaft. +var isCrankshafted; + +// Returns true if given function is compiled by TurboFan. +var isTurboFanned; + (function () { // Scope for utility functions. @@ -462,12 +494,87 @@ var assertMatches; assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { if (sync_opt === undefined) sync_opt = ""; - assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt); + var opt_status = OptimizationStatus(fun, sync_opt); + // Tests that use assertOptimized() do not make sense if --always-opt + // option is provided. Such tests must add --no-always-opt to flags comment. + assertFalse((opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0, + "test does not make sense with --always-opt"); + assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt); + if ((opt_status & V8OptimizationStatus.kMaybeDeopted) !== 0) { + // When --deopt-every-n-times flag is specified it's no longer guaranteed + // that particular function is still deoptimized, so keep running the test + // to stress test the deoptimizer. + return; + } + assertFalse((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt); } assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { if (sync_opt === undefined) sync_opt = ""; - assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt); + var opt_status = OptimizationStatus(fun, sync_opt); + // Tests that use assertOptimized() do not make sense if --no-crankshaft + // option is provided. Such tests must add --crankshaft to flags comment. + assertFalse((opt_status & V8OptimizationStatus.kNeverOptimize) !== 0, + "test does not make sense with --no-crankshaft"); + assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt); + if ((opt_status & V8OptimizationStatus.kMaybeDeopted) !== 0) { + // When --deopt-every-n-times flag is specified it's no longer guaranteed + // that particular function is still optimized, so keep running the test + // to stress test the deoptimizer. + return; + } + assertTrue((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt); + } + + isNeverOptimize = function isNeverOptimize() { + var opt_status = OptimizationStatus(undefined, ""); + return (opt_status & V8OptimizationStatus.kNeverOptimize) !== 0; + } + + isAlwaysOptimize = function isAlwaysOptimize() { + var opt_status = OptimizationStatus(undefined, ""); + return (opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0; + } + + isInterpreted = function isInterpreted(fun) { + var opt_status = OptimizationStatus(fun, ""); + assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, + "not a function"); + return (opt_status & V8OptimizationStatus.kOptimized) === 0 && + (opt_status & V8OptimizationStatus.kInterpreted) !== 0; + } + + // NOTE: This predicate also returns true for functions that have never + // been compiled (i.e. that have LazyCompile stub as a code). + isBaselined = function isBaselined(fun) { + var opt_status = OptimizationStatus(fun, ""); + assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, + "not a function"); + return (opt_status & V8OptimizationStatus.kOptimized) === 0 && + (opt_status & V8OptimizationStatus.kInterpreted) === 0; + } + + isOptimized = function isOptimized(fun) { + var opt_status = OptimizationStatus(fun, ""); + assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, + "not a function"); + return (opt_status & V8OptimizationStatus.kOptimized) !== 0; + } + + isCrankshafted = function isCrankshafted(fun) { + var opt_status = OptimizationStatus(fun, ""); + assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, + "not a function"); + return (opt_status & V8OptimizationStatus.kOptimized) !== 0 && + (opt_status & V8OptimizationStatus.kTurboFanned) === 0; + } + + isTurboFanned = function isTurboFanned(fun) { + var opt_status = OptimizationStatus(fun, ""); + assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, + "not a function"); + return (opt_status & V8OptimizationStatus.kOptimized) !== 0 && + (opt_status & V8OptimizationStatus.kTurboFanned) !== 0; } })(); diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status index c82befb209..34649a46a0 100644 --- a/deps/v8/test/mjsunit/mjsunit.status +++ b/deps/v8/test/mjsunit/mjsunit.status @@ -53,6 +53,9 @@ # Issue 3784: setters-on-elements is flaky 'setters-on-elements': [PASS, FAIL], + # Issue 5495: enable the test when the constant field tracking in enabled. + 'const-field-tracking': [SKIP], + ############################################################################## # Too slow in debug mode with --stress-opt mode. 'regress/regress-create-exception': [PASS, ['mode == debug', SKIP]], @@ -156,6 +159,9 @@ # desugaring regexp property class relies on ICU. 'harmony/regexp-property-*': [PASS, ['no_i18n == True', FAIL]], + # noi18n build cannot parse characters in supplementary plane. + 'harmony/regexp-named-captures': [PASS, ['no_i18n == True', FAIL]], + # Allocates a large array buffer, which TSAN sometimes cannot handle. 'regress/regress-599717': [PASS, ['tsan', SKIP]], @@ -237,12 +243,6 @@ # BUG(v8:4779): Crashes flakily with stress mode on arm64. 'array-splice': [PASS, SLOW, ['arch == arm64', FAST_VARIANTS]], - - #BUG(v8:5683) - 'wasm/import-memory': [SKIP], - - # Crashes with WASM turned on by default on arm64 gc-stress - 'regress/regress-500831': [PASS, ['arch == arm64', SKIP]], }], # 'gc_stress == True' ############################################################################## @@ -408,6 +408,24 @@ }], # 'arch == arm or arch == android_arm' ############################################################################## +['(arch == mipsel or arch == mips or arch == mips64el or arch == mips64) and simulator_run != True', { + # These tests fail occasionally on the buildbots because they consume + # a large amount of memory if executed in parallel. Therefore we + # run only a single instance of these tests + 'regress/regress-crbug-514081': [PASS, NO_VARIANTS], + 'regress/regress-599717': [PASS, NO_VARIANTS], + 'regress/regress-599414-array-concat-fast-path': [PASS, NO_VARIANTS], + 'array-functions-prototype-misc': [PASS, NO_VARIANTS], +}], # 'arch == mipsel or arch == mips or arch == mips64el or arch == mips64' + +############################################################################## +['arch == mipsel or arch == mips or arch == mips64el or arch == mips64', { + # These tests fail because qNaN and sNaN values are encoded differently on + # MIPS and ARM/x86 architectures + 'wasm/float-constant-folding': [SKIP], +}], + +############################################################################## ['arch == mipsel or arch == mips', { # Slow tests which times out in debug mode. @@ -533,7 +551,6 @@ # Forced optimisation path tests. 'shared-function-tier-up-default': [SKIP], - 'shared-function-tier-up-ignition': [SKIP], 'shared-function-tier-up-turbo': [SKIP], # Fails deopt_fuzzer due to --deopt_every_n_times or @@ -576,6 +593,7 @@ ['variant == stress', { 'es6/array-iterator-turbo': [SKIP], + 'array-natives-elements': [SKIP], 'ignition/regress-599001-verifyheap': [SKIP], 'unicode-test': [SKIP], }], # variant == stress @@ -604,12 +622,6 @@ }], # 'gcov_coverage' ############################################################################## -['variant == stress or variant == turbofan_opt', { - # BUG(v8:5553). - 'wasm/grow-memory': [SKIP], -}], # variant == stress or variant == turbofan_opt - -############################################################################## ['variant == asm_wasm', { # Skip stuff uninteresting for asm.js 'bugs/*': [SKIP], @@ -646,13 +658,4 @@ 'whitespaces': [SKIP], }], # variant == wasm_traps -############################################################################## -# This test allocates a 2G block of memory and if there are multiple -# varients this leads kills by the OOM killer, crashes or messages -# indicating the OS cannot allocate memory, exclude for Node.js runs -# re-evalute when we move up to v8 5.1 -[ALWAYS, { -'regress/regress-crbug-514081': [PASS, NO_VARIANTS], -}], # ALWAYS - ] diff --git a/deps/v8/test/mjsunit/modules-namespace1.js b/deps/v8/test/mjsunit/modules-namespace1.js index 8406efe61e..9c2ce93504 100644 --- a/deps/v8/test/mjsunit/modules-namespace1.js +++ b/deps/v8/test/mjsunit/modules-namespace1.js @@ -48,8 +48,10 @@ assertEquals("string", typeof Reflect.get(foo, Symbol.toStringTag)); assertEquals( {value: "Module", configurable: false, writable: false, enumerable: false}, Reflect.getOwnPropertyDescriptor(foo, Symbol.toStringTag)); -// TODO(neis): Spec currently says the next one should return true. assertFalse(Reflect.deleteProperty(foo, Symbol.toStringTag)); +assertEquals( + {value: "Module", configurable: false, writable: false, enumerable: false}, + Reflect.getOwnPropertyDescriptor(foo, Symbol.toStringTag)); // Nonexistant properties. let nonexistant = ["gaga", 123, Symbol('')]; diff --git a/deps/v8/test/mjsunit/modules-turbo.js b/deps/v8/test/mjsunit/modules-turbo1.js index 7c31682a5b..ca28d8b789 100644 --- a/deps/v8/test/mjsunit/modules-turbo.js +++ b/deps/v8/test/mjsunit/modules-turbo1.js @@ -3,7 +3,7 @@ // found in the LICENSE file. // MODULE -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --turbo export let x = 0; function foo() { x++ }; diff --git a/deps/v8/test/mjsunit/modules-turbo2.js b/deps/v8/test/mjsunit/modules-turbo2.js new file mode 100644 index 0000000000..734b2c4093 --- /dev/null +++ b/deps/v8/test/mjsunit/modules-turbo2.js @@ -0,0 +1,17 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// MODULE +// Flags: --allow-natives-syntax --turbo + +export let x = 0; + +function foo() { return x++ }; + +function gaga(f) { return f() }; + +assertEquals(0, gaga(foo)); +assertEquals(1, gaga(foo)); +%OptimizeFunctionOnNextCall(gaga); +assertEquals(2, gaga(foo)); diff --git a/deps/v8/test/mjsunit/never-optimize.js b/deps/v8/test/mjsunit/never-optimize.js index 643588ebf4..2949f06268 100644 --- a/deps/v8/test/mjsunit/never-optimize.js +++ b/deps/v8/test/mjsunit/never-optimize.js @@ -25,39 +25,35 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt function o1() { } -if (%GetOptimizationStatus(o1) != 4) { - // 4 == optimization disabled. - o1(); o1(); - %OptimizeFunctionOnNextCall(o1); - o1(); +o1(); o1(); +%OptimizeFunctionOnNextCall(o1); +o1(); - // Check that the given function was optimized. - assertOptimized(o1); +// Check that the given function was optimized. +assertOptimized(o1); - // Test the %NeverOptimizeFunction runtime call. - %NeverOptimizeFunction(u1); - function u1() { - } +// Test the %NeverOptimizeFunction runtime call. +%NeverOptimizeFunction(u1); +function u1() { +} - function u2() { - u1(); - } +function u2() { + u1(); +} - u1(); u1(); - u2(); u2(); +u1(); u1(); +u2(); u2(); - %OptimizeFunctionOnNextCall(u1); - %OptimizeFunctionOnNextCall(u2); +%OptimizeFunctionOnNextCall(u1); +%OptimizeFunctionOnNextCall(u2); - u1(); u1(); - u2(); u2(); +u1(); u1(); +u2(); u2(); - // 2 => not optimized. - assertUnoptimized(u1); - assertOptimized(u2); -} +assertUnoptimized(u1); +assertOptimized(u2); diff --git a/deps/v8/test/mjsunit/object-seal.js b/deps/v8/test/mjsunit/object-seal.js index ef1b16d906..a901b1f480 100644 --- a/deps/v8/test/mjsunit/object-seal.js +++ b/deps/v8/test/mjsunit/object-seal.js @@ -28,7 +28,7 @@ // Tests the Object.seal and Object.isSealed methods - ES 19.1.2.17 and // ES 19.1.2.13 -// Flags: --allow-natives-syntax --noalways-opt +// Flags: --allow-natives-syntax --crankshaft --noalways-opt // Test that we return obj if non-object is passed as argument var non_objects = new Array(undefined, null, 1, -1, 0, 42.43, Symbol("test")); diff --git a/deps/v8/test/mjsunit/opt-elements-kind.js b/deps/v8/test/mjsunit/opt-elements-kind.js index 515305a928..472f6eddf7 100644 --- a/deps/v8/test/mjsunit/opt-elements-kind.js +++ b/deps/v8/test/mjsunit/opt-elements-kind.js @@ -142,9 +142,9 @@ function test1() { } function clear_ic_state() { - %ClearFunctionTypeFeedback(construct_smis); - %ClearFunctionTypeFeedback(construct_doubles); - %ClearFunctionTypeFeedback(convert_mixed); + %ClearFunctionFeedback(construct_smis); + %ClearFunctionFeedback(construct_doubles); + %ClearFunctionFeedback(convert_mixed); } test1(); diff --git a/deps/v8/test/mjsunit/parallel-optimize-disabled.js b/deps/v8/test/mjsunit/parallel-optimize-disabled.js index f8d5848f0d..f2a10f57ee 100644 --- a/deps/v8/test/mjsunit/parallel-optimize-disabled.js +++ b/deps/v8/test/mjsunit/parallel-optimize-disabled.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --nodead-code-elimination --concurrent-recompilation -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --no-always-opt if (!%IsConcurrentRecompilationSupported()) { print("Concurrent recompilation is disabled. Skipping this test."); diff --git a/deps/v8/test/mjsunit/proto-elements-add-during-foreach.js b/deps/v8/test/mjsunit/proto-elements-add-during-foreach.js new file mode 100644 index 0000000000..a99e8070d0 --- /dev/null +++ b/deps/v8/test/mjsunit/proto-elements-add-during-foreach.js @@ -0,0 +1,12 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --enable-fast-array-builtins + +var a = [0,1,2,,,,7]; +var proto = {} +a.__proto__ = proto; +var visits = 0; +Array.prototype.forEach.call(a, (v,i,o) => { ++visits; proto[4] = 4; }); +assertEquals(5, visits); diff --git a/deps/v8/test/mjsunit/readonly.js b/deps/v8/test/mjsunit/readonly.js index 3839731e02..72a08a7c86 100644 --- a/deps/v8/test/mjsunit/readonly.js +++ b/deps/v8/test/mjsunit/readonly.js @@ -173,8 +173,8 @@ function TestAllScenarios(f) { // Make sure that the assignments are monomorphic. %DeoptimizeFunction(Assign); %DeoptimizeFunction(AssignStrict); - %ClearFunctionTypeFeedback(Assign); - %ClearFunctionTypeFeedback(AssignStrict); + %ClearFunctionFeedback(Assign); + %ClearFunctionFeedback(AssignStrict); for (var i = 0; i < t; ++i) { var o = create(); assertFalse("a" in o && !("a" in o.__proto__)); diff --git a/deps/v8/test/mjsunit/regexp.js b/deps/v8/test/mjsunit/regexp.js index 04c723665a..c9a1fd21b3 100644 --- a/deps/v8/test/mjsunit/regexp.js +++ b/deps/v8/test/mjsunit/regexp.js @@ -564,21 +564,21 @@ log = []; re.lastIndex = fakeLastIndex; var result = re.exec(fakeString); assertEquals(["str"], result); -assertEquals(["ts"], log); +assertEquals(["ts", "li"], log); // Again, to check if caching interferes. log = []; re.lastIndex = fakeLastIndex; result = re.exec(fakeString); assertEquals(["str"], result); -assertEquals(["ts"], log); +assertEquals(["ts", "li"], log); // And one more time, just to be certain. log = []; re.lastIndex = fakeLastIndex; result = re.exec(fakeString); assertEquals(["str"], result); -assertEquals(["ts"], log); +assertEquals(["ts", "li"], log); // Now with a global regexp, where lastIndex is actually used. re = /str/g; diff --git a/deps/v8/test/mjsunit/regress/compare-map-elim1.js b/deps/v8/test/mjsunit/regress/compare-map-elim1.js index c7ea05def8..d98c089dec 100644 --- a/deps/v8/test/mjsunit/regress/compare-map-elim1.js +++ b/deps/v8/test/mjsunit/regress/compare-map-elim1.js @@ -49,7 +49,7 @@ Object.defineProperty(o2, "foo1", {get:getter}); foo(o1); foo(o1); foo(o2); -%ClearFunctionTypeFeedback(foo2); +%ClearFunctionFeedback(foo2); foo2(o2); foo2(o2); foo2(o3); diff --git a/deps/v8/test/mjsunit/regress/regress-2132.js b/deps/v8/test/mjsunit/regress/regress-2132.js index 9eb2dc5b07..51938c8027 100644 --- a/deps/v8/test/mjsunit/regress/regress-2132.js +++ b/deps/v8/test/mjsunit/regress/regress-2132.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt function mul(x, y) { return (x * y) | 0; diff --git a/deps/v8/test/mjsunit/regress/regress-2250.js b/deps/v8/test/mjsunit/regress/regress-2250.js index 88d4dd434f..013771971e 100644 --- a/deps/v8/test/mjsunit/regress/regress-2250.js +++ b/deps/v8/test/mjsunit/regress/regress-2250.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft // The original problem from the bug: In the example below SMI check for b // generated for inlining of equals invocation (marked with (*)) will be hoisted diff --git a/deps/v8/test/mjsunit/regress/regress-2315.js b/deps/v8/test/mjsunit/regress/regress-2315.js index 28c78eae48..41211c42e9 100644 --- a/deps/v8/test/mjsunit/regress/regress-2315.js +++ b/deps/v8/test/mjsunit/regress/regress-2315.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft var foo = (function() { return eval("(function bar() { return 1; })"); diff --git a/deps/v8/test/mjsunit/regress/regress-2339.js b/deps/v8/test/mjsunit/regress/regress-2339.js index 8355446cfc..9db2f9c2bf 100644 --- a/deps/v8/test/mjsunit/regress/regress-2339.js +++ b/deps/v8/test/mjsunit/regress/regress-2339.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --expose-gc +// Flags: --allow-natives-syntax --expose-gc --crankshaft function simple() { return simple_two_args(0, undefined); diff --git a/deps/v8/test/mjsunit/regress/regress-2437.js b/deps/v8/test/mjsunit/regress/regress-2437.js index 66f0abfef5..d11307948c 100644 --- a/deps/v8/test/mjsunit/regress/regress-2437.js +++ b/deps/v8/test/mjsunit/regress/regress-2437.js @@ -55,31 +55,31 @@ assertEquals(1, r.lastIndex); r = /a/; r.lastIndex = 1; "zzzz".replace(r, ""); -assertEquals(0, r.lastIndex); +assertEquals(1, r.lastIndex); // Test String.prototype.replace with non-atomic regexp and empty string. r = /\d/; r.lastIndex = 1; "zzzz".replace(r, ""); -assertEquals(0, r.lastIndex); +assertEquals(1, r.lastIndex); // Test String.prototype.replace with atomic regexp and non-empty string. r = /a/; r.lastIndex = 1; "zzzz".replace(r, "a"); -assertEquals(0, r.lastIndex); +assertEquals(1, r.lastIndex); // Test String.prototype.replace with non-atomic regexp and non-empty string. r = /\d/; r.lastIndex = 1; "zzzz".replace(r, "a"); -assertEquals(0, r.lastIndex); +assertEquals(1, r.lastIndex); // Test String.prototype.replace with replacement function r = /a/; r.lastIndex = 1; "zzzz".replace(r, function() { return ""; }); -assertEquals(0, r.lastIndex); +assertEquals(1, r.lastIndex); // Regexp functions that returns multiple results: // A global regexp always resets lastIndex regardless of whether it matches. @@ -100,7 +100,7 @@ r.lastIndex = -1; "01234567".match(r); assertEquals(0, r.lastIndex); -// A non-global regexp resets lastIndex iff it does not match. +// A non-global regexp resets lastIndex iff it is sticky. r = /a/; r.lastIndex = -1; "0123abcd".replace(r, "x"); @@ -108,7 +108,7 @@ assertEquals(-1, r.lastIndex); r.lastIndex = -1; "01234567".replace(r, "x"); -assertEquals(0, r.lastIndex); +assertEquals(-1, r.lastIndex); r.lastIndex = -1; "0123abcd".match(r); @@ -118,6 +118,16 @@ r.lastIndex = -1; "01234567".match(r); assertEquals(-1, r.lastIndex); +r = /a/y; +r.lastIndex = -1; +"0123abcd".replace(r, "x"); +assertEquals(0, r.lastIndex); + +r.lastIndex = -1; +"01234567".replace(r, "x"); +assertEquals(0, r.lastIndex); + + // Also test RegExp.prototype.exec and RegExp.prototype.test r = /a/g; r.lastIndex = 1; diff --git a/deps/v8/test/mjsunit/regress/regress-2438.js b/deps/v8/test/mjsunit/regress/regress-2438.js index 51092788ac..b9d8875cb5 100644 --- a/deps/v8/test/mjsunit/regress/regress-2438.js +++ b/deps/v8/test/mjsunit/regress/regress-2438.js @@ -27,20 +27,16 @@ function testSideEffects(subject, re) { var counter = 0; - var expected_counter = 0; - const accesses_lastindex = (re.global || re.sticky); var side_effect_object = { valueOf: function() { return counter++; } }; re.lastIndex = side_effect_object; re.exec(subject); - if (accesses_lastindex) expected_counter++; - assertEquals(expected_counter, counter); + assertEquals(1, counter); re.lastIndex = side_effect_object; re.test(subject); - if (accesses_lastindex) expected_counter++; - assertEquals(expected_counter, counter); + assertEquals(2, counter); } testSideEffects("zzzz", /a/); diff --git a/deps/v8/test/mjsunit/regress/regress-2451.js b/deps/v8/test/mjsunit/regress/regress-2451.js index c1749b178f..1a486be8b1 100644 --- a/deps/v8/test/mjsunit/regress/regress-2451.js +++ b/deps/v8/test/mjsunit/regress/regress-2451.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function f() { assertEquals(-1.0, Math.round(-1.5)); diff --git a/deps/v8/test/mjsunit/regress/regress-2470.js b/deps/v8/test/mjsunit/regress/regress-2470.js index 29a0b250ac..cba1b06c3e 100644 --- a/deps/v8/test/mjsunit/regress/regress-2470.js +++ b/deps/v8/test/mjsunit/regress/regress-2470.js @@ -34,12 +34,14 @@ assertThrows('Function("});(function(){");', SyntaxError); // Test whether block comments are handled correctly. assertDoesNotThrow('Function("/*", "*/", "/**/");'); assertDoesNotThrow('Function("/*", "a", "*/", "/**/");'); -assertThrows('Function("a", "/*", "*/", "/**/");', SyntaxError); +assertDoesNotThrow('Function("a", "/*", "*/", "/**/");'); +assertThrows('Function("a", "/*", "*/", "b", "/*", "*/", "/**/");', SyntaxError); // Test whether line comments are handled correctly. assertDoesNotThrow('Function("//", "//")'); assertDoesNotThrow('Function("//", "//", "//")'); -assertThrows('Function("a", "//", "//")', SyntaxError); +assertDoesNotThrow('Function("a", "//", "//")'); +assertThrows('Function("a", "", "//", "//")', SyntaxError); // Some embedders rely on the string representation of the resulting // function in cases where no formal parameters are specified. diff --git a/deps/v8/test/mjsunit/regress/regress-252797.js b/deps/v8/test/mjsunit/regress/regress-252797.js index ac776a17d8..c3bb139965 100644 --- a/deps/v8/test/mjsunit/regress/regress-252797.js +++ b/deps/v8/test/mjsunit/regress/regress-252797.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft // The type feedback oracle had a bug when retrieving the map from an IC // starting with a negative lookup. diff --git a/deps/v8/test/mjsunit/regress/regress-2618.js b/deps/v8/test/mjsunit/regress/regress-2618.js index faffc5bf47..be3168c1cd 100644 --- a/deps/v8/test/mjsunit/regress/regress-2618.js +++ b/deps/v8/test/mjsunit/regress/regress-2618.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --use-osr --allow-natives-syntax --ignition-osr +// Flags: --use-osr --allow-natives-syntax --ignition-osr --crankshaft function f() { do { @@ -36,7 +36,7 @@ function f() { } f(); -assertTrue(%GetOptimizationCount(f) > 0 || %GetOptimizationStatus(f) == 4); +assertTrue(%GetOptimizationCount(f) > 0); function g() { for (var i = 0; i < 1; i++) { } @@ -67,4 +67,4 @@ function g() { } g(); -assertTrue(%GetOptimizationCount(g) > 0 || %GetOptimizationStatus(g) == 4); +assertTrue(%GetOptimizationCount(g) > 0); diff --git a/deps/v8/test/mjsunit/regress/regress-3176.js b/deps/v8/test/mjsunit/regress/regress-3176.js index e2563c0d3a..370065d777 100644 --- a/deps/v8/test/mjsunit/regress/regress-3176.js +++ b/deps/v8/test/mjsunit/regress/regress-3176.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function foo(a) { var sum = 0; diff --git a/deps/v8/test/mjsunit/regress/regress-3281.js b/deps/v8/test/mjsunit/regress/regress-3281.js deleted file mode 100644 index f7b167e3b8..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-3281.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-natives-as=builtins -// Should not crash or raise an exception. - -var SetIterator = builtins.ImportNow("SetIterator"); -var s = new Set(); -var setIterator = new SetIterator(s, 2); - -var MapIterator = builtins.ImportNow("MapIterator"); -var m = new Map(); -var mapIterator = new MapIterator(m, 2); diff --git a/deps/v8/test/mjsunit/regress/regress-347914.js b/deps/v8/test/mjsunit/regress/regress-347914.js index bc4dcd7f74..ec693ee92c 100644 --- a/deps/v8/test/mjsunit/regress/regress-347914.js +++ b/deps/v8/test/mjsunit/regress/regress-347914.js @@ -3,6 +3,7 @@ // found in the LICENSE file. // Flags: --allow-natives-syntax --debug-code --gc-interval=201 --verify-heap --max-inlined-source-size=999999 --max-inlined-nodes=999999 --max-inlined-nodes-cumulative=999999 +// Flags: --crankshaft --no-always-opt // Begin stripped down and modified version of mjsunit.js for easy minimization in CF. function MjsUnitAssertionError(message) {} diff --git a/deps/v8/test/mjsunit/regress/regress-3650-3.js b/deps/v8/test/mjsunit/regress/regress-3650-3.js index 013e4df283..f842428262 100644 --- a/deps/v8/test/mjsunit/regress/regress-3650-3.js +++ b/deps/v8/test/mjsunit/regress/regress-3650-3.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function foo(a) { for (var d in a) { diff --git a/deps/v8/test/mjsunit/regress/regress-3709.js b/deps/v8/test/mjsunit/regress/regress-3709.js index d2de7117f5..0f6f7b71d4 100644 --- a/deps/v8/test/mjsunit/regress/regress-3709.js +++ b/deps/v8/test/mjsunit/regress/regress-3709.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt function getobj() { return { bar : function() { return 0}}; @@ -25,4 +25,4 @@ foo(); assertOptimized(foo); foo(10); assertUnoptimized(foo); -%ClearFunctionTypeFeedback(foo); +%ClearFunctionFeedback(foo); diff --git a/deps/v8/test/mjsunit/regress/regress-385565.js b/deps/v8/test/mjsunit/regress/regress-385565.js index 2a471b24be..0244cdf75c 100644 --- a/deps/v8/test/mjsunit/regress/regress-385565.js +++ b/deps/v8/test/mjsunit/regress/regress-385565.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt var calls = 0; diff --git a/deps/v8/test/mjsunit/regress/regress-410912.js b/deps/v8/test/mjsunit/regress/regress-410912.js index 98367bdf20..5691161521 100644 --- a/deps/v8/test/mjsunit/regress/regress-410912.js +++ b/deps/v8/test/mjsunit/regress/regress-410912.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --expose-gc +// Flags: --allow-natives-syntax --expose-gc --crankshaft --no-always-opt var assertDoesNotThrow; var assertInstanceof; diff --git a/deps/v8/test/mjsunit/regress/regress-4121.js b/deps/v8/test/mjsunit/regress/regress-4121.js index a175ed9fd2..2ca68be5ab 100644 --- a/deps/v8/test/mjsunit/regress/regress-4121.js +++ b/deps/v8/test/mjsunit/regress/regress-4121.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --no-always-opt function literals_sharing_test(warmup, optimize) { function closure() { @@ -39,10 +39,4 @@ function test() { literals_sharing_test(warmup, true); } - -function stress_opt_test() {} -stress_opt_test(); -if (%GetOptimizationStatus(stress_opt_test) == 2) { - // This test is not suitable for --always-opt mode. - test(); -} +test(); diff --git a/deps/v8/test/mjsunit/regress/regress-4173.js b/deps/v8/test/mjsunit/regress/regress-4173.js index bef0b47ee5..72a476bd60 100644 --- a/deps/v8/test/mjsunit/regress/regress-4173.js +++ b/deps/v8/test/mjsunit/regress/regress-4173.js @@ -54,5 +54,5 @@ assertFalse(%HasFastSmiElements(second_object_array)); assertTrue(%HaveSameMap(first_object_array, second_object_array)); assertFalse(%HaveSameMap(first_smi_array, second_object_array)); -%ClearFunctionTypeFeedback(Loader); -%ClearFunctionTypeFeedback(Migrator); +%ClearFunctionFeedback(Loader); +%ClearFunctionFeedback(Migrator); diff --git a/deps/v8/test/mjsunit/regress/regress-4380.js b/deps/v8/test/mjsunit/regress/regress-4380.js index 8a83def6e2..f51241ac7d 100644 --- a/deps/v8/test/mjsunit/regress/regress-4380.js +++ b/deps/v8/test/mjsunit/regress/regress-4380.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function bar(a) { var x = a[0]; diff --git a/deps/v8/test/mjsunit/regress/regress-5404.js b/deps/v8/test/mjsunit/regress/regress-5404.js index 652db4bdb5..b776a73bd0 100644 --- a/deps/v8/test/mjsunit/regress/regress-5404.js +++ b/deps/v8/test/mjsunit/regress/regress-5404.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function foo(a, b) { return a + "0123456789012"; diff --git a/deps/v8/test/mjsunit/regress/regress-5636-1.js b/deps/v8/test/mjsunit/regress/regress-5636-1.js new file mode 100644 index 0000000000..c1cafe639b --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5636-1.js @@ -0,0 +1,22 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --function-context-specialization + +function f(n) { + var a = []; + function g() { return x } + for (var i = 0; i < n; ++i) { + var x = i; + a[i] = g; + %OptimizeFunctionOnNextCall(g); + g(); + } + return a; +} +var a = f(3); +assertEquals(3, a.length); +assertEquals(2, a[0]()); +assertEquals(2, a[1]()); +assertEquals(2, a[2]()); diff --git a/deps/v8/test/mjsunit/regress/regress-5636-2.js b/deps/v8/test/mjsunit/regress/regress-5636-2.js new file mode 100644 index 0000000000..e76733654d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5636-2.js @@ -0,0 +1,23 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function f(n) { + "use asm"; + var a = []; + function g() { return x } + for (var i = 0; i < n; ++i) { + var x = i; + a[i] = g; + %OptimizeFunctionOnNextCall(g); + g(); + } + return a; +} +var a = f(3); +assertEquals(3, a.length); +assertEquals(2, a[0]()); +assertEquals(2, a[1]()); +assertEquals(2, a[2]()); diff --git a/deps/v8/test/mjsunit/regress/regress-5638.js b/deps/v8/test/mjsunit/regress/regress-5638.js new file mode 100644 index 0000000000..034e4c40be --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5638.js @@ -0,0 +1,32 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +class MyErrorA {} + +class MyErrorB {} + +class A {} + +class B extends A { + constructor() { + try { + super(); + } catch (e) { + throw new MyErrorB(); + } + } +} + +var thrower = new Proxy(A, { + get(target, property, receiver) { + if (property === 'prototype') throw new MyErrorA(); + } +}); + +assertThrows(() => Reflect.construct(B, [], thrower), MyErrorB); +assertThrows(() => Reflect.construct(B, [], thrower), MyErrorB); +%OptimizeFunctionOnNextCall(B); +assertThrows(() => Reflect.construct(B, [], thrower), MyErrorB); diff --git a/deps/v8/test/mjsunit/regress/regress-5638b.js b/deps/v8/test/mjsunit/regress/regress-5638b.js new file mode 100644 index 0000000000..b72a80eac5 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5638b.js @@ -0,0 +1,44 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +class A { + constructor(arg) { + assertEquals(123, arg); + assertSame(observer, new.target); + superclass_counter++; + } +} + +class B extends A { + constructor() { + super(123); + construction_counter++; + } +} + +var superclass_counter = 0; + +var construction_counter = 0; + +var observation_counter = 0; + +var observer = new Proxy(A, { + get(target, property, receiver) { + if (property === 'prototype') { + %DeoptimizeFunction(B); + observation_counter++; + } + return Reflect.get(target, property, receiver); + } +}); + +Reflect.construct(B, [], observer); +Reflect.construct(B, [], observer); +%OptimizeFunctionOnNextCall(B); +Reflect.construct(B, [], observer); +assertEquals(3, observation_counter); +assertEquals(3, construction_counter); +assertEquals(3, superclass_counter); diff --git a/deps/v8/test/mjsunit/regress/regress-5692.js b/deps/v8/test/mjsunit/regress/regress-5692.js new file mode 100644 index 0000000000..af9f131c44 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5692.js @@ -0,0 +1,16 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// "let" in non-strict mode can be a label, even if composed of unicode escape +// sequences. + +var wasTouched = false; +l\u0065t: +do { + break l\u0065t; + wasTouched = true; +} while (false); +// Verify that in addition to no exception thrown, breaking to the label also +// works. +assertFalse(wasTouched); diff --git a/deps/v8/test/mjsunit/regress/regress-5790.js b/deps/v8/test/mjsunit/regress/regress-5790.js index 7790db5ea9..8709cd4aa3 100644 --- a/deps/v8/test/mjsunit/regress/regress-5790.js +++ b/deps/v8/test/mjsunit/regress/regress-5790.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function foo(a) { "use strict"; diff --git a/deps/v8/test/mjsunit/regress/regress-5802.js b/deps/v8/test/mjsunit/regress/regress-5802.js index 6a84c09851..b7146fb64e 100644 --- a/deps/v8/test/mjsunit/regress/regress-5802.js +++ b/deps/v8/test/mjsunit/regress/regress-5802.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft (function() { function eq(a, b) { return a == b; } diff --git a/deps/v8/test/mjsunit/regress/regress-5845.js b/deps/v8/test/mjsunit/regress/regress-5845.js new file mode 100644 index 0000000000..45a580b24f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5845.js @@ -0,0 +1,6 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +assertDoesNotThrow('/(?:(?=(foo)))?/u.exec("foo")'); +assertThrows('/(?=(foo))?/u.exec("foo")'); diff --git a/deps/v8/test/mjsunit/regress/regress-5888.js b/deps/v8/test/mjsunit/regress/regress-5888.js new file mode 100644 index 0000000000..0725ac4285 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5888.js @@ -0,0 +1,76 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +(function() { + var builder = new WasmModuleBuilder(); + builder.addMemory(32, 32, false); + builder.addFunction("test", kSig_i_iii) + .addBodyWithEnd([ +// body: +kExprI64Const, 0xb4, 0x42, +kExprI64Const, 0x7a, +kExprI64Const, 0x42, +kExprI64Const, 0x7a, +kExprI64Ior, +kExprI64Ctz, +kExprI64Ctz, +kExprI64Shl, +kExprI64Mul, +kExprI64Const, 0x41, +kExprI64Ctz, +kExprI64Ctz, +kExprI64Shl, +kExprF32SConvertI64, +kExprI64Const, 0x42, +kExprI64Const, 0x02, +kExprI64Const, 0x7a, +kExprI64Mul, +kExprI64Const, 0x42, +kExprI64Ctz, +kExprI64Shl, +kExprI64Const, 0x7a, +kExprI64Ctz, +kExprI64Shl, +kExprI64Mul, +kExprI64Const, 0x41, +kExprI64Ctz, +kExprI64Ctz, +kExprI64Shl, +kExprF32SConvertI64, +kExprUnreachable, +kExprEnd, // @65 + ]) + .exportFunc(); + var module = new WebAssembly.Module(builder.toBuffer()); +})(); + +(function() { + var builder = new WasmModuleBuilder(); + builder.addMemory(16, 32, false); + builder.addFunction("test", kSig_i_iii) + .addBodyWithEnd([ + // body: + kExprI64Const, 0x42, + kExprI64Const, 0x7a, + kExprI64Ctz, + kExprI64Mul, + kExprI64Ctz, + kExprI64Const, 0x41, + kExprI64Ctz, + kExprI64Ctz, + kExprI64Shl, + kExprI64Const, 0x41, + kExprI64Ctz, + kExprI64Ctz, + kExprI64Shl, + kExprF32SConvertI64, + kExprUnreachable, + kExprEnd, // @20 + ]) + .exportFunc(); + var module = new WebAssembly.Module(builder.toBuffer()); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-5902.js b/deps/v8/test/mjsunit/regress/regress-5902.js new file mode 100644 index 0000000000..034b6a7951 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5902.js @@ -0,0 +1,63 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var log = []; + +function check(predicate, item) { + if (!predicate) log.push(item); +} + +var global = this; + +Object.getOwnPropertyNames(global).forEach(function(name) { + // Only check for global properties with uppercase names. + if (name[0] != name[0].toUpperCase()) return; + + var obj = global[name]; + + // Skip non-receivers. + if (! % IsJSReceiver(obj)) return; + + // Skip non-natives. + if (!obj.toString().includes('native')) return; + + // Construct an instance. + try { + new obj(); + } catch (e) { + } + + // Check the object. + check(%HasFastProperties(obj), `${name}`); + + // Check the constructor. + var constructor = obj.constructor; + if (!%IsJSReceiver(constructor)) return; + check(%HasFastProperties(constructor), `${name}.constructor`); + + // Check the prototype. + var prototype = obj.prototype; + if (!%IsJSReceiver(prototype)) return; + check(%HasFastProperties(prototype), `${name}.prototype`); + + // Check the prototype.constructor. + var prototype_constructor = prototype.constructor; + if (!%IsJSReceiver(prototype_constructor)) return; + check( + %HasFastProperties(prototype_constructor), + `${name}.prototype.constructor`); +}); + +// This is the current set of dictionary mode objects. +// Remove items as we fix them. See issue 5902. +assertEquals( + [ + 'Error.prototype', + 'EvalError.prototype', 'RangeError.prototype', 'ReferenceError.prototype', + 'SyntaxError.prototype', 'TypeError.prototype', 'URIError.prototype', + 'Map', 'Map.prototype.constructor', 'Set', 'Set.prototype.constructor' + ], + log); diff --git a/deps/v8/test/mjsunit/regress/regress-5911.js b/deps/v8/test/mjsunit/regress/regress-5911.js new file mode 100644 index 0000000000..0175fd3e2c --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5911.js @@ -0,0 +1,32 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +(function() { + var builder = new WasmModuleBuilder(); + builder.addMemory(32, 32, false); + builder.addFunction("test", kSig_i_iii) + .addBodyWithEnd([ + // body: + kExprI64Const, 0x42, + kExprI64Const, 0x7a, + kExprI64RemU, + kExprI64Const, 0x42, + kExprI64Const, 0x37, + kExprI64Mul, + kExprI64Const, 0x36, + kExprI64Mul, + kExprI64Const, 0x42, + kExprI64Ctz, + kExprI64Ctz, + kExprI64Shl, + kExprF32SConvertI64, + kExprUnreachable, + kExprEnd, // @21 + ]) + .exportFunc(); + var module = new WebAssembly.Module(builder.toBuffer()); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-5927.js b/deps/v8/test/mjsunit/regress/regress-5927.js new file mode 100644 index 0000000000..bcec611f8b --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5927.js @@ -0,0 +1,7 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +let a = Object.freeze({}); +assertThrows(() => class C {[a.b = "foo"]() {}}, TypeError); +assertThrows(() => class C extends (a.c = null) {}, TypeError); diff --git a/deps/v8/test/mjsunit/regress/regress-5938.js b/deps/v8/test/mjsunit/regress/regress-5938.js new file mode 100644 index 0000000000..567498ed47 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5938.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --lazy-inner-functions + +let global = 0; +{ + let confusing = 13; + function lazy_func(b = confusing) { let confusing = 0; global = b; } + lazy_func(); +} + +assertEquals(13, global); diff --git a/deps/v8/test/mjsunit/regress/regress-5972.js b/deps/v8/test/mjsunit/regress/regress-5972.js new file mode 100644 index 0000000000..68fe3ac720 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5972.js @@ -0,0 +1,17 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var undetectable = %GetUndetectable(); + +function foo(a) { + const o = a ? foo : undetectable; + return typeof o === 'function'; +} + +assertFalse(foo(false)); +assertFalse(foo(false)); +%OptimizeFunctionOnNextCall(foo); +assertFalse(foo(false)); diff --git a/deps/v8/test/mjsunit/regress/regress-5974.js b/deps/v8/test/mjsunit/regress/regress-5974.js new file mode 100644 index 0000000000..b9d263844d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5974.js @@ -0,0 +1,9 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(function() { + var a = Array(...Array(5)).map(() => 1); + + assertEquals([1, 1, 1, 1, 1], a); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-6063.js b/deps/v8/test/mjsunit/regress/regress-6063.js new file mode 100644 index 0000000000..4a0d16824a --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6063.js @@ -0,0 +1,17 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var U16 = new Uint16Array(2); +U16[0] = 0xffff; + +function foo(a, i) { + return U16[0] === 0xffff; +} + +assertTrue(foo()); +assertTrue(foo()); +%OptimizeFunctionOnNextCall(foo); +assertTrue(foo()); diff --git a/deps/v8/test/mjsunit/regress/regress-6121.js b/deps/v8/test/mjsunit/regress/regress-6121.js new file mode 100644 index 0000000000..c29ba2b067 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6121.js @@ -0,0 +1,23 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function foo(o) { + try { + for (var x in o) {} + return false; + } catch (e) { + return true; + } +} + +var o = new Proxy({a:1},{ + getOwnPropertyDescriptor(target, property) { throw target; } +}); + +assertTrue(foo(o)); +assertTrue(foo(o)); +%OptimizeFunctionOnNextCall(foo); +assertTrue(foo(o)); diff --git a/deps/v8/test/mjsunit/regress/regress-618608.js b/deps/v8/test/mjsunit/regress/regress-618608.js index 102452e4b8..742cc6e32e 100644 --- a/deps/v8/test/mjsunit/regress/regress-618608.js +++ b/deps/v8/test/mjsunit/regress/regress-618608.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --validate-asm --allow-natives-syntax +// Flags: --validate-asm --allow-natives-syntax --crankshaft --no-always-opt // /v8/test/mjsunit/regress/regress-crbug-431602.js // /v8/test/mjsunit/lazy-load.js @@ -1238,7 +1238,6 @@ gc(); "use asm"; var __v_9 = new stdlib.Float32Array(heap); var __v_13 = stdlib.Math.fround; - assertEquals("number", debug.LookupMirror(__v_112).type()); function __f_73() { var __v_23 = __v_13(1.0); var __v_25 = __v_13(2.0); @@ -1433,38 +1432,3 @@ gc(); assertEquals(0x87654321, __v_30.__f_50()); })(); } catch(e) { print("Caught: " + e); } -try { -var __v_112 = debug.MakeMirror(123).handle(); -assertEquals("number", debug.LookupMirror(__v_112).type()); -debug.ToggleMirrorCache(false); -var __v_114 = debug.MakeMirror(123).handle(); -gc(); -assertEquals(undefined, __v_114); -assertThrows(function() { debug.LookupMirror(__v_114) }); -debug.ToggleMirrorCache(true); -var __v_113 = debug.MakeMirror(123).handle(); -assertEquals("number", debug.LookupMirror(__v_113).type()); -} catch(e) { print("Caught: " + e); } -try { -var Debug = debug.Debug; -var __v_25 = null; -var __v_113 = true; -} catch(e) { print("Caught: " + e); } -function __f_112(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertTrue(exec_state.frame(0).sourceLineText().indexOf("BREAK") > 0); - } catch (e) { - __v_0 = e; - } -} -function __f_113() { - return 1; -} -try { -Debug.setListener(__f_112); -nop(); -__f_113(); -Debug.setListener(null); -assertNull(__v_112); -} catch(e) { print("Caught: " + e); } diff --git a/deps/v8/test/mjsunit/regress/regress-618657.js b/deps/v8/test/mjsunit/regress/regress-618657.js index 170e235014..cdec212fe7 100644 --- a/deps/v8/test/mjsunit/regress/regress-618657.js +++ b/deps/v8/test/mjsunit/regress/regress-618657.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition --ignition-filter=-foo +// Flags: --ignition function* foo() { yield 42 } function* goo() { yield 42 } diff --git a/deps/v8/test/mjsunit/regress/regress-6209.js b/deps/v8/test/mjsunit/regress/regress-6209.js new file mode 100644 index 0000000000..fa0f8880fa --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6209.js @@ -0,0 +1,25 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function testAdvanceStringIndex(lastIndex, expectedLastIndex) { + let exec_count = 0; + let last_last_index = -1; + + let fake_re = { + exec: () => { return (exec_count++ == 0) ? [""] : null }, + get lastIndex() { return lastIndex; }, + set lastIndex(value) { last_last_index = value }, + get global() { return true; }, + get flags() { return "g"; } + }; + + assertEquals([""], RegExp.prototype[Symbol.match].call(fake_re, "abc")); + assertEquals(expectedLastIndex, last_last_index); +} + +testAdvanceStringIndex(new Number(42), 43); // Value wrapper. +testAdvanceStringIndex(%AllocateHeapNumber(), 1); // HeapNumber. +testAdvanceStringIndex(4294967295, 4294967296); // HeapNumber. diff --git a/deps/v8/test/mjsunit/regress/regress-6210.js b/deps/v8/test/mjsunit/regress/regress-6210.js new file mode 100644 index 0000000000..16a65c9689 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6210.js @@ -0,0 +1,34 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --predictable + +const str = '2016-01-02'; + +function testToUint32InSplit() { + var re; + function toDictMode() { + re.x = 42; + delete re.x; + return "def"; + } + + re = /./g; // Needs to be global to trigger lastIndex accesses. + return re[Symbol.replace]("abc", { valueOf: toDictMode }); +} + +function testToStringInReplace() { + var re; + function toDictMode() { + re.x = 42; + delete re.x; + return 42; + } + + re = /./g; // Needs to be global to trigger lastIndex accesses. + return re[Symbol.split]("abc", { valueOf: toDictMode }); +} + +testToUint32InSplit(); +testToStringInReplace(); diff --git a/deps/v8/test/mjsunit/regress/regress-681984.js b/deps/v8/test/mjsunit/regress/regress-681984.js new file mode 100644 index 0000000000..ffc51f3400 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-681984.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function __f_0() { + try { + __f_0(); + } catch(e) { + + Realm.create(); + } +} +__f_0(); diff --git a/deps/v8/test/mjsunit/regress/regress-682242.js b/deps/v8/test/mjsunit/regress/regress-682242.js new file mode 100644 index 0000000000..c22d976ec9 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-682242.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --es-staging + +class BaseClass { + method() { + return 1; + } +} +class SubClass extends BaseClass { + method(...args) { + return super.method(...args); + } +} +var a = new SubClass(); +a.method(); diff --git a/deps/v8/test/mjsunit/regress/regress-682349.js b/deps/v8/test/mjsunit/regress/regress-682349.js new file mode 100644 index 0000000000..162774fa0b --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-682349.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +let success = false; +function f() { + success = (f.caller.arguments === null); +} +Promise.resolve().then(f); +%RunMicrotasks(); +assertTrue(success); diff --git a/deps/v8/test/mjsunit/regress/regress-683617.js b/deps/v8/test/mjsunit/regress/regress-683617.js new file mode 100644 index 0000000000..18da682f2e --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-683617.js @@ -0,0 +1,17 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +global = 'n'; +function f(deopt) { + let it = global[Symbol.iterator](); + if (deopt) { + return it.next().value; + } +} +f(); +f(); +%OptimizeFunctionOnNextCall(f); +assertEquals('n', f(true)); diff --git a/deps/v8/test/mjsunit/regress/regress-685086.js b/deps/v8/test/mjsunit/regress/regress-685086.js new file mode 100644 index 0000000000..2cdaec4221 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-685086.js @@ -0,0 +1,8 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +try { + Math.max(...0); +} catch (e) { +} diff --git a/deps/v8/test/mjsunit/regress/regress-688690.js b/deps/v8/test/mjsunit/regress/regress-688690.js new file mode 100644 index 0000000000..ac4eb77e23 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-688690.js @@ -0,0 +1,16 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var foo = "01234567"; + +foo += foo; +foo += foo; +foo += foo; +foo += foo; +foo += foo; // foo.length = 256; + +// Create an adaptor frame, and take the StringReplaceOneCharWithString runtime +// fast path. This crashed originally since TailCallRuntime could not handle +// adaptor frames. +var bar = foo.replace('x', 'y', 'z'); diff --git a/deps/v8/test/mjsunit/regress/regress-689016.js b/deps/v8/test/mjsunit/regress/regress-689016.js new file mode 100644 index 0000000000..da31350fed --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-689016.js @@ -0,0 +1,12 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(function() { + function f() {} + + assertThrows(function() { + f(...Array(1000000)); + }, RangeError); + +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-696251.js b/deps/v8/test/mjsunit/regress/regress-696251.js new file mode 100644 index 0000000000..b31a876046 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-696251.js @@ -0,0 +1,7 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var a = new Uint8Array(1000); +a.fill(255); +a.sort(); diff --git a/deps/v8/test/mjsunit/regress/regress-696651.js b/deps/v8/test/mjsunit/regress/regress-696651.js new file mode 100644 index 0000000000..66a474d8f5 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-696651.js @@ -0,0 +1,22 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --turbo + +function get_a() { return "aaaaaaaaaaaaaa"; } +function get_b() { return "bbbbbbbbbbbbbb"; } + +function get_string() { + return get_a() + get_b(); +} + +function prefix(s) { + return s + get_string(); +} + +prefix(""); +prefix(""); +%OptimizeFunctionOnNextCall(prefix); +var s = prefix(""); +assertFalse(s === "aaaaaaaaaaaaaabbbbbbbbbbbbbc"); diff --git a/deps/v8/test/mjsunit/regress/regress-704811.js b/deps/v8/test/mjsunit/regress/regress-704811.js new file mode 100644 index 0000000000..dcdeb4e930 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-704811.js @@ -0,0 +1,88 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// The bug was that destructuring assignments which occur inside a lazy arrow +// function parameter list were not rewritten. + +// Repro from the bug (slightly modified so that it doesn't produce a run-time +// exception). +(({x = {} = {}}) => {})({}); + +// ... and without the parens. +let a0 = ({x = {} = {}}) => {}; +a0({}); + +// Testing that the destructuring assignments also work properly. The semantics +// are: The value of the destructuring assignment is an object {myprop: 2115} +// and 2115 also gets assigned to global_side_assignment. So the default value +// for x is {myprop: 2115}. This is the value which x will have if the function +// is called with an object which doesn't have property x. +let called = false; +let global_side_assignment = undefined; +(({x = {myprop: global_side_assignment} = {myprop: 2115}}) => { + assertTrue('myprop' in x); + assertEquals(2115, x.myprop); + called = true; +})({}); +assertTrue(called); +assertEquals(2115, global_side_assignment); + +// If the parameter is an object which has property x, the default value is not +// used. +called = false; +global_side_assignment = undefined; +(({x = {myprop: global_side_assignment} = {myprop: 2115}}) => { + assertEquals(3000, x); + called = true; +})({x: 3000}); +assertTrue(called); +// Global side assignment doesn't happen, since the default value was not used. +assertEquals(undefined, global_side_assignment); + +// Different kinds of lazy arrow functions (it's actually a bit weird that the +// above functions are lazy, since they are parenthesized). +called = false; +global_side_assignment = undefined; +let a1 = ({x = {myprop: global_side_assignment} = {myprop: 2115}}) => { + assertTrue('myprop' in x); + assertEquals(2115, x.myprop); + called = true; +} +a1({}); +assertTrue(called); +assertEquals(2115, global_side_assignment); + +called = false; +global_side_assignment = undefined; +let a2 = ({x = {myprop: global_side_assignment} = {myprop: 2115}}) => { + assertEquals(3000, x); + called = true; +} +a2({x: 3000}); +assertTrue(called); +assertEquals(undefined, global_side_assignment); + +// We never had a problem with non-arrow functions, but testing them too for +// completeness. +called = false; +global_side_assignment = undefined; +function f1({x = {myprop: global_side_assignment} = {myprop: 2115}}) { + assertTrue('myprop' in x); + assertEquals(2115, x.myprop); + assertEquals(2115, global_side_assignment); + called = true; +} +f1({}); +assertTrue(called); +assertEquals(2115, global_side_assignment); + +called = false; +global_side_assignment = undefined; +function f2({x = {myprop: global_side_assignment} = {myprop: 2115}}) { + assertEquals(3000, x); + called = true; +} +f2({x: 3000}); +assertTrue(called); +assertEquals(undefined, global_side_assignment); diff --git a/deps/v8/test/mjsunit/regress/regress-706234-2.js b/deps/v8/test/mjsunit/regress/regress-706234-2.js new file mode 100644 index 0000000000..ed5facf7f4 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-706234-2.js @@ -0,0 +1,37 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Lazy top-level arrow function which must be re-parsed and eagerly compiled. +var f = ({ x } = { x: 1 }) => { + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; + x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; +}; + +f(); diff --git a/deps/v8/test/mjsunit/regress/regress-706234.js b/deps/v8/test/mjsunit/regress/regress-706234.js new file mode 100644 index 0000000000..aee31ae833 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-706234.js @@ -0,0 +1,8 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var fn = ({foo = {} = {}}) => { return foo; } +if (true) { + fn({}); +} diff --git a/deps/v8/test/mjsunit/regress/regress-708247.js b/deps/v8/test/mjsunit/regress/regress-708247.js new file mode 100644 index 0000000000..7512791cd9 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-708247.js @@ -0,0 +1,26 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --predictable + +const str = '2016-01-02'; + +function t() { + var re; + function toDictMode() { + for (var i = 0; i < 100; i++) { // Loop is required. + re.x = 42; + delete re.x; + } + return 0; + } + + re = /-/g; // Needs to be global to trigger lastIndex accesses. + re.lastIndex = { valueOf : toDictMode }; + return re.exec(str); +} + +for (var q = 0; q < 10000; q++) { + t(); // Needs repetitions to trigger a crash. +} diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-471702.js b/deps/v8/test/mjsunit/regress/regress-crbug-471702.js deleted file mode 100644 index dcd9f9bfe4..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-471702.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --allow-natives-syntax - -assertThrows(function() { JSON.stringify(%DebugGetLoadedScripts()); }); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-500497.js b/deps/v8/test/mjsunit/regress/regress-crbug-500497.js index 356e4e6942..4917193261 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-500497.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-500497.js @@ -4,7 +4,7 @@ // New space must be at max capacity to trigger pretenuring decision. // Flags: --allow-natives-syntax --verify-heap --max-semi-space-size=1 -// Flags: --expose-gc +// Flags: --expose-gc --no-always-opt var global = []; // Used to keep some objects alive. diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-505007-2.js b/deps/v8/test/mjsunit/regress/regress-crbug-505007-2.js deleted file mode 100644 index 96014c848d..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-505007-2.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --stack-size=100 --allow-natives-syntax - -function g() {} - -var count = 0; -function f() { - try { - f(); - } catch(e) { - if (count < 100) { - count++; - %ExecuteInDebugContext(g); - } - } -} -f(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-506443.js b/deps/v8/test/mjsunit/regress/regress-crbug-506443.js index 13cbac6769..0ab518f9b9 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-506443.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-506443.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt assertSame = function assertSame() { if (found === expected) { diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-514081.js b/deps/v8/test/mjsunit/regress/regress-crbug-514081.js index af31f4b9c6..ee3ed81300 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-514081.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-514081.js @@ -5,16 +5,14 @@ if (this.Worker) { var __v_7 = new Worker('onmessage = function() {};'); var e; + var ab = new ArrayBuffer(2 * 1000 * 1000); try { - var ab = new ArrayBuffer(2147483648); - try { - __v_7.postMessage(ab); - } catch (e) { - // postMessage failed, should be a DataCloneError message. - assertContains('cloned', e.message); - } + __v_7.postMessage(ab); + threw = false; } catch (e) { - // Creating the ArrayBuffer failed. - assertInstanceof(e, RangeError); + // postMessage failed, should be a DataCloneError message. + assertContains('cloned', e.message); + threw = true; } + assertTrue(threw, 'Should throw when trying to serialize large message.'); } diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-554831.js b/deps/v8/test/mjsunit/regress/regress-crbug-554831.js index f7343e08b9..da78fa4c07 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-554831.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-554831.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft (function() { var key = "s"; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-587068.js b/deps/v8/test/mjsunit/regress/regress-crbug-587068.js index 4cdd3ffbdb..4af8110497 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-587068.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-587068.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft // The Crankshaft fast case for String.fromCharCode used to unconditionally // deoptimize on non int32 indices. diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-594183.js b/deps/v8/test/mjsunit/regress/regress-crbug-594183.js index c87e325458..87f3195917 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-594183.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-594183.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt var global = {} @@ -79,4 +79,8 @@ assertOptimized(inferrable_store); // seeing a property name key. It should have inferred a receiver map and // emitted an elements store, however. inferrable_store("deopt"); -assertUnoptimized(inferrable_store); + +// TurboFan is not sophisticated enough to use key type provided by ICs. +if (!isTurboFanned(inferrable_store)) { + assertUnoptimized(inferrable_store); +} diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-681983.js b/deps/v8/test/mjsunit/regress/regress-crbug-681983.js new file mode 100644 index 0000000000..eab161c97c --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-681983.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function g(a) { + a = a >>> 0; + %_DeoptimizeNow(); + return a; +} + +function f() { + return g(-1); +} + +%OptimizeFunctionOnNextCall(f); +assertEquals(4294967295, f()); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-683581.js b/deps/v8/test/mjsunit/regress/regress-crbug-683581.js new file mode 100644 index 0000000000..6b6c54b4a8 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-683581.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var v = 0; +function foo() { + for (var i = 0; i < 70000; i++) { + v += i; + } + eval(); +} +foo() +assertEquals(2449965000, v); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-684208.js b/deps/v8/test/mjsunit/regress/regress-crbug-684208.js new file mode 100644 index 0000000000..7055a7eb82 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-684208.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function foo() { + var a = [1, 2.3, /*hole*/, 4.2]; + %_DeoptimizeNow(); + return a[2]; +} +assertSame(undefined, foo()); +assertSame(undefined, foo()); +%OptimizeFunctionOnNextCall(foo) +assertSame(undefined, foo()); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-685050.js b/deps/v8/test/mjsunit/regress/regress-crbug-685050.js new file mode 100644 index 0000000000..2560e2ee61 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-685050.js @@ -0,0 +1,19 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function bar(a) { + a[0] = 0; + a[1] = 0; +} + +var a = new Int32Array(2); +bar([1, 2, 3]); +function foo() { + bar([1, 2, 3]); + bar(a); +} +%OptimizeFunctionOnNextCall(foo); +foo(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-685504.js b/deps/v8/test/mjsunit/regress/regress-crbug-685504.js new file mode 100644 index 0000000000..83975bfd6d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-685504.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var v2 = 1073741823; +var v13 = {}; +function f1(a, b) { + var v4 = a + b; + var v1 = v4.substring(20); + v2[v4]; + return v1; +} + +v5 = f1("abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"); +function f8(name, input, regexp) { + var v14 = input.match(regexp); + RegExp["$'"]} +f8("CaptureGlobal", v5, v13, []["anama"]); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-685506.js b/deps/v8/test/mjsunit/regress/regress-crbug-685506.js new file mode 100644 index 0000000000..1be9c02bc0 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-685506.js @@ -0,0 +1,26 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --noconcurrent-recompilation + +var a = {}; + +function init() { + a = []; + for (var __v_1 = 0; __v_1 < 10016; __v_1++) { + a.push({}); + } + a.map(function() {}) + ""; +} +init(); + +function foo() { + a.push((a + "!", 23)); + return a; +} +assertEquals(23, foo()[10016]); +assertEquals(23, foo()[10017]); +assertEquals(23, foo()[10018]); +%OptimizeFunctionOnNextCall(foo); +assertEquals(23, foo()[10019]); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-685634.js b/deps/v8/test/mjsunit/regress/regress-crbug-685634.js new file mode 100644 index 0000000000..2e647ce970 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-685634.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --harmony-tailcalls + +"use strict"; + +function foo(f) { return f.apply(this, arguments); } +function bar() {} + +foo(bar); +%OptimizeFunctionOnNextCall(foo); +foo(bar); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-685680.js b/deps/v8/test/mjsunit/regress/regress-crbug-685680.js new file mode 100644 index 0000000000..3c23e414cb --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-685680.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function foo(s) { + s = s + '0123456789012'; + return s.indexOf('0'); +} + +assertEquals(0, foo('0')); +assertEquals(0, foo('0')); +%OptimizeFunctionOnNextCall(foo); +assertEquals(0, foo('0')); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-685965.js b/deps/v8/test/mjsunit/regress/regress-crbug-685965.js new file mode 100644 index 0000000000..1f2c6c8536 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-685965.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function __f_0(a) { + var __v_3 = a + undefined; + var __v_0 = __v_3.substring(0, 20); + var __v_1 = {}; + __v_1[__v_3]; + return __v_0; +} +__v_4 = __f_0( "abcdefghijklmnopqrstuvwxyz"); +assertEquals("bcdefg", __v_4.substring(7, 1)); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-686737.js b/deps/v8/test/mjsunit/regress/regress-crbug-686737.js new file mode 100644 index 0000000000..aab7113c6a --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-686737.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +Object.prototype.__defineGetter__(0, () => { throw Error() }); +var a = [,0.1]; +function foo(i) { a[i]; } +foo(1); +foo(1); +%OptimizeFunctionOnNextCall(foo); +assertThrows(() => foo(0), Error); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-687029.js b/deps/v8/test/mjsunit/regress/regress-crbug-687029.js new file mode 100644 index 0000000000..c3ca01fad1 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-687029.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function foo(x) { + x = Math.clz32(x); + return "a".indexOf("a", x); +} +foo(1); +foo(1); +%OptimizeFunctionOnNextCall(foo); +foo(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-687990.js b/deps/v8/test/mjsunit/regress/regress-crbug-687990.js new file mode 100644 index 0000000000..24100854c4 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-687990.js @@ -0,0 +1,16 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var x = 1; + +var foo = (function() { + "use asm"; + var o = this; + return function() { o.x = null; } +})(); + +%OptimizeFunctionOnNextCall(foo); +foo(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-694416.js b/deps/v8/test/mjsunit/regress/regress-crbug-694416.js new file mode 100644 index 0000000000..064b8fc9c2 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-694416.js @@ -0,0 +1,17 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --turbo + +var good = 23; +var boom = 42; + +function foo(name) { + return this[name]; +} + +assertEquals(23, foo('good')); +assertEquals(23, foo('good')); +%OptimizeFunctionOnNextCall(foo); +assertEquals(42, foo('boom')); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-694709.js b/deps/v8/test/mjsunit/regress/regress-crbug-694709.js new file mode 100644 index 0000000000..2b1bf073a8 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-694709.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --turbo + +function f(primitive) { + return primitive.__proto__; +} +assertEquals(Symbol.prototype, f(Symbol())); +assertEquals(Symbol.prototype, f(Symbol())); +%OptimizeFunctionOnNextCall(f); +assertEquals(Symbol.prototype, f(Symbol())); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-702058-1.js b/deps/v8/test/mjsunit/regress/regress-crbug-702058-1.js new file mode 100644 index 0000000000..6f0190660a --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-702058-1.js @@ -0,0 +1,10 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var arr = []; +for (var i = 0; i < 100000; i++) arr[i] = 0; +var fromIndex = {valueOf: function() { arr.length = 0; }}; +arr.indexOf(1, fromIndex); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-702058-2.js b/deps/v8/test/mjsunit/regress/regress-crbug-702058-2.js new file mode 100644 index 0000000000..a4bb18deef --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-702058-2.js @@ -0,0 +1,10 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var arr = []; +for (var i = 0; i < 100000; i++) arr[i] = 0.1; +var fromIndex = {valueOf: function() { arr.length = 0; }}; +arr.indexOf(1.1, fromIndex); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-702058-3.js b/deps/v8/test/mjsunit/regress/regress-crbug-702058-3.js new file mode 100644 index 0000000000..f78fdc001e --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-702058-3.js @@ -0,0 +1,10 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var arr = []; +for (var i = 0; i < 100000; i++) arr[i] = []; +var fromIndex = {valueOf: function() { arr.length = 0; }}; +arr.indexOf({}, fromIndex); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-706642.js b/deps/v8/test/mjsunit/regress/regress-crbug-706642.js new file mode 100644 index 0000000000..4467c68495 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-706642.js @@ -0,0 +1,37 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +class A extends Object { + constructor(arg) { + super(); + superclass_counter++; + if (superclass_counter === 3) { + return 1; + } + } +} + +class B extends A { + constructor() { + let x = super(123); + return x.a; + } +} + +var superclass_counter = 0; +var observer = new Proxy(A, { + get(target, property, receiver) { + if (property === 'prototype') { + %DeoptimizeFunction(B); + } + return Reflect.get(target, property, receiver); + } +}); + +Reflect.construct(B, [], observer); +Reflect.construct(B, [], observer); +%OptimizeFunctionOnNextCall(B); +assertThrows(() => Reflect.construct(B, [], observer), TypeError); diff --git a/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js b/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js index 57028b0cef..63fc7f7371 100644 --- a/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js +++ b/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js @@ -28,6 +28,7 @@ // Flags: --fold-constants --nodead-code-elimination // Flags: --expose-gc --allow-natives-syntax // Flags: --concurrent-recompilation --block-concurrent-recompilation +// Flags: --crankshaft --no-always-opt if (!%IsConcurrentRecompilationSupported()) { print("Concurrent recompilation is disabled. Skipping this test."); diff --git a/deps/v8/test/mjsunit/regress/regress-map-invalidation-2.js b/deps/v8/test/mjsunit/regress/regress-map-invalidation-2.js index 1f896a495f..f1d2b7703f 100644 --- a/deps/v8/test/mjsunit/regress/regress-map-invalidation-2.js +++ b/deps/v8/test/mjsunit/regress/regress-map-invalidation-2.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft var c = { x: 2, y: 1 }; @@ -40,7 +40,7 @@ function g() { else return c; } // Clear type feedback from previous stress runs. - %ClearFunctionTypeFeedback(f); + %ClearFunctionFeedback(f); return f; } diff --git a/deps/v8/test/mjsunit/regress/regress-param-local-type.js b/deps/v8/test/mjsunit/regress/regress-param-local-type.js index bf26090089..076a56dd25 100644 --- a/deps/v8/test/mjsunit/regress/regress-param-local-type.js +++ b/deps/v8/test/mjsunit/regress/regress-param-local-type.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft // Test that we do not confuse the first local and the first parameter // when gathering type information. diff --git a/deps/v8/test/mjsunit/regress/regress-store-uncacheable.js b/deps/v8/test/mjsunit/regress/regress-store-uncacheable.js index e9c9fc25b4..fdd200ae3a 100644 --- a/deps/v8/test/mjsunit/regress/regress-store-uncacheable.js +++ b/deps/v8/test/mjsunit/regress/regress-store-uncacheable.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function f() { var o = {}; diff --git a/deps/v8/test/mjsunit/regress/regress-v8-5697.js b/deps/v8/test/mjsunit/regress/regress-v8-5697.js index 5a88614b13..550bd98017 100644 --- a/deps/v8/test/mjsunit/regress/regress-v8-5697.js +++ b/deps/v8/test/mjsunit/regress/regress-v8-5697.js @@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft function load(o) { return o.x; } for (var x = 0; x < 1000; ++x) { load({x}); load({x}); + %OptimizeFunctionOnNextCall(load); try { load(); } catch (e) { } } @@ -20,6 +21,7 @@ function store(o) { o.x = -1; } for (var x = 0; x < 1000; ++x) { store({x}); store({x}); + %OptimizeFunctionOnNextCall(store); try { store(); } catch (e) { } } diff --git a/deps/v8/test/mjsunit/regress/regress-v8-5958.js b/deps/v8/test/mjsunit/regress/regress-v8-5958.js new file mode 100644 index 0000000000..dc5b95db52 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-v8-5958.js @@ -0,0 +1,16 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +class A {} +class B {} + +A.__proto__ = new Proxy(A.__proto__, { + get: function (target, property, receiver) { + if (property === Symbol.hasInstance) throw new B; + } +}); + +assertThrows(() => (new A) instanceof A, B); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-5860.js b/deps/v8/test/mjsunit/regress/wasm/regress-5860.js new file mode 100644 index 0000000000..b193323dd1 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-5860.js @@ -0,0 +1,30 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Flags: --expose-wasm + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +let module1 = (() => { + let builder = new WasmModuleBuilder(); + builder.addMemory(1, 1); + builder.addFunction('load', kSig_i_i) + .addBody([kExprI32Const, 0, kExprI32LoadMem, 0, 0]) + .exportAs('load'); + return new WebAssembly.Module(builder.toBuffer()); +})(); + +let module2 = (() => { + let builder = new WasmModuleBuilder(); + builder.addMemory(1, 1); + builder.addImport('A', 'load', kSig_i_i); + builder.addExportOfKind('load', kExternalFunction, 0); + return new WebAssembly.Module(builder.toBuffer()); +})(); + +let instance1 = new WebAssembly.Instance(module1); +let instance2 = new WebAssembly.Instance(module2, {A: instance1.exports}); + +assertEquals(0, instance2.exports.load()); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-02256.js b/deps/v8/test/mjsunit/regress/wasm/regression-02256.js index 27764a22ce..d0db4ca82a 100644 --- a/deps/v8/test/mjsunit/regress/wasm/regression-02256.js +++ b/deps/v8/test/mjsunit/regress/wasm/regression-02256.js @@ -4,6 +4,7 @@ // // Flags: --random-seed=891196975 --expose-gc --allow-natives-syntax // Flags: --gc-interval=207 --stress-compaction --validate-asm +// Flags: --crankshaft --no-always-opt // // /v8/test/mjsunit/wasm/grow-memory.js // /v8/test/mjsunit/regress/regress-540.js diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-02256b.js b/deps/v8/test/mjsunit/regress/wasm/regression-02256b.js index 032a02684b..6facf0d4e3 100644 --- a/deps/v8/test/mjsunit/regress/wasm/regression-02256b.js +++ b/deps/v8/test/mjsunit/regress/wasm/regression-02256b.js @@ -4,6 +4,7 @@ // // Flags: --random-seed=891196975 --expose-gc --allow-natives-syntax // Flags: --gc-interval=207 --stress-compaction --validate-asm +// Flags: --crankshaft --no-always-opt // // /v8/test/mjsunit/wasm/grow-memory.js // /v8/test/mjsunit/regress/regress-540.js diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-6054.js b/deps/v8/test/mjsunit/regress/wasm/regression-6054.js new file mode 100644 index 0000000000..7b309b6f82 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-6054.js @@ -0,0 +1,342 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +(function() { + var builder = new WasmModuleBuilder(); + builder.addMemory(16, 32, false); + builder.addFunction('test', kSig_i_i) + .addBodyWithEnd([ + kExprI32Const, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, + kExprI32LoadMem8S, 0x00, 0x00, +kExprEnd, // @44 + ]) + .exportFunc(); + var module = builder.instantiate(); + assertEquals(0, module.exports.test(1)); +})(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-688876.js b/deps/v8/test/mjsunit/regress/wasm/regression-688876.js new file mode 100644 index 0000000000..83bebbb802 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-688876.js @@ -0,0 +1,42 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +(function() { + var builder = new WasmModuleBuilder(); + builder.addMemory(16, 32, false); + builder.addFunction('test', kSig_i_i) + .addBodyWithEnd([ + kExprI32Const, 0x41, + kExprI32Const, 0x45, + kExprI32Const, 0x41, + kExprI32DivU, + kExprI32LoadMem8S, 0x00, 0x3a, + kExprI32Const, 0x75, + kExprI32Const, 0x75, + kExprI32Const, 0x6e, + kExprI32Eqz, + kExprI32LoadMem8S, 0x00, 0x3a, + kExprI32Add, + kExprI32DivU, + kExprI32LoadMem8S, 0x00, 0x74, + kExprI32And, + kExprI32Eqz, + kExprI32And, +kExprGrowMemory, 0x00, + kExprI32Const, 0x55, + kExprI32LoadMem8S, 0x00, 0x3a, + kExprI32LoadMem16U, 0x00, 0x71, + kExprI32Const, 0x00, + kExprI32RemU, + kExprI32And, +kExprI32Eqz, +kExprEnd, // @44 + ]) + .exportFunc(); + var module = builder.instantiate(); + assertThrows(() => {module.exports.test(1);}); +})(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-689450.js b/deps/v8/test/mjsunit/regress/wasm/regression-689450.js new file mode 100644 index 0000000000..9a4989c633 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-689450.js @@ -0,0 +1,25 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +(function() { + var builder = new WasmModuleBuilder(); + builder.addMemory(16, 32, false); + builder.addFunction('test', kSig_i_i) + .addBodyWithEnd([ + kExprGetLocal, 0x00, + kExprI32Const, 0x29, + kExprI32Shl, + kExprI32Const, 0x18, + kExprI32ShrS, + kExprI32Const, 0x18, + kExprI32Shl, + kExprEnd, + ]) + .exportFunc(); + var module = builder.instantiate(); + assertEquals(0, module.exports.test(16)); +})(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-694433.js b/deps/v8/test/mjsunit/regress/wasm/regression-694433.js new file mode 100644 index 0000000000..a260e20790 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-694433.js @@ -0,0 +1,6 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var size = 0x40000000; +assertThrows(() => WebAssembly.validate(new Uint16Array(size)), RangeError); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-698587.js b/deps/v8/test/mjsunit/regress/wasm/regression-698587.js new file mode 100644 index 0000000000..8e0be882b4 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-698587.js @@ -0,0 +1,10 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var heap = new ArrayBuffer(); +function asm(stdlib, ffi, heap) { + "use asm"; + return {}; +} +asm({}, {}, heap); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-699485.js b/deps/v8/test/mjsunit/regress/wasm/regression-699485.js new file mode 100644 index 0000000000..12477c5d37 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-699485.js @@ -0,0 +1,22 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +(function() { +"use asm"; +var builder = new WasmModuleBuilder(); +builder.addMemory(0, 5, false); +builder.addFunction("regression_699485", kSig_i_v) + .addBody([ + kExprI32Const, 0x04, + kExprNop, + kExprGrowMemory, 0x00, + ]).exportFunc(); +let module = builder.instantiate(); +assertEquals(0, module.exports.regression_699485()); +})(); diff --git a/deps/v8/test/mjsunit/setters-on-elements.js b/deps/v8/test/mjsunit/setters-on-elements.js index 001906c290..f90c510c22 100644 --- a/deps/v8/test/mjsunit/setters-on-elements.js +++ b/deps/v8/test/mjsunit/setters-on-elements.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --max-opt-count=100 --noalways-opt +// Flags: --crankshaft // We specify max-opt-count because we opt/deopt the same function many // times. @@ -63,7 +64,7 @@ if (standalone) { %OptimizeFunctionOnNextCall(name); } clearFunctionTypeFeedback = function(name) { - %ClearFunctionTypeFeedback(name); + %ClearFunctionFeedback(name); } deoptimizeFunction = function(name) { %DeoptimizeFunction(name); diff --git a/deps/v8/test/mjsunit/shared-function-tier-up-default.js b/deps/v8/test/mjsunit/shared-function-tier-up-default.js index 09c5f8e7fe..40af1a4464 100644 --- a/deps/v8/test/mjsunit/shared-function-tier-up-default.js +++ b/deps/v8/test/mjsunit/shared-function-tier-up-default.js @@ -2,7 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Flags: --mark-shared-functions-for-tier-up --allow-natives-syntax --no-ignition --no-ignition-staging --no-turbo +// Flags: --mark-shared-functions-for-tier-up --allow-natives-syntax +// Flags: --no-ignition --no-ignition-staging --no-turbo +// Flags: --crankshaft --no-always-opt + +// If we are always or never optimizing it is useless. +assertFalse(isAlwaysOptimize()); +assertFalse(isNeverOptimize()); (function() { var sum = 0; @@ -13,20 +19,15 @@ } sum += f(i); - if (%GetOptimizationStatus(f) == 3 || %GetOptimizationStatus(f) == 4) { - // If we are always or never optimizing f, just exit, this test is useless. - return; - } - if (i == 1) { // f must be baseline code. - assertEquals(2, %GetOptimizationStatus(f)); + assertTrue(isBaselined(f)); // Run twice (i = 0, 1), then tier-up. %OptimizeFunctionOnNextCall(f); } else if (i == 2) { // Tier-up at i = 2 should go up to crankshaft. - assertEquals(1, %GetOptimizationStatus(f)); + assertTrue(isCrankshafted(f)); } } })() diff --git a/deps/v8/test/mjsunit/shared-function-tier-up-ignition.js b/deps/v8/test/mjsunit/shared-function-tier-up-ignition.js deleted file mode 100644 index 607c2e1e04..0000000000 --- a/deps/v8/test/mjsunit/shared-function-tier-up-ignition.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// Flags: --mark-shared-functions-for-tier-up --allow-natives-syntax --ignition-staging --no-turbo - -(function() { - var sum = 0; - var i = 0; - for (var i = 0; i < 5; ++i) { - var f = function(x) { - return 2 * x; - } - sum += f(i); - - if (%GetOptimizationStatus(f) == 3 || %GetOptimizationStatus(f) == 4) { - // If we are always or never optimizing f, just exit, this test is useless. - return; - } - - if (i == 1) { - // f must be interpreted code. - assertEquals(8, %GetOptimizationStatus(f)); - - // Allow it to run twice (i = 0, 1), then tier-up to baseline. - %BaselineFunctionOnNextCall(f); - } else if (i == 2) { - // Tier-up at i = 2 should only go up to baseline. - assertEquals(2, %GetOptimizationStatus(f)); - } else if (i == 3) { - // Now f must be baseline code. - assertEquals(2, %GetOptimizationStatus(f)); - - // Run two more times (i = 2, 3), then tier-up to optimized. - %OptimizeFunctionOnNextCall(f); - } else if (i == 4) { - // Tier-up at i = 4 should now go up to crankshaft. - assertEquals(1, %GetOptimizationStatus(f)); - } - } -})() diff --git a/deps/v8/test/mjsunit/shared-function-tier-up-turbo.js b/deps/v8/test/mjsunit/shared-function-tier-up-turbo.js index aed30e8150..bf27bc77a2 100644 --- a/deps/v8/test/mjsunit/shared-function-tier-up-turbo.js +++ b/deps/v8/test/mjsunit/shared-function-tier-up-turbo.js @@ -2,7 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Flags: --mark-shared-functions-for-tier-up --allow-natives-syntax --ignition-staging --turbo +// Flags: --mark-shared-functions-for-tier-up --allow-natives-syntax +// Flags: --ignition-staging --turbo --no-always-opt + +// If we are always or never optimizing it is useless. +assertFalse(isAlwaysOptimize()); +assertFalse(isNeverOptimize()); (function() { var sum = 0; @@ -13,20 +18,15 @@ } sum += f(i); - if (%GetOptimizationStatus(f) == 3 || %GetOptimizationStatus(f) == 4) { - // If we are always or never optimizing f, just exit, this test is useless. - return; - } - if (i == 1) { // f must be interpreted code. - assertEquals(8, %GetOptimizationStatus(f)); + assertTrue(isInterpreted(f)); // Run twice (i = 0, 1), then tier-up. %OptimizeFunctionOnNextCall(f); } else if (i == 2) { // Tier-up at i = 2 should go up to turbofan. - assertEquals(7, %GetOptimizationStatus(f)); + assertTrue(isTurboFanned(f)); } } })() diff --git a/deps/v8/test/mjsunit/shift-for-integer-div.js b/deps/v8/test/mjsunit/shift-for-integer-div.js index 884202d313..7aadb4d237 100644 --- a/deps/v8/test/mjsunit/shift-for-integer-div.js +++ b/deps/v8/test/mjsunit/shift-for-integer-div.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt function divp4(x) { return x / 4; diff --git a/deps/v8/test/mjsunit/sin-cos.js b/deps/v8/test/mjsunit/sin-cos.js index fb6f858c7c..8c4b80e8c1 100644 --- a/deps/v8/test/mjsunit/sin-cos.js +++ b/deps/v8/test/mjsunit/sin-cos.js @@ -27,7 +27,7 @@ // Test Math.sin and Math.cos. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft assertEquals("-Infinity", String(1/Math.sin(-0))); assertEquals(1, Math.cos(-0)); diff --git a/deps/v8/test/mjsunit/smi-mul-const.js b/deps/v8/test/mjsunit/smi-mul-const.js index ca627fc27e..ef0685b7a9 100644 --- a/deps/v8/test/mjsunit/smi-mul-const.js +++ b/deps/v8/test/mjsunit/smi-mul-const.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --noalways-opt +// Flags: --allow-natives-syntax --crankshaft --noalways-opt function check(func, input, expected) { func(-1); diff --git a/deps/v8/test/mjsunit/smi-mul.js b/deps/v8/test/mjsunit/smi-mul.js index 6f23d5e3a0..236563590b 100644 --- a/deps/v8/test/mjsunit/smi-mul.js +++ b/deps/v8/test/mjsunit/smi-mul.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --noalways-opt +// Flags: --allow-natives-syntax --crankshaft --noalways-opt function mul(a, b) { return a * b; diff --git a/deps/v8/test/mjsunit/smi-representation.js b/deps/v8/test/mjsunit/smi-representation.js index 882b5b91f0..10545c7680 100644 --- a/deps/v8/test/mjsunit/smi-representation.js +++ b/deps/v8/test/mjsunit/smi-representation.js @@ -28,7 +28,11 @@ // Flags: --track-fields --track-double-fields --allow-natives-syntax function smi_field() { - return {"smi":0}; + // Assign twice to make the field non-constant. + // TODO(ishell): update test once constant field tracking is done. + var o = {smi: 1}; + o.smi = 0; + return o; } function check_smi_repr(o, d1, d2) { diff --git a/deps/v8/test/mjsunit/string-indexof-1.js b/deps/v8/test/mjsunit/string-indexof-1.js index e403ec4dad..d83c784fd1 100644 --- a/deps/v8/test/mjsunit/string-indexof-1.js +++ b/deps/v8/test/mjsunit/string-indexof-1.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + var s = "test test test"; assertEquals(0, s.indexOf("t")); @@ -205,3 +207,97 @@ for (var lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { assertEquals(2, "aba".indexOf("a", "2.00000")); assertEquals(-1, "aba".indexOf("a", "3.00000")); })(); + +(function optimize() { + function f() { + return 'abc'.indexOf('a'); + } + assertEquals(0, f()); + assertEquals(0, f()); + assertEquals(0, f()); + % OptimizeFunctionOnNextCall(f); + assertEquals(0, f()); + + function f2() { + return 'abc'.indexOf('a', 1); + } + assertEquals(-1, f2()); + assertEquals(-1, f2()); + assertEquals(-1, f2()); + % OptimizeFunctionOnNextCall(f2); + assertEquals(-1, f2()); + + function f3() { + return 'abc'.indexOf('a'); + } + assertEquals(0, f3()); + assertEquals(0, f3()); + assertEquals(0, f3()); + % OptimizeFunctionOnNextCall(f3); + assertEquals(0, f3()); + + function f4() { + return 'abcbc'.indexOf('bc', 2); + } + assertEquals(3, f4()); + assertEquals(3, f4()); + assertEquals(3, f4()); + % OptimizeFunctionOnNextCall(f4); + assertEquals(3, f4()); + + function f5() { + return 'abcbc'.indexOf('b', -1); + } + assertEquals(1, f5()); + assertEquals(1, f5()); + assertEquals(1, f5()); + % OptimizeFunctionOnNextCall(f5); + assertEquals(1, f5()); + + function f6() { + return 'abcbc'.indexOf('b', -10737418); + } + assertEquals(1, f6()); + assertEquals(1, f6()); + assertEquals(1, f6()); + % OptimizeFunctionOnNextCall(f6); + assertEquals(1, f6()); +})(); + +(function optimizeOSR() { + function f() { + var result; + for (var i = 0; i < 100000; i++) { + result = 'abc'.indexOf('a'); + } + return result; + } + assertEquals(0, f()); + + function f2() { + var result; + for (var i = 0; i < 100000; i++) { + result = 'abc'.indexOf('a', 1); + } + return result; + } + assertEquals(-1, f2()); + + function f3() { + var result; + for (var i = 0; i < 100000; i++) { + result = 'abc'.indexOf('a'); + } + return result; + } + assertEquals(0, f3()); + + function f4() { + var result; + for (var i = 0; i < 100000; i++) { + result = 'abcbc'.indexOf('bc', 2); + } + return result; + } + assertEquals(3, f4()); +})(); diff --git a/deps/v8/test/mjsunit/string-replace.js b/deps/v8/test/mjsunit/string-replace.js index e8392ae2bf..b391b8c2f5 100644 --- a/deps/v8/test/mjsunit/string-replace.js +++ b/deps/v8/test/mjsunit/string-replace.js @@ -283,3 +283,16 @@ function testIndices59(re) { testIndices59(new RegExp(regexp59pattern)); testIndices59(new RegExp(regexp59pattern, "g")); + +// Test that ToString(replace) is called. + +let replace_tostring_count = 0; +const fake_replacer = { + [Symbol.toPrimitive]: () => { replace_tostring_count++; return "b"; } +}; + +"a".replace("x", fake_replacer); +assertEquals(1, replace_tostring_count); + +"a".replace("a", fake_replacer); +assertEquals(2, replace_tostring_count); diff --git a/deps/v8/test/mjsunit/strong-rooted-literals.js b/deps/v8/test/mjsunit/strong-rooted-literals.js new file mode 100644 index 0000000000..005a03934e --- /dev/null +++ b/deps/v8/test/mjsunit/strong-rooted-literals.js @@ -0,0 +1,55 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-gc --turbo + +// Make sure literals are strongly rooted and safe from weak-code deopts. + +(function() { + function foo() { + var a = {y: 0}; + a.y = 1; + return a; + } + + foo(); + foo(); + % OptimizeFunctionOnNextCall(foo); + foo(); + gc(); + assertOptimized(foo); +})(); + +(function() { + function hot(o) { + return o.x + o.y; + } + function mapPlus(a, y) { + return a.map(x => hot({x, y})); + } + + var a = [1, 2, 3]; + print(mapPlus(a, 1)); + print(mapPlus(a, 2)); + % OptimizeFunctionOnNextCall(hot); + print(mapPlus(a, 3)); + gc(); // BOOOM! + assertOptimized(hot); + print(mapPlus(a, 4)); +})(); + +// Verify that we can handle the creation of a new script, where the +// code is cached and the feedback vector has to be re-created. +(function() { + var sopen = 'function wrapper() { '; + var s1 = 'function foo() { return bar(5); } '; + var s2 = 'foo(); foo(); %OptimizeFunctionOnNextCall(foo); foo(); '; + var sclose = '} wrapper(); '; + var s = sopen + s1 + s2 + sclose; + function bar(i){return i + 3}; + + for (var i = 0; i < 4; i++) { + eval(s); + } +})(); diff --git a/deps/v8/test/mjsunit/thin-strings.js b/deps/v8/test/mjsunit/thin-strings.js new file mode 100644 index 0000000000..c86764259a --- /dev/null +++ b/deps/v8/test/mjsunit/thin-strings.js @@ -0,0 +1,90 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function get_thin_string(a, b) { + var str = a + b; // Make a ConsString. + var o = {}; + o[str]; // Turn it into a ThinString. + return str; +} + +var str = get_thin_string("foo", "bar"); + +var re = /.o+ba./; +assertEquals(["foobar"], re.exec(str)); +assertEquals(["foobar"], re.exec(str)); +assertEquals(["foobar"], re.exec(str)); + +function CheckCS() { + assertEquals("o", str.substring(1, 2)); + assertEquals("f".charCodeAt(0), str.charCodeAt(0)); + assertEquals("f", str.split(/oo/)[0]); +} +CheckCS(); +%OptimizeFunctionOnNextCall(CheckCS); +CheckCS(); + +function CheckTF() { + try {} catch(e) {} // Turbofan. + assertEquals("o", str.substring(1, 2)); + assertEquals("f".charCodeAt(0), str.charCodeAt(0)); + assertEquals("f", str.split(/oo/)[0]); +} +CheckTF(); +%OptimizeFunctionOnNextCall(CheckTF); +CheckTF(); + +// Flat cons strings can point to a thin string. + +function get_cons_thin_string(a, b) { + // Make a ConsString. + var s = a + b; + // Flatten it. + s.endsWith("a"); + // Internalize the first part. + var o = {}; + o[s]; + return s; +} + +var s = get_cons_thin_string("__________", "@@@@@@@@@@a"); +s.match(/.*a/); +assertEquals("________", s.substring(0, 8)); + +function cc1(s) { + assertEquals(95, s.charCodeAt(0)); + assertEquals(95, s.codePointAt(0)); +} +cc1(s); +cc1(s); +%OptimizeFunctionOnNextCall(cc1); +cc1(s); + +// Sliced strings can have a thin string as their parent. + +function get_sliced_thin_string(a, b) { + // Make a long thin string. + var s = a + b; + // Slice a substring out of it. + var slice = s.substring(0, 20); + // Make the original string thin. + var o = {}; + o[s]; + return slice; +} + +var t = get_sliced_thin_string("abcdefghijklmnopqrstuvwxyz", + "abcdefghijklmnopqrstuvwxyz"); +assertEquals("abcdefghijklmnopqrst", decodeURI(t)); + +function cc2(s) { + assertEquals(97, s.charCodeAt(0)); + assertEquals(97, s.codePointAt(0)); +} +cc2(t); +cc2(t); +%OptimizeFunctionOnNextCall(cc2); +cc2(t); diff --git a/deps/v8/test/mjsunit/tools/tickprocessor-test.func-info b/deps/v8/test/mjsunit/tools/tickprocessor-test.func-info index 1f34cfb72d..6d4628487d 100644 --- a/deps/v8/test/mjsunit/tools/tickprocessor-test.func-info +++ b/deps/v8/test/mjsunit/tools/tickprocessor-test.func-info @@ -5,8 +5,7 @@ Statistical profiling result from v8.log, (3 ticks, 0 unaccounted, 0 excluded). [JavaScript]: ticks total nonlib name - 2 66.7% 66.7% Stub: CompareStub_GE - 1 33.3% 33.3% LazyCompile: DrawLine 3d-cube.js:17 + 3 100.0% 100.0% LazyCompile: DrawLine 3d-cube.js:17 [C++]: ticks total nonlib name @@ -27,9 +26,6 @@ Statistical profiling result from v8.log, (3 ticks, 0 unaccounted, 0 excluded). Callers occupying less than 2.0% are not shown. ticks parent name - 2 66.7% Stub: CompareStub_GE - 2 100.0% LazyCompile: DrawLine 3d-cube.js:17 - 2 100.0% LazyCompile: DrawQube 3d-cube.js:188 + 3 100.0% LazyCompile: DrawLine 3d-cube.js:17 + 3 100.0% LazyCompile: DrawQube 3d-cube.js:188 - 1 33.3% LazyCompile: DrawLine 3d-cube.js:17 - 1 100.0% LazyCompile: DrawQube 3d-cube.js:188 diff --git a/deps/v8/test/mjsunit/track-fields.js b/deps/v8/test/mjsunit/track-fields.js index 4da1ab5d22..7804fffec0 100644 --- a/deps/v8/test/mjsunit/track-fields.js +++ b/deps/v8/test/mjsunit/track-fields.js @@ -263,6 +263,9 @@ assertEquals(100, o20.dbl); function attr_mismatch_obj(v, writable) { var o = {}; + // Assign twice to make the field non-constant. + // TODO(ishell): update test once constant field tracking is done. + o.some_value = 0; o.some_value = v; Object.defineProperty(o, "second_value", {value:10, writable:writable}); return o; diff --git a/deps/v8/test/mjsunit/typed-array-slice.js b/deps/v8/test/mjsunit/typed-array-slice.js index c6e7e9415a..b7debce8d9 100644 --- a/deps/v8/test/mjsunit/typed-array-slice.js +++ b/deps/v8/test/mjsunit/typed-array-slice.js @@ -53,7 +53,7 @@ for (var t = 0; t < types.length; t++) { delete a[5]; var sliced = do_slice(a); - %ClearFunctionTypeFeedback(do_slice); + %ClearFunctionFeedback(do_slice); assertEquals(results1[t], sliced[0]); assertEquals(results2[t], sliced[1]); assertEquals(results3[t], sliced[2]); diff --git a/deps/v8/test/mjsunit/unary-minus-deopt.js b/deps/v8/test/mjsunit/unary-minus-deopt.js index 367ef75c83..cc3bede4d2 100644 --- a/deps/v8/test/mjsunit/unary-minus-deopt.js +++ b/deps/v8/test/mjsunit/unary-minus-deopt.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --crankshaft --no-always-opt // This is a boiled-down example happening in the Epic Citadel demo: // After deopting, the multiplication for unary minus stayed in Smi diff --git a/deps/v8/test/mjsunit/unbox-double-arrays.js b/deps/v8/test/mjsunit/unbox-double-arrays.js index 8711ffdf3d..ef29bafebe 100644 --- a/deps/v8/test/mjsunit/unbox-double-arrays.js +++ b/deps/v8/test/mjsunit/unbox-double-arrays.js @@ -279,8 +279,8 @@ function testOneArrayType(allocator) { expected_array_value(7)); %DeoptimizeFunction(test_various_loads6); - %ClearFunctionTypeFeedback(test_various_stores); - %ClearFunctionTypeFeedback(test_various_loads7); + %ClearFunctionFeedback(test_various_stores); + %ClearFunctionFeedback(test_various_loads7); // Test stores for non-NaN. var large_array = new allocator(large_array_size); diff --git a/deps/v8/test/mjsunit/wasm/asm-wasm.js b/deps/v8/test/mjsunit/wasm/asm-wasm.js index 126c66d97c..6becaad6b7 100644 --- a/deps/v8/test/mjsunit/wasm/asm-wasm.js +++ b/deps/v8/test/mjsunit/wasm/asm-wasm.js @@ -410,6 +410,22 @@ function TestContinueInNamedWhile() { assertWasm(20, TestContinueInNamedWhile); +function TestContinueInDoWhileFalse() { + "use asm"; + + function caller() { + do { + continue; + } while (false); + return 47; + } + + return {caller: caller}; +} + +assertWasm(47, TestContinueInDoWhileFalse); + + function TestNot() { "use asm"; diff --git a/deps/v8/test/mjsunit/wasm/float-constant-folding.js b/deps/v8/test/mjsunit/wasm/float-constant-folding.js index 30757c403d..b08aee3d0e 100644 --- a/deps/v8/test/mjsunit/wasm/float-constant-folding.js +++ b/deps/v8/test/mjsunit/wasm/float-constant-folding.js @@ -10,15 +10,22 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F32: sNaN - 0 = qNaN"); var builder = new WasmModuleBuilder(); - builder.addFunction("F32Sub0", kSig_i_i) - .addBody([ - kExprGetLocal, 0, - kExprF32ReinterpretI32, - kExprF32Const, 0x00, 0x00, 0x00, 0x00, // 0.0 - kExprF32Sub, - kExprI32ReinterpretF32, - ]) - .exportFunc(); + builder.addFunction("F32Sub0", kSig_i_i).addBody( + [ kExprGetLocal, 0, kExprF32ReinterpretI32, kExprF32Const, 0x00, 0x00, + 0x00, 0x00, // 0.0 + kExprF32Sub, kExprI32ReinterpretF32, ]).exportFunc(); + var module = builder.instantiate(); + // F32Sub0(signalling_NaN) + assertEquals(0x7fe00000, module.exports.F32Sub0(0x7fa00000)); +})(); + +(function() { + print("F32: -0 sNaN = qNaN"); + var builder = new WasmModuleBuilder(); + builder.addFunction("F32Sub0", kSig_i_i).addBody( + [ kExprF32Const, 0x00, 0x00, 0x00, 0x80, // 0.0 + kExprGetLocal, 0, kExprF32ReinterpretI32, kExprF32Sub, + kExprI32ReinterpretF32, ]).exportFunc(); var module = builder.instantiate(); // F32Sub0(signalling_NaN) assertEquals(0x7fe00000, module.exports.F32Sub0(0x7fa00000)); @@ -27,14 +34,9 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F32: sNaN - X = qNaN"); var builder = new WasmModuleBuilder(); - builder.addFunction("F32NaNSubX", kSig_i_i) - .addBody([ - kExprF32Const, 0x00, 0x00, 0xa0, 0x7f, - kExprF32Const, 0x12, 0x34, 0x56, 0x78, - kExprF32Sub, - kExprI32ReinterpretF32, - ]) - .exportFunc(); + builder.addFunction("F32NaNSubX", kSig_i_i).addBody( + [ kExprF32Const, 0x00, 0x00, 0xa0, 0x7f, kExprF32Const, 0x12, 0x34, 0x56, + 0x78, kExprF32Sub, kExprI32ReinterpretF32, ]).exportFunc(); var module = builder.instantiate(); assertEquals(0x7fe00000, module.exports.F32NaNSubX()); })(); @@ -42,14 +44,9 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F32: X - sNaN = qNaN"); var builder = new WasmModuleBuilder(); - builder.addFunction("F32XSubNaN", kSig_i_i) - .addBody([ - kExprF32Const, 0x12, 0x34, 0x56, 0x78, - kExprF32Const, 0x00, 0x00, 0xa0, 0x7f, - kExprF32Sub, - kExprI32ReinterpretF32, - ]) - .exportFunc(); + builder.addFunction("F32XSubNaN", kSig_i_i).addBody( + [ kExprF32Const, 0x12, 0x34, 0x56, 0x78, kExprF32Const, 0x00, 0x00, 0xa0, + 0x7f, kExprF32Sub, kExprI32ReinterpretF32, ]).exportFunc(); var module = builder.instantiate(); assertEquals(0x7fe00000, module.exports.F32XSubNaN()); })(); @@ -57,17 +54,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F64: X + sNaN = qNaN"); var builder = new WasmModuleBuilder(); - builder.addFunction("F32XAddNaN", kSig_i_i) - .addBody([ - kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, - kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, - kExprF64Add, - kExprI64ReinterpretF64, - kExprI64Const, 32, - kExprI64ShrU, - kExprI32ConvertI64, - ]) - .exportFunc(); + builder.addFunction("F32XAddNaN", kSig_i_i).addBody( + [ kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, + kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, + kExprF64Add, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU, + kExprI32ConvertI64, ]).exportFunc(); var module = builder.instantiate(); assertEquals(0x7ffa0000, module.exports.F32XAddNaN()); })(); @@ -75,18 +66,24 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F64: sNaN - 0 = qNaN"); var builder = new WasmModuleBuilder(); - builder.addFunction("F64Sub0", kSig_i_i) - .addBody([ - kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00, - kExprF64ReinterpretI64, - kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0.0 - kExprF64Sub, - kExprI64ReinterpretF64, - kExprI64Const, 32, - kExprI64ShrU, - kExprI32ConvertI64, - ]) - .exportFunc(); + builder.addFunction("F64Sub0", kSig_i_i).addBody( + [ kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, + 0x00, kExprF64ReinterpretI64, kExprF64Const, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, // 0.0 + kExprF64Sub, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU, + kExprI32ConvertI64, ]).exportFunc(); + var module = builder.instantiate(); + assertEquals(0x7ffa0000, module.exports.F64Sub0()); +})(); + +(function() { + print("F64: -0 - sNaN = qNaN"); + var builder = new WasmModuleBuilder(); + builder.addFunction("F64Sub0", kSig_i_i).addBody( + [ kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, // 0.0 + kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, + 0x00, kExprF64ReinterpretI64, kExprF64Sub, kExprI64ReinterpretF64, + kExprI64Const, 32, kExprI64ShrU, kExprI32ConvertI64, ]).exportFunc(); var module = builder.instantiate(); assertEquals(0x7ffa0000, module.exports.F64Sub0()); })(); @@ -94,17 +91,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F64: sNaN - X = qNaN"); var builder = new WasmModuleBuilder(); - builder.addFunction("F64NaNSubX", kSig_i_i) - .addBody([ - kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, - kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, - kExprF64Sub, - kExprI64ReinterpretF64, - kExprI64Const, 32, - kExprI64ShrU, - kExprI32ConvertI64, - ]) - .exportFunc(); + builder.addFunction("F64NaNSubX", kSig_i_i).addBody( + [ kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, + kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, + kExprF64Sub, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU, + kExprI32ConvertI64, ]).exportFunc(); var module = builder.instantiate(); assertEquals(0x7ffa0000, module.exports.F64NaNSubX()); })(); @@ -112,17 +103,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F64: X - sNaN = qNaN"); var builder = new WasmModuleBuilder(); - builder.addFunction("F64XSubNaN", kSig_i_i) - .addBody([ - kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, - kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, - kExprF64Sub, - kExprI64ReinterpretF64, - kExprI64Const, 32, - kExprI64ShrU, - kExprI32ConvertI64, - ]) - .exportFunc(); + builder.addFunction("F64XSubNaN", kSig_i_i).addBody( + [ kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, + kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, + kExprF64Sub, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU, + kExprI32ConvertI64, ]).exportFunc(); var module = builder.instantiate(); assertEquals(0x7ffa0000, module.exports.F64XSubNaN()); })(); @@ -130,18 +115,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F64: sNaN * 1 = qNaN"); var builder = new WasmModuleBuilder(); - builder.addFunction("F64Mul1", kSig_i_i) - .addBody([ - kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00, - kExprF64ReinterpretI64, - kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, - kExprF64Mul, - kExprI64ReinterpretF64, - kExprI64Const, 32, - kExprI64ShrU, - kExprI32ConvertI64, - ]) - .exportFunc(); + builder.addFunction("F64Mul1", kSig_i_i).addBody( + [ kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, + 0x00, kExprF64ReinterpretI64, kExprF64Const, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf0, 0x3f, kExprF64Mul, kExprI64ReinterpretF64, + kExprI64Const, 32, kExprI64ShrU, kExprI32ConvertI64, ]).exportFunc(); var module = builder.instantiate(); assertEquals(0x7ffa0000, module.exports.F64Mul1()); })(); @@ -149,17 +127,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F64: X * sNaN = qNaN"); var builder = new WasmModuleBuilder(); - builder.addFunction("F64XMulNaN", kSig_i_i) - .addBody([ - kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, - kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, - kExprF64Mul, - kExprI64ReinterpretF64, - kExprI64Const, 32, - kExprI64ShrU, - kExprI32ConvertI64, - ]) - .exportFunc(); + builder.addFunction("F64XMulNaN", kSig_i_i).addBody( + [ kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, + kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, + kExprF64Mul, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU, + kExprI32ConvertI64, ]).exportFunc(); var module = builder.instantiate(); assertEquals(0x7ffa0000, module.exports.F64XMulNaN()); })(); @@ -167,11 +139,35 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F64: sNaN / 1 = qNaN"); var builder = new WasmModuleBuilder(); + builder.addFunction("F64Div1", kSig_i_i).addBody( + [ kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, + 0x00, kExprF64ReinterpretI64, kExprF64Const, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf0, 0x3f, kExprF64Div, kExprI64ReinterpretF64, + kExprI64Const, 32, kExprI64ShrU, kExprI32ConvertI64, ]).exportFunc(); + var module = builder.instantiate(); + assertEquals(0x7ffa0000, module.exports.F64Div1()); +})(); + +(function() { + print("F64: sNaN / -1 = qNaN"); + var builder = new WasmModuleBuilder(); + builder.addFunction("F64Div1", kSig_i_i).addBody( + [ kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, + 0x00, kExprF64ReinterpretI64, kExprF64Const, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf0, 0xbf, kExprF64Div, kExprI64ReinterpretF64, + kExprI64Const, 32, kExprI64ShrU, kExprI32ConvertI64, ]).exportFunc(); + var module = builder.instantiate(); + assertEquals(0x7ffa0000, module.exports.F64Div1()); +})(); + +(function() { + print("F64: sNaN / -1 = qNaN"); + var builder = new WasmModuleBuilder(); builder.addFunction("F64Div1", kSig_i_i) .addBody([ kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00, kExprF64ReinterpretI64, - kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, + kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xbf, kExprF64Div, kExprI64ReinterpretF64, kExprI64Const, 32, @@ -186,17 +182,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F64: X / sNaN = qNaN"); var builder = new WasmModuleBuilder(); - builder.addFunction("F64XDivNaN", kSig_i_i) - .addBody([ - kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, - kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, - kExprF64Div, - kExprI64ReinterpretF64, - kExprI64Const, 32, - kExprI64ShrU, - kExprI32ConvertI64, - ]) - .exportFunc(); + builder.addFunction("F64XDivNaN", kSig_i_i).addBody( + [ kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, + kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, + kExprF64Div, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU, + kExprI32ConvertI64, ]).exportFunc(); var module = builder.instantiate(); assertEquals(0x7ffa0000, module.exports.F64XDivNaN()); })(); @@ -204,17 +194,44 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { print("F64: sNaN / X = qNaN"); var builder = new WasmModuleBuilder(); - builder.addFunction("F64NaNDivX", kSig_i_i) - .addBody([ - kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, - kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, - kExprF64Div, - kExprI64ReinterpretF64, - kExprI64Const, 32, - kExprI64ShrU, - kExprI32ConvertI64, - ]) - .exportFunc(); + builder.addFunction("F64NaNDivX", kSig_i_i).addBody( + [ kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, + kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, + kExprF64Div, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU, + kExprI32ConvertI64, ]).exportFunc(); var module = builder.instantiate(); assertEquals(0x7ffa0000, module.exports.F64NaNDivX()); })(); + +(function() { + print("F32ConvertF64(sNaN) = qNaN"); + var builder = new WasmModuleBuilder(); + builder.addFunction("F32ConvertF64X", kSig_i_i).addBody( + [ kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, + kExprF32ConvertF64, kExprI32ReinterpretF32, ]).exportFunc(); + var module = builder.instantiate(); + assertEquals(0x7fd00000, module.exports.F32ConvertF64X()); +})(); + +(function() { + print("F64ConvertF32(sNaN) = qNaN"); + var builder = new WasmModuleBuilder(); + builder.addFunction("F64ConvertF32X", kSig_i_i).addBody( + [ kExprF32Const, 0x00, 0x00, 0xa0, 0x7f, kExprF64ConvertF32, + kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU, + kExprI32ConvertI64, ]).exportFunc(); + var module = builder.instantiate(); + assertEquals(0x7ffc0000, module.exports.F64ConvertF32X()); +})(); + +(function() { + print("F64ConvertF32(F32ConvertF64(sNaN)) = qNaN"); + var builder = new WasmModuleBuilder(); + builder.addFunction("F64toF32toF64", kSig_i_i).addBody( + [ kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, + 0x00, kExprF64ReinterpretI64, kExprF32ConvertF64, kExprF64ConvertF32, + kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU, + kExprI32ConvertI64, ]).exportFunc(); + var module = builder.instantiate(); + assertEquals(0x7ffa0000, module.exports.F64toF32toF64()); +})(); diff --git a/deps/v8/test/mjsunit/wasm/import-memory.js b/deps/v8/test/mjsunit/wasm/import-memory.js index 96317b7f64..178febdff4 100644 --- a/deps/v8/test/mjsunit/wasm/import-memory.js +++ b/deps/v8/test/mjsunit/wasm/import-memory.js @@ -397,3 +397,17 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); // no maximum assertThrows(() => builder.instantiate({m: {m: new WebAssembly.Memory({initial: 1})}})); })(); + +(function TestMemoryGrowDetachBuffer() { + print("TestMemoryGrowDetachBuffer"); + let memory = new WebAssembly.Memory({initial: 1, maximum: 5}); + var builder = new WasmModuleBuilder(); + builder.addImportedMemory("m", "imported_mem"); + let instance = builder.instantiate({m: {imported_mem: memory}}); + let buffer = memory.buffer; + assertEquals(kPageSize, buffer.byteLength); + assertEquals(1, memory.grow(2)); + assertTrue(buffer !== memory.buffer); + assertEquals(0, buffer.byteLength); + assertEquals(3*kPageSize, memory.buffer.byteLength); +})(); diff --git a/deps/v8/test/mjsunit/wasm/js-api.js b/deps/v8/test/mjsunit/wasm/js-api.js index e08822aced..c2ec4d48af 100644 --- a/deps/v8/test/mjsunit/wasm/js-api.js +++ b/deps/v8/test/mjsunit/wasm/js-api.js @@ -292,19 +292,10 @@ assertErrorMessage( let customSectionModuleBinary2 = (() => { let builder = new WasmModuleBuilder(); - builder.addExplicitSection([kUnknownSectionCode, 3, 1, 'x'.charCodeAt(0), 2]); - builder.addExplicitSection([ - kUnknownSectionCode, 6, 3, 'f'.charCodeAt(0), 'o'.charCodeAt(0), - 'o'.charCodeAt(0), 66, 77 - ]); - builder.addExplicitSection([ - kUnknownSectionCode, 7, 3, 'f'.charCodeAt(0), 'o'.charCodeAt(0), - 'o'.charCodeAt(0), 91, 92, 93 - ]); - builder.addExplicitSection([ - kUnknownSectionCode, 7, 3, 'f'.charCodeAt(0), 'o'.charCodeAt(0), - 'x'.charCodeAt(0), 99, 99, 99 - ]); + builder.addCustomSection('x', [2]); + builder.addCustomSection('foo', [66, 77]); + builder.addCustomSection('foo', [91, 92, 93]); + builder.addCustomSection('fox', [99, 99, 99]); return new Int8Array(builder.toBuffer()); })(); var arr = moduleCustomSections(new Module(customSectionModuleBinary2), 'x'); @@ -371,6 +362,12 @@ assertTrue(instanceExportsDesc.writable); assertTrue(instanceExportsDesc.enumerable); assertTrue(instanceExportsDesc.configurable); +exportsObj = exportingInstance.exports; +assertEq(typeof exportsObj, 'object'); +assertFalse(Object.isExtensible(exportsObj)); +assertEq(Object.getPrototypeOf(exportsObj), null); +assertEq(Object.keys(exportsObj).join(), 'f'); + // Exported WebAssembly functions let f = exportingInstance.exports.f; assertTrue(f instanceof Function); @@ -457,14 +454,13 @@ var mem = new Memory({initial:1, maximum:2}); var buf = mem.buffer; assertEq(buf.byteLength, kPageSize); assertEq(mem.grow(0), 1); -// TODO(gdeepti): Pending spec clarification -// assertTrue(buf !== mem.buffer); -// assertEq(buf.byteLength, 0); +assertTrue(buf !== mem.buffer); +assertEq(buf.byteLength, 0); buf = mem.buffer; assertEq(buf.byteLength, kPageSize); assertEq(mem.grow(1), 1); -// TODO(gdeepti): assertTrue(buf !== mem.buffer); -// TODO(gdeepti): assertEq(buf.byteLength, 0); +assertTrue(buf !== mem.buffer); +assertEq(buf.byteLength, 0); buf = mem.buffer; assertEq(buf.byteLength, 2 * kPageSize); assertErrorMessage(() => mem.grow(1), Error, /failed to grow memory/); @@ -622,8 +618,8 @@ function assertCompileError(args, err, msg) { compile(...args).catch(e => error = e); drainJobQueue(); assertTrue(error instanceof err); - assertTrue(Boolean(error.stack.match("js-api.js"))); -//TODO assertEq(Boolean(error.message.match(msg)), true); + assertTrue(Boolean(error.stack.match('js-api.js'))); + // TODO assertTrue(Boolean(error.message.match(msg))); } assertCompileError([], TypeError, /requires more than 0 arguments/); assertCompileError([undefined], TypeError, /first argument must be an ArrayBuffer or typed array object/); diff --git a/deps/v8/test/mjsunit/wasm/jsapi-harness.js b/deps/v8/test/mjsunit/wasm/jsapi-harness.js new file mode 100644 index 0000000000..0c3b91b265 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/jsapi-harness.js @@ -0,0 +1,83 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// TODO(titzer): update spec test suite to version 0x1 +if (false) { + +// TODO(eholk): Once we have stable test IDs, use those as the key instead. +// See https://github.com/WebAssembly/spec/issues/415 +const known_failures = { + "'WebAssembly.Module.customSections' method": + 'https://bugs.chromium.org/p/v8/issues/detail?id=5815', + "'WebAssembly.Table.prototype.get' method": + 'https://bugs.chromium.org/p/v8/issues/detail?id=5507', + "'WebAssembly.Table.prototype.set' method": + 'https://bugs.chromium.org/p/v8/issues/detail?id=5507', +}; + +let failures = []; + +let last_promise = new Promise((resolve, reject) => { resolve(); }); + +function test(func, description) { + let maybeErr; + try { func(); } + catch(e) { maybeErr = e; } + if (typeof maybeErr !== 'undefined') { + print(`${description}: FAIL. ${maybeErr}`); + failures.push(description); + } else { + print(`${description}: PASS.`); + } +} + +function promise_test(func, description) { + last_promise = last_promise.then(func) + .then(_ => { print(`${description}: PASS.`); }) + .catch(err => { + print(`${description}: FAIL. ${err}`); + failures.push(description); + }); +} + +let assert_equals = assertEquals; +let assert_true = assertEquals.bind(null, true); +let assert_false = assertEquals.bind(null, false); + +function assert_unreached(description) { + throw new Error(`unreachable:\n${description}`); +} + +function assertErrorMessage(f, ctor, test) { + try { f(); } + catch (e) { + assert_true(e instanceof ctor, "expected exception " + ctor.name + ", got " + e); + return; + } + assert_true(false, "expected exception " + ctor.name + ", no exception thrown"); +}; + +load("test/wasm-js/test/harness/wasm-constants.js"); +load("test/wasm-js/test/harness/wasm-module-builder.js"); +load("test/wasm-js/test/js-api/jsapi.js"); + +last_promise.then(_ => { + if (failures.length > 0) { + let unexpected = false; + print("Some tests FAILED:"); + for (let i in failures) { + if (known_failures[failures[i]]) { + print(` ${failures[i]} [KNOWN: ${known_failures[failures[i]]}]`); + } else { + print(` ${failures[i]}`); + unexpected = true; + } + } + if (unexpected) { + quit(1); + } + } +}); + +} diff --git a/deps/v8/test/mjsunit/wasm/wasm-module-builder.js b/deps/v8/test/mjsunit/wasm/wasm-module-builder.js index df26fed12a..334a8a14b8 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-module-builder.js +++ b/deps/v8/test/mjsunit/wasm/wasm-module-builder.js @@ -168,6 +168,22 @@ class WasmModuleBuilder { return this; } + stringToBytes(name) { + var result = new Binary(); + result.emit_u32v(name.length); + for (var i = 0; i < name.length; i++) { + result.emit_u8(name.charCodeAt(i)); + } + return result; + } + + addCustomSection(name, bytes) { + name = this.stringToBytes(name); + var length = new Binary(); + length.emit_u32v(name.length + bytes.length); + this.explicit.push([0, ...length, ...name, ...bytes]); + } + addType(type) { // TODO: canonicalize types? this.types.push(type); diff --git a/deps/v8/test/mozilla/mozilla.status b/deps/v8/test/mozilla/mozilla.status index f8b215e862..4050700968 100644 --- a/deps/v8/test/mozilla/mozilla.status +++ b/deps/v8/test/mozilla/mozilla.status @@ -662,7 +662,6 @@ # than 4Mbytes of stack space. 'js1_5/Array/regress-350256-02': [FAIL], - # This test seems designed to fail (it produces a 700Mbyte string). # We fail on out of memory. The important thing is not to crash. 'js1_5/Regress/regress-303213': [FAIL, ['mode == debug', TIMEOUT, NO_VARIANTS]], @@ -671,14 +670,10 @@ # is given null or undefined as this argument (and so does firefox nightly). 'js1_5/Regress/regress-295052': [FAIL], - # Bug 1202592: New ecma_3/String/15.5.4.11 is failing. - 'ecma_3/String/15.5.4.11': [FAIL], - # Bug 1202597: New js1_5/Expressions/regress-394673 is failing. # Marked as: Will not fix. V8 throws an acceptable RangeError. 'js1_5/Expressions/regress-394673': [FAIL], - # Bug 762: http://code.google.com/p/v8/issues/detail?id=762 # We do not correctly handle assignments within "with" 'ecma_3/Statements/12.10-01': [FAIL], diff --git a/deps/v8/test/perf.isolate b/deps/v8/test/perf.isolate index 6142152658..5eec44a3ee 100644 --- a/deps/v8/test/perf.isolate +++ b/deps/v8/test/perf.isolate @@ -18,7 +18,6 @@ '../tools/whitespace.txt', 'js-perf-test/', 'memory/', - 'simdjs/', ], }, 'includes': [ diff --git a/deps/v8/test/simdjs/SimdJs.json b/deps/v8/test/simdjs/SimdJs.json deleted file mode 100644 index e0683226d4..0000000000 --- a/deps/v8/test/simdjs/SimdJs.json +++ /dev/null @@ -1,244 +0,0 @@ -{ - "flags": [ - "--harmony-simd", - "test/simdjs/harness-adapt.js" - ], - "name": "SIMDJS", - "path": [ - "../../" - ], - "resources": [ - "test/simdjs/data/src/benchmarks/base.js", - "test/simdjs/harness-adapt.js", - "test/simdjs/harness-finish.js", - "test/simdjs/data/src/benchmarks/kernel-template.js", - "test/simdjs/data/src/benchmarks/averageFloat32x4.js", - "test/simdjs/data/src/benchmarks/averageFloat32x4LoadFromInt8Array.js", - "test/simdjs/data/src/benchmarks/averageFloat32x4LoadX.js", - "test/simdjs/data/src/benchmarks/averageFloat32x4LoadXY.js", - "test/simdjs/data/src/benchmarks/averageFloat32x4LoadXYZ.js", - "test/simdjs/data/src/benchmarks/matrix-multiplication.js", - "test/simdjs/data/src/benchmarks/transform.js", - "test/simdjs/data/src/benchmarks/shiftrows.js", - "test/simdjs/data/src/benchmarks/transpose4x4.js", - "test/simdjs/data/src/benchmarks/inverse4x4.js", - "test/simdjs/data/src/benchmarks/memset.js", - "test/simdjs/data/src/benchmarks/memcpy.js" - ], - "run_count": 5, - "run_count_arm": 3, - "run_count_arm64": 3, - "tests": [ - { - "flags": [ - "test/simdjs/data/src/benchmarks/kernel-template.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "kernel-template", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/averageFloat32x4.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "averageFloat32x4", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/averageFloat32x4LoadFromInt8Array.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "averageFloat32x4LoadFromInt8Array", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/averageFloat32x4LoadX.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "averageFloat32x4LoadX", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/averageFloat32x4LoadXY.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "averageFloat32x4LoadXY", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/averageFloat32x4LoadXYZ.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "averageFloat32x4LoadXYZ", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/matrix-multiplication.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "matrix-multiplication", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/transform.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "transform", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/shiftrows.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "shiftrows", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/transpose4x4.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "transpose4x4", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/inverse4x4.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "inverse4x4", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/memset.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "memset", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - }, - { - "flags": [ - "test/simdjs/data/src/benchmarks/memcpy.js" - ], - "main": "test/simdjs/harness-finish.js", - "name": "memcpy", - "results_regexp": "%s\\([ ]*([0-9.]+)(ms)?\\)", - "tests": [ - { - "name": "SIMD" - }, - { - "name": "Non-SIMD" - } - ] - } - ], - "timeout_arm": 480, - "timeout_arm64": 120, - "units": "ms" -} diff --git a/deps/v8/test/simdjs/generate.py b/deps/v8/test/simdjs/generate.py deleted file mode 100755 index 2ddd6d82ab..0000000000 --- a/deps/v8/test/simdjs/generate.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python -# Copyright 2015 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Script to re-generate SimdJs.json from a SimdJs.json.template. - -import json -import os -import re - -SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) - -SKIP_FILES = [ - '../ecmascript_simd', - 'base', - # TODO(bradnelson): Drop these when tests are fixed upstream. - 'aobench', - 'averageFloat32x4Load', - 'matrix-multiplication-load', -] - -run_js = open( - os.path.join(SCRIPT_DIR, 'data', 'src', 'benchmarks', 'run.js')).read() -tests = re.findall("load \\(\\'([^']+)[.]js\\'\\)", run_js) -tests = [t for t in tests if t not in SKIP_FILES] - -output = { - 'name': 'SIMDJS', - 'run_count': 5, - 'run_count_arm': 3, - 'run_count_android_arm': 1, - 'run_count_android_arm64': 3, - 'timeout_arm': 120, - 'timeout_android_arm': 180, - 'timeout_android_arm64': 120, - 'units': 'ms', - 'resources': [ - 'test/simdjs/data/src/benchmarks/base.js', - 'test/simdjs/harness-adapt.js', - 'test/simdjs/harness-finish.js' - ] + ['test/simdjs/data/src/benchmarks/%s.js' % t for t in tests], - 'flags': ['test/simdjs/harness-adapt.js'], - 'path': ['../../'], - 'tests': [ - { - 'name': test, - 'main': 'test/simdjs/harness-finish.js', - 'flags': ['test/simdjs/data/src/benchmarks/%s.js' % test], - 'results_regexp': '%s\\([ ]*([0-9.]+)(ms)?\\)', - 'tests': [ - {'name': 'SIMD'}, - {'name': 'Non-SIMD'}, - ] - } - for test in tests], -} - -with open(os.path.join(SCRIPT_DIR, 'SimdJs.json'), 'w') as fh: - fh.write(json.dumps(output, separators=(',',': '), indent=2, sort_keys=True)) diff --git a/deps/v8/test/simdjs/harness-adapt.js b/deps/v8/test/simdjs/harness-adapt.js deleted file mode 100644 index 252eb41ba5..0000000000 --- a/deps/v8/test/simdjs/harness-adapt.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -(function() { - -"use strict"; - -var _oldLoad = load; - -// Filter load paths in the ecmascript_simd tests that -// assume the test is run with a current working directory -// set to the directory containing the test. -load = function(filename) { - // Decide if this is the compliance test or the benchmarks. - if (filename === 'ecmascript_simd.js' || - filename === 'ecmascript_simd_tests.js') { - _oldLoad('test/simdjs/data/src/' + filename); - } else { - _oldLoad('test/simdjs/data/src/benchmarks/' + filename); - } -}; - -// To enable SIMD polyfill, load ecmascript_simd.js here, -// add to resources in SimdJs.json as well as the script -// to re-generate SimdJs.json. - -load('base.js'); - -})(); - -// ecmascript_simd_tests logs errors to the console. -var console = { - log: function(x) { print(x); }, -}; - - -// Disable value type tests for now. The value semantics tests are incorrect. -// TODO(bbudge): Drop when tests are fixed. -var skipValueTests = true; diff --git a/deps/v8/test/simdjs/harness-finish.js b/deps/v8/test/simdjs/harness-finish.js deleted file mode 100644 index 9df611085c..0000000000 --- a/deps/v8/test/simdjs/harness-finish.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -(function() { - -"use strict"; - -function printResult (str) { - print (str); -} - -function printError (str) { - print (str); -} - -function printScore (str) { - print (str); -} - -benchmarks.runAll ({notifyResult: printResult, - notifyError: printError, - notifyScore: printScore}, - true); - -})(); diff --git a/deps/v8/test/simdjs/simdjs.gyp b/deps/v8/test/simdjs/simdjs.gyp deleted file mode 100644 index c0c24dc325..0000000000 --- a/deps/v8/test/simdjs/simdjs.gyp +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2015 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'conditions': [ - ['test_isolation_mode != "noop"', { - 'targets': [ - { - 'target_name': 'simdjs_run', - 'type': 'none', - 'dependencies': [ - '../../src/d8.gyp:d8_run', - ], - 'includes': [ - '../../gypfiles/features.gypi', - '../../gypfiles/isolate.gypi', - ], - 'sources': [ - 'simdjs.isolate', - ], - }, - ], - }], - ], -} diff --git a/deps/v8/test/simdjs/simdjs.isolate b/deps/v8/test/simdjs/simdjs.isolate deleted file mode 100644 index dbeca5e55c..0000000000 --- a/deps/v8/test/simdjs/simdjs.isolate +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2015 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -{ - 'variables': { - 'files': [ - './', - ], - }, - 'includes': [ - '../../src/d8.isolate', - '../../tools/testrunner/testrunner.isolate', - ], -}
\ No newline at end of file diff --git a/deps/v8/test/simdjs/simdjs.status b/deps/v8/test/simdjs/simdjs.status deleted file mode 100644 index dba1681bdc..0000000000 --- a/deps/v8/test/simdjs/simdjs.status +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2015 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# -------------------------------------------------------------------- -# If you add a test case to this file, please try to provide -# an explanation of why the test fails; this may ease future -# debugging. -# -------------------------------------------------------------------- - -[ -[ALWAYS, { - # TODO(bbudge): Drop when test is fixed upstream. - 'benchmarks/aobench': SKIP, - 'benchmarks/averageFloat64x2': SKIP, - 'benchmarks/averageFloat64x2Load': SKIP, - 'benchmarks/mandelbrot': SKIP, - 'benchmarks/sinx4': SKIP, - - # TODO(bbudge): Drop this when simd implementation is faster. - 'benchmarks/memcpy': SKIP, - - # Slow tests. - 'benchmarks/kernel-template': [PASS, SLOW], - 'benchmarks/memset': [PASS, SLOW], -}], - -###################################################################### -['byteorder == big', { - # shell_test_runner requires little-endian, skip it on big-endian. - 'shell_test_runner': [SKIP], -}], # 'byteorder == big' - -] diff --git a/deps/v8/test/simdjs/testcfg.py b/deps/v8/test/simdjs/testcfg.py deleted file mode 100644 index d22368b0a6..0000000000 --- a/deps/v8/test/simdjs/testcfg.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2014 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - - -import os -import sys - -from testrunner.local import testsuite -from testrunner.objects import testcase - -SIMDJS_SUITE_PATH = ["data", "src"] - - -class SimdJsTestSuite(testsuite.TestSuite): - - def __init__(self, name, root): - super(SimdJsTestSuite, self).__init__(name, root) - self.testroot = os.path.join(self.root, *SIMDJS_SUITE_PATH) - self.ParseTestRecord = None - - def ListTests(self, context): - tests = [ - testcase.TestCase(self, 'shell_test_runner'), - ] - for filename in os.listdir(os.path.join(self.testroot, 'benchmarks')): - if (not filename.endswith('.js') or - filename in ['run.js', 'run_browser.js', 'base.js']): - continue - name = filename.rsplit('.')[0] - tests.append( - testcase.TestCase(self, 'benchmarks/' + name)) - return tests - - def GetFlagsForTestCase(self, testcase, context): - return (testcase.flags + context.mode_flags + - [os.path.join(self.root, "harness-adapt.js"), - "--harmony", "--harmony-simd", - os.path.join(self.testroot, testcase.path + ".js"), - os.path.join(self.root, "harness-finish.js")]) - - def GetSourceForTest(self, testcase): - filename = os.path.join(self.testroot, testcase.path + ".js") - with open(filename) as f: - return f.read() - - def IsNegativeTest(self, testcase): - return False - - def IsFailureOutput(self, testcase): - if testcase.output.exit_code != 0: - return True - return "FAILED!" in testcase.output.stdout - - -def GetSuite(name, root): - return SimdJsTestSuite(name, root) diff --git a/deps/v8/test/test262/harness-agent.js b/deps/v8/test/test262/harness-agent.js new file mode 100644 index 0000000000..c141fe287a --- /dev/null +++ b/deps/v8/test/test262/harness-agent.js @@ -0,0 +1,106 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +$.agent = (function () { + +var workers = []; +var i32a = null; +var pendingReports = []; + +// Agents call Atomics.wait on this location to sleep. +var SLEEP_LOC = 0; +// 1 if the started worker is ready, 0 otherwise. +var START_LOC = 1; +// The number of workers that have received the broadcast. +var BROADCAST_LOC = 2; +// Each worker has a count of outstanding reports; worker N uses memory +// location [WORKER_REPORT_LOC + N]. +var WORKER_REPORT_LOC = 3; + +function workerScript(script) { + return ` + var index; + var i32a = null; + var broadcasts = []; + var pendingReceiver = null; + + function handleBroadcast() { + if (pendingReceiver && broadcasts.length > 0) { + pendingReceiver.apply(null, broadcasts.shift()); + pendingReceiver = null; + } + }; + + var onmessage = function(msg) { + switch (msg.kind) { + case 'start': + i32a = msg.i32a; + index = msg.index; + (0, eval)(\`${script}\`); + break; + + case 'broadcast': + Atomics.add(i32a, ${BROADCAST_LOC}, 1); + broadcasts.push([msg.sab, msg.id]); + handleBroadcast(); + break; + } + }; + + var $ = { + agent: { + receiveBroadcast(receiver) { + pendingReceiver = receiver; + handleBroadcast(); + }, + + report(msg) { + postMessage(msg); + Atomics.add(i32a, ${WORKER_REPORT_LOC} + index, 1); + }, + + sleep(s) { Atomics.wait(i32a, ${SLEEP_LOC}, 0, s); }, + + leaving() {} + } + };`; +} + +var agent = { + start(script) { + if (i32a === null) { + i32a = new Int32Array(new SharedArrayBuffer(256)); + } + var w = new Worker(workerScript(script)); + w.index = workers.length; + w.postMessage({kind: 'start', i32a: i32a, index: w.index}); + workers.push(w); + }, + + broadcast(sab, id) { + Atomics.store(i32a, BROADCAST_LOC, 0); + + for (var w of workers) { + w.postMessage({kind: 'broadcast', sab: sab, id: id|0}); + } + + while (Atomics.load(i32a, BROADCAST_LOC) != workers.length) {} + }, + + getReport() { + for (var w of workers) { + while (Atomics.load(i32a, WORKER_REPORT_LOC + w.index) > 0) { + pendingReports.push(w.getMessage()); + Atomics.sub(i32a, WORKER_REPORT_LOC + w.index, 1); + } + } + + return pendingReports.shift() || null; + }, + + sleep(s) { Atomics.wait(i32a, SLEEP_LOC, 0, s); } +}; +return agent; + +})(); diff --git a/deps/v8/test/test262/local-tests/test/intl402/NumberFormat/default-currency-maximum-fraction-digits.js b/deps/v8/test/test262/local-tests/test/intl402/NumberFormat/default-currency-maximum-fraction-digits.js new file mode 100644 index 0000000000..9ca6ffe2b9 --- /dev/null +++ b/deps/v8/test/test262/local-tests/test/intl402/NumberFormat/default-currency-maximum-fraction-digits.js @@ -0,0 +1,17 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: ECMA-402 #sec-setnfdigitoptions +description: > + When a currency is used in Intl.NumberFormat and minimumFractionDigits is + not provided, maximumFractionDigits should be range-checked against it. +include: [assert.js] +---*/ + +assert.throws(RangeError, + () => new Intl.NumberFormat('en', { + style: 'currency', + currency: 'USD', + maximumFractionDigits: 1 + })); diff --git a/deps/v8/test/test262/local-tests/test/intl402/NumberFormat/fraction-digit-options-read-once.js b/deps/v8/test/test262/local-tests/test/intl402/NumberFormat/fraction-digit-options-read-once.js new file mode 100644 index 0000000000..e7e37b8735 --- /dev/null +++ b/deps/v8/test/test262/local-tests/test/intl402/NumberFormat/fraction-digit-options-read-once.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: ECMA-402 #sec-setnfdigitoptions +description: > + The maximum and minimum fraction digits properties should be read from + the options bag exactly once from the NumberFormat constructor. + Regression test for https://bugs.chromium.org/p/v8/issues/detail?id=6015 +include: [assert.js] +---*/ + +var minCounter = 0; +var maxCounter = 0; +new Intl.NumberFormat("en", { get minimumFractionDigits() { minCounter++ }, + get maximumFractionDigits() { maxCounter++ } }); +assert.sameValue(1, minCounter); +assert.sameValue(1, maxCounter); diff --git a/deps/v8/test/test262/prune-local-tests.sh b/deps/v8/test/test262/prune-local-tests.sh index a0c309bbe3..3d78f6963c 100755 --- a/deps/v8/test/test262/prune-local-tests.sh +++ b/deps/v8/test/test262/prune-local-tests.sh @@ -7,9 +7,11 @@ # when they are identical to upstreamed tests. It should be run as part of # the test262 roll process. -find -f test/test262/local-tests | while read localpath; do +find test/test262/local-tests -type f | while read localpath; do datapath=${localpath/local-tests/data} - if diff $localpath $datapath >/dev/null ; then - git rm $localpath || exit 1 + if [ -e $datapath ] ; then + if diff $localpath $datapath >/dev/null ; then + git rm $localpath || exit 1 + fi fi done diff --git a/deps/v8/test/test262/test262.isolate b/deps/v8/test/test262/test262.isolate index 4e1419030e..720370d23d 100644 --- a/deps/v8/test/test262/test262.isolate +++ b/deps/v8/test/test262/test262.isolate @@ -7,6 +7,7 @@ 'data.tar', 'detachArrayBuffer.js', 'harness-adapt.js', + 'harness-agent.js', 'test262.status', 'testcfg.py', ], diff --git a/deps/v8/test/test262/test262.status b/deps/v8/test/test262/test262.status index 4e36d22120..73a0ee3d51 100644 --- a/deps/v8/test/test262/test262.status +++ b/deps/v8/test/test262/test262.status @@ -87,9 +87,9 @@ 'language/asi/S7.9_A5.7_T1': [PASS, FAIL_OK], ###### BEGIN REGEXP SUBCLASSING SECTION ###### - # https://bugs.chromium.org/p/v8/issues/detail?id=5361 - 'built-ins/RegExp/prototype/Symbol.replace/y-init-lastindex': [FAIL], - 'built-ins/RegExp/prototype/Symbol.replace/y-set-lastindex': [FAIL], + # https://bugs.chromium.org/p/v8/issues/detail?id=5949 + 'built-ins/RegExp/prototype/exec/failure-lastindex-no-access': [FAIL], + 'built-ins/RegExp/prototype/exec/success-lastindex-no-access': [FAIL], ###### END REGEXP SUBCLASSING SECTION ###### @@ -125,6 +125,10 @@ 'built-ins/TypedArray/prototype/some/callbackfn-detachbuffer': [FAIL], 'built-ins/TypedArray/prototype/sort/detached-buffer-comparefn': [FAIL], # DataView functions should also throw on detached buffers + 'built-ins/ArrayBuffer/prototype/byteLength/detached-buffer': [FAIL], + 'built-ins/DataView/detached-buffer': [FAIL], + 'built-ins/DataView/prototype/byteLength/detached-buffer': [FAIL], + 'built-ins/DataView/prototype/byteOffset/detached-buffer': [FAIL], 'built-ins/DataView/prototype/getFloat32/detached-buffer': [FAIL], 'built-ins/DataView/prototype/getFloat32/detached-buffer-before-outofrange-byteoffset': [FAIL], 'built-ins/DataView/prototype/getFloat64/detached-buffer': [FAIL], @@ -157,12 +161,6 @@ 'built-ins/DataView/prototype/setUint32/detached-buffer-before-outofrange-byteoffset': [FAIL], 'built-ins/DataView/prototype/setUint8/detached-buffer': [FAIL], 'built-ins/DataView/prototype/setUint8/detached-buffer-before-outofrange-byteoffset': [FAIL], - 'built-ins/DataView/prototype/byteLength/detached-buffer': [FAIL], - 'built-ins/DataView/prototype/byteOffset/detached-buffer': [FAIL], - 'built-ins/DataView/detached-buffer': [FAIL], - 'built-ins/ArrayBuffer/prototype/byteLength/detached-buffer': [FAIL], - 'built-ins/DataView/prototype/setFloat64/detached-buffer-after-toindex-byteoffset': [FAIL], - 'built-ins/DataView/prototype/setInt16/detached-buffer-after-toindex-byteoffset': [FAIL], # https://bugs.chromium.org/p/v8/issues/detail?id=4648 'built-ins/TypedArray/prototype/copyWithin/detached-buffer': [FAIL], @@ -250,32 +248,32 @@ 'built-ins/Simd/*': [SKIP], # https://bugs.chromium.org/p/v8/issues/detail?id=4958 - 'built-ins/Function/prototype/toString/AsyncFunction': [FAIL], - 'built-ins/Function/prototype/toString/async-function-declaration': [FAIL], - 'built-ins/Function/prototype/toString/async-function-expression': [FAIL], - 'built-ins/Function/prototype/toString/async-method': [FAIL], - 'built-ins/Function/prototype/toString/Function': [FAIL], - 'built-ins/Function/prototype/toString/GeneratorFunction': [FAIL], - 'built-ins/Function/prototype/toString/function-declaration': [FAIL], - 'built-ins/Function/prototype/toString/function-declaration-non-simple-parameter-list': [FAIL], - 'built-ins/Function/prototype/toString/function-expression': [FAIL], - 'built-ins/Function/prototype/toString/generator-function-declaration': [FAIL], - 'built-ins/Function/prototype/toString/generator-function-expression': [FAIL], - 'built-ins/Function/prototype/toString/generator-method': [FAIL], - 'built-ins/Function/prototype/toString/getter-class': [FAIL], - 'built-ins/Function/prototype/toString/getter-class-static': [FAIL], - 'built-ins/Function/prototype/toString/getter-object': [FAIL], - 'built-ins/Function/prototype/toString/line-terminator-normalisation-CR': [FAIL], - 'built-ins/Function/prototype/toString/line-terminator-normalisation-CR-LF': [FAIL], - 'built-ins/Function/prototype/toString/line-terminator-normalisation-LF': [FAIL], - 'built-ins/Function/prototype/toString/method-class': [FAIL], - 'built-ins/Function/prototype/toString/method-class-static': [FAIL], - 'built-ins/Function/prototype/toString/method-computed-property-name': [FAIL], - 'built-ins/Function/prototype/toString/method-object': [FAIL], - 'built-ins/Function/prototype/toString/setter-class': [FAIL], - 'built-ins/Function/prototype/toString/setter-class-static': [FAIL], - 'built-ins/Function/prototype/toString/setter-object': [FAIL], - 'built-ins/Function/prototype/toString/unicode': [FAIL], + 'built-ins/Function/prototype/toString/AsyncFunction': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/async-function-declaration': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/async-function-expression': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/async-method': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/Function': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/GeneratorFunction': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/function-declaration': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/function-declaration-non-simple-parameter-list': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/function-expression': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/generator-function-declaration': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/generator-function-expression': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/generator-method': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/getter-class': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/getter-class-static': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/getter-object': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/line-terminator-normalisation-CR': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/line-terminator-normalisation-CR-LF': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/line-terminator-normalisation-LF': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/method-class': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/method-class-static': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/method-computed-property-name': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/method-object': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/setter-class': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/setter-class-static': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/setter-object': ['--harmony-function-tostring'], + 'built-ins/Function/prototype/toString/unicode': ['--harmony-function-tostring'], # https://bugs.chromium.org/p/v8/issues/detail?id=5115 'language/statements/class/subclass/class-definition-null-proto-missing-return-override': [FAIL], @@ -326,7 +324,6 @@ 'annexB/language/eval-code/direct/func-switch-dflt-eval-func-block-scoping': [FAIL], # https://bugs.chromium.org/p/v8/issues/detail?id=5139 - 'annexB/built-ins/Date/prototype/setYear/time-clip': [FAIL], 'annexB/built-ins/Date/prototype/setYear/year-number-relative': [FAIL], # https://bugs.chromium.org/p/v8/issues/detail?id=5155 @@ -341,28 +338,6 @@ 'built-ins/Number/S9.3.1_A3_T1_U180E': [FAIL], 'built-ins/Number/S9.3.1_A2_U180E': [FAIL], - # https://bugs.chromium.org/p/v8/issues/detail?id=5051 - 'language/expressions/arrow-function/params-trailing-comma': ['--harmony-trailing-commas'], - 'language/expressions/arrow-function/params-trailing-comma-length': ['--harmony-trailing-commas'], - 'language/expressions/call/trailing-comma': ['--harmony-trailing-commas'], - 'language/expressions/function/params-trailing-comma': ['--harmony-trailing-commas'], - 'language/expressions/function/params-trailing-comma-arguments': ['--harmony-trailing-commas'], - 'language/expressions/function/params-trailing-comma-length': ['--harmony-trailing-commas'], - 'language/expressions/generators/params-trailing-comma': ['--harmony-trailing-commas'], - 'language/expressions/generators/params-trailing-comma-arguments': ['--harmony-trailing-commas'], - 'language/expressions/generators/params-trailing-comma-length': ['--harmony-trailing-commas'], - 'language/expressions/object/method-definition/params-trailing-comma': ['--harmony-trailing-commas'], - 'language/expressions/object/method-definition/params-trailing-comma-arguments': ['--harmony-trailing-commas'], - 'language/expressions/object/method-definition/params-trailing-comma-length': ['--harmony-trailing-commas'], - 'language/statements/class/definition/params-trailing-comma': ['--harmony-trailing-commas'], - 'language/statements/class/definition/params-trailing-comma-arguments': ['--harmony-trailing-commas'], - 'language/statements/class/definition/params-trailing-comma-length': ['--harmony-trailing-commas'], - 'language/statements/function/params-trailing-comma': ['--harmony-trailing-commas'], - 'language/statements/function/params-trailing-comma-arguments': ['--harmony-trailing-commas'], - 'language/statements/function/params-trailing-comma-length': ['--harmony-trailing-commas'], - 'language/statements/generators/params-trailing-comma': ['--harmony-trailing-commas'], - 'language/statements/generators/params-trailing-comma-length': ['--harmony-trailing-commas'], - # https://bugs.chromium.org/p/v8/issues/detail?id=4698 'language/expressions/call/tco-call-args': ['--harmony-tailcalls'], 'language/expressions/call/tco-member-args': ['--harmony-tailcalls'], @@ -421,7 +396,7 @@ 'annexB/language/eval-code/direct/func-switch-dflt-eval-func-no-skip-try': [FAIL], # https://bugs.chromium.org/p/v8/issues/detail?id=5546 - 'language/expressions/tagged-template/invalid-escape-sequences': [FAIL], + 'language/expressions/tagged-template/invalid-escape-sequences': ['--harmony-template-escapes'], # https://bugs.chromium.org/p/v8/issues/detail?id=5537 'built-ins/global/*': [SKIP], @@ -429,7 +404,6 @@ # PreParser doesn't produce early errors # https://bugs.chromium.org/p/v8/issues/detail?id=2728 'language/expressions/async-arrow-function/early-errors-arrow-formals-body-duplicate': [FAIL], - 'language/expressions/async-function/early-errors-expression-formals-body-duplicate': [FAIL], 'language/expressions/object/method-definition/generator-param-redecl-const': [FAIL], 'language/expressions/object/method-definition/generator-param-redecl-let': [FAIL], 'language/expressions/object/method-definition/name-param-redecl': [FAIL], @@ -439,34 +413,12 @@ # v8:5485 'language/module-code/comment-multi-line-html*': [FAIL], 'language/module-code/comment-single-line-html*': [FAIL], - - # v8:5486 - 'language/module-code/instn-iee-star-cycle': [FAIL], - 'language/module-code/instn-named-star-cycle': [FAIL], - 'language/module-code/instn-star-star-cycle': [FAIL], - # v8:5487 'language/module-code/namespace/internals/get-own-property-str-found-uninit': [FAIL], - # v8:5401 'language/module-code/namespace/internals/set': [FAIL], 'language/module-code/namespace/internals/define-own-property': [FAIL], - # Symbol.iterator on namespace objects was removed, tests need to be updated. - 'language/module-code/namespace/Symbol.iterator/*': [SKIP], - 'language/module-code/namespace/internals/get-own-property-sym': [SKIP], - 'language/module-code/namespace/internals/get-sym-found': [SKIP], - 'language/module-code/namespace/internals/has-property-sym-found': [SKIP], - 'language/module-code/namespace/internals/own-property-keys-binding-types': [SKIP], - 'language/module-code/namespace/internals/own-property-keys-sort': [SKIP], - - # Symbol.toString on namespace objects was made non-configurable, tests need - # to be updated. - 'language/module-code/namespace/Symbol.toStringTag': [SKIP], - - # Possible spec bug, see comment in https://github.com/tc39/ecma262/pull/747. - 'language/module-code/namespace/internals/delete-non-exported': [SKIP], - # https://code.google.com/p/v8/issues/detail?id=4476 'built-ins/String/prototype/toLowerCase/special_casing_conditional': ['--icu-case-mapping'], 'built-ins/String/prototype/toLowerCase/supplementary_plane': ['--icu-case-mapping'], @@ -485,6 +437,98 @@ 'intl402/String/prototype/toLocaleUpperCase/special_casing_Lithuanian': ['--icu-case-mapping'], 'intl402/String/prototype/toLocaleUpperCase/special_casing_Turkish': ['--icu-case-mapping'], + # https://bugs.chromium.org/p/v8/issues/detail?id=5601 + 'intl402/PluralRules/*': [SKIP], + + # https://bugs.chromium.org/p/v8/issues/detail?id=5855 + 'language/expressions/async-generators/*': [SKIP], + + # SharedArrayBuffer tests that require flags + 'built-ins/SharedArrayBuffer/*': ['--harmony-sharedarraybuffer'], + 'built-ins/Atomics/*': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/buffer-does-not-have-arraybuffer-data-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/buffer-reference-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/byteoffset-is-negative-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/custom-proto-access-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/custom-proto-if-not-object-fallbacks-to-default-prototype-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/custom-proto-if-object-is-used-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/defined-bytelength-and-byteoffset-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/defined-byteoffset-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/defined-byteoffset-undefined-bytelength-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/excessive-bytelength-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/excessive-byteoffset-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/instance-extensibility-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/negative-bytelength-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/negative-byteoffset-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/newtarget-undefined-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/proto-from-ctor-realm-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/buffer/return-buffer-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/buffer/this-has-no-dataview-internal-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/byteLength/return-bytelength-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/byteLength/this-has-no-dataview-internal-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/byteOffset/return-byteoffset-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/getInt32/index-is-out-of-range-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/getInt32/negative-byteoffset-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/getInt32/return-abrupt-from-tonumber-byteoffset-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/getInt32/return-abrupt-from-tonumber-byteoffset-symbol-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/getInt32/return-value-clean-arraybuffer-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/getInt32/return-values-custom-offset-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/getInt32/return-values-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/getInt32/this-has-no-dataview-internal-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/getInt32/to-boolean-littleendian-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/prototype/getInt32/toindex-byteoffset-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/return-abrupt-tonumber-bytelength-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/return-abrupt-tonumber-bytelength-symbol-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/return-abrupt-tonumber-byteoffset-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/return-abrupt-tonumber-byteoffset-symbol-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/return-instance-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/toindex-bytelength-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/DataView/toindex-byteoffset-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-byteoffset-is-negative-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-byteoffset-is-negative-zero-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-byteoffset-is-symbol-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-byteoffset-throws-from-modulo-element-size-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-byteoffset-to-number-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-custom-proto-access-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-defined-length-and-offset-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-defined-length-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-defined-negative-length-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-defined-offset-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-excessive-length-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-excessive-offset-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-invoked-with-undefined-newtarget-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-is-referenced-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-length-access-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-length-is-symbol-throws-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-new-instance-extensibility-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-proto-from-ctor-realm-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-returns-new-instance-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-toindex-bytelength-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-toindex-byteoffset-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-use-custom-proto-if-object-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-use-default-proto-if-custom-proto-is-not-object-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/internals/Get/indexed-value-sab': ['--harmony-sharedarraybuffer'], + 'built-ins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer': ['--harmony-sharedarraybuffer'], + 'built-ins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer': ['--harmony-sharedarraybuffer'], + 'built-ins/TypedArrays/buffer-arg-typedarray-backed-by-sharedarraybuffer': ['--harmony-sharedarraybuffer'], + + # https://bugs.chromium.org/p/v8/issues/detail?id=5983 + 'built-ins/SharedArrayBuffer/newtarget-prototype-is-not-object': [FAIL], + + # https://bugs.chromium.org/p/v8/issues/detail?id=5984 + 'built-ins/SharedArrayBuffer/proto-from-ctor-realm': [FAIL], + + # https://bugs.chromium.org/p/v8/issues/detail?id=5982 + 'built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab': ['--harmony-sharedarraybuffer', FAIL], + + # https://bugs.chromium.org/p/v8/issues/detail?id=5897 + 'built-ins/SharedArrayBuffer/prototype/slice/*': [SKIP], + ######################## NEEDS INVESTIGATION ########################### # These test failures are specific to the intl402 suite and need investigation @@ -504,6 +548,8 @@ 'intl402/NumberFormat/11.2.3_b': [FAIL], 'intl402/NumberFormat/prototype/11.3_a': [FAIL], 'intl402/String/prototype/localeCompare/13.1.1_7': [PASS, FAIL], + 'intl402/NumberFormat/default-currency-maximum-fraction-digits': [PASS, FAIL], + 'intl402/NumberFormat/fraction-digit-options-read-once': [PASS, FAIL], ##################### DELIBERATE INCOMPATIBILITIES ##################### @@ -549,14 +595,30 @@ 'built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm': [FAIL], 'built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm': [FAIL], - # https://github.com/tc39/test262/commit/c779cba592fcb39051fd1d467e472ea71aa2b1d6#commitcomment-20276482 - 'language/statements/class/strict-mode/arguments-caller': [FAIL], - # Date tests that fail in CE(S)T timezone. # https://bugs.chromium.org/p/v8/issues/detail?id=5449 'built-ins/Date/prototype/setFullYear/new-value-time-clip': [PASS, FAIL], 'built-ins/Date/prototype/setMonth/new-value-time-clip': [PASS, FAIL], + # v8:5486 + # Spec changed to be more permissive, tests need to be updated. + 'language/module-code/instn-iee-star-cycle': [FAIL], + 'language/module-code/instn-named-star-cycle': [FAIL], + 'language/module-code/instn-star-star-cycle': [FAIL], + + # Symbol.iterator on namespace objects was removed, tests need to be updated. + 'language/module-code/namespace/Symbol.iterator/*': [SKIP], + 'language/module-code/namespace/internals/get-own-property-sym': [SKIP], + 'language/module-code/namespace/internals/get-sym-found': [SKIP], + 'language/module-code/namespace/internals/has-property-sym-found': [SKIP], + 'language/module-code/namespace/internals/own-property-keys-binding-types': [SKIP], + 'language/module-code/namespace/internals/own-property-keys-sort': [SKIP], + + # Symbol.toStringTag on namespace objects was made non-configurable, tests + # need to be updated. + 'language/module-code/namespace/Symbol.toStringTag': [SKIP], + 'language/module-code/namespace/internals/delete-non-exported': [SKIP], + ############################ SKIPPED TESTS ############################# # These tests take a looong time to run. @@ -636,6 +698,8 @@ # The failed allocation causes an asan/msan/tsan error 'built-ins/ArrayBuffer/allocation-limit': [SKIP], 'built-ins/ArrayBuffer/length-is-too-large-throws': [SKIP], + 'built-ins/SharedArrayBuffer/allocation-limit': [SKIP], + 'built-ins/SharedArrayBuffer/length-is-too-large-throws': [SKIP], }], # asan == True or msan == True or tsan == True ['variant == asm_wasm', { diff --git a/deps/v8/test/test262/testcfg.py b/deps/v8/test/test262/testcfg.py index e54b58993a..66bd6fae13 100644 --- a/deps/v8/test/test262/testcfg.py +++ b/deps/v8/test/test262/testcfg.py @@ -142,6 +142,8 @@ class Test262TestSuite(testsuite.TestSuite): def GetFlagsForTestCase(self, testcase, context): return (testcase.flags + context.mode_flags + self.harness + + ([os.path.join(self.root, "harness-agent.js")] + if testcase.path.startswith('built-ins/Atomics') else []) + self.GetIncludesForTest(testcase) + (["--module"] if "module" in self.GetTestRecord(testcase) else []) + [self.GetPathForTest(testcase)] + diff --git a/deps/v8/test/unittests/BUILD.gn b/deps/v8/test/unittests/BUILD.gn index 221ca74cab..06477ed45f 100644 --- a/deps/v8/test/unittests/BUILD.gn +++ b/deps/v8/test/unittests/BUILD.gn @@ -11,6 +11,10 @@ v8_executable("unittests") { "../../testing/gmock-support.h", "../../testing/gtest-support.h", "api/access-check-unittest.cc", + "api/exception-unittest.cc", + "api/isolate-unittest.cc", + "api/remote-object-unittest.cc", + "api/v8-object-unittest.cc", "base/atomic-utils-unittest.cc", "base/bits-unittest.cc", "base/cpu-unittest.cc", @@ -34,6 +38,7 @@ v8_executable("unittests") { "compiler-dispatcher/compiler-dispatcher-job-unittest.cc", "compiler-dispatcher/compiler-dispatcher-tracer-unittest.cc", "compiler-dispatcher/compiler-dispatcher-unittest.cc", + "compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc", "compiler/branch-elimination-unittest.cc", "compiler/bytecode-analysis-unittest.cc", "compiler/checkpoint-elimination-unittest.cc", @@ -141,6 +146,7 @@ v8_executable("unittests") { "wasm/switch-logic-unittest.cc", "wasm/wasm-macro-gen-unittest.cc", "wasm/wasm-module-builder-unittest.cc", + "wasm/wasm-opcodes-unittest.cc", "zone/segmentpool-unittest.cc", "zone/zone-chunk-list-unittest.cc", "zone/zone-unittest.cc", diff --git a/deps/v8/test/unittests/api/exception-unittest.cc b/deps/v8/test/unittests/api/exception-unittest.cc new file mode 100644 index 0000000000..b8f21cc4e2 --- /dev/null +++ b/deps/v8/test/unittests/api/exception-unittest.cc @@ -0,0 +1,45 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "include/v8.h" +#include "src/flags.h" +#include "test/unittests/test-utils.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace v8 { +namespace { + +using APIExceptionTest = TestWithIsolate; + +class ScopedExposeGc { + public: + ScopedExposeGc() : was_exposed_(i::FLAG_expose_gc) { + i::FLAG_expose_gc = true; + } + ~ScopedExposeGc() { i::FLAG_expose_gc = was_exposed_; } + + private: + const bool was_exposed_; +}; + +TEST_F(APIExceptionTest, ExceptionMessageDoesNotKeepContextAlive) { + ScopedExposeGc expose_gc; + Persistent<Context> weak_context; + { + HandleScope handle_scope(isolate()); + Local<Context> context = Context::New(isolate()); + weak_context.Reset(isolate(), context); + weak_context.SetWeak(); + + Context::Scope context_scope(context); + TryCatch try_catch(isolate()); + isolate()->ThrowException(Undefined(isolate())); + } + isolate()->RequestGarbageCollectionForTesting( + Isolate::kFullGarbageCollection); + EXPECT_TRUE(weak_context.IsEmpty()); +} + +} // namespace +} // namespace v8 diff --git a/deps/v8/test/unittests/api/isolate-unittest.cc b/deps/v8/test/unittests/api/isolate-unittest.cc new file mode 100644 index 0000000000..5a7c8e0cef --- /dev/null +++ b/deps/v8/test/unittests/api/isolate-unittest.cc @@ -0,0 +1,73 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "testing/gtest/include/gtest/gtest.h" + +#include "include/libplatform/libplatform.h" +#include "include/v8-platform.h" +#include "include/v8.h" +#include "src/base/macros.h" +#include "src/base/platform/semaphore.h" +#include "src/execution.h" +#include "src/isolate.h" +#include "src/v8.h" +#include "test/unittests/test-utils.h" + +namespace v8 { + +typedef TestWithIsolate IsolateTest; + +namespace { + +class MemoryPressureTask : public v8::Task { + public: + MemoryPressureTask(Isolate* isolate, base::Semaphore* semaphore) + : isolate_(isolate), semaphore_(semaphore) {} + ~MemoryPressureTask() override = default; + + // v8::Task implementation. + void Run() override { + isolate_->MemoryPressureNotification(MemoryPressureLevel::kCritical); + semaphore_->Signal(); + } + + private: + Isolate* isolate_; + base::Semaphore* semaphore_; + + DISALLOW_COPY_AND_ASSIGN(MemoryPressureTask); +}; + +} // namespace + +// Check that triggering a memory pressure notification on the isolate thread +// doesn't request a GC interrupt. +TEST_F(IsolateTest, MemoryPressureNotificationForeground) { + internal::Isolate* i_isolate = + reinterpret_cast<internal::Isolate*>(isolate()); + + ASSERT_FALSE(i_isolate->stack_guard()->CheckGC()); + isolate()->MemoryPressureNotification(MemoryPressureLevel::kCritical); + ASSERT_FALSE(i_isolate->stack_guard()->CheckGC()); +} + +// Check that triggering a memory pressure notification on an background thread +// requests a GC interrupt. +TEST_F(IsolateTest, MemoryPressureNotificationBackground) { + internal::Isolate* i_isolate = + reinterpret_cast<internal::Isolate*>(isolate()); + + base::Semaphore semaphore(0); + + internal::V8::GetCurrentPlatform()->CallOnBackgroundThread( + new MemoryPressureTask(isolate(), &semaphore), + v8::Platform::kShortRunningTask); + + semaphore.Wait(); + + ASSERT_TRUE(i_isolate->stack_guard()->CheckGC()); + v8::platform::PumpMessageLoop(internal::V8::GetCurrentPlatform(), isolate()); +} + +} // namespace v8 diff --git a/deps/v8/test/unittests/api/remote-object-unittest.cc b/deps/v8/test/unittests/api/remote-object-unittest.cc new file mode 100644 index 0000000000..1c58b418ff --- /dev/null +++ b/deps/v8/test/unittests/api/remote-object-unittest.cc @@ -0,0 +1,97 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "testing/gtest/include/gtest/gtest.h" + +#include "include/v8.h" +#include "test/unittests/test-utils.h" + +namespace v8 { + +typedef TestWithIsolate RemoteObjectTest; + +namespace { + +bool AccessCheck(Local<Context> accessing_context, + Local<Object> accessed_object, Local<Value> data) { + return false; +} + +void NamedGetter(Local<Name> property, + const PropertyCallbackInfo<Value>& info) {} + +void Constructor(const FunctionCallbackInfo<Value>& info) { + ASSERT_TRUE(info.IsConstructCall()); +} + +} // namespace + +TEST_F(RemoteObjectTest, CreationContextOfRemoteContext) { + Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate()); + global_template->SetAccessCheckCallbackAndHandler( + AccessCheck, NamedPropertyHandlerConfiguration(NamedGetter), + IndexedPropertyHandlerConfiguration()); + + Local<Object> remote_context = + Context::NewRemoteContext(isolate(), global_template).ToLocalChecked(); + EXPECT_TRUE(remote_context->CreationContext().IsEmpty()); +} + +TEST_F(RemoteObjectTest, CreationContextOfRemoteObject) { + Local<FunctionTemplate> constructor_template = + FunctionTemplate::New(isolate(), Constructor); + constructor_template->InstanceTemplate()->SetAccessCheckCallbackAndHandler( + AccessCheck, NamedPropertyHandlerConfiguration(NamedGetter), + IndexedPropertyHandlerConfiguration()); + + Local<Object> remote_object = + constructor_template->NewRemoteInstance().ToLocalChecked(); + EXPECT_TRUE(remote_object->CreationContext().IsEmpty()); +} + +TEST_F(RemoteObjectTest, RemoteContextInstanceChecks) { + Local<FunctionTemplate> parent_template = + FunctionTemplate::New(isolate(), Constructor); + + Local<FunctionTemplate> constructor_template = + FunctionTemplate::New(isolate(), Constructor); + constructor_template->InstanceTemplate()->SetAccessCheckCallbackAndHandler( + AccessCheck, NamedPropertyHandlerConfiguration(NamedGetter), + IndexedPropertyHandlerConfiguration()); + constructor_template->Inherit(parent_template); + + Local<Object> remote_context = + Context::NewRemoteContext(isolate(), + constructor_template->InstanceTemplate()) + .ToLocalChecked(); + EXPECT_TRUE(parent_template->HasInstance(remote_context)); + EXPECT_TRUE(constructor_template->HasInstance(remote_context)); +} + +TEST_F(RemoteObjectTest, TypeOfRemoteContext) { + Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate()); + global_template->SetAccessCheckCallbackAndHandler( + AccessCheck, NamedPropertyHandlerConfiguration(NamedGetter), + IndexedPropertyHandlerConfiguration()); + + Local<Object> remote_context = + Context::NewRemoteContext(isolate(), global_template).ToLocalChecked(); + String::Utf8Value result(remote_context->TypeOf(isolate())); + EXPECT_STREQ("object", *result); +} + +TEST_F(RemoteObjectTest, TypeOfRemoteObject) { + Local<FunctionTemplate> constructor_template = + FunctionTemplate::New(isolate(), Constructor); + constructor_template->InstanceTemplate()->SetAccessCheckCallbackAndHandler( + AccessCheck, NamedPropertyHandlerConfiguration(NamedGetter), + IndexedPropertyHandlerConfiguration()); + + Local<Object> remote_object = + constructor_template->NewRemoteInstance().ToLocalChecked(); + String::Utf8Value result(remote_object->TypeOf(isolate())); + EXPECT_STREQ("object", *result); +} + +} // namespace v8 diff --git a/deps/v8/test/unittests/api/v8-object-unittest.cc b/deps/v8/test/unittests/api/v8-object-unittest.cc new file mode 100644 index 0000000000..2e7ab350ea --- /dev/null +++ b/deps/v8/test/unittests/api/v8-object-unittest.cc @@ -0,0 +1,37 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "include/v8.h" +#include "test/unittests/test-utils.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace v8 { +namespace { + +using ObjectTest = TestWithContext; + +void accessor_name_getter_callback(Local<Name>, + const PropertyCallbackInfo<Value>&) {} + +TEST_F(ObjectTest, SetAccessorWhenUnconfigurablePropAlreadyDefined) { + TryCatch try_catch(isolate()); + + Local<Object> global = context()->Global(); + Local<String> property_name = + String::NewFromUtf8(isolate(), "foo", NewStringType::kNormal) + .ToLocalChecked(); + + PropertyDescriptor prop_desc; + prop_desc.set_configurable(false); + global->DefineProperty(context(), property_name, prop_desc).ToChecked(); + + Maybe<bool> result = global->SetAccessor(context(), property_name, + accessor_name_getter_callback); + ASSERT_TRUE(result.IsJust()); + ASSERT_FALSE(result.FromJust()); + ASSERT_FALSE(try_catch.HasCaught()); +} + +} // namespace +} // namespace v8 diff --git a/deps/v8/test/unittests/base/logging-unittest.cc b/deps/v8/test/unittests/base/logging-unittest.cc index 5c0ca007c4..e59456f4fc 100644 --- a/deps/v8/test/unittests/base/logging-unittest.cc +++ b/deps/v8/test/unittests/base/logging-unittest.cc @@ -63,5 +63,24 @@ TEST(LoggingTest, CompareAgainstStaticConstPointer) { CHECK_SUCCEED(GT, 0, v8::internal::Smi::kMinValue); } +TEST(LoggingTest, CompareWithDifferentSignedness) { +#define CHECK_BOTH(name, lhs, rhs) \ + CHECK_##name(lhs, rhs); \ + DCHECK_##name(lhs, rhs) + + int32_t i32 = 10; + uint32_t u32 = 20; + int64_t i64 = 30; + uint64_t u64 = 40; + + // All these checks should compile (!) and succeed. + CHECK_BOTH(EQ, i32 + 10, u32); + CHECK_BOTH(LT, i32, u64); + CHECK_BOTH(LE, u32, i64); + CHECK_BOTH(IMPLIES, i32, i64); + CHECK_BOTH(IMPLIES, u32, i64); + CHECK_BOTH(IMPLIES, !u32, !i64); +} + } // namespace base } // namespace v8 diff --git a/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc b/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc index ca9f44725b..538a5ebb12 100644 --- a/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc +++ b/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc @@ -112,7 +112,9 @@ TEST_F(CompilerDispatcherJobTest, StateTransitions) { job->Parse(); ASSERT_TRUE(job->status() == CompileJobStatus::kParsed); ASSERT_TRUE(job->FinalizeParsingOnMainThread()); - ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToAnalyse); + ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToAnalyze); + ASSERT_TRUE(job->AnalyzeOnMainThread()); + ASSERT_TRUE(job->status() == CompileJobStatus::kAnalyzed); ASSERT_TRUE(job->PrepareToCompileOnMainThread()); ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToCompile); job->Compile(); @@ -153,6 +155,7 @@ TEST_F(CompilerDispatcherJobTest, ScopeChain) { job->PrepareToParseOnMainThread(); job->Parse(); ASSERT_TRUE(job->FinalizeParsingOnMainThread()); + ASSERT_TRUE(job->AnalyzeOnMainThread()); ASSERT_TRUE(job->PrepareToCompileOnMainThread()); ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToCompile); @@ -189,6 +192,7 @@ TEST_F(CompilerDispatcherJobTest, CompileAndRun) { job->PrepareToParseOnMainThread(); job->Parse(); job->FinalizeParsingOnMainThread(); + job->AnalyzeOnMainThread(); job->PrepareToCompileOnMainThread(); job->Compile(); ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); @@ -201,7 +205,7 @@ TEST_F(CompilerDispatcherJobTest, CompileAndRun) { ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); } -TEST_F(CompilerDispatcherJobTest, CompileFailureToPrepare) { +TEST_F(CompilerDispatcherJobTest, CompileFailureToAnalyse) { std::string raw_script("() { var a = "); for (int i = 0; i < 100000; i++) { raw_script += "'x' + "; @@ -215,7 +219,7 @@ TEST_F(CompilerDispatcherJobTest, CompileFailureToPrepare) { job->PrepareToParseOnMainThread(); job->Parse(); job->FinalizeParsingOnMainThread(); - ASSERT_FALSE(job->PrepareToCompileOnMainThread()); + ASSERT_FALSE(job->AnalyzeOnMainThread()); ASSERT_TRUE(job->status() == CompileJobStatus::kFailed); ASSERT_TRUE(i_isolate()->has_pending_exception()); @@ -238,6 +242,7 @@ TEST_F(CompilerDispatcherJobTest, CompileFailureToFinalize) { job->PrepareToParseOnMainThread(); job->Parse(); job->FinalizeParsingOnMainThread(); + job->AnalyzeOnMainThread(); job->PrepareToCompileOnMainThread(); job->Compile(); ASSERT_FALSE(job->FinalizeCompilingOnMainThread()); @@ -282,6 +287,7 @@ TEST_F(CompilerDispatcherJobTest, CompileOnBackgroundThread) { job->PrepareToParseOnMainThread(); job->Parse(); job->FinalizeParsingOnMainThread(); + job->AnalyzeOnMainThread(); job->PrepareToCompileOnMainThread(); base::Semaphore semaphore(0); @@ -314,6 +320,7 @@ TEST_F(CompilerDispatcherJobTest, LazyInnerFunctions) { job->PrepareToParseOnMainThread(); job->Parse(); ASSERT_TRUE(job->FinalizeParsingOnMainThread()); + ASSERT_TRUE(job->AnalyzeOnMainThread()); ASSERT_TRUE(job->PrepareToCompileOnMainThread()); job->Compile(); ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); diff --git a/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc b/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc index 8e47c48866..f1f6f9997c 100644 --- a/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc +++ b/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc @@ -5,12 +5,16 @@ #include "src/compiler-dispatcher/compiler-dispatcher.h" #include "include/v8-platform.h" +#include "src/api.h" #include "src/base/platform/semaphore.h" #include "src/compiler-dispatcher/compiler-dispatcher-job.h" #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" +#include "src/compiler.h" #include "src/flags.h" #include "src/handles.h" #include "src/objects-inl.h" +#include "src/parsing/parse-info.h" +#include "src/parsing/parsing.h" #include "src/v8.h" #include "test/unittests/compiler-dispatcher/compiler-dispatcher-helper.h" #include "test/unittests/test-utils.h" @@ -19,34 +23,67 @@ namespace v8 { namespace internal { +class CompilerDispatcherTestFlags { + public: + static void SetFlagsForTest() { + old_compiler_dispatcher_flag_ = i::FLAG_compiler_dispatcher; + i::FLAG_compiler_dispatcher = true; + old_ignition_flag_ = i::FLAG_ignition; + i::FLAG_ignition = true; + } + + static void RestoreFlags() { + i::FLAG_compiler_dispatcher = old_compiler_dispatcher_flag_; + i::FLAG_ignition = old_ignition_flag_; + } + + private: + static bool old_compiler_dispatcher_flag_; + static bool old_ignition_flag_; + + DISALLOW_IMPLICIT_CONSTRUCTORS(CompilerDispatcherTestFlags); +}; + +bool CompilerDispatcherTestFlags::old_compiler_dispatcher_flag_; +bool CompilerDispatcherTestFlags::old_ignition_flag_; + class CompilerDispatcherTest : public TestWithContext { public: CompilerDispatcherTest() = default; ~CompilerDispatcherTest() override = default; static void SetUpTestCase() { - old_flag_ = i::FLAG_ignition; - i::FLAG_compiler_dispatcher = true; - old_ignition_flag_ = i::FLAG_ignition; - i::FLAG_ignition = true; + CompilerDispatcherTestFlags::SetFlagsForTest(); TestWithContext::SetUpTestCase(); } static void TearDownTestCase() { TestWithContext::TearDownTestCase(); - i::FLAG_compiler_dispatcher = old_flag_; - i::FLAG_ignition = old_ignition_flag_; + CompilerDispatcherTestFlags::RestoreFlags(); } private: - static bool old_flag_; - static bool old_ignition_flag_; - DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherTest); }; -bool CompilerDispatcherTest::old_flag_; -bool CompilerDispatcherTest::old_ignition_flag_; +class CompilerDispatcherTestWithoutContext : public v8::TestWithIsolate { + public: + CompilerDispatcherTestWithoutContext() = default; + ~CompilerDispatcherTestWithoutContext() override = default; + + static void SetUpTestCase() { + CompilerDispatcherTestFlags::SetFlagsForTest(); + TestWithContext::SetUpTestCase(); + } + + static void TearDownTestCase() { + TestWithContext::TearDownTestCase(); + CompilerDispatcherTestFlags::RestoreFlags(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherTestWithoutContext); +}; namespace { @@ -802,5 +839,268 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStep) { platform.ClearBackgroundTasks(); } +TEST_F(CompilerDispatcherTest, EnqueueParsed) { + MockPlatform platform; + CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size); + + const char source[] = + "function g() { var y = 1; function f17(x) { return x * y }; return f17; " + "} g();"; + Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), source)); + Handle<SharedFunctionInfo> shared(f->shared(), i_isolate()); + Handle<Script> script(Script::cast(shared->script()), i_isolate()); + + ParseInfo parse_info(shared); + ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info)); + std::shared_ptr<DeferredHandles> handles; + + ASSERT_FALSE(dispatcher.IsEnqueued(shared)); + ASSERT_TRUE(dispatcher.Enqueue(script, shared, parse_info.literal(), + parse_info.zone_shared(), handles, handles)); + ASSERT_TRUE(dispatcher.IsEnqueued(shared)); + + ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() == + CompileJobStatus::kAnalyzed); + + ASSERT_TRUE(platform.IdleTaskPending()); + platform.ClearIdleTask(); + ASSERT_FALSE(platform.BackgroundTasksPending()); +} + +TEST_F(CompilerDispatcherTest, EnqueueAndStepParsed) { + MockPlatform platform; + CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size); + + const char source[] = + "function g() { var y = 1; function f18(x) { return x * y }; return f18; " + "} g();"; + Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), source)); + Handle<SharedFunctionInfo> shared(f->shared(), i_isolate()); + Handle<Script> script(Script::cast(shared->script()), i_isolate()); + + ParseInfo parse_info(shared); + ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info)); + std::shared_ptr<DeferredHandles> handles; + + ASSERT_FALSE(dispatcher.IsEnqueued(shared)); + ASSERT_TRUE(dispatcher.EnqueueAndStep(script, shared, parse_info.literal(), + parse_info.zone_shared(), handles, + handles)); + ASSERT_TRUE(dispatcher.IsEnqueued(shared)); + + ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() == + CompileJobStatus::kReadyToCompile); + + ASSERT_TRUE(platform.IdleTaskPending()); + ASSERT_TRUE(platform.BackgroundTasksPending()); + platform.ClearIdleTask(); + platform.ClearBackgroundTasks(); +} + +TEST_F(CompilerDispatcherTest, CompileParsedOutOfScope) { + MockPlatform platform; + CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size); + + const char source[] = + "function g() { var y = 1; function f20(x) { return x + y }; return f20; " + "} g();"; + Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), source)); + Handle<SharedFunctionInfo> shared(f->shared(), i_isolate()); + Handle<Script> script(Script::cast(shared->script()), i_isolate()); + + { + HandleScope scope(i_isolate()); // Create handles scope for parsing. + + ASSERT_FALSE(shared->is_compiled()); + ParseInfo parse_info(shared); + + ASSERT_TRUE(parsing::ParseAny(&parse_info)); + DeferredHandleScope handles_scope(i_isolate()); + { ASSERT_TRUE(Compiler::Analyze(&parse_info)); } + std::shared_ptr<DeferredHandles> compilation_handles( + handles_scope.Detach()); + + ASSERT_FALSE(platform.IdleTaskPending()); + ASSERT_TRUE(dispatcher.Enqueue( + script, shared, parse_info.literal(), parse_info.zone_shared(), + parse_info.deferred_handles(), compilation_handles)); + ASSERT_TRUE(platform.IdleTaskPending()); + } + // Exit the handles scope and destroy ParseInfo before running the idle task. + + // Since time doesn't progress on the MockPlatform, this is enough idle time + // to finish compiling the function. + platform.RunIdleTask(1000.0, 0.0); + + ASSERT_FALSE(dispatcher.IsEnqueued(shared)); + ASSERT_TRUE(shared->is_compiled()); +} + +namespace { + +const char kExtensionSource[] = "native function Dummy();"; + +class MockNativeFunctionExtension : public Extension { + public: + MockNativeFunctionExtension() + : Extension("mock-extension", kExtensionSource), function_(&Dummy) {} + + virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( + v8::Isolate* isolate, v8::Local<v8::String> name) { + return v8::FunctionTemplate::New(isolate, function_); + } + + static void Dummy(const v8::FunctionCallbackInfo<v8::Value>& args) { return; } + + private: + v8::FunctionCallback function_; + + DISALLOW_COPY_AND_ASSIGN(MockNativeFunctionExtension); +}; + +} // namespace + +TEST_F(CompilerDispatcherTestWithoutContext, CompileExtensionWithoutContext) { + MockPlatform platform; + CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size); + Local<v8::Context> context = v8::Context::New(isolate()); + + MockNativeFunctionExtension extension; + Handle<String> script_str = + i_isolate() + ->factory() + ->NewStringFromUtf8(CStrVector(kExtensionSource)) + .ToHandleChecked(); + Handle<Script> script = i_isolate()->factory()->NewScript(script_str); + script->set_type(Script::TYPE_EXTENSION); + + Handle<SharedFunctionInfo> shared; + { + v8::Context::Scope scope(context); + + ParseInfo parse_info(script); + parse_info.set_extension(&extension); + + ASSERT_TRUE(parsing::ParseAny(&parse_info)); + Handle<FixedArray> shared_infos_array(i_isolate()->factory()->NewFixedArray( + parse_info.max_function_literal_id() + 1)); + parse_info.script()->set_shared_function_infos(*shared_infos_array); + DeferredHandleScope handles_scope(i_isolate()); + { ASSERT_TRUE(Compiler::Analyze(&parse_info)); } + std::shared_ptr<DeferredHandles> compilation_handles( + handles_scope.Detach()); + + shared = i_isolate()->factory()->NewSharedFunctionInfoForLiteral( + parse_info.literal(), script); + parse_info.set_shared_info(shared); + + ASSERT_FALSE(platform.IdleTaskPending()); + ASSERT_TRUE(dispatcher.Enqueue( + script, shared, parse_info.literal(), parse_info.zone_shared(), + parse_info.deferred_handles(), compilation_handles)); + ASSERT_TRUE(platform.IdleTaskPending()); + } + // Exit the context scope before running the idle task. + + // Since time doesn't progress on the MockPlatform, this is enough idle time + // to finish compiling the function. + platform.RunIdleTask(1000.0, 0.0); + + ASSERT_FALSE(dispatcher.IsEnqueued(shared)); + ASSERT_TRUE(shared->is_compiled()); +} + +TEST_F(CompilerDispatcherTest, CompileLazyFinishesDispatcherJob) { + // Use the real dispatcher so that CompileLazy checks the same one for + // enqueued functions. + CompilerDispatcher* dispatcher = i_isolate()->compiler_dispatcher(); + + const char source[] = + "function g() { var y = 1; function f16(x) { return x * y }; return f16; " + "} g();"; + Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), source)); + Handle<SharedFunctionInfo> shared(f->shared(), i_isolate()); + + ASSERT_FALSE(shared->is_compiled()); + ASSERT_FALSE(dispatcher->IsEnqueued(shared)); + ASSERT_TRUE(dispatcher->Enqueue(shared)); + ASSERT_TRUE(dispatcher->IsEnqueued(shared)); + + // Now force the function to run and ensure CompileLazy finished and dequeues + // it from the dispatcher. + RunJS(isolate(), "g()();"); + ASSERT_TRUE(shared->is_compiled()); + ASSERT_FALSE(dispatcher->IsEnqueued(shared)); +} + +TEST_F(CompilerDispatcherTest, CompileLazy2FinishesDispatcherJob) { + // Use the real dispatcher so that CompileLazy checks the same one for + // enqueued functions. + CompilerDispatcher* dispatcher = i_isolate()->compiler_dispatcher(); + + const char source2[] = "function lazy2() { return 42; }; lazy2;"; + Handle<JSFunction> lazy2 = + Handle<JSFunction>::cast(RunJS(isolate(), source2)); + Handle<SharedFunctionInfo> shared2(lazy2->shared(), i_isolate()); + ASSERT_FALSE(shared2->is_compiled()); + + const char source1[] = "function lazy1() { return lazy2(); }; lazy1;"; + Handle<JSFunction> lazy1 = + Handle<JSFunction>::cast(RunJS(isolate(), source1)); + Handle<SharedFunctionInfo> shared1(lazy1->shared(), i_isolate()); + ASSERT_FALSE(shared1->is_compiled()); + + ASSERT_TRUE(dispatcher->Enqueue(shared1)); + ASSERT_TRUE(dispatcher->Enqueue(shared2)); + + RunJS(isolate(), "lazy1();"); + ASSERT_TRUE(shared1->is_compiled()); + ASSERT_TRUE(shared2->is_compiled()); + ASSERT_FALSE(dispatcher->IsEnqueued(shared1)); + ASSERT_FALSE(dispatcher->IsEnqueued(shared2)); +} + +TEST_F(CompilerDispatcherTest, EnqueueAndStepTwice) { + MockPlatform platform; + CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size); + + const char source[] = + "function g() { var y = 1; function f18(x) { return x * y }; return f18; " + "} g();"; + Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), source)); + Handle<SharedFunctionInfo> shared(f->shared(), i_isolate()); + Handle<Script> script(Script::cast(shared->script()), i_isolate()); + + ParseInfo parse_info(shared); + ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info)); + std::shared_ptr<DeferredHandles> handles; + + ASSERT_FALSE(dispatcher.IsEnqueued(shared)); + ASSERT_TRUE(dispatcher.EnqueueAndStep(script, shared, parse_info.literal(), + parse_info.zone_shared(), handles, + handles)); + ASSERT_TRUE(dispatcher.IsEnqueued(shared)); + + ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() == + CompileJobStatus::kReadyToCompile); + + // EnqueueAndStep of the same function again (either already parsed or for + // compile and parse) shouldn't step the job. + ASSERT_TRUE(dispatcher.EnqueueAndStep(script, shared, parse_info.literal(), + parse_info.zone_shared(), handles, + handles)); + ASSERT_TRUE(dispatcher.IsEnqueued(shared)); + ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() == + CompileJobStatus::kReadyToCompile); + ASSERT_TRUE(dispatcher.EnqueueAndStep(shared)); + ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() == + CompileJobStatus::kReadyToCompile); + + ASSERT_TRUE(platform.IdleTaskPending()); + ASSERT_TRUE(platform.BackgroundTasksPending()); + platform.ClearIdleTask(); + platform.ClearBackgroundTasks(); +} + } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc b/deps/v8/test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc new file mode 100644 index 0000000000..aeb80e7fd4 --- /dev/null +++ b/deps/v8/test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc @@ -0,0 +1,95 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" + +#include "src/base/atomic-utils.h" +#include "src/base/platform/semaphore.h" +#include "src/compilation-info.h" +#include "src/compiler.h" +#include "src/handles.h" +#include "src/isolate.h" +#include "src/objects-inl.h" +#include "src/parsing/parse-info.h" +#include "test/unittests/compiler-dispatcher/compiler-dispatcher-helper.h" +#include "test/unittests/test-utils.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace v8 { +namespace internal { + +typedef TestWithContext OptimizingCompileDispatcherTest; + +namespace { + +class BlockingCompilationJob : public CompilationJob { + public: + BlockingCompilationJob(Isolate* isolate, Handle<JSFunction> function) + : CompilationJob(isolate, &info_, "BlockingCompilationJob", + State::kReadyToExecute), + parse_info_(handle(function->shared())), + info_(parse_info_.zone(), &parse_info_, function), + blocking_(false), + semaphore_(0) {} + ~BlockingCompilationJob() override = default; + + bool IsBlocking() const { return blocking_.Value(); } + void Signal() { semaphore_.Signal(); } + + // CompilationJob implementation. + Status PrepareJobImpl() override { + UNREACHABLE(); + return FAILED; + } + + Status ExecuteJobImpl() override { + blocking_.SetValue(true); + semaphore_.Wait(); + blocking_.SetValue(false); + return SUCCEEDED; + } + + Status FinalizeJobImpl() override { return SUCCEEDED; } + + private: + ParseInfo parse_info_; + CompilationInfo info_; + base::AtomicValue<bool> blocking_; + base::Semaphore semaphore_; + + DISALLOW_COPY_AND_ASSIGN(BlockingCompilationJob); +}; + +} // namespace + +TEST_F(OptimizingCompileDispatcherTest, Construct) { + OptimizingCompileDispatcher dispatcher(i_isolate()); + ASSERT_TRUE(OptimizingCompileDispatcher::Enabled()); + ASSERT_TRUE(dispatcher.IsQueueAvailable()); +} + +TEST_F(OptimizingCompileDispatcherTest, NonBlockingFlush) { + Handle<JSFunction> fun = Handle<JSFunction>::cast( + RunJS(isolate(), "function f() { function g() {}; return g;}; f();")); + BlockingCompilationJob* job = new BlockingCompilationJob(i_isolate(), fun); + + OptimizingCompileDispatcher dispatcher(i_isolate()); + ASSERT_TRUE(OptimizingCompileDispatcher::Enabled()); + ASSERT_TRUE(dispatcher.IsQueueAvailable()); + dispatcher.QueueForOptimization(job); + + // Busy-wait for the job to run on a background thread. + while (!job->IsBlocking()) { + } + + // Should not block. + dispatcher.Flush(OptimizingCompileDispatcher::BlockingBehavior::kDontBlock); + + // Unblock the job & finish. + job->Signal(); + dispatcher.Stop(); +} + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc b/deps/v8/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc index 7892c4bbb9..fe62996b75 100644 --- a/deps/v8/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc +++ b/deps/v8/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc @@ -745,7 +745,7 @@ TEST_F(InstructionSelectorTest, SubZeroOnLeftWithShift) { EXPECT_TRUE(s[0]->InputAt(0)->IsImmediate()); EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(0))); EXPECT_EQ(shift.mode, s[0]->addressing_mode()); - EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); + EXPECT_EQ(0x3f & imm, 0x3f & s.ToInt32(s[0]->InputAt(2))); EXPECT_EQ(1U, s[0]->OutputCount()); } } @@ -771,7 +771,7 @@ TEST_F(InstructionSelectorTest, SubZeroOnLeftWithShift) { EXPECT_TRUE(s[0]->InputAt(0)->IsImmediate()); EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(0))); EXPECT_EQ(shift.mode, s[0]->addressing_mode()); - EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); + EXPECT_EQ(0x3f & imm, 0x3f & s.ToInt32(s[0]->InputAt(2))); EXPECT_EQ(1U, s[0]->OutputCount()); } } @@ -835,7 +835,7 @@ TEST_F(InstructionSelectorTest, AddShiftByImmediateOnLeft) { EXPECT_EQ(kArm64Add32, s[0]->arch_opcode()); EXPECT_EQ(shift.mode, s[0]->addressing_mode()); EXPECT_EQ(3U, s[0]->InputCount()); - EXPECT_EQ(imm, s.ToInt64(s[0]->InputAt(2))); + EXPECT_EQ(0x3f & imm, 0x3f & s.ToInt64(s[0]->InputAt(2))); EXPECT_EQ(1U, s[0]->OutputCount()); } } @@ -859,7 +859,7 @@ TEST_F(InstructionSelectorTest, AddShiftByImmediateOnLeft) { EXPECT_EQ(kArm64Add, s[0]->arch_opcode()); EXPECT_EQ(shift.mode, s[0]->addressing_mode()); EXPECT_EQ(3U, s[0]->InputCount()); - EXPECT_EQ(imm, s.ToInt64(s[0]->InputAt(2))); + EXPECT_EQ(0x3f & imm, 0x3f & s.ToInt64(s[0]->InputAt(2))); EXPECT_EQ(1U, s[0]->OutputCount()); } } @@ -2924,7 +2924,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithWord32Shift) { ASSERT_EQ(3U, s[0]->InputCount()); EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); - EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); + EXPECT_EQ(0x3f & imm, 0x3f & s.ToInt32(s[0]->InputAt(2))); ASSERT_EQ(1U, s[0]->OutputCount()); } TRACED_FORRANGE(int32_t, imm, -32, 63) { @@ -2941,7 +2941,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithWord32Shift) { ASSERT_EQ(3U, s[0]->InputCount()); EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); - EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); + EXPECT_EQ(0x3f & imm, 0x3f & s.ToInt32(s[0]->InputAt(2))); ASSERT_EQ(1U, s[0]->OutputCount()); } } @@ -3203,7 +3203,7 @@ TEST_F(InstructionSelectorTest, Word32CompareNegateWithWord32Shift) { EXPECT_EQ(kArm64Cmn32, s[0]->arch_opcode()); EXPECT_EQ(3U, s[0]->InputCount()); EXPECT_EQ(shift.mode, s[0]->addressing_mode()); - EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); + EXPECT_EQ(0x3f & imm, 0x3f & s.ToInt32(s[0]->InputAt(2))); EXPECT_EQ(1U, s[0]->OutputCount()); EXPECT_EQ(kFlags_set, s[0]->flags_mode()); EXPECT_EQ(cmp.cond, s[0]->flags_condition()); @@ -3311,7 +3311,7 @@ TEST_F(InstructionSelectorTest, CmpShiftByImmediateOnLeft) { EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); EXPECT_EQ(shift.mode, s[0]->addressing_mode()); EXPECT_EQ(3U, s[0]->InputCount()); - EXPECT_EQ(imm, s.ToInt64(s[0]->InputAt(2))); + EXPECT_EQ(0x3f & imm, 0x3f & s.ToInt64(s[0]->InputAt(2))); EXPECT_EQ(1U, s[0]->OutputCount()); EXPECT_EQ(kFlags_set, s[0]->flags_mode()); EXPECT_EQ(cmp.commuted_cond, s[0]->flags_condition()); @@ -3345,7 +3345,7 @@ TEST_F(InstructionSelectorTest, CmnShiftByImmediateOnLeft) { EXPECT_EQ(kArm64Cmn32, s[0]->arch_opcode()); EXPECT_EQ(shift.mode, s[0]->addressing_mode()); EXPECT_EQ(3U, s[0]->InputCount()); - EXPECT_EQ(imm, s.ToInt64(s[0]->InputAt(2))); + EXPECT_EQ(0x3f & imm, 0x3f & s.ToInt64(s[0]->InputAt(2))); EXPECT_EQ(1U, s[0]->OutputCount()); EXPECT_EQ(kFlags_set, s[0]->flags_mode()); EXPECT_EQ(cmp.cond, s[0]->flags_condition()); diff --git a/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc b/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc index 7b4150ec0c..6beb8171c9 100644 --- a/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc +++ b/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc @@ -9,6 +9,7 @@ #include "src/compiler/graph.h" #include "src/compiler/schedule.h" #include "src/flags.h" +#include "src/objects-inl.h" #include "test/unittests/compiler/compiler-test-utils.h" namespace v8 { diff --git a/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc b/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc index 83c8d003db..6e79c0a031 100644 --- a/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc +++ b/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc @@ -10,6 +10,7 @@ #include "src/compiler/node-properties.h" +#include "src/objects-inl.h" #include "src/signature.h" #include "src/wasm/wasm-module.h" @@ -237,6 +238,38 @@ TEST_F(Int64LoweringTest, Int64Store) { INT64_STORE_LOWERING(Store, rep32, rep64); } +TEST_F(Int64LoweringTest, Int32Store) { + const StoreRepresentation rep32(MachineRepresentation::kWord32, + WriteBarrierKind::kNoWriteBarrier); + int32_t base = 1111; + int32_t index = 2222; + int32_t return_value = 0x5555; + + Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 0); + sig_builder.AddReturn(MachineRepresentation::kWord32); + + Node* store = graph()->NewNode(machine()->Store(rep32), Int32Constant(base), + Int32Constant(index), Int64Constant(value(0)), + start(), start()); + + Node* zero = graph()->NewNode(common()->Int32Constant(0)); + Node* ret = graph()->NewNode(common()->Return(), zero, + Int32Constant(return_value), store, start()); + + NodeProperties::MergeControlToEnd(graph(), common(), ret); + + Int64Lowering lowering(graph(), machine(), common(), zone(), + sig_builder.Build()); + lowering.LowerGraph(); + + EXPECT_THAT( + graph()->end()->InputAt(1), + IsReturn(IsInt32Constant(return_value), + IsStore(rep32, IsInt32Constant(base), IsInt32Constant(index), + IsInt32Constant(low_word_value(0)), start(), start()), + start())); +} + TEST_F(Int64LoweringTest, Int64UnalignedStore) { const UnalignedStoreRepresentation rep64(MachineRepresentation::kWord64); const UnalignedStoreRepresentation rep32(MachineRepresentation::kWord32); diff --git a/deps/v8/test/unittests/compiler/js-builtin-reducer-unittest.cc b/deps/v8/test/unittests/compiler/js-builtin-reducer-unittest.cc index e3857ef526..a4332042cb 100644 --- a/deps/v8/test/unittests/compiler/js-builtin-reducer-unittest.cc +++ b/deps/v8/test/unittests/compiler/js-builtin-reducer-unittest.cc @@ -123,9 +123,9 @@ TEST_F(JSBuiltinReducerTest, GlobalIsFiniteWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -142,9 +142,9 @@ TEST_F(JSBuiltinReducerTest, GlobalIsFiniteWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -167,9 +167,9 @@ TEST_F(JSBuiltinReducerTest, GlobalIsNaNWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -185,9 +185,9 @@ TEST_F(JSBuiltinReducerTest, GlobalIsNaNWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -208,9 +208,9 @@ TEST_F(JSBuiltinReducerTest, MathAbsWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -226,9 +226,9 @@ TEST_F(JSBuiltinReducerTest, MathAbsWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -247,9 +247,9 @@ TEST_F(JSBuiltinReducerTest, MathAcosWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -265,9 +265,9 @@ TEST_F(JSBuiltinReducerTest, MathAcosWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -286,9 +286,9 @@ TEST_F(JSBuiltinReducerTest, MathAcoshWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -304,9 +304,9 @@ TEST_F(JSBuiltinReducerTest, MathAcoshWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -325,9 +325,9 @@ TEST_F(JSBuiltinReducerTest, MathAsinWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -343,9 +343,9 @@ TEST_F(JSBuiltinReducerTest, MathAsinWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -364,9 +364,9 @@ TEST_F(JSBuiltinReducerTest, MathAsinhWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -382,9 +382,9 @@ TEST_F(JSBuiltinReducerTest, MathAsinhWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -403,9 +403,9 @@ TEST_F(JSBuiltinReducerTest, MathAtanWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -421,9 +421,9 @@ TEST_F(JSBuiltinReducerTest, MathAtanWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -442,9 +442,9 @@ TEST_F(JSBuiltinReducerTest, MathAtanhWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -460,9 +460,9 @@ TEST_F(JSBuiltinReducerTest, MathAtanhWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -483,9 +483,9 @@ TEST_F(JSBuiltinReducerTest, MathAtan2WithNumber) { Node* p0 = Parameter(t0, 0); TRACED_FOREACH(Type*, t1, kNumberTypes) { Node* p1 = Parameter(t1, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(4), function, - UndefinedConstant(), p0, p1, context, - frame_state, effect, control); + Node* call = + graph()->NewNode(javascript()->Call(4), function, UndefinedConstant(), + p0, p1, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -503,9 +503,9 @@ TEST_F(JSBuiltinReducerTest, MathAtan2WithPlainPrimitive) { Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); Node* p1 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(4), function, - UndefinedConstant(), p0, p1, context, - frame_state, effect, control); + Node* call = + graph()->NewNode(javascript()->Call(4), function, UndefinedConstant(), p0, + p1, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -525,9 +525,9 @@ TEST_F(JSBuiltinReducerTest, MathCeilWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -543,9 +543,9 @@ TEST_F(JSBuiltinReducerTest, MathCeilWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -563,9 +563,9 @@ TEST_F(JSBuiltinReducerTest, MathClz32WithUnsigned32) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::Unsigned32(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -580,9 +580,9 @@ TEST_F(JSBuiltinReducerTest, MathClz32WithNumber) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::Number(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -597,9 +597,9 @@ TEST_F(JSBuiltinReducerTest, MathClz32WithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -619,9 +619,9 @@ TEST_F(JSBuiltinReducerTest, MathCosWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -637,9 +637,9 @@ TEST_F(JSBuiltinReducerTest, MathCosWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -658,9 +658,9 @@ TEST_F(JSBuiltinReducerTest, MathCoshWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -676,9 +676,9 @@ TEST_F(JSBuiltinReducerTest, MathCoshWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -697,9 +697,9 @@ TEST_F(JSBuiltinReducerTest, MathExpWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -715,9 +715,9 @@ TEST_F(JSBuiltinReducerTest, MathExpWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -736,9 +736,9 @@ TEST_F(JSBuiltinReducerTest, MathFloorWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -754,9 +754,9 @@ TEST_F(JSBuiltinReducerTest, MathFloorWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -775,9 +775,9 @@ TEST_F(JSBuiltinReducerTest, MathFroundWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -793,9 +793,9 @@ TEST_F(JSBuiltinReducerTest, MathFroundWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -814,9 +814,9 @@ TEST_F(JSBuiltinReducerTest, MathImulWithUnsigned32) { Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::Unsigned32(), 0); Node* p1 = Parameter(Type::Unsigned32(), 1); - Node* call = graph()->NewNode(javascript()->CallFunction(4), function, - UndefinedConstant(), p0, p1, context, - frame_state, effect, control); + Node* call = + graph()->NewNode(javascript()->Call(4), function, UndefinedConstant(), p0, + p1, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -832,9 +832,9 @@ TEST_F(JSBuiltinReducerTest, MathImulWithNumber) { Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::Number(), 0); Node* p1 = Parameter(Type::Number(), 1); - Node* call = graph()->NewNode(javascript()->CallFunction(4), function, - UndefinedConstant(), p0, p1, context, - frame_state, effect, control); + Node* call = + graph()->NewNode(javascript()->Call(4), function, UndefinedConstant(), p0, + p1, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -851,9 +851,9 @@ TEST_F(JSBuiltinReducerTest, MathImulWithPlainPrimitive) { Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); Node* p1 = Parameter(Type::PlainPrimitive(), 1); - Node* call = graph()->NewNode(javascript()->CallFunction(4), function, - UndefinedConstant(), p0, p1, context, - frame_state, effect, control); + Node* call = + graph()->NewNode(javascript()->Call(4), function, UndefinedConstant(), p0, + p1, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -874,9 +874,9 @@ TEST_F(JSBuiltinReducerTest, MathLogWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -892,9 +892,9 @@ TEST_F(JSBuiltinReducerTest, MathLogWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -913,9 +913,9 @@ TEST_F(JSBuiltinReducerTest, MathLog1pWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -931,9 +931,9 @@ TEST_F(JSBuiltinReducerTest, MathLog1pWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -950,9 +950,9 @@ TEST_F(JSBuiltinReducerTest, MathMaxWithNoArguments) { Node* control = graph()->start(); Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); - Node* call = graph()->NewNode(javascript()->CallFunction(2), function, - UndefinedConstant(), context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(2), function, UndefinedConstant(), + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -968,9 +968,9 @@ TEST_F(JSBuiltinReducerTest, MathMaxWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -987,9 +987,9 @@ TEST_F(JSBuiltinReducerTest, MathMaxWithPlainPrimitive) { Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); Node* p1 = Parameter(Type::PlainPrimitive(), 1); - Node* call = graph()->NewNode(javascript()->CallFunction(4), function, - UndefinedConstant(), p0, p1, context, - frame_state, effect, control); + Node* call = + graph()->NewNode(javascript()->Call(4), function, UndefinedConstant(), p0, + p1, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1007,9 +1007,9 @@ TEST_F(JSBuiltinReducerTest, MathMinWithNoArguments) { Node* control = graph()->start(); Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); - Node* call = graph()->NewNode(javascript()->CallFunction(2), function, - UndefinedConstant(), context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(2), function, UndefinedConstant(), + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1025,9 +1025,9 @@ TEST_F(JSBuiltinReducerTest, MathMinWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1044,9 +1044,9 @@ TEST_F(JSBuiltinReducerTest, MathMinWithPlainPrimitive) { Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); Node* p1 = Parameter(Type::PlainPrimitive(), 1); - Node* call = graph()->NewNode(javascript()->CallFunction(4), function, - UndefinedConstant(), p0, p1, context, - frame_state, effect, control); + Node* call = + graph()->NewNode(javascript()->Call(4), function, UndefinedConstant(), p0, + p1, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1066,9 +1066,9 @@ TEST_F(JSBuiltinReducerTest, MathRoundWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1084,9 +1084,9 @@ TEST_F(JSBuiltinReducerTest, MathRoundWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1107,9 +1107,9 @@ TEST_F(JSBuiltinReducerTest, MathPowWithNumber) { Node* p0 = Parameter(t0, 0); TRACED_FOREACH(Type*, t1, kNumberTypes) { Node* p1 = Parameter(t1, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(4), function, - UndefinedConstant(), p0, p1, context, - frame_state, effect, control); + Node* call = + graph()->NewNode(javascript()->Call(4), function, UndefinedConstant(), + p0, p1, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1127,9 +1127,9 @@ TEST_F(JSBuiltinReducerTest, MathPowWithPlainPrimitive) { Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); Node* p1 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(4), function, - UndefinedConstant(), p0, p1, context, - frame_state, effect, control); + Node* call = + graph()->NewNode(javascript()->Call(4), function, UndefinedConstant(), p0, + p1, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1149,9 +1149,9 @@ TEST_F(JSBuiltinReducerTest, MathSignWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1167,9 +1167,9 @@ TEST_F(JSBuiltinReducerTest, MathSignWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1188,9 +1188,9 @@ TEST_F(JSBuiltinReducerTest, MathSinWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1206,9 +1206,9 @@ TEST_F(JSBuiltinReducerTest, MathSinWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1227,9 +1227,9 @@ TEST_F(JSBuiltinReducerTest, MathSinhWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1245,9 +1245,9 @@ TEST_F(JSBuiltinReducerTest, MathSinhWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1266,9 +1266,9 @@ TEST_F(JSBuiltinReducerTest, MathSqrtWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1284,9 +1284,9 @@ TEST_F(JSBuiltinReducerTest, MathSqrtWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1305,9 +1305,9 @@ TEST_F(JSBuiltinReducerTest, MathTanWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1323,9 +1323,9 @@ TEST_F(JSBuiltinReducerTest, MathTanWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1344,9 +1344,9 @@ TEST_F(JSBuiltinReducerTest, MathTanhWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1362,9 +1362,9 @@ TEST_F(JSBuiltinReducerTest, MathTanhWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1383,9 +1383,9 @@ TEST_F(JSBuiltinReducerTest, MathTruncWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1401,9 +1401,9 @@ TEST_F(JSBuiltinReducerTest, MathTruncWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1422,9 +1422,9 @@ TEST_F(JSBuiltinReducerTest, NumberIsFiniteWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1445,9 +1445,9 @@ TEST_F(JSBuiltinReducerTest, NumberIsIntegerWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1469,9 +1469,9 @@ TEST_F(JSBuiltinReducerTest, NumberIsNaNWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1491,9 +1491,9 @@ TEST_F(JSBuiltinReducerTest, NumberIsSafeIntegerWithIntegral32) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kIntegral32Types) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1513,9 +1513,9 @@ TEST_F(JSBuiltinReducerTest, NumberParseIntWithIntegral32) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kIntegral32Types) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1533,9 +1533,9 @@ TEST_F(JSBuiltinReducerTest, NumberParseIntWithIntegral32AndUndefined) { TRACED_FOREACH(Type*, t0, kIntegral32Types) { Node* p0 = Parameter(t0, 0); Node* p1 = Parameter(Type::Undefined(), 1); - Node* call = graph()->NewNode(javascript()->CallFunction(4), function, - UndefinedConstant(), p0, p1, context, - frame_state, effect, control); + Node* call = + graph()->NewNode(javascript()->Call(4), function, UndefinedConstant(), + p0, p1, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1555,9 +1555,9 @@ TEST_F(JSBuiltinReducerTest, StringFromCharCodeWithNumber) { Node* frame_state = graph()->start(); TRACED_FOREACH(Type*, t0, kNumberTypes) { Node* p0 = Parameter(t0, 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), + p0, context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); @@ -1573,9 +1573,9 @@ TEST_F(JSBuiltinReducerTest, StringFromCharCodeWithPlainPrimitive) { Node* context = UndefinedConstant(); Node* frame_state = graph()->start(); Node* p0 = Parameter(Type::PlainPrimitive(), 0); - Node* call = graph()->NewNode(javascript()->CallFunction(3), function, - UndefinedConstant(), p0, context, frame_state, - effect, control); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); diff --git a/deps/v8/test/unittests/compiler/js-create-lowering-unittest.cc b/deps/v8/test/unittests/compiler/js-create-lowering-unittest.cc index c982f8f18c..7ea1894322 100644 --- a/deps/v8/test/unittests/compiler/js-create-lowering-unittest.cc +++ b/deps/v8/test/unittests/compiler/js-create-lowering-unittest.cc @@ -41,7 +41,7 @@ class JSCreateLoweringTest : public TypedGraphTest { // TODO(titzer): mock the GraphReducer here for better unit testing. GraphReducer graph_reducer(zone(), graph()); JSCreateLowering reducer(&graph_reducer, &deps_, &jsgraph, - MaybeHandle<LiteralsArray>(), native_context(), + MaybeHandle<FeedbackVector>(), native_context(), zone()); return reducer.Reduce(node); } @@ -65,19 +65,24 @@ class JSCreateLoweringTest : public TypedGraphTest { CompilationDependencies deps_; }; +// ----------------------------------------------------------------------------- +// JSCreate + TEST_F(JSCreateLoweringTest, JSCreate) { Handle<JSFunction> function = isolate()->object_function(); Node* const target = Parameter(Type::HeapConstant(function, graph()->zone())); Node* const context = Parameter(Type::Any()); Node* const effect = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->Create(), target, target, - context, EmptyFrameState(), effect)); + Node* const control = graph()->start(); + Reduction r = + Reduce(graph()->NewNode(javascript()->Create(), target, target, context, + EmptyFrameState(), effect, control)); ASSERT_TRUE(r.Changed()); EXPECT_THAT( r.replacement(), IsFinishRegion( IsAllocate(IsNumberConstant(function->initial_map()->instance_size()), - IsBeginRegion(effect), _), + IsBeginRegion(effect), control), _)); } @@ -137,36 +142,6 @@ TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedRestArray) { } // ----------------------------------------------------------------------------- -// JSCreateClosure - -TEST_F(JSCreateLoweringTest, JSCreateClosureViaInlinedAllocation) { - if (!FLAG_turbo_lower_create_closure) return; - Node* const context = UndefinedConstant(); - Node* const effect = graph()->start(); - Node* const control = graph()->start(); - Handle<SharedFunctionInfo> shared(isolate()->number_function()->shared()); - - // Create a mock feedback vector. It just has to be an array with an array - // in slot 0. - Handle<FixedArray> array = isolate()->factory()->NewFixedArray( - FeedbackVector::kReservedIndexCount + 1); - array->set_map_no_write_barrier(isolate()->heap()->feedback_vector_map()); - Handle<FeedbackVector> vector = Handle<FeedbackVector>::cast(array); - FeedbackVectorSlot slot(0); - vector->Set(slot, *vector); - VectorSlotPair pair(vector, slot); - - Reduction r = Reduce( - graph()->NewNode(javascript()->CreateClosure(shared, pair, NOT_TENURED), - context, effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsFinishRegion(IsAllocate(IsNumberConstant(JSFunction::kSize), - IsBeginRegion(_), control), - _)); -} - -// ----------------------------------------------------------------------------- // JSCreateFunctionContext TEST_F(JSCreateLoweringTest, JSCreateFunctionContextViaInlinedAllocation) { diff --git a/deps/v8/test/unittests/compiler/js-operator-unittest.cc b/deps/v8/test/unittests/compiler/js-operator-unittest.cc index 853249785e..886fbe02ce 100644 --- a/deps/v8/test/unittests/compiler/js-operator-unittest.cc +++ b/deps/v8/test/unittests/compiler/js-operator-unittest.cc @@ -44,7 +44,7 @@ const SharedOperator kSharedOperators[] = { SHARED(ToString, Operator::kNoProperties, 1, 1, 1, 1, 1, 1, 2), SHARED(ToName, Operator::kNoProperties, 1, 1, 1, 1, 1, 1, 2), SHARED(ToObject, Operator::kFoldable, 1, 1, 1, 1, 1, 1, 2), - SHARED(Create, Operator::kEliminatable, 2, 1, 1, 0, 1, 1, 0), + SHARED(Create, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), SHARED(TypeOf, Operator::kPure, 1, 0, 0, 0, 1, 0, 0), #undef SHARED }; diff --git a/deps/v8/test/unittests/compiler/js-typed-lowering-unittest.cc b/deps/v8/test/unittests/compiler/js-typed-lowering-unittest.cc index 979d146164..925d1ff7be 100644 --- a/deps/v8/test/unittests/compiler/js-typed-lowering-unittest.cc +++ b/deps/v8/test/unittests/compiler/js-typed-lowering-unittest.cc @@ -130,6 +130,17 @@ TEST_F(JSTypedLoweringTest, JSToBooleanWithReceiverOrNullOrUndefined) { EXPECT_THAT(r.replacement(), IsBooleanNot(IsObjectIsUndetectable(input))); } +TEST_F(JSTypedLoweringTest, JSToBooleanWithString) { + Node* input = Parameter(Type::String(), 0); + Node* context = Parameter(Type::Any(), 1); + Reduction r = Reduce(graph()->NewNode( + javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); + ASSERT_TRUE(r.Changed()); + EXPECT_THAT(r.replacement(), + IsBooleanNot(IsReferenceEqual( + input, IsHeapConstant(factory()->empty_string())))); +} + TEST_F(JSTypedLoweringTest, JSToBooleanWithAny) { Node* input = Parameter(Type::Any(), 0); Node* context = Parameter(Type::Any(), 1); @@ -278,13 +289,12 @@ TEST_F(JSTypedLoweringTest, JSStrictEqualWithUnique) { // JSShiftLeft TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { - BinaryOperationHint const hint = BinaryOperationHint::kAny; Node* const lhs = Parameter(Type::Signed32()); Node* const context = UndefinedConstant(); Node* const effect = graph()->start(); Node* const control = graph()->start(); TRACED_FORRANGE(double, rhs, 0, 31) { - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hint), lhs, + Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(), lhs, NumberConstant(rhs), context, EmptyFrameState(), effect, control)); ASSERT_TRUE(r.Changed()); @@ -294,76 +304,30 @@ TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { } TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { - BinaryOperationHint const hint = BinaryOperationHint::kAny; Node* const lhs = Parameter(Type::Signed32()); Node* const rhs = Parameter(Type::Unsigned32()); Node* const context = UndefinedConstant(); Node* const effect = graph()->start(); Node* const control = graph()->start(); Reduction r = - Reduce(graph()->NewNode(javascript()->ShiftLeft(hint), lhs, rhs, context, + Reduce(graph()->NewNode(javascript()->ShiftLeft(), lhs, rhs, context, EmptyFrameState(), effect, control)); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsNumberShiftLeft(lhs, rhs)); } -TEST_F(JSTypedLoweringTest, JSShiftLeftWithSignedSmallHint) { - BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hint), lhs, rhs, - UndefinedConstant(), EmptyFrameState(), - effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberShiftLeft(NumberOperationHint::kSignedSmall, - lhs, rhs, effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32Hint) { - BinaryOperationHint const hint = BinaryOperationHint::kSigned32; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hint), lhs, rhs, - UndefinedConstant(), EmptyFrameState(), - effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberShiftLeft(NumberOperationHint::kSigned32, lhs, - rhs, effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSShiftLeftWithNumberOrOddballHint) { - BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hint), lhs, rhs, - UndefinedConstant(), EmptyFrameState(), - effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftLeft( - NumberOperationHint::kNumberOrOddball, lhs, - rhs, effect, control)); -} // ----------------------------------------------------------------------------- // JSShiftRight TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { - BinaryOperationHint const hint = BinaryOperationHint::kAny; Node* const lhs = Parameter(Type::Signed32()); Node* const context = UndefinedConstant(); Node* const effect = graph()->start(); Node* const control = graph()->start(); TRACED_FORRANGE(double, rhs, 0, 31) { - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hint), lhs, + Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(), lhs, NumberConstant(rhs), context, EmptyFrameState(), effect, control)); ASSERT_TRUE(r.Changed()); @@ -374,63 +338,18 @@ TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { - BinaryOperationHint const hint = BinaryOperationHint::kAny; Node* const lhs = Parameter(Type::Signed32()); Node* const rhs = Parameter(Type::Unsigned32()); Node* const context = UndefinedConstant(); Node* const effect = graph()->start(); Node* const control = graph()->start(); Reduction r = - Reduce(graph()->NewNode(javascript()->ShiftRight(hint), lhs, rhs, context, + Reduce(graph()->NewNode(javascript()->ShiftRight(), lhs, rhs, context, EmptyFrameState(), effect, control)); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsNumberShiftRight(lhs, rhs)); } -TEST_F(JSTypedLoweringTest, JSShiftRightWithSignedSmallHint) { - BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hint), lhs, - rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberShiftRight(NumberOperationHint::kSignedSmall, - lhs, rhs, effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32Hint) { - BinaryOperationHint const hint = BinaryOperationHint::kSigned32; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hint), lhs, - rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberShiftRight(NumberOperationHint::kSigned32, lhs, - rhs, effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSShiftRightWithNumberOrOddballHint) { - BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hint), lhs, - rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRight( - NumberOperationHint::kNumberOrOddball, lhs, - rhs, effect, control)); -} // ----------------------------------------------------------------------------- // JSShiftRightLogical @@ -438,13 +357,12 @@ TEST_F(JSTypedLoweringTest, JSShiftRightWithNumberOrOddballHint) { TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndConstant) { - BinaryOperationHint const hint = BinaryOperationHint::kAny; Node* const lhs = Parameter(Type::Unsigned32()); Node* const context = UndefinedConstant(); Node* const effect = graph()->start(); Node* const control = graph()->start(); TRACED_FORRANGE(double, rhs, 0, 31) { - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hint), + Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(), lhs, NumberConstant(rhs), context, EmptyFrameState(), effect, control)); ASSERT_TRUE(r.Changed()); @@ -455,63 +373,18 @@ TEST_F(JSTypedLoweringTest, TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndUnsigned32) { - BinaryOperationHint const hint = BinaryOperationHint::kAny; Node* const lhs = Parameter(Type::Unsigned32()); Node* const rhs = Parameter(Type::Unsigned32()); Node* const context = UndefinedConstant(); Node* const effect = graph()->start(); Node* const control = graph()->start(); Reduction r = - Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hint), lhs, rhs, + Reduce(graph()->NewNode(javascript()->ShiftRightLogical(), lhs, rhs, context, EmptyFrameState(), effect, control)); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsNumberShiftRightLogical(lhs, rhs)); } -TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithSignedSmallHint) { - BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hint), - lhs, rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRightLogical( - NumberOperationHint::kSignedSmall, lhs, rhs, - effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithSigned32Hint) { - BinaryOperationHint const hint = BinaryOperationHint::kSigned32; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hint), - lhs, rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberShiftRightLogical( - NumberOperationHint::kSigned32, lhs, rhs, effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithNumberOrOddballHint) { - BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hint), - lhs, rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRightLogical( - NumberOperationHint::kNumberOrOddball, lhs, - rhs, effect, control)); -} // ----------------------------------------------------------------------------- // JSLoadContext @@ -721,14 +594,10 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithConversion) { Node* context = UndefinedConstant(); Node* effect = graph()->start(); Node* control = graph()->start(); - // TODO(mstarzinger): Once the effect-control-linearizer provides a frame - // state we can get rid of this checkpoint again. The reducer won't care. - Node* checkpoint = graph()->NewNode(common()->Checkpoint(), - EmptyFrameState(), effect, control); VectorSlotPair feedback; const Operator* op = javascript()->StoreProperty(language_mode, feedback); Node* node = graph()->NewNode(op, base, key, value, context, - EmptyFrameState(), checkpoint, control); + EmptyFrameState(), effect, control); Reduction r = Reduce(node); Matcher<Node*> offset_matcher = @@ -746,7 +615,7 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithConversion) { BufferAccess(type), IsPointerConstant(bit_cast<intptr_t>(&backing_store[0])), offset_matcher, IsNumberConstant(array->byte_length()->Number()), - value_matcher, checkpoint, control)); + value_matcher, effect, control)); } } } @@ -832,185 +701,6 @@ TEST_F(JSTypedLoweringTest, JSAddWithString) { lhs, rhs, context, frame_state, effect, control)); } -TEST_F(JSTypedLoweringTest, JSAddSmis) { - BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall; - Node* lhs = Parameter(Type::Number(), 0); - Node* rhs = Parameter(Type::Number(), 1); - Node* context = Parameter(Type::Any(), 2); - Node* frame_state = EmptyFrameState(); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->Add(hint), lhs, rhs, - context, frame_state, effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberAdd(NumberOperationHint::kSignedSmall, lhs, - rhs, effect, control)); -} - -// ----------------------------------------------------------------------------- -// JSSubtract - -TEST_F(JSTypedLoweringTest, JSSubtractSmis) { - BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall; - Node* lhs = Parameter(Type::Number(), 0); - Node* rhs = Parameter(Type::Number(), 1); - Node* context = Parameter(Type::Any(), 2); - Node* frame_state = EmptyFrameState(); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->Subtract(hint), lhs, rhs, - context, frame_state, effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberSubtract(NumberOperationHint::kSignedSmall, - lhs, rhs, effect, control)); -} - -// ----------------------------------------------------------------------------- -// JSBitwiseAnd - -TEST_F(JSTypedLoweringTest, JSBitwiseAndWithSignedSmallHint) { - BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseAnd(hint), lhs, - rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberBitwiseAnd(NumberOperationHint::kSignedSmall, - lhs, rhs, effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSBitwiseAndWithSigned32Hint) { - BinaryOperationHint const hint = BinaryOperationHint::kSigned32; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseAnd(hint), lhs, - rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberBitwiseAnd(NumberOperationHint::kSigned32, lhs, - rhs, effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSBitwiseAndWithNumberOrOddballHint) { - BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseAnd(hint), lhs, - rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseAnd( - NumberOperationHint::kNumberOrOddball, lhs, - rhs, effect, control)); -} - -// ----------------------------------------------------------------------------- -// JSBitwiseOr - -TEST_F(JSTypedLoweringTest, JSBitwiseOrWithSignedSmallHint) { - BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseOr(hint), lhs, rhs, - UndefinedConstant(), EmptyFrameState(), - effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberBitwiseOr(NumberOperationHint::kSignedSmall, - lhs, rhs, effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSBitwiseOrWithSigned32Hint) { - BinaryOperationHint const hint = BinaryOperationHint::kSigned32; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseOr(hint), lhs, rhs, - UndefinedConstant(), EmptyFrameState(), - effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberBitwiseOr(NumberOperationHint::kSigned32, lhs, - rhs, effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSBitwiseOrWithNumberOrOddballHint) { - BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseOr(hint), lhs, rhs, - UndefinedConstant(), EmptyFrameState(), - effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseOr( - NumberOperationHint::kNumberOrOddball, lhs, - rhs, effect, control)); -} - -// ----------------------------------------------------------------------------- -// JSBitwiseXor - -TEST_F(JSTypedLoweringTest, JSBitwiseXorWithSignedSmallHint) { - BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseXor(hint), lhs, - rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberBitwiseXor(NumberOperationHint::kSignedSmall, - lhs, rhs, effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSBitwiseXorWithSigned32Hint) { - BinaryOperationHint const hint = BinaryOperationHint::kSigned32; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseXor(hint), lhs, - rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsSpeculativeNumberBitwiseXor(NumberOperationHint::kSigned32, lhs, - rhs, effect, control)); -} - -TEST_F(JSTypedLoweringTest, JSBitwiseXorWithNumberOrOddballHint) { - BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball; - Node* lhs = Parameter(Type::Number(), 2); - Node* rhs = Parameter(Type::Number(), 3); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseXor(hint), lhs, - rhs, UndefinedConstant(), - EmptyFrameState(), effect, control)); - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( - NumberOperationHint::kNumberOrOddball, lhs, - rhs, effect, control)); -} - } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/node-matchers-unittest.cc b/deps/v8/test/unittests/compiler/node-matchers-unittest.cc index 45d7427494..7f043049f0 100644 --- a/deps/v8/test/unittests/compiler/node-matchers-unittest.cc +++ b/deps/v8/test/unittests/compiler/node-matchers-unittest.cc @@ -43,6 +43,17 @@ void CheckBaseWithIndexAndDisplacement( } // namespace +#define ADD_ADDRESSING_OPERAND_USES(node) \ + graph()->NewNode(machine()->Load(MachineType::Int32()), node, d0, \ + graph()->start(), graph()->start()); \ + graph()->NewNode(machine()->Store(rep), node, d0, d0, graph()->start(), \ + graph()->start()); \ + graph()->NewNode(machine()->Int32Add(), node, d0); \ + graph()->NewNode(machine()->Int64Add(), node, d0); + +#define ADD_NONE_ADDRESSING_OPERAND_USES(node) \ + graph()->NewNode(machine()->Store(rep), b0, d0, node, graph()->start(), \ + graph()->start()); TEST_F(NodeMatcherTest, ScaledWithOffset32Matcher) { graph()->SetStart(graph()->NewNode(common()->Start(0))); @@ -125,6 +136,10 @@ TEST_F(NodeMatcherTest, ScaledWithOffset32Matcher) { USE(s3); USE(s4); + const StoreRepresentation rep(MachineRepresentation::kWord32, + kNoWriteBarrier); + USE(rep); + // 1 INPUT // Only relevant test dases is Checking for non-match. @@ -378,6 +393,613 @@ TEST_F(NodeMatcherTest, ScaledWithOffset32Matcher) { graph()->NewNode(a_op, graph()->NewNode(sub_op, b0, d15), s3)); CheckBaseWithIndexAndDisplacement(&match46, p1, 3, b0, d15, kNegativeDisplacement); + + // 4 INPUT - with addressing operand uses + + // (B0 + M1) -> [p1, 0, B0, NULL] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement32Matcher match47(graph()->NewNode(a_op, b0, m1)); + CheckBaseWithIndexAndDisplacement(&match47, p1, 0, b0, NULL); + + // (M1 + B0) -> [p1, 0, B0, NULL] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement32Matcher match48(graph()->NewNode(a_op, m1, b0)); + CheckBaseWithIndexAndDisplacement(&match48, p1, 0, b0, NULL); + + // (D15 + M1) -> [P1, 0, NULL, D15] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement32Matcher match49( + graph()->NewNode(a_op, d15, m1)); + CheckBaseWithIndexAndDisplacement(&match49, p1, 0, NULL, d15); + + // (M1 + D15) -> [P1, 0, NULL, D15] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement32Matcher match50( + graph()->NewNode(a_op, m1, d15)); + CheckBaseWithIndexAndDisplacement(&match50, p1, 0, NULL, d15); + + // (B0 + S0) -> [p1, 0, B0, NULL] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement32Matcher match51(graph()->NewNode(a_op, b0, s0)); + CheckBaseWithIndexAndDisplacement(&match51, p1, 0, b0, NULL); + + // (S0 + B0) -> [p1, 0, B0, NULL] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement32Matcher match52(graph()->NewNode(a_op, s0, b0)); + CheckBaseWithIndexAndDisplacement(&match52, p1, 0, b0, NULL); + + // (D15 + S0) -> [P1, 0, NULL, D15] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement32Matcher match53( + graph()->NewNode(a_op, d15, s0)); + CheckBaseWithIndexAndDisplacement(&match53, p1, 0, NULL, d15); + + // (S0 + D15) -> [P1, 0, NULL, D15] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement32Matcher match54( + graph()->NewNode(a_op, s0, d15)); + CheckBaseWithIndexAndDisplacement(&match54, p1, 0, NULL, d15); + + // (B0 + M2) -> [p1, 1, B0, NULL] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement32Matcher match55(graph()->NewNode(a_op, b0, m2)); + CheckBaseWithIndexAndDisplacement(&match55, p1, 1, b0, NULL); + + // (M2 + B0) -> [p1, 1, B0, NULL] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement32Matcher match56(graph()->NewNode(a_op, m2, b0)); + CheckBaseWithIndexAndDisplacement(&match56, p1, 1, b0, NULL); + + // (D15 + M2) -> [P1, 1, NULL, D15] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement32Matcher match57( + graph()->NewNode(a_op, d15, m2)); + CheckBaseWithIndexAndDisplacement(&match57, p1, 1, NULL, d15); + + // (M2 + D15) -> [P1, 1, NULL, D15] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement32Matcher match58( + graph()->NewNode(a_op, m2, d15)); + CheckBaseWithIndexAndDisplacement(&match58, p1, 1, NULL, d15); + + // (B0 + S1) -> [p1, 1, B0, NULL] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement32Matcher match59(graph()->NewNode(a_op, b0, s1)); + CheckBaseWithIndexAndDisplacement(&match59, p1, 1, b0, NULL); + + // (S1 + B0) -> [p1, 1, B0, NULL] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement32Matcher match60(graph()->NewNode(a_op, s1, b0)); + CheckBaseWithIndexAndDisplacement(&match60, p1, 1, b0, NULL); + + // (D15 + S1) -> [P1, 1, NULL, D15] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement32Matcher match61( + graph()->NewNode(a_op, d15, s1)); + CheckBaseWithIndexAndDisplacement(&match61, p1, 1, NULL, d15); + + // (S1 + D15) -> [P1, 1, NULL, D15] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement32Matcher match62( + graph()->NewNode(a_op, s1, d15)); + CheckBaseWithIndexAndDisplacement(&match62, p1, 1, NULL, d15); + + // (B0 + M4) -> [p1, 2, B0, NULL] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement32Matcher match63(graph()->NewNode(a_op, b0, m4)); + CheckBaseWithIndexAndDisplacement(&match63, p1, 2, b0, NULL); + + // (M4 + B0) -> [p1, 2, B0, NULL] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement32Matcher match64(graph()->NewNode(a_op, m4, b0)); + CheckBaseWithIndexAndDisplacement(&match64, p1, 2, b0, NULL); + + // (D15 + M4) -> [p1, 2, NULL, D15] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement32Matcher match65( + graph()->NewNode(a_op, d15, m4)); + CheckBaseWithIndexAndDisplacement(&match65, p1, 2, NULL, d15); + + // (M4 + D15) -> [p1, 2, NULL, D15] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement32Matcher match66( + graph()->NewNode(a_op, m4, d15)); + CheckBaseWithIndexAndDisplacement(&match66, p1, 2, NULL, d15); + + // (B0 + S2) -> [p1, 2, B0, NULL] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement32Matcher match67(graph()->NewNode(a_op, b0, s2)); + CheckBaseWithIndexAndDisplacement(&match67, p1, 2, b0, NULL); + + // (S2 + B0) -> [p1, 2, B0, NULL] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement32Matcher match68(graph()->NewNode(a_op, s2, b0)); + CheckBaseWithIndexAndDisplacement(&match68, p1, 2, b0, NULL); + + // (D15 + S2) -> [p1, 2, NULL, D15] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement32Matcher match69( + graph()->NewNode(a_op, d15, s2)); + CheckBaseWithIndexAndDisplacement(&match69, p1, 2, NULL, d15); + + // (S2 + D15) -> [p1, 2, NULL, D15] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement32Matcher match70( + graph()->NewNode(a_op, s2, d15)); + CheckBaseWithIndexAndDisplacement(&match70, p1, 2, NULL, d15); + + // (B0 + M8) -> [p1, 2, B0, NULL] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement32Matcher match71(graph()->NewNode(a_op, b0, m8)); + CheckBaseWithIndexAndDisplacement(&match71, p1, 3, b0, NULL); + + // (M8 + B0) -> [p1, 2, B0, NULL] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement32Matcher match72(graph()->NewNode(a_op, m8, b0)); + CheckBaseWithIndexAndDisplacement(&match72, p1, 3, b0, NULL); + + // (D15 + M8) -> [p1, 2, NULL, D15] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement32Matcher match73( + graph()->NewNode(a_op, d15, m8)); + CheckBaseWithIndexAndDisplacement(&match73, p1, 3, NULL, d15); + + // (M8 + D15) -> [p1, 2, NULL, D15] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement32Matcher match74( + graph()->NewNode(a_op, m8, d15)); + CheckBaseWithIndexAndDisplacement(&match74, p1, 3, NULL, d15); + + // (B0 + S3) -> [p1, 2, B0, NULL] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement32Matcher match75(graph()->NewNode(a_op, b0, s3)); + CheckBaseWithIndexAndDisplacement(&match75, p1, 3, b0, NULL); + + // (S3 + B0) -> [p1, 2, B0, NULL] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement32Matcher match76(graph()->NewNode(a_op, s3, b0)); + CheckBaseWithIndexAndDisplacement(&match76, p1, 3, b0, NULL); + + // (D15 + S3) -> [p1, 2, NULL, D15] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement32Matcher match77( + graph()->NewNode(a_op, d15, s3)); + CheckBaseWithIndexAndDisplacement(&match77, p1, 3, NULL, d15); + + // (S3 + D15) -> [p1, 2, NULL, D15] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement32Matcher match78( + graph()->NewNode(a_op, s3, d15)); + CheckBaseWithIndexAndDisplacement(&match78, p1, 3, NULL, d15); + + // (D15 + S3) + B0 -> [p1, 2, b0, d15] + s3 = graph()->NewNode(s_op, p1, d3); + Node* temp = graph()->NewNode(a_op, d15, s3); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match79( + graph()->NewNode(a_op, temp, b0)); + CheckBaseWithIndexAndDisplacement(&match79, p1, 3, b0, d15); + + // (B0 + D15) + S3 -> [p1, 2, b0, d15] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, b0, d15); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match80( + graph()->NewNode(a_op, temp, s3)); + CheckBaseWithIndexAndDisplacement(&match80, p1, 3, b0, d15); + + // (S3 + B0) + D15 -> [NULL, 0, (s3 + b0), d15] + // Avoid changing simple addressing to complex addressing + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, s3, b0); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match81( + graph()->NewNode(a_op, temp, d15)); + CheckBaseWithIndexAndDisplacement(&match81, NULL, 0, temp, d15); + + // D15 + (S3 + B0) -> [NULL, 0, (s3 + b0), d15] + // Avoid changing simple addressing to complex addressing + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, s3, b0); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match82( + graph()->NewNode(a_op, d15, temp)); + CheckBaseWithIndexAndDisplacement(&match82, NULL, 0, temp, d15); + + // B0 + (D15 + S3) -> [p1, 2, b0, d15] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, d15, s3); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match83( + graph()->NewNode(a_op, b0, temp)); + CheckBaseWithIndexAndDisplacement(&match83, p1, 3, b0, d15); + + // S3 + (B0 + D15) -> [p1, 2, b0, d15] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, b0, d15); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match84( + graph()->NewNode(a_op, s3, temp)); + CheckBaseWithIndexAndDisplacement(&match84, p1, 3, b0, d15); + + // S3 + (B0 - D15) -> [p1, 2, b0, d15, true] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(sub_op, b0, d15); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match85( + graph()->NewNode(a_op, s3, temp)); + CheckBaseWithIndexAndDisplacement(&match85, p1, 3, b0, d15, + kNegativeDisplacement); + + // B0 + (B1 - D15) -> [p1, 2, b0, d15, true] + temp = graph()->NewNode(sub_op, b1, d15); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match86( + graph()->NewNode(a_op, b0, temp)); + CheckBaseWithIndexAndDisplacement(&match86, b1, 0, b0, d15, + kNegativeDisplacement); + + // (B0 - D15) + S3 -> [p1, 2, b0, d15, true] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(sub_op, b0, d15); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match87( + graph()->NewNode(a_op, temp, s3)); + CheckBaseWithIndexAndDisplacement(&match87, p1, 3, b0, d15, + kNegativeDisplacement); + + // (B0 + B1) + D15 -> [NULL, 0, (b0 + b1), d15] + // Avoid changing simple addressing to complex addressing + temp = graph()->NewNode(a_op, b0, b1); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match88( + graph()->NewNode(a_op, temp, d15)); + CheckBaseWithIndexAndDisplacement(&match88, NULL, 0, temp, d15); + + // D15 + (B0 + B1) -> [NULL, 0, (b0 + b1), d15] + // Avoid changing simple addressing to complex addressing + temp = graph()->NewNode(a_op, b0, b1); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match89( + graph()->NewNode(a_op, d15, temp)); + CheckBaseWithIndexAndDisplacement(&match89, NULL, 0, temp, d15); + + // 5 INPUT - with none-addressing operand uses + + // (B0 + M1) -> [b0, 0, m1, NULL] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement32Matcher match90(graph()->NewNode(a_op, b0, m1)); + CheckBaseWithIndexAndDisplacement(&match90, b0, 0, m1, NULL); + + // (M1 + B0) -> [b0, 0, m1, NULL] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement32Matcher match91(graph()->NewNode(a_op, m1, b0)); + CheckBaseWithIndexAndDisplacement(&match91, b0, 0, m1, NULL); + + // (D15 + M1) -> [NULL, 0, m1, d15] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement32Matcher match92( + graph()->NewNode(a_op, d15, m1)); + CheckBaseWithIndexAndDisplacement(&match92, NULL, 0, m1, d15); + + // (M1 + D15) -> [NULL, 0, m1, d15] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement32Matcher match93( + graph()->NewNode(a_op, m1, d15)); + CheckBaseWithIndexAndDisplacement(&match93, NULL, 0, m1, d15); + + // (B0 + S0) -> [b0, 0, s0, NULL] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_NONE_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement32Matcher match94(graph()->NewNode(a_op, b0, s0)); + CheckBaseWithIndexAndDisplacement(&match94, b0, 0, s0, NULL); + + // (S0 + B0) -> [b0, 0, s0, NULL] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_NONE_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement32Matcher match95(graph()->NewNode(a_op, s0, b0)); + CheckBaseWithIndexAndDisplacement(&match95, b0, 0, s0, NULL); + + // (D15 + S0) -> [NULL, 0, s0, d15] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_NONE_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement32Matcher match96( + graph()->NewNode(a_op, d15, s0)); + CheckBaseWithIndexAndDisplacement(&match96, NULL, 0, s0, d15); + + // (S0 + D15) -> [NULL, 0, s0, d15] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_NONE_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement32Matcher match97( + graph()->NewNode(a_op, s0, d15)); + CheckBaseWithIndexAndDisplacement(&match97, NULL, 0, s0, d15); + + // (B0 + M2) -> [b0, 0, m2, NULL] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement32Matcher match98(graph()->NewNode(a_op, b0, m2)); + CheckBaseWithIndexAndDisplacement(&match98, b0, 0, m2, NULL); + + // (M2 + B0) -> [b0, 0, m2, NULL] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement32Matcher match99(graph()->NewNode(a_op, m2, b0)); + CheckBaseWithIndexAndDisplacement(&match99, b0, 0, m2, NULL); + + // (D15 + M2) -> [NULL, 0, m2, d15] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement32Matcher match100( + graph()->NewNode(a_op, d15, m2)); + CheckBaseWithIndexAndDisplacement(&match100, NULL, 0, m2, d15); + + // (M2 + D15) -> [NULL, 0, m2, d15] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement32Matcher match101( + graph()->NewNode(a_op, m2, d15)); + CheckBaseWithIndexAndDisplacement(&match101, NULL, 0, m2, d15); + + // (B0 + S1) -> [b0, 0, s1, NULL] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement32Matcher match102( + graph()->NewNode(a_op, b0, s1)); + CheckBaseWithIndexAndDisplacement(&match102, b0, 0, s1, NULL); + + // (S1 + B0) -> [b0, 0, s1, NULL] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement32Matcher match103( + graph()->NewNode(a_op, s1, b0)); + CheckBaseWithIndexAndDisplacement(&match103, b0, 0, s1, NULL); + + // (D15 + S1) -> [NULL, 0, s1, d15] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement32Matcher match104( + graph()->NewNode(a_op, d15, s1)); + CheckBaseWithIndexAndDisplacement(&match104, NULL, 0, s1, d15); + + // (S1 + D15) -> [NULL, 0, s1, d15] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement32Matcher match105( + graph()->NewNode(a_op, s1, d15)); + CheckBaseWithIndexAndDisplacement(&match105, NULL, 0, s1, d15); + + // (B0 + M4) -> [b0, 0, m4, NULL] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_NONE_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement32Matcher match106( + graph()->NewNode(a_op, b0, m4)); + CheckBaseWithIndexAndDisplacement(&match106, b0, 0, m4, NULL); + + // (M4 + B0) -> [b0, 0, m4, NULL] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_NONE_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement32Matcher match107( + graph()->NewNode(a_op, m4, b0)); + CheckBaseWithIndexAndDisplacement(&match107, b0, 0, m4, NULL); + + // (D15 + M4) -> [NULL, 0, m4, d15] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_NONE_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement32Matcher match108( + graph()->NewNode(a_op, d15, m4)); + CheckBaseWithIndexAndDisplacement(&match108, NULL, 0, m4, d15); + + // (M4 + D15) -> [NULL, 0, m4, d15] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_NONE_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement32Matcher match109( + graph()->NewNode(a_op, m4, d15)); + CheckBaseWithIndexAndDisplacement(&match109, NULL, 0, m4, d15); + + // (B0 + S2) -> [b0, 0, s2, NULL] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement32Matcher match110( + graph()->NewNode(a_op, b0, s2)); + CheckBaseWithIndexAndDisplacement(&match110, b0, 0, s2, NULL); + + // (S2 + B0) -> [b0, 0, s2, NULL] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement32Matcher match111( + graph()->NewNode(a_op, s2, b0)); + CheckBaseWithIndexAndDisplacement(&match111, b0, 0, s2, NULL); + + // (D15 + S2) -> [NULL, 0, s2, d15] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement32Matcher match112( + graph()->NewNode(a_op, d15, s2)); + CheckBaseWithIndexAndDisplacement(&match112, NULL, 0, s2, d15); + + // (S2 + D15) -> [NULL, 0, s2, d15] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement32Matcher match113( + graph()->NewNode(a_op, s2, d15)); + CheckBaseWithIndexAndDisplacement(&match113, NULL, 0, s2, d15); + + // (B0 + M8) -> [b0, 0, m8, NULL] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_NONE_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement32Matcher match114( + graph()->NewNode(a_op, b0, m8)); + CheckBaseWithIndexAndDisplacement(&match114, b0, 0, m8, NULL); + + // (M8 + B0) -> [b0, 0, m8, NULL] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_NONE_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement32Matcher match115( + graph()->NewNode(a_op, m8, b0)); + CheckBaseWithIndexAndDisplacement(&match115, b0, 0, m8, NULL); + + // (D15 + M8) -> [NULL, 0, m8, d15] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_NONE_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement32Matcher match116( + graph()->NewNode(a_op, d15, m8)); + CheckBaseWithIndexAndDisplacement(&match116, NULL, 0, m8, d15); + + // (M8 + D15) -> [NULL, 0, m8, d15] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_NONE_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement32Matcher match117( + graph()->NewNode(a_op, m8, d15)); + CheckBaseWithIndexAndDisplacement(&match117, NULL, 0, m8, d15); + + // (B0 + S3) -> [b0, 0, s3, NULL] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_NONE_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement32Matcher match118( + graph()->NewNode(a_op, b0, s3)); + CheckBaseWithIndexAndDisplacement(&match118, b0, 0, s3, NULL); + + // (S3 + B0) -> [b0, 0, s3, NULL] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_NONE_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement32Matcher match119( + graph()->NewNode(a_op, s3, b0)); + CheckBaseWithIndexAndDisplacement(&match119, b0, 0, s3, NULL); + + // (D15 + S3) -> [NULL, 0, s3, d15] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_NONE_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement32Matcher match120( + graph()->NewNode(a_op, d15, s3)); + CheckBaseWithIndexAndDisplacement(&match120, NULL, 0, s3, d15); + + // (S3 + D15) -> [NULL, 0, s3, d15] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_NONE_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement32Matcher match121( + graph()->NewNode(a_op, s3, d15)); + CheckBaseWithIndexAndDisplacement(&match121, NULL, 0, s3, d15); + + // (D15 + S3) + B0 -> [b0, 0, (D15 + S3), NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, d15, s3); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match122( + graph()->NewNode(a_op, temp, b0)); + CheckBaseWithIndexAndDisplacement(&match122, b0, 0, temp, NULL); + + // (B0 + D15) + S3 -> [p1, 3, (B0 + D15), NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, b0, d15); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match123( + graph()->NewNode(a_op, temp, s3)); + CheckBaseWithIndexAndDisplacement(&match123, p1, 3, temp, NULL); + + // (S3 + B0) + D15 -> [NULL, 0, (S3 + B0), d15] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, s3, b0); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match124( + graph()->NewNode(a_op, temp, d15)); + CheckBaseWithIndexAndDisplacement(&match124, NULL, 0, temp, d15); + + // D15 + (S3 + B0) -> [NULL, 0, (S3 + B0), d15] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, s3, b0); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match125( + graph()->NewNode(a_op, d15, temp)); + CheckBaseWithIndexAndDisplacement(&match125, NULL, 0, temp, d15); + + // B0 + (D15 + S3) -> [b0, 0, (D15 + S3), NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, d15, s3); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match126( + graph()->NewNode(a_op, b0, temp)); + CheckBaseWithIndexAndDisplacement(&match126, b0, 0, temp, NULL); + + // S3 + (B0 + D15) -> [p1, 3, (B0 + D15), NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, b0, d15); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match127( + graph()->NewNode(a_op, s3, temp)); + CheckBaseWithIndexAndDisplacement(&match127, p1, 3, temp, NULL); + + // S3 + (B0 - D15) -> [p1, 3, (B0 - D15), NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(sub_op, b0, d15); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match128( + graph()->NewNode(a_op, s3, temp)); + CheckBaseWithIndexAndDisplacement(&match128, p1, 3, temp, NULL); + + // B0 + (B1 - D15) -> [b0, 0, (B1 - D15), NULL] + temp = graph()->NewNode(sub_op, b1, d15); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match129( + graph()->NewNode(a_op, b0, temp)); + CheckBaseWithIndexAndDisplacement(&match129, b0, 0, temp, NULL); + + // (B0 - D15) + S3 -> [p1, 3, temp, NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(sub_op, b0, d15); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match130( + graph()->NewNode(a_op, temp, s3)); + CheckBaseWithIndexAndDisplacement(&match130, p1, 3, temp, NULL); + + // (B0 + B1) + D15 -> [NULL, 0, (B0 + B1), d15] + temp = graph()->NewNode(a_op, b0, b1); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match131( + graph()->NewNode(a_op, temp, d15)); + CheckBaseWithIndexAndDisplacement(&match131, NULL, 0, temp, d15); + + // D15 + (B0 + B1) -> [NULL, 0, (B0 + B1), d15] + temp = graph()->NewNode(a_op, b0, b1); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement32Matcher match132( + graph()->NewNode(a_op, d15, temp)); + CheckBaseWithIndexAndDisplacement(&match132, NULL, 0, temp, d15); } @@ -465,6 +1087,10 @@ TEST_F(NodeMatcherTest, ScaledWithOffset64Matcher) { USE(s3); USE(s4); + const StoreRepresentation rep(MachineRepresentation::kWord32, + kNoWriteBarrier); + USE(rep); + // 1 INPUT // Only relevant test dases is Checking for non-match. @@ -635,8 +1261,8 @@ TEST_F(NodeMatcherTest, ScaledWithOffset64Matcher) { CheckBaseWithIndexAndDisplacement(&match31, p1, 3, NULL, d15); // (B0 + S3) -> [p1, 2, B0, NULL] - BaseWithIndexAndDisplacement64Matcher match64(graph()->NewNode(a_op, b0, s3)); - CheckBaseWithIndexAndDisplacement(&match64, p1, 3, b0, NULL); + BaseWithIndexAndDisplacement64Matcher match32(graph()->NewNode(a_op, b0, s3)); + CheckBaseWithIndexAndDisplacement(&match32, p1, 3, b0, NULL); // (S3 + B0) -> [p1, 2, B0, NULL] s3 = graph()->NewNode(s_op, p1, d3); @@ -772,6 +1398,617 @@ TEST_F(NodeMatcherTest, ScaledWithOffset64Matcher) { graph()->NewNode(a_op, graph()->NewNode(sub_op, b0, d15), s3)); CheckBaseWithIndexAndDisplacement(&match53, p1, 3, b0, d15, kNegativeDisplacement); + + // 4 INPUT - with addressing operand uses + + // (B0 + M1) -> [p1, 0, B0, NULL] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement64Matcher match54(graph()->NewNode(a_op, b0, m1)); + CheckBaseWithIndexAndDisplacement(&match54, p1, 0, b0, NULL); + + // (M1 + B0) -> [p1, 0, B0, NULL] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement64Matcher match55(graph()->NewNode(a_op, m1, b0)); + CheckBaseWithIndexAndDisplacement(&match55, p1, 0, b0, NULL); + + // (D15 + M1) -> [P1, 0, NULL, D15] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement64Matcher match56( + graph()->NewNode(a_op, d15, m1)); + CheckBaseWithIndexAndDisplacement(&match56, p1, 0, NULL, d15); + + // (M1 + D15) -> [P1, 0, NULL, D15] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement64Matcher match57( + graph()->NewNode(a_op, m1, d15)); + CheckBaseWithIndexAndDisplacement(&match57, p1, 0, NULL, d15); + + // (B0 + S0) -> [p1, 0, B0, NULL] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement64Matcher match58(graph()->NewNode(a_op, b0, s0)); + CheckBaseWithIndexAndDisplacement(&match58, p1, 0, b0, NULL); + + // (S0 + B0) -> [p1, 0, B0, NULL] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement64Matcher match59(graph()->NewNode(a_op, s0, b0)); + CheckBaseWithIndexAndDisplacement(&match59, p1, 0, b0, NULL); + + // (D15 + S0) -> [P1, 0, NULL, D15] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement64Matcher match60( + graph()->NewNode(a_op, d15, s0)); + CheckBaseWithIndexAndDisplacement(&match60, p1, 0, NULL, d15); + + // (S0 + D15) -> [P1, 0, NULL, D15] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement64Matcher match61( + graph()->NewNode(a_op, s0, d15)); + CheckBaseWithIndexAndDisplacement(&match61, p1, 0, NULL, d15); + + // (B0 + M2) -> [p1, 1, B0, NULL] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement64Matcher match62(graph()->NewNode(a_op, b0, m2)); + CheckBaseWithIndexAndDisplacement(&match62, p1, 1, b0, NULL); + + // (M2 + B0) -> [p1, 1, B0, NULL] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement64Matcher match63(graph()->NewNode(a_op, m2, b0)); + CheckBaseWithIndexAndDisplacement(&match63, p1, 1, b0, NULL); + + // (D15 + M2) -> [P1, 1, NULL, D15] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement64Matcher match64( + graph()->NewNode(a_op, d15, m2)); + CheckBaseWithIndexAndDisplacement(&match64, p1, 1, NULL, d15); + + // (M2 + D15) -> [P1, 1, NULL, D15] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement64Matcher match65( + graph()->NewNode(a_op, m2, d15)); + CheckBaseWithIndexAndDisplacement(&match65, p1, 1, NULL, d15); + + // (B0 + S1) -> [p1, 1, B0, NULL] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement64Matcher match66(graph()->NewNode(a_op, b0, s1)); + CheckBaseWithIndexAndDisplacement(&match66, p1, 1, b0, NULL); + + // (S1 + B0) -> [p1, 1, B0, NULL] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement64Matcher match67(graph()->NewNode(a_op, s1, b0)); + CheckBaseWithIndexAndDisplacement(&match67, p1, 1, b0, NULL); + + // (D15 + S1) -> [P1, 1, NULL, D15] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement64Matcher match68( + graph()->NewNode(a_op, d15, s1)); + CheckBaseWithIndexAndDisplacement(&match68, p1, 1, NULL, d15); + + // (S1 + D15) -> [P1, 1, NULL, D15] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement64Matcher match69( + graph()->NewNode(a_op, s1, d15)); + CheckBaseWithIndexAndDisplacement(&match69, p1, 1, NULL, d15); + + // (B0 + M4) -> [p1, 2, B0, NULL] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement64Matcher match70(graph()->NewNode(a_op, b0, m4)); + CheckBaseWithIndexAndDisplacement(&match70, p1, 2, b0, NULL); + + // (M4 + B0) -> [p1, 2, B0, NULL] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement64Matcher match71(graph()->NewNode(a_op, m4, b0)); + CheckBaseWithIndexAndDisplacement(&match71, p1, 2, b0, NULL); + + // (D15 + M4) -> [p1, 2, NULL, D15] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement64Matcher match72( + graph()->NewNode(a_op, d15, m4)); + CheckBaseWithIndexAndDisplacement(&match72, p1, 2, NULL, d15); + + // (M4 + D15) -> [p1, 2, NULL, D15] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement64Matcher match73( + graph()->NewNode(a_op, m4, d15)); + CheckBaseWithIndexAndDisplacement(&match73, p1, 2, NULL, d15); + + // (B0 + S2) -> [p1, 2, B0, NULL] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement64Matcher match74(graph()->NewNode(a_op, b0, s2)); + CheckBaseWithIndexAndDisplacement(&match74, p1, 2, b0, NULL); + + // (S2 + B0) -> [p1, 2, B0, NULL] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement64Matcher match75(graph()->NewNode(a_op, s2, b0)); + CheckBaseWithIndexAndDisplacement(&match75, p1, 2, b0, NULL); + + // (D15 + S2) -> [p1, 2, NULL, D15] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement64Matcher match76( + graph()->NewNode(a_op, d15, s2)); + CheckBaseWithIndexAndDisplacement(&match76, p1, 2, NULL, d15); + + // (S2 + D15) -> [p1, 2, NULL, D15] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement64Matcher match77( + graph()->NewNode(a_op, s2, d15)); + CheckBaseWithIndexAndDisplacement(&match77, p1, 2, NULL, d15); + + // (B0 + M8) -> [p1, 2, B0, NULL] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement64Matcher match78(graph()->NewNode(a_op, b0, m8)); + CheckBaseWithIndexAndDisplacement(&match78, p1, 3, b0, NULL); + + // (M8 + B0) -> [p1, 2, B0, NULL] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement64Matcher match79(graph()->NewNode(a_op, m8, b0)); + CheckBaseWithIndexAndDisplacement(&match79, p1, 3, b0, NULL); + + // (D15 + M8) -> [p1, 2, NULL, D15] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement64Matcher match80( + graph()->NewNode(a_op, d15, m8)); + CheckBaseWithIndexAndDisplacement(&match80, p1, 3, NULL, d15); + + // (M8 + D15) -> [p1, 2, NULL, D15] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement64Matcher match81( + graph()->NewNode(a_op, m8, d15)); + CheckBaseWithIndexAndDisplacement(&match81, p1, 3, NULL, d15); + + // (B0 + S3) -> [p1, 2, B0, NULL] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement64Matcher match82(graph()->NewNode(a_op, b0, s3)); + CheckBaseWithIndexAndDisplacement(&match82, p1, 3, b0, NULL); + + // (S3 + B0) -> [p1, 2, B0, NULL] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement64Matcher match83(graph()->NewNode(a_op, s3, b0)); + CheckBaseWithIndexAndDisplacement(&match83, p1, 3, b0, NULL); + + // (D15 + S3) -> [p1, 2, NULL, D15] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement64Matcher match84( + graph()->NewNode(a_op, d15, s3)); + CheckBaseWithIndexAndDisplacement(&match84, p1, 3, NULL, d15); + + // (S3 + D15) -> [p1, 2, NULL, D15] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement64Matcher match85( + graph()->NewNode(a_op, s3, d15)); + CheckBaseWithIndexAndDisplacement(&match85, p1, 3, NULL, d15); + + // (D15 + S3) + B0 -> [p1, 2, b0, d15] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, d15, s3); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match86( + graph()->NewNode(a_op, temp, b0)); + CheckBaseWithIndexAndDisplacement(&match86, p1, 3, b0, d15); + + // (B0 + D15) + S3 -> [p1, 2, b0, d15] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, b0, d15); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match87( + graph()->NewNode(a_op, temp, s3)); + CheckBaseWithIndexAndDisplacement(&match87, p1, 3, b0, d15); + + // (S3 + B0) + D15 -> [NULL, 0, (s3 + b0), d15] + // Avoid changing simple addressing to complex addressing + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, s3, b0); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match88( + graph()->NewNode(a_op, temp, d15)); + CheckBaseWithIndexAndDisplacement(&match88, NULL, 0, temp, d15); + + // D15 + (S3 + B0) -> [NULL, 0, (s3 + b0), d15] + // Avoid changing simple addressing to complex addressing + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, s3, b0); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match89( + graph()->NewNode(a_op, d15, temp)); + CheckBaseWithIndexAndDisplacement(&match89, NULL, 0, temp, d15); + + // B0 + (D15 + S3) -> [p1, 2, b0, d15] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, d15, s3); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match90( + graph()->NewNode(a_op, b0, temp)); + CheckBaseWithIndexAndDisplacement(&match90, p1, 3, b0, d15); + + // S3 + (B0 + D15) -> [p1, 2, b0, d15] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, b0, d15); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match91( + graph()->NewNode(a_op, s3, temp)); + CheckBaseWithIndexAndDisplacement(&match91, p1, 3, b0, d15); + + // S3 + (B0 - D15) -> [p1, 2, b0, d15, true] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(sub_op, b0, d15); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match92( + graph()->NewNode(a_op, s3, temp)); + CheckBaseWithIndexAndDisplacement(&match92, p1, 3, b0, d15, + kNegativeDisplacement); + + // B0 + (B1 - D15) -> [p1, 2, b0, d15, true] + temp = graph()->NewNode(sub_op, b1, d15); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match93( + graph()->NewNode(a_op, b0, temp)); + CheckBaseWithIndexAndDisplacement(&match93, b1, 0, b0, d15, + kNegativeDisplacement); + + // (B0 - D15) + S3 -> [p1, 2, b0, d15, true] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(sub_op, b0, d15); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match94( + graph()->NewNode(a_op, temp, s3)); + CheckBaseWithIndexAndDisplacement(&match94, p1, 3, b0, d15, + kNegativeDisplacement); + + // (B0 + B1) + D15 -> [NULL, 0, (b0 + b1), d15] + // Avoid changing simple addressing to complex addressing + temp = graph()->NewNode(a_op, b0, b1); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match95( + graph()->NewNode(a_op, temp, d15)); + CheckBaseWithIndexAndDisplacement(&match95, NULL, 0, temp, d15); + + // D15 + (B0 + B1) -> [NULL, 0, (b0 + b1), d15] + // Avoid changing simple addressing to complex addressing + temp = graph()->NewNode(a_op, b0, b1); + ADD_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match96( + graph()->NewNode(a_op, d15, temp)); + CheckBaseWithIndexAndDisplacement(&match96, NULL, 0, temp, d15); + + // 5 INPUT - with none-addressing operand uses + + // (B0 + M1) -> [b0, 0, m1, NULL] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement64Matcher match97(graph()->NewNode(a_op, b0, m1)); + CheckBaseWithIndexAndDisplacement(&match97, b0, 0, m1, NULL); + + // (M1 + B0) -> [b0, 0, m1, NULL] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement64Matcher match98(graph()->NewNode(a_op, m1, b0)); + CheckBaseWithIndexAndDisplacement(&match98, b0, 0, m1, NULL); + + // (D15 + M1) -> [NULL, 0, m1, d15] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement64Matcher match99( + graph()->NewNode(a_op, d15, m1)); + CheckBaseWithIndexAndDisplacement(&match99, NULL, 0, m1, d15); + + // (M1 + D15) -> [NULL, 0, m1, d15] + m1 = graph()->NewNode(m_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(m1); + BaseWithIndexAndDisplacement64Matcher match100( + graph()->NewNode(a_op, m1, d15)); + CheckBaseWithIndexAndDisplacement(&match100, NULL, 0, m1, d15); + + // (B0 + S0) -> [b0, 0, s0, NULL] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_NONE_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement64Matcher match101( + graph()->NewNode(a_op, b0, s0)); + CheckBaseWithIndexAndDisplacement(&match101, b0, 0, s0, NULL); + + // (S0 + B0) -> [b0, 0, s0, NULL] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_NONE_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement64Matcher match102( + graph()->NewNode(a_op, s0, b0)); + CheckBaseWithIndexAndDisplacement(&match102, b0, 0, s0, NULL); + + // (D15 + S0) -> [NULL, 0, s0, d15] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_NONE_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement64Matcher match103( + graph()->NewNode(a_op, d15, s0)); + CheckBaseWithIndexAndDisplacement(&match103, NULL, 0, s0, d15); + + // (S0 + D15) -> [NULL, 0, s0, d15] + s0 = graph()->NewNode(s_op, p1, d0); + ADD_NONE_ADDRESSING_OPERAND_USES(s0); + BaseWithIndexAndDisplacement64Matcher match104( + graph()->NewNode(a_op, s0, d15)); + CheckBaseWithIndexAndDisplacement(&match104, NULL, 0, s0, d15); + + // (B0 + M2) -> [b0, 0, m2, NULL] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement64Matcher match105( + graph()->NewNode(a_op, b0, m2)); + CheckBaseWithIndexAndDisplacement(&match105, b0, 0, m2, NULL); + + // (M2 + B0) -> [b0, 0, m2, NULL] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement64Matcher match106( + graph()->NewNode(a_op, m2, b0)); + CheckBaseWithIndexAndDisplacement(&match106, b0, 0, m2, NULL); + + // (D15 + M2) -> [NULL, 0, m2, d15] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement64Matcher match107( + graph()->NewNode(a_op, d15, m2)); + CheckBaseWithIndexAndDisplacement(&match107, NULL, 0, m2, d15); + + // (M2 + D15) -> [NULL, 0, m2, d15] + m2 = graph()->NewNode(m_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(m2); + BaseWithIndexAndDisplacement64Matcher match108( + graph()->NewNode(a_op, m2, d15)); + CheckBaseWithIndexAndDisplacement(&match108, NULL, 0, m2, d15); + + // (B0 + S1) -> [b0, 0, s1, NULL] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement64Matcher match109( + graph()->NewNode(a_op, b0, s1)); + CheckBaseWithIndexAndDisplacement(&match109, b0, 0, s1, NULL); + + // (S1 + B0) -> [b0, 0, s1, NULL] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement64Matcher match110( + graph()->NewNode(a_op, s1, b0)); + CheckBaseWithIndexAndDisplacement(&match110, b0, 0, s1, NULL); + + // (D15 + S1) -> [NULL, 0, s1, d15] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement64Matcher match111( + graph()->NewNode(a_op, d15, s1)); + CheckBaseWithIndexAndDisplacement(&match111, NULL, 0, s1, d15); + + // (S1 + D15) -> [NULL, 0, s1, d15] + s1 = graph()->NewNode(s_op, p1, d1); + ADD_NONE_ADDRESSING_OPERAND_USES(s1); + BaseWithIndexAndDisplacement64Matcher match112( + graph()->NewNode(a_op, s1, d15)); + CheckBaseWithIndexAndDisplacement(&match112, NULL, 0, s1, d15); + + // (B0 + M4) -> [b0, 0, m4, NULL] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_NONE_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement64Matcher match113( + graph()->NewNode(a_op, b0, m4)); + CheckBaseWithIndexAndDisplacement(&match113, b0, 0, m4, NULL); + + // (M4 + B0) -> [b0, 0, m4, NULL] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_NONE_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement64Matcher match114( + graph()->NewNode(a_op, m4, b0)); + CheckBaseWithIndexAndDisplacement(&match114, b0, 0, m4, NULL); + + // (D15 + M4) -> [NULL, 0, m4, d15] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_NONE_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement64Matcher match115( + graph()->NewNode(a_op, d15, m4)); + CheckBaseWithIndexAndDisplacement(&match115, NULL, 0, m4, d15); + + // (M4 + D15) -> [NULL, 0, m4, d15] + m4 = graph()->NewNode(m_op, p1, d4); + ADD_NONE_ADDRESSING_OPERAND_USES(m4); + BaseWithIndexAndDisplacement64Matcher match116( + graph()->NewNode(a_op, m4, d15)); + CheckBaseWithIndexAndDisplacement(&match116, NULL, 0, m4, d15); + + // (B0 + S2) -> [b0, 0, s2, NULL] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement64Matcher match117( + graph()->NewNode(a_op, b0, s2)); + CheckBaseWithIndexAndDisplacement(&match117, b0, 0, s2, NULL); + + // (S2 + B0) -> [b0, 0, s2, NULL] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement64Matcher match118( + graph()->NewNode(a_op, s2, b0)); + CheckBaseWithIndexAndDisplacement(&match118, b0, 0, s2, NULL); + + // (D15 + S2) -> [NULL, 0, s2, d15] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement64Matcher match119( + graph()->NewNode(a_op, d15, s2)); + CheckBaseWithIndexAndDisplacement(&match119, NULL, 0, s2, d15); + + // (S2 + D15) -> [NULL, 0, s2, d15] + s2 = graph()->NewNode(s_op, p1, d2); + ADD_NONE_ADDRESSING_OPERAND_USES(s2); + BaseWithIndexAndDisplacement64Matcher match120( + graph()->NewNode(a_op, s2, d15)); + CheckBaseWithIndexAndDisplacement(&match120, NULL, 0, s2, d15); + + // (B0 + M8) -> [b0, 0, m8, NULL] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_NONE_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement64Matcher match121( + graph()->NewNode(a_op, b0, m8)); + CheckBaseWithIndexAndDisplacement(&match121, b0, 0, m8, NULL); + + // (M8 + B0) -> [b0, 0, m8, NULL] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_NONE_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement64Matcher match122( + graph()->NewNode(a_op, m8, b0)); + CheckBaseWithIndexAndDisplacement(&match122, b0, 0, m8, NULL); + + // (D15 + M8) -> [NULL, 0, m8, d15] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_NONE_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement64Matcher match123( + graph()->NewNode(a_op, d15, m8)); + CheckBaseWithIndexAndDisplacement(&match123, NULL, 0, m8, d15); + + // (M8 + D15) -> [NULL, 0, m8, d15] + m8 = graph()->NewNode(m_op, p1, d8); + ADD_NONE_ADDRESSING_OPERAND_USES(m8); + BaseWithIndexAndDisplacement64Matcher match124( + graph()->NewNode(a_op, m8, d15)); + CheckBaseWithIndexAndDisplacement(&match124, NULL, 0, m8, d15); + + // (B0 + S3) -> [b0, 0, s3, NULL] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_NONE_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement64Matcher match125( + graph()->NewNode(a_op, b0, s3)); + CheckBaseWithIndexAndDisplacement(&match125, b0, 0, s3, NULL); + + // (S3 + B0) -> [b0, 0, s3, NULL] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_NONE_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement64Matcher match126( + graph()->NewNode(a_op, s3, b0)); + CheckBaseWithIndexAndDisplacement(&match126, b0, 0, s3, NULL); + + // (D15 + S3) -> [NULL, 0, s3, d15] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_NONE_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement64Matcher match127( + graph()->NewNode(a_op, d15, s3)); + CheckBaseWithIndexAndDisplacement(&match127, NULL, 0, s3, d15); + + // (S3 + D15) -> [NULL, 0, s3, d15] + s3 = graph()->NewNode(s_op, p1, d3); + ADD_NONE_ADDRESSING_OPERAND_USES(s3); + BaseWithIndexAndDisplacement64Matcher match128( + graph()->NewNode(a_op, s3, d15)); + CheckBaseWithIndexAndDisplacement(&match128, NULL, 0, s3, d15); + + // (D15 + S3) + B0 -> [b0, 0, (D15 + S3), NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, d15, s3); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match129( + graph()->NewNode(a_op, temp, b0)); + CheckBaseWithIndexAndDisplacement(&match129, b0, 0, temp, NULL); + + // (B0 + D15) + S3 -> [p1, 3, (B0 + D15), NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, b0, d15); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match130( + graph()->NewNode(a_op, temp, s3)); + CheckBaseWithIndexAndDisplacement(&match130, p1, 3, temp, NULL); + + // (S3 + B0) + D15 -> [NULL, 0, (S3 + B0), d15] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, s3, b0); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match131( + graph()->NewNode(a_op, temp, d15)); + CheckBaseWithIndexAndDisplacement(&match131, NULL, 0, temp, d15); + + // D15 + (S3 + B0) -> [NULL, 0, (S3 + B0), d15] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, s3, b0); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match132( + graph()->NewNode(a_op, d15, temp)); + CheckBaseWithIndexAndDisplacement(&match132, NULL, 0, temp, d15); + + // B0 + (D15 + S3) -> [b0, 0, (D15 + S3), NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, d15, s3); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match133( + graph()->NewNode(a_op, b0, temp)); + CheckBaseWithIndexAndDisplacement(&match133, b0, 0, temp, NULL); + + // S3 + (B0 + D15) -> [p1, 3, (B0 + D15), NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(a_op, b0, d15); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match134( + graph()->NewNode(a_op, s3, temp)); + CheckBaseWithIndexAndDisplacement(&match134, p1, 3, temp, NULL); + + // S3 + (B0 - D15) -> [p1, 3, (B0 - D15), NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(sub_op, b0, d15); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match135( + graph()->NewNode(a_op, s3, temp)); + CheckBaseWithIndexAndDisplacement(&match135, p1, 3, temp, NULL); + + // B0 + (B1 - D15) -> [b0, 0, (B1 - D15), NULL] + temp = graph()->NewNode(sub_op, b1, d15); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match136( + graph()->NewNode(a_op, b0, temp)); + CheckBaseWithIndexAndDisplacement(&match136, b0, 0, temp, NULL); + + // (B0 - D15) + S3 -> [p1, 3, temp, NULL] + s3 = graph()->NewNode(s_op, p1, d3); + temp = graph()->NewNode(sub_op, b0, d15); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match137( + graph()->NewNode(a_op, temp, s3)); + CheckBaseWithIndexAndDisplacement(&match137, p1, 3, temp, NULL); + + // (B0 + B1) + D15 -> [NULL, 0, (B0 + B1), d15] + temp = graph()->NewNode(a_op, b0, b1); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match138( + graph()->NewNode(a_op, temp, d15)); + CheckBaseWithIndexAndDisplacement(&match138, NULL, 0, temp, d15); + + // D15 + (B0 + B1) -> [NULL, 0, (B0 + B1), d15] + temp = graph()->NewNode(a_op, b0, b1); + ADD_NONE_ADDRESSING_OPERAND_USES(temp); + BaseWithIndexAndDisplacement64Matcher match139( + graph()->NewNode(a_op, d15, temp)); + CheckBaseWithIndexAndDisplacement(&match139, NULL, 0, temp, d15); } TEST_F(NodeMatcherTest, BranchMatcher_match) { diff --git a/deps/v8/test/unittests/compiler/regalloc/move-optimizer-unittest.cc b/deps/v8/test/unittests/compiler/regalloc/move-optimizer-unittest.cc index d61543a252..2dc161b150 100644 --- a/deps/v8/test/unittests/compiler/regalloc/move-optimizer-unittest.cc +++ b/deps/v8/test/unittests/compiler/regalloc/move-optimizer-unittest.cc @@ -4,6 +4,7 @@ #include "src/compiler/move-optimizer.h" #include "src/compiler/pipeline.h" +#include "src/ostreams.h" #include "test/unittests/compiler/instruction-sequence-unittest.h" namespace v8 { diff --git a/deps/v8/test/unittests/compiler/typer-unittest.cc b/deps/v8/test/unittests/compiler/typer-unittest.cc index c9b5c9db34..ac3da6e13b 100644 --- a/deps/v8/test/unittests/compiler/typer-unittest.cc +++ b/deps/v8/test/unittests/compiler/typer-unittest.cc @@ -8,6 +8,7 @@ #include "src/compiler/js-operator.h" #include "src/compiler/node-properties.h" #include "src/compiler/operator-properties.h" +#include "src/objects-inl.h" #include "test/cctest/types-fuzz.h" #include "test/unittests/compiler/graph-unittest.h" @@ -245,47 +246,47 @@ TEST_F(TyperTest, TypeJSAdd) { TEST_F(TyperTest, TypeJSSubtract) { - TestBinaryArithOp(javascript_.Subtract(hints_), std::minus<double>()); + TestBinaryArithOp(javascript_.Subtract(), std::minus<double>()); } TEST_F(TyperTest, TypeJSMultiply) { - TestBinaryArithOp(javascript_.Multiply(hints_), std::multiplies<double>()); + TestBinaryArithOp(javascript_.Multiply(), std::multiplies<double>()); } TEST_F(TyperTest, TypeJSDivide) { - TestBinaryArithOp(javascript_.Divide(hints_), std::divides<double>()); + TestBinaryArithOp(javascript_.Divide(), std::divides<double>()); } TEST_F(TyperTest, TypeJSModulus) { - TestBinaryArithOp(javascript_.Modulus(hints_), modulo); + TestBinaryArithOp(javascript_.Modulus(), modulo); } TEST_F(TyperTest, TypeJSBitwiseOr) { - TestBinaryBitOp(javascript_.BitwiseOr(hints_), bit_or); + TestBinaryBitOp(javascript_.BitwiseOr(), bit_or); } TEST_F(TyperTest, TypeJSBitwiseAnd) { - TestBinaryBitOp(javascript_.BitwiseAnd(hints_), bit_and); + TestBinaryBitOp(javascript_.BitwiseAnd(), bit_and); } TEST_F(TyperTest, TypeJSBitwiseXor) { - TestBinaryBitOp(javascript_.BitwiseXor(hints_), bit_xor); + TestBinaryBitOp(javascript_.BitwiseXor(), bit_xor); } TEST_F(TyperTest, TypeJSShiftLeft) { - TestBinaryBitOp(javascript_.ShiftLeft(hints_), shift_left); + TestBinaryBitOp(javascript_.ShiftLeft(), shift_left); } TEST_F(TyperTest, TypeJSShiftRight) { - TestBinaryBitOp(javascript_.ShiftRight(hints_), shift_right); + TestBinaryBitOp(javascript_.ShiftRight(), shift_right); } @@ -356,9 +357,9 @@ TEST_BINARY_MONOTONICITY(LessThanOrEqual) TEST_BINARY_MONOTONICITY(GreaterThanOrEqual) #undef TEST_BINARY_MONOTONICITY -#define TEST_BINARY_MONOTONICITY(name) \ - TEST_F(TyperTest, Monotonicity_##name) { \ - TestBinaryMonotonicity(javascript_.name(BinaryOperationHint::kAny)); \ +#define TEST_BINARY_MONOTONICITY(name) \ + TEST_F(TyperTest, Monotonicity_##name) { \ + TestBinaryMonotonicity(javascript_.name()); \ } TEST_BINARY_MONOTONICITY(BitwiseOr) TEST_BINARY_MONOTONICITY(BitwiseXor) @@ -366,13 +367,19 @@ TEST_BINARY_MONOTONICITY(BitwiseAnd) TEST_BINARY_MONOTONICITY(ShiftLeft) TEST_BINARY_MONOTONICITY(ShiftRight) TEST_BINARY_MONOTONICITY(ShiftRightLogical) -TEST_BINARY_MONOTONICITY(Add) TEST_BINARY_MONOTONICITY(Subtract) TEST_BINARY_MONOTONICITY(Multiply) TEST_BINARY_MONOTONICITY(Divide) TEST_BINARY_MONOTONICITY(Modulus) #undef TEST_BINARY_MONOTONICITY +#define TEST_BINARY_MONOTONICITY(name) \ + TEST_F(TyperTest, Monotonicity_##name) { \ + TestBinaryMonotonicity(javascript_.name(BinaryOperationHint::kAny)); \ + } +TEST_BINARY_MONOTONICITY(Add) +#undef TEST_BINARY_MONOTONICITY + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc b/deps/v8/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc index 074d0c8677..580b59a35c 100644 --- a/deps/v8/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc +++ b/deps/v8/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc @@ -5,6 +5,7 @@ #include "test/unittests/compiler/instruction-selector-unittest.h" #include "src/compiler/node-matchers.h" +#include "src/objects-inl.h" namespace v8 { namespace internal { diff --git a/deps/v8/test/unittests/heap/slot-set-unittest.cc b/deps/v8/test/unittests/heap/slot-set-unittest.cc index ec905ea2a7..f89feffe33 100644 --- a/deps/v8/test/unittests/heap/slot-set-unittest.cc +++ b/deps/v8/test/unittests/heap/slot-set-unittest.cc @@ -150,8 +150,11 @@ TEST(SlotSet, RemoveRange) { TEST(TypedSlotSet, Iterate) { TypedSlotSet set(0); - const int kDelta = 10000001; - const int kHostDelta = 50001; + // These two constants must be static as a workaround + // for a MSVC++ bug about lambda captures, see the discussion at + // https://social.msdn.microsoft.com/Forums/SqlServer/4abf18bd-4ae4-4c72-ba3e-3b13e7909d5f + static const int kDelta = 10000001; + static const int kHostDelta = 50001; int added = 0; uint32_t j = 0; for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset; @@ -162,8 +165,8 @@ TEST(TypedSlotSet, Iterate) { } int iterated = 0; set.Iterate( - [&iterated, kDelta, kHostDelta](SlotType type, Address host_addr, - Address addr) { + [&iterated](SlotType type, Address host_addr, + Address addr) { uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)); uint32_t j = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(host_addr)); diff --git a/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc index e9b996ea09..9f8a2d4dbe 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc @@ -4,6 +4,7 @@ #include "src/v8.h" +#include "src/ast/scopes.h" #include "src/interpreter/bytecode-array-builder.h" #include "src/interpreter/bytecode-array-iterator.h" #include "src/interpreter/bytecode-label.h" @@ -21,11 +22,13 @@ class BytecodeArrayBuilderTest : public TestWithIsolateAndZone { ~BytecodeArrayBuilderTest() override {} }; - TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { CanonicalHandleScope canonical(isolate()); BytecodeArrayBuilder builder(isolate(), zone(), 0, 1, 131); Factory* factory = isolate()->factory(); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); + DeclarationScope scope(zone(), &ast_factory); CHECK_EQ(builder.locals_count(), 131); CHECK_EQ(builder.context_count(), 1); @@ -52,7 +55,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { .StoreAccumulatorInRegister(reg) .LoadLiteral(Smi::FromInt(10000000)) .StoreAccumulatorInRegister(reg) - .LoadLiteral(factory->NewStringFromStaticChars("A constant")) + .LoadLiteral( + ast_factory.NewString(ast_factory.GetOneByteString("A constant"))) .StoreAccumulatorInRegister(reg) .LoadUndefined() .StoreAccumulatorInRegister(reg) @@ -77,7 +81,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { builder.MoveRegister(reg, wide); // Emit global load / store operations. - Handle<String> name = factory->NewStringFromStaticChars("var_name"); + const AstRawString* name = ast_factory.GetOneByteString("var_name"); builder.LoadGlobal(name, 1, TypeofMode::NOT_INSIDE_TYPEOF) .LoadGlobal(name, 1, TypeofMode::INSIDE_TYPEOF) .StoreGlobal(name, 1, LanguageMode::SLOPPY) @@ -86,12 +90,19 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { // Emit context operations. builder.PushContext(reg) .PopContext(reg) - .LoadContextSlot(reg, 1, 0) - .StoreContextSlot(reg, 1, 0); + .LoadContextSlot(reg, 1, 0, BytecodeArrayBuilder::kMutableSlot) + .StoreContextSlot(reg, 1, 0) + .LoadContextSlot(reg, 2, 0, BytecodeArrayBuilder::kImmutableSlot) + .StoreContextSlot(reg, 3, 0); // Emit context operations which operate on the local context. - builder.LoadContextSlot(Register::current_context(), 1, 0) - .StoreContextSlot(Register::current_context(), 1, 0); + builder + .LoadContextSlot(Register::current_context(), 1, 0, + BytecodeArrayBuilder::kMutableSlot) + .StoreContextSlot(Register::current_context(), 1, 0) + .LoadContextSlot(Register::current_context(), 2, 0, + BytecodeArrayBuilder::kImmutableSlot) + .StoreContextSlot(Register::current_context(), 3, 0); // Emit load / store property operations. builder.LoadNamedProperty(reg, name, 0) @@ -99,7 +110,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { .StoreNamedProperty(reg, name, 0, LanguageMode::SLOPPY) .StoreKeyedProperty(reg, reg, 0, LanguageMode::SLOPPY) .StoreNamedProperty(reg, name, 0, LanguageMode::STRICT) - .StoreKeyedProperty(reg, reg, 0, LanguageMode::STRICT); + .StoreKeyedProperty(reg, reg, 0, LanguageMode::STRICT) + .StoreNamedOwnProperty(reg, name, 0); // Emit load / store lookup slots. builder.LoadLookupSlot(name, TypeofMode::NOT_INSIDE_TYPEOF) @@ -119,14 +131,14 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { builder.CreateClosure(0, 1, NOT_TENURED); // Emit create context operation. - builder.CreateBlockContext(factory->NewScopeInfo(1)); - builder.CreateCatchContext(reg, name, factory->NewScopeInfo(1)); + builder.CreateBlockContext(&scope); + builder.CreateCatchContext(reg, name, &scope); builder.CreateFunctionContext(1); builder.CreateEvalContext(1); - builder.CreateWithContext(reg, factory->NewScopeInfo(1)); + builder.CreateWithContext(reg, &scope); // Emit literal creation operations. - builder.CreateRegExpLiteral(factory->NewStringFromStaticChars("a"), 0, 0); + builder.CreateRegExpLiteral(ast_factory.GetOneByteString("a"), 0, 0); builder.CreateArrayLiteral(0, 0, 0); builder.CreateObjectLiteral(0, 0, 0, reg); @@ -138,7 +150,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { .CallRuntime(Runtime::kIsArray, reg) .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, reg_list, pair) .CallJSRuntime(Context::SPREAD_ITERABLE_INDEX, reg_list) - .NewWithSpread(reg_list); + .CallWithSpread(reg, reg_list); // Emit binary operator invocations. builder.BinaryOperation(Token::Value::ADD, reg, 1) @@ -184,8 +196,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { // Emit delete builder.Delete(reg, LanguageMode::SLOPPY).Delete(reg, LanguageMode::STRICT); - // Emit new. - builder.New(reg, reg_list, 1); + // Emit construct. + builder.Construct(reg, reg_list, 1).ConstructWithSpread(reg, reg_list); // Emit test operator invocations. builder.CompareOperation(Token::Value::EQ, reg, 1) @@ -251,7 +263,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { .JumpIfNull(&end[5]) .JumpIfUndefined(&end[6]) .JumpIfNotHole(&end[7]) - .LoadLiteral(factory->prototype_string()) + .LoadLiteral(ast_factory.prototype_string()) .JumpIfJSReceiver(&end[8]); } @@ -300,10 +312,10 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { // Wide constant pool loads for (int i = 0; i < 256; i++) { // Emit junk in constant pool to force wide constant pool index. - builder.LoadLiteral(factory->NewNumber(2.5321 + i)); + builder.LoadLiteral(ast_factory.NewNumber(2.5321 + i)); } builder.LoadLiteral(Smi::FromInt(20000000)); - Handle<String> wide_name = factory->NewStringFromStaticChars("var_wide_name"); + const AstRawString* wide_name = ast_factory.GetOneByteString("var_wide_name"); // Emit wide global load / store operations. builder.LoadGlobal(name, 1024, TypeofMode::NOT_INSIDE_TYPEOF) @@ -321,13 +333,15 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { .StoreNamedProperty(reg, wide_name, 0, LanguageMode::SLOPPY) .StoreKeyedProperty(reg, reg, 2056, LanguageMode::SLOPPY) .StoreNamedProperty(reg, wide_name, 0, LanguageMode::STRICT) - .StoreKeyedProperty(reg, reg, 2056, LanguageMode::STRICT); + .StoreKeyedProperty(reg, reg, 2056, LanguageMode::STRICT) + .StoreNamedOwnProperty(reg, wide_name, 0); builder.StoreDataPropertyInLiteral(reg, reg, DataPropertyInLiteralFlag::kNoFlags, 0); // Emit wide context operations. - builder.LoadContextSlot(reg, 1024, 0).StoreContextSlot(reg, 1024, 0); + builder.LoadContextSlot(reg, 1024, 0, BytecodeArrayBuilder::kMutableSlot) + .StoreContextSlot(reg, 1024, 0); // Emit wide load / store lookup slots. builder.LoadLookupSlot(wide_name, TypeofMode::NOT_INSIDE_TYPEOF) @@ -340,8 +354,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { // Emit wide variant of literal creation operations. builder - .CreateRegExpLiteral(factory->NewStringFromStaticChars("wide_literal"), 0, - 0) + .CreateRegExpLiteral(ast_factory.GetOneByteString("wide_literal"), 0, 0) .CreateArrayLiteral(0, 0, 0) .CreateObjectLiteral(0, 0, 0, reg); @@ -364,8 +377,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { builder.Debugger(); // Insert dummy ops to force longer jumps. - for (int i = 0; i < 128; i++) { - builder.LoadTrue(); + for (int i = 0; i < 256; i++) { + builder.Debugger(); } // Bind labels for long jumps at the very end. @@ -377,6 +390,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { builder.Return(); // Generate BytecodeArray. + scope.SetScriptScopeInfo(factory->NewScopeInfo(1)); + ast_factory.Internalize(isolate()); Handle<BytecodeArray> the_array = builder.ToBytecodeArray(isolate()); CHECK_EQ(the_array->frame_size(), builder.total_register_count() * kPointerSize); @@ -496,20 +511,25 @@ TEST_F(BytecodeArrayBuilderTest, Parameters) { TEST_F(BytecodeArrayBuilderTest, Constants) { CanonicalHandleScope canonical(isolate()); BytecodeArrayBuilder builder(isolate(), zone(), 0, 0, 0); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); + + const AstValue* heap_num_1 = ast_factory.NewNumber(3.14); + const AstValue* heap_num_2 = ast_factory.NewNumber(5.2); + const AstValue* string = + ast_factory.NewString(ast_factory.GetOneByteString("foo")); + const AstValue* string_copy = + ast_factory.NewString(ast_factory.GetOneByteString("foo")); - Factory* factory = isolate()->factory(); - Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(3.14); - Handle<HeapObject> heap_num_2 = factory->NewHeapNumber(5.2); - Handle<Object> large_smi(Smi::FromInt(0x12345678), isolate()); - Handle<HeapObject> heap_num_2_copy(*heap_num_2); builder.LoadLiteral(heap_num_1) .LoadLiteral(heap_num_2) - .LoadLiteral(large_smi) + .LoadLiteral(string) .LoadLiteral(heap_num_1) .LoadLiteral(heap_num_1) - .LoadLiteral(heap_num_2_copy) + .LoadLiteral(string_copy) .Return(); + ast_factory.Internalize(isolate()); Handle<BytecodeArray> array = builder.ToBytecodeArray(isolate()); // Should only have one entry for each identical constant. CHECK_EQ(array->constant_pool()->length(), 3); @@ -523,7 +543,7 @@ static Bytecode PeepholeToBoolean(Bytecode jump_bytecode) { TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { CanonicalHandleScope canonical(isolate()); - static const int kFarJumpDistance = 256; + static const int kFarJumpDistance = 256 + 20; BytecodeArrayBuilder builder(isolate(), zone(), 0, 0, 1); @@ -568,7 +588,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { BytecodeArrayIterator iterator(array); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJump); - CHECK_EQ(iterator.GetImmediateOperand(0), 22); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 22); iterator.Advance(); // Ignore compare operation. @@ -576,7 +596,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { CHECK_EQ(iterator.current_bytecode(), PeepholeToBoolean(Bytecode::kJumpIfToBooleanTrue)); - CHECK_EQ(iterator.GetImmediateOperand(0), 17); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 17); iterator.Advance(); // Ignore compare operation. @@ -584,21 +604,21 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { CHECK_EQ(iterator.current_bytecode(), PeepholeToBoolean(Bytecode::kJumpIfToBooleanFalse)); - CHECK_EQ(iterator.GetImmediateOperand(0), 12); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 12); iterator.Advance(); // Ignore add operation. iterator.Advance(); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfToBooleanTrue); - CHECK_EQ(iterator.GetImmediateOperand(0), 7); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 7); iterator.Advance(); // Ignore add operation. iterator.Advance(); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfToBooleanFalse); - CHECK_EQ(iterator.GetImmediateOperand(0), 2); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 2); iterator.Advance(); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpConstant); @@ -669,13 +689,13 @@ TEST_F(BytecodeArrayBuilderTest, BackwardJumps) { Handle<BytecodeArray> array = builder.ToBytecodeArray(isolate()); BytecodeArrayIterator iterator(array); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpLoop); - CHECK_EQ(iterator.GetImmediateOperand(0), 0); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 0); iterator.Advance(); - for (int i = 0; i < 42; i++) { + for (unsigned i = 0; i < 42; i++) { CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpLoop); CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); // offset of 3 (because kJumpLoop takes two immediate operands) - CHECK_EQ(iterator.GetImmediateOperand(0), -i * 3 - 3); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), i * 3 + 3); iterator.Advance(); } // Check padding to force wide backwards jumps. @@ -685,7 +705,7 @@ TEST_F(BytecodeArrayBuilderTest, BackwardJumps) { } CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpLoop); CHECK_EQ(iterator.current_operand_scale(), OperandScale::kDouble); - CHECK_EQ(iterator.GetImmediateOperand(0), -386); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 386); iterator.Advance(); CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); iterator.Advance(); @@ -712,13 +732,13 @@ TEST_F(BytecodeArrayBuilderTest, LabelReuse) { Handle<BytecodeArray> array = builder.ToBytecodeArray(isolate()); BytecodeArrayIterator iterator(array); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJump); - CHECK_EQ(iterator.GetImmediateOperand(0), 2); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 2); iterator.Advance(); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpLoop); - CHECK_EQ(iterator.GetImmediateOperand(0), 0); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 0); iterator.Advance(); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpLoop); - CHECK_EQ(iterator.GetImmediateOperand(0), -3); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 3); iterator.Advance(); CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); iterator.Advance(); @@ -746,13 +766,13 @@ TEST_F(BytecodeArrayBuilderTest, LabelAddressReuse) { BytecodeArrayIterator iterator(array); for (int i = 0; i < kRepeats; i++) { CHECK_EQ(iterator.current_bytecode(), Bytecode::kJump); - CHECK_EQ(iterator.GetImmediateOperand(0), 2); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 2); iterator.Advance(); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpLoop); - CHECK_EQ(iterator.GetImmediateOperand(0), 0); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 0); iterator.Advance(); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpLoop); - CHECK_EQ(iterator.GetImmediateOperand(0), -3); + CHECK_EQ(iterator.GetUnsignedImmediateOperand(0), 3); iterator.Advance(); } CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); diff --git a/deps/v8/test/unittests/interpreter/bytecode-array-iterator-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-array-iterator-unittest.cc index cd7d764ee5..2befb103d6 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-array-iterator-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-array-iterator-unittest.cc @@ -19,14 +19,14 @@ class BytecodeArrayIteratorTest : public TestWithIsolateAndZone { ~BytecodeArrayIteratorTest() override {} }; - TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { // Use a builder to create an array with containing multiple bytecodes // with 0, 1 and 2 operands. BytecodeArrayBuilder builder(isolate(), zone(), 3, 3, 0); - Factory* factory = isolate()->factory(); - Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); - Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); + const AstValue* heap_num_0 = ast_factory.NewNumber(2.718); + const AstValue* heap_num_1 = ast_factory.NewNumber(2.0 * Smi::kMaxValue); Smi* zero = Smi::kZero; Smi* smi_0 = Smi::FromInt(64); Smi* smi_1 = Smi::FromInt(-65536); @@ -35,7 +35,7 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { RegisterList pair(0, 2); RegisterList triple(0, 3); Register param = Register::FromParameterIndex(2, builder.parameter_count()); - Handle<String> name = factory->NewStringFromStaticChars("abc"); + const AstRawString* name = ast_factory.GetOneByteString("abc"); uint32_t name_index = 2; uint32_t feedback_slot = 97; @@ -65,6 +65,7 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { .Return(); // Test iterator sees the expected output from the builder. + ast_factory.Internalize(isolate()); BytecodeArrayIterator iterator(builder.ToBytecodeArray(isolate())); const int kPrefixByteSize = 1; int offset = 0; @@ -72,7 +73,8 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); CHECK_EQ(iterator.current_offset(), offset); CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_0)); + CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to( + heap_num_0->value())); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle); iterator.Advance(); @@ -89,7 +91,8 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); CHECK_EQ(iterator.current_offset(), offset); CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_1)); + CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to( + heap_num_1->value())); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle); iterator.Advance(); diff --git a/deps/v8/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc index 2209dc9219..294adf711f 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc @@ -23,9 +23,10 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidBeforeStart) { // Use a builder to create an array with containing multiple bytecodes // with 0, 1 and 2 operands. BytecodeArrayBuilder builder(isolate(), zone(), 3, 3, 0); - Factory* factory = isolate()->factory(); - Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); - Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); + const AstValue* heap_num_0 = ast_factory.NewNumber(2.718); + const AstValue* heap_num_1 = ast_factory.NewNumber(2.0 * Smi::kMaxValue); Smi* zero = Smi::kZero; Smi* smi_0 = Smi::FromInt(64); Smi* smi_1 = Smi::FromInt(-65536); @@ -34,7 +35,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidBeforeStart) { RegisterList pair(0, 2); RegisterList triple(0, 3); Register param = Register::FromParameterIndex(2, builder.parameter_count()); - Handle<String> name = factory->NewStringFromStaticChars("abc"); + const AstRawString* name = ast_factory.GetOneByteString("abc"); uint32_t feedback_slot = 97; builder.LoadLiteral(heap_num_0) @@ -62,6 +63,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidBeforeStart) { .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) .Return(); + ast_factory.Internalize(isolate()); Handle<BytecodeArray> bytecodeArray = builder.ToBytecodeArray(isolate()); BytecodeArrayRandomIterator iterator(bytecodeArray, zone()); @@ -75,9 +77,10 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidAfterEnd) { // Use a builder to create an array with containing multiple bytecodes // with 0, 1 and 2 operands. BytecodeArrayBuilder builder(isolate(), zone(), 3, 3, 0); - Factory* factory = isolate()->factory(); - Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); - Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); + const AstValue* heap_num_0 = ast_factory.NewNumber(2.718); + const AstValue* heap_num_1 = ast_factory.NewNumber(2.0 * Smi::kMaxValue); Smi* zero = Smi::kZero; Smi* smi_0 = Smi::FromInt(64); Smi* smi_1 = Smi::FromInt(-65536); @@ -86,7 +89,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidAfterEnd) { RegisterList pair(0, 2); RegisterList triple(0, 3); Register param = Register::FromParameterIndex(2, builder.parameter_count()); - Handle<String> name = factory->NewStringFromStaticChars("abc"); + const AstRawString* name = ast_factory.GetOneByteString("abc"); uint32_t feedback_slot = 97; builder.LoadLiteral(heap_num_0) @@ -114,6 +117,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidAfterEnd) { .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) .Return(); + ast_factory.Internalize(isolate()); Handle<BytecodeArray> bytecodeArray = builder.ToBytecodeArray(isolate()); BytecodeArrayRandomIterator iterator(bytecodeArray, zone()); @@ -127,9 +131,10 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesFirst) { // Use a builder to create an array with containing multiple bytecodes // with 0, 1 and 2 operands. BytecodeArrayBuilder builder(isolate(), zone(), 3, 3, 0); - Factory* factory = isolate()->factory(); - Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); - Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); + const AstValue* heap_num_0 = ast_factory.NewNumber(2.718); + const AstValue* heap_num_1 = ast_factory.NewNumber(2.0 * Smi::kMaxValue); Smi* zero = Smi::kZero; Smi* smi_0 = Smi::FromInt(64); Smi* smi_1 = Smi::FromInt(-65536); @@ -138,7 +143,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesFirst) { RegisterList pair(0, 2); RegisterList triple(0, 3); Register param = Register::FromParameterIndex(2, builder.parameter_count()); - Handle<String> name = factory->NewStringFromStaticChars("abc"); + const AstRawString* name = ast_factory.GetOneByteString("abc"); uint32_t feedback_slot = 97; builder.LoadLiteral(heap_num_0) @@ -166,6 +171,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesFirst) { .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) .Return(); + ast_factory.Internalize(isolate()); Handle<BytecodeArray> bytecodeArray = builder.ToBytecodeArray(isolate()); BytecodeArrayRandomIterator iterator(bytecodeArray, zone()); @@ -175,8 +181,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesFirst) { EXPECT_EQ(iterator.current_index(), 0); EXPECT_EQ(iterator.current_offset(), 0); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - EXPECT_TRUE( - iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_0)); + EXPECT_TRUE(iterator.GetConstantForIndexOperand(0).is_identical_to( + heap_num_0->value())); ASSERT_TRUE(iterator.IsValid()); } @@ -184,9 +190,10 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesLast) { // Use a builder to create an array with containing multiple bytecodes // with 0, 1 and 2 operands. BytecodeArrayBuilder builder(isolate(), zone(), 3, 3, 0); - Factory* factory = isolate()->factory(); - Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); - Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); + const AstValue* heap_num_0 = ast_factory.NewNumber(2.718); + const AstValue* heap_num_1 = ast_factory.NewNumber(2.0 * Smi::kMaxValue); Smi* zero = Smi::kZero; Smi* smi_0 = Smi::FromInt(64); Smi* smi_1 = Smi::FromInt(-65536); @@ -195,7 +202,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesLast) { RegisterList pair(0, 2); RegisterList triple(0, 3); Register param = Register::FromParameterIndex(2, builder.parameter_count()); - Handle<String> name = factory->NewStringFromStaticChars("abc"); + const AstRawString* name = ast_factory.GetOneByteString("abc"); uint32_t feedback_slot = 97; builder.LoadLiteral(heap_num_0) @@ -223,6 +230,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesLast) { .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) .Return(); + ast_factory.Internalize(isolate()); Handle<BytecodeArray> bytecodeArray = builder.ToBytecodeArray(isolate()); BytecodeArrayRandomIterator iterator(bytecodeArray, zone()); @@ -241,9 +249,10 @@ TEST_F(BytecodeArrayRandomIteratorTest, RandomAccessValid) { // Use a builder to create an array with containing multiple bytecodes // with 0, 1 and 2 operands. BytecodeArrayBuilder builder(isolate(), zone(), 3, 3, 0); - Factory* factory = isolate()->factory(); - Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); - Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); + const AstValue* heap_num_0 = ast_factory.NewNumber(2.718); + const AstValue* heap_num_1 = ast_factory.NewNumber(2.0 * Smi::kMaxValue); Smi* zero = Smi::kZero; Smi* smi_0 = Smi::FromInt(64); Smi* smi_1 = Smi::FromInt(-65536); @@ -252,7 +261,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, RandomAccessValid) { RegisterList pair(0, 2); RegisterList triple(0, 3); Register param = Register::FromParameterIndex(2, builder.parameter_count()); - Handle<String> name = factory->NewStringFromStaticChars("abc"); + const AstRawString* name = ast_factory.GetOneByteString("abc"); uint32_t name_index = 2; uint32_t feedback_slot = 97; @@ -282,6 +291,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, RandomAccessValid) { .Return(); // Test iterator sees the expected output from the builder. + ast_factory.Internalize(isolate()); BytecodeArrayRandomIterator iterator(builder.ToBytecodeArray(isolate()), zone()); const int kPrefixByteSize = 1; @@ -319,8 +329,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, RandomAccessValid) { EXPECT_EQ(iterator.current_index(), 2); EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - EXPECT_TRUE( - iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_1)); + EXPECT_TRUE(iterator.GetConstantForIndexOperand(0).is_identical_to( + heap_num_1->value())); ASSERT_TRUE(iterator.IsValid()); iterator.GoToIndex(18); @@ -427,9 +437,10 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) { // Use a builder to create an array with containing multiple bytecodes // with 0, 1 and 2 operands. BytecodeArrayBuilder builder(isolate(), zone(), 3, 3, 0); - Factory* factory = isolate()->factory(); - Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); - Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); + const AstValue* heap_num_0 = ast_factory.NewNumber(2.718); + const AstValue* heap_num_1 = ast_factory.NewNumber(2.0 * Smi::kMaxValue); Smi* zero = Smi::kZero; Smi* smi_0 = Smi::FromInt(64); Smi* smi_1 = Smi::FromInt(-65536); @@ -438,7 +449,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) { RegisterList pair(0, 2); RegisterList triple(0, 3); Register param = Register::FromParameterIndex(2, builder.parameter_count()); - Handle<String> name = factory->NewStringFromStaticChars("abc"); + const AstRawString* name = ast_factory.GetOneByteString("abc"); uint32_t name_index = 2; uint32_t feedback_slot = 97; @@ -468,6 +479,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) { .Return(); // Test iterator sees the expected output from the builder. + ast_factory.Internalize(isolate()); BytecodeArrayRandomIterator iterator(builder.ToBytecodeArray(isolate()), zone()); const int kPrefixByteSize = 1; @@ -477,8 +489,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) { EXPECT_EQ(iterator.current_index(), 0); EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - EXPECT_TRUE( - iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_0)); + EXPECT_TRUE(iterator.GetConstantForIndexOperand(0).is_identical_to( + heap_num_0->value())); ASSERT_TRUE(iterator.IsValid()); offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle); ++iterator; @@ -497,8 +509,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) { EXPECT_EQ(iterator.current_index(), 2); EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - EXPECT_TRUE( - iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_1)); + EXPECT_TRUE(iterator.GetConstantForIndexOperand(0).is_identical_to( + heap_num_1->value())); ASSERT_TRUE(iterator.IsValid()); offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle); ++iterator; @@ -717,9 +729,10 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) { // Use a builder to create an array with containing multiple bytecodes // with 0, 1 and 2 operands. BytecodeArrayBuilder builder(isolate(), zone(), 3, 3, 0); - Factory* factory = isolate()->factory(); - Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); - Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); + const AstValue* heap_num_0 = ast_factory.NewNumber(2.718); + const AstValue* heap_num_1 = ast_factory.NewNumber(2.0 * Smi::kMaxValue); Smi* zero = Smi::kZero; Smi* smi_0 = Smi::FromInt(64); Smi* smi_1 = Smi::FromInt(-65536); @@ -728,7 +741,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) { RegisterList pair(0, 2); RegisterList triple(0, 3); Register param = Register::FromParameterIndex(2, builder.parameter_count()); - Handle<String> name = factory->NewStringFromStaticChars("abc"); + const AstRawString* name = ast_factory.GetOneByteString("abc"); uint32_t name_index = 2; uint32_t feedback_slot = 97; @@ -758,6 +771,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) { .Return(); // Test iterator sees the expected output from the builder. + ast_factory.Internalize(isolate()); Handle<BytecodeArray> bytecodeArray = builder.ToBytecodeArray(isolate()); BytecodeArrayRandomIterator iterator(bytecodeArray, zone()); const int kPrefixByteSize = 1; @@ -979,8 +993,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) { EXPECT_EQ(iterator.current_index(), 2); EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - EXPECT_TRUE( - iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_1)); + EXPECT_TRUE(iterator.GetConstantForIndexOperand(0).is_identical_to( + heap_num_1->value())); ASSERT_TRUE(iterator.IsValid()); --iterator; @@ -999,8 +1013,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) { EXPECT_EQ(iterator.current_index(), 0); EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - EXPECT_TRUE( - iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_0)); + EXPECT_TRUE(iterator.GetConstantForIndexOperand(0).is_identical_to( + heap_num_0->value())); ASSERT_TRUE(iterator.IsValid()); --iterator; ASSERT_FALSE(iterator.IsValid()); diff --git a/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc index 91b3a7554b..f7e17714da 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc @@ -23,7 +23,7 @@ namespace interpreter { class BytecodeArrayWriterUnittest : public TestWithIsolateAndZone { public: BytecodeArrayWriterUnittest() - : constant_array_builder_(zone(), isolate()->factory()->the_hole_value()), + : constant_array_builder_(zone()), bytecode_array_writer_( zone(), &constant_array_builder_, SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS) {} @@ -168,7 +168,7 @@ TEST_F(BytecodeArrayWriterUnittest, ComplexExample) { /* 36 85 S> */ B(Return), /* 37 */ B(ForInStep), R8(7), /* 39 */ B(Star), R8(7), - /* 41 */ B(JumpLoop), U8(-24), U8(0), + /* 41 */ B(JumpLoop), U8(24), U8(0), /* 44 */ B(LdaUndefined), /* 45 85 S> */ B(Return), // clang-format on diff --git a/deps/v8/test/unittests/interpreter/bytecode-decoder-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-decoder-unittest.cc index 1b0af73e05..14972259da 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-decoder-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-decoder-unittest.cc @@ -7,6 +7,7 @@ #include "src/v8.h" #include "src/interpreter/bytecode-decoder.h" +#include "src/runtime/runtime.h" #include "test/unittests/interpreter/bytecode-utils.h" #include "test/unittests/test-utils.h" @@ -45,10 +46,10 @@ TEST(BytecodeDecoder, DecodeBytecodeAndOperands) { 3, 0, " ForInPrepare r10, r11-r13"}, - {{B(CallRuntime), U16(134), R8(0), U8(0)}, + {{B(CallRuntime), U16(Runtime::FunctionId::kIsDate), R8(0), U8(0)}, 5, 0, - " CallRuntime [134], r0-r0"}, + " CallRuntime [IsDate], r0-r0"}, {{B(Ldar), static_cast<uint8_t>(Register::FromParameterIndex(2, 3).ToOperand())}, 2, diff --git a/deps/v8/test/unittests/interpreter/constant-array-builder-unittest.cc b/deps/v8/test/unittests/interpreter/constant-array-builder-unittest.cc index 3a0ec0835c..027fa95ede 100644 --- a/deps/v8/test/unittests/interpreter/constant-array-builder-unittest.cc +++ b/deps/v8/test/unittests/interpreter/constant-array-builder-unittest.cc @@ -4,6 +4,7 @@ #include "src/v8.h" +#include "src/ast/ast-value-factory.h" #include "src/factory.h" #include "src/handles-inl.h" #include "src/interpreter/constant-array-builder.h" @@ -31,68 +32,91 @@ STATIC_CONST_MEMBER_DEFINITION const size_t TEST_F(ConstantArrayBuilderTest, AllocateAllEntries) { CanonicalHandleScope canonical(isolate()); - ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); + ConstantArrayBuilder builder(zone()); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); for (size_t i = 0; i < k16BitCapacity; i++) { - builder.Insert(handle(Smi::FromInt(static_cast<int>(i)), isolate())); + builder.Insert(ast_factory.NewNumber(i + 0.5)); } CHECK_EQ(builder.size(), k16BitCapacity); + ast_factory.Internalize(isolate()); for (size_t i = 0; i < k16BitCapacity; i++) { - CHECK_EQ(Handle<Smi>::cast(builder.At(i))->value(), static_cast<int>(i)); + CHECK_EQ( + Handle<HeapNumber>::cast(builder.At(i, isolate()).ToHandleChecked()) + ->value(), + i + 0.5); } } TEST_F(ConstantArrayBuilderTest, ToFixedArray) { CanonicalHandleScope canonical(isolate()); - ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); + ConstantArrayBuilder builder(zone()); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); static const size_t kNumberOfElements = 37; for (size_t i = 0; i < kNumberOfElements; i++) { - Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); - builder.Insert(object); - CHECK(builder.At(i)->SameValue(*object)); + const AstValue* value = ast_factory.NewNumber(i + 0.5); + builder.Insert(value); + ast_factory.Internalize(isolate()); + CHECK( + builder.At(i, isolate()).ToHandleChecked()->SameValue(*value->value())); } + ast_factory.Internalize(isolate()); Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); CHECK_EQ(constant_array->length(), static_cast<int>(kNumberOfElements)); for (size_t i = 0; i < kNumberOfElements; i++) { - CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i))); + CHECK(constant_array->get(static_cast<int>(i)) + ->SameValue(*builder.At(i, isolate()).ToHandleChecked())); } } TEST_F(ConstantArrayBuilderTest, ToLargeFixedArray) { CanonicalHandleScope canonical(isolate()); - ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); + ConstantArrayBuilder builder(zone()); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); static const size_t kNumberOfElements = 37373; for (size_t i = 0; i < kNumberOfElements; i++) { - Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); - builder.Insert(object); - CHECK(builder.At(i)->SameValue(*object)); + const AstValue* value = ast_factory.NewNumber(i + 0.5); + builder.Insert(value); + ast_factory.Internalize(isolate()); + CHECK( + builder.At(i, isolate()).ToHandleChecked()->SameValue(*value->value())); } + ast_factory.Internalize(isolate()); Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); CHECK_EQ(constant_array->length(), static_cast<int>(kNumberOfElements)); for (size_t i = 0; i < kNumberOfElements; i++) { - CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i))); + CHECK(constant_array->get(static_cast<int>(i)) + ->SameValue(*builder.At(i, isolate()).ToHandleChecked())); } } TEST_F(ConstantArrayBuilderTest, ToLargeFixedArrayWithReservations) { CanonicalHandleScope canonical(isolate()); - ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); + ConstantArrayBuilder builder(zone()); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); static const size_t kNumberOfElements = 37373; for (size_t i = 0; i < kNumberOfElements; i++) { builder.CommitReservedEntry(builder.CreateReservedEntry(), Smi::FromInt(static_cast<int>(i))); } + ast_factory.Internalize(isolate()); Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); CHECK_EQ(constant_array->length(), static_cast<int>(kNumberOfElements)); for (size_t i = 0; i < kNumberOfElements; i++) { - CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i))); + CHECK(constant_array->get(static_cast<int>(i)) + ->SameValue(*builder.At(i, isolate()).ToHandleChecked())); } } TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx8Reservations) { CanonicalHandleScope canonical(isolate()); for (size_t reserved = 1; reserved < k8BitCapacity; reserved *= 3) { - ConstantArrayBuilder builder(zone(), - isolate()->factory()->the_hole_value()); + ConstantArrayBuilder builder(zone()); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); for (size_t i = 0; i < reserved; i++) { OperandSize operand_size = builder.CreateReservedEntry(); CHECK(operand_size == OperandSize::kByte); @@ -110,12 +134,6 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx8Reservations) { } CHECK_EQ(builder.size(), 2 * k8BitCapacity + reserved); - // Check reserved values represented by the hole. - for (size_t i = 0; i < reserved; i++) { - Handle<Object> empty = builder.At(k8BitCapacity - reserved + i); - CHECK(empty->SameValue(isolate()->heap()->the_hole_value())); - } - // Commit reserved entries with duplicates and check size does not change. DCHECK_EQ(reserved + 2 * k8BitCapacity, builder.size()); size_t duplicates_in_idx8_space = @@ -137,6 +155,12 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx8Reservations) { CHECK_EQ(index, k8BitCapacity - reserved + i); } + // Clear any remaining uncommited reservations. + for (size_t i = 0; i < reserved - duplicates_in_idx8_space; i++) { + builder.DiscardReservedEntry(OperandSize::kByte); + } + + ast_factory.Internalize(isolate()); Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); CHECK_EQ(constant_array->length(), static_cast<int>(2 * k8BitCapacity + reserved)); @@ -158,8 +182,9 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx8Reservations) { TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithWideReservations) { CanonicalHandleScope canonical(isolate()); for (size_t reserved = 1; reserved < k8BitCapacity; reserved *= 3) { - ConstantArrayBuilder builder(zone(), - isolate()->factory()->the_hole_value()); + ConstantArrayBuilder builder(zone()); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); for (size_t i = 0; i < k8BitCapacity; i++) { builder.CommitReservedEntry(builder.CreateReservedEntry(), Smi::FromInt(static_cast<int>(i))); @@ -189,6 +214,7 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithWideReservations) { CHECK_EQ(builder.size(), i + 1); } + ast_factory.Internalize(isolate()); Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); CHECK_EQ(constant_array->length(), static_cast<int>(k8BitCapacity + reserved)); @@ -201,7 +227,9 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithWideReservations) { TEST_F(ConstantArrayBuilderTest, GapFilledWhenLowReservationCommitted) { CanonicalHandleScope canonical(isolate()); - ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); + ConstantArrayBuilder builder(zone()); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); for (size_t i = 0; i < k8BitCapacity; i++) { OperandSize operand_size = builder.CreateReservedEntry(); CHECK(OperandSize::kByte == operand_size); @@ -217,6 +245,7 @@ TEST_F(ConstantArrayBuilderTest, GapFilledWhenLowReservationCommitted) { Smi::FromInt(static_cast<int>(i))); CHECK_EQ(builder.size(), 2 * k8BitCapacity); } + ast_factory.Internalize(isolate()); Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); CHECK_EQ(constant_array->length(), static_cast<int>(2 * k8BitCapacity)); for (size_t i = 0; i < k8BitCapacity; i++) { @@ -230,59 +259,81 @@ TEST_F(ConstantArrayBuilderTest, GapFilledWhenLowReservationCommitted) { TEST_F(ConstantArrayBuilderTest, GapNotFilledWhenLowReservationDiscarded) { CanonicalHandleScope canonical(isolate()); - ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); + ConstantArrayBuilder builder(zone()); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); for (size_t i = 0; i < k8BitCapacity; i++) { OperandSize operand_size = builder.CreateReservedEntry(); CHECK(OperandSize::kByte == operand_size); CHECK_EQ(builder.size(), 0u); } + const AstValue* ast_values[k8BitCapacity]; for (size_t i = 0; i < k8BitCapacity; i++) { - Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); - builder.Insert(object); + ast_values[i] = ast_factory.NewNumber(i + 0.5); + } + + for (size_t i = 0; i < k8BitCapacity; i++) { + builder.Insert(ast_values[i]); CHECK_EQ(builder.size(), i + k8BitCapacity + 1); } for (size_t i = 0; i < k8BitCapacity; i++) { builder.DiscardReservedEntry(OperandSize::kByte); - builder.Insert(builder.At(i + k8BitCapacity)); + builder.Insert(ast_values[i]); CHECK_EQ(builder.size(), 2 * k8BitCapacity); } + ast_factory.Internalize(isolate()); for (size_t i = 0; i < k8BitCapacity; i++) { - Handle<Object> reference = isolate()->factory()->NewNumberFromSize(i); - Handle<Object> original = builder.At(k8BitCapacity + i); + Handle<Object> reference = isolate()->factory()->NewNumber(i + 0.5); + Handle<Object> original = + builder.At(k8BitCapacity + i, isolate()).ToHandleChecked(); CHECK(original->SameValue(*reference)); - Handle<Object> duplicate = builder.At(i); - CHECK(duplicate->SameValue(*isolate()->factory()->the_hole_value())); + MaybeHandle<Object> duplicate = builder.At(i, isolate()); + CHECK(duplicate.is_null()); } } TEST_F(ConstantArrayBuilderTest, HolesWithUnusedReservations) { CanonicalHandleScope canonical(isolate()); static int kNumberOfHoles = 128; - ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); + static int k8BitCapacity = ConstantArrayBuilder::k8BitCapacity; + ConstantArrayBuilder builder(zone()); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); for (int i = 0; i < kNumberOfHoles; ++i) { CHECK_EQ(builder.CreateReservedEntry(), OperandSize::kByte); } - for (int i = 0; i < 128; ++i) { - CHECK_EQ(builder.Insert(isolate()->factory()->NewNumber(i)), + // Values are placed before the reserved entries in the same slice. + for (int i = 0; i < k8BitCapacity - kNumberOfHoles; ++i) { + CHECK_EQ(builder.Insert(ast_factory.NewNumber(i + 0.5)), static_cast<size_t>(i)); } - CHECK_EQ(builder.Insert(isolate()->factory()->NewNumber(256)), 256u); + // The next value is pushed into the next slice. + CHECK_EQ(builder.Insert(ast_factory.NewNumber(k8BitCapacity + 0.5)), + k8BitCapacity); + // Discard the reserved entries. + for (int i = 0; i < kNumberOfHoles; ++i) { + builder.DiscardReservedEntry(OperandSize::kByte); + } + + ast_factory.Internalize(isolate()); Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); - CHECK_EQ(constant_array->length(), 257); - for (int i = 128; i < 256; i++) { + CHECK_EQ(constant_array->length(), k8BitCapacity + 1); + for (int i = kNumberOfHoles; i < k8BitCapacity; i++) { CHECK(constant_array->get(i)->SameValue( *isolate()->factory()->the_hole_value())); } - CHECK(!constant_array->get(127)->SameValue( - *isolate()->factory()->the_hole_value())); - CHECK(!constant_array->get(256)->SameValue( - *isolate()->factory()->the_hole_value())); + CHECK(!constant_array->get(kNumberOfHoles - 1) + ->SameValue(*isolate()->factory()->the_hole_value())); + CHECK(!constant_array->get(k8BitCapacity) + ->SameValue(*isolate()->factory()->the_hole_value())); } TEST_F(ConstantArrayBuilderTest, ReservationsAtAllScales) { CanonicalHandleScope canonical(isolate()); - ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); + ConstantArrayBuilder builder(zone()); + AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), + isolate()->heap()->HashSeed()); for (int i = 0; i < 256; i++) { CHECK_EQ(builder.CreateReservedEntry(), OperandSize::kByte); } @@ -298,6 +349,17 @@ TEST_F(ConstantArrayBuilderTest, ReservationsAtAllScales) { 256u); CHECK_EQ(builder.CommitReservedEntry(OperandSize::kQuad, Smi::FromInt(3)), 65536u); + for (int i = 1; i < 256; i++) { + builder.DiscardReservedEntry(OperandSize::kByte); + } + for (int i = 257; i < 65536; ++i) { + builder.DiscardReservedEntry(OperandSize::kShort); + } + for (int i = 65537; i < 131072; ++i) { + builder.DiscardReservedEntry(OperandSize::kQuad); + } + + ast_factory.Internalize(isolate()); Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); CHECK_EQ(constant_array->length(), 65537); int count = 1; @@ -314,12 +376,12 @@ TEST_F(ConstantArrayBuilderTest, ReservationsAtAllScales) { TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithFixedReservations) { CanonicalHandleScope canonical(isolate()); - ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); + ConstantArrayBuilder builder(zone()); for (size_t i = 0; i < k16BitCapacity; i++) { if ((i % 2) == 0) { - CHECK_EQ(i, builder.AllocateEntry()); + CHECK_EQ(i, builder.InsertDeferred()); } else { - builder.Insert(handle(Smi::FromInt(static_cast<int>(i)), isolate())); + builder.Insert(Smi::FromInt(static_cast<int>(i))); } } CHECK_EQ(builder.size(), k16BitCapacity); @@ -327,23 +389,27 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithFixedReservations) { // Check values before reserved entries are inserted. for (size_t i = 0; i < k16BitCapacity; i++) { if ((i % 2) == 0) { - // Check reserved values are the hole. - Handle<Object> empty = builder.At(i); - CHECK(empty->SameValue(isolate()->heap()->the_hole_value())); + // Check reserved values are null. + MaybeHandle<Object> empty = builder.At(i, isolate()); + CHECK(empty.is_null()); } else { - CHECK_EQ(Handle<Smi>::cast(builder.At(i))->value(), static_cast<int>(i)); + CHECK_EQ(Handle<Smi>::cast(builder.At(i, isolate()).ToHandleChecked()) + ->value(), + static_cast<int>(i)); } } // Insert reserved entries. for (size_t i = 0; i < k16BitCapacity; i += 2) { - builder.InsertAllocatedEntry( - i, handle(Smi::FromInt(static_cast<int>(i)), isolate())); + builder.SetDeferredAt(i, + handle(Smi::FromInt(static_cast<int>(i)), isolate())); } // Check values after reserved entries are inserted. for (size_t i = 0; i < k16BitCapacity; i++) { - CHECK_EQ(Handle<Smi>::cast(builder.At(i))->value(), static_cast<int>(i)); + CHECK_EQ( + Handle<Smi>::cast(builder.At(i, isolate()).ToHandleChecked())->value(), + static_cast<int>(i)); } } diff --git a/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc b/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc index 7e0542b68f..1cb1afdbc1 100644 --- a/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc +++ b/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc @@ -8,6 +8,7 @@ #include "src/compiler/node.h" #include "src/interface-descriptors.h" #include "src/isolate.h" +#include "src/objects-inl.h" #include "test/unittests/compiler/compiler-test-utils.h" #include "test/unittests/compiler/node-test-utils.h" @@ -18,6 +19,14 @@ namespace internal { using namespace compiler; +#ifdef ENABLE_VERIFY_CSA +#define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) IsBitcastWordToTaggedSigned(x) +#define IS_BITCAST_TAGGED_TO_WORD(x) IsBitcastTaggedToWord(x) +#else +#define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) (x) +#define IS_BITCAST_TAGGED_TO_WORD(x) (x) +#endif + namespace interpreter { InterpreterAssemblerTestState::InterpreterAssemblerTestState( @@ -305,61 +314,6 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedOperand( return nullptr; } -TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) { - TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { - InterpreterAssemblerTestState state(this, bytecode); - InterpreterAssemblerForTest m(&state, bytecode); - Node* tail_call_node = m.Dispatch(); - - OperandScale operand_scale = OperandScale::kSingle; - Matcher<Node*> next_bytecode_offset_matcher = - IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant( - interpreter::Bytecodes::Size(bytecode, operand_scale))); - Matcher<Node*> target_bytecode_matcher = - m.IsLoad(MachineType::Uint8(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - next_bytecode_offset_matcher); - target_bytecode_matcher = IsChangeUint32ToWord(target_bytecode_matcher); - Matcher<Node*> code_target_matcher = m.IsLoad( - MachineType::Pointer(), - IsParameter(InterpreterDispatchDescriptor::kDispatchTable), - IsWordShl(target_bytecode_matcher, IsIntPtrConstant(kPointerSizeLog2))); - - if (interpreter::Bytecodes::IsStarLookahead(bytecode, operand_scale)) { - Matcher<Node*> after_lookahead_offset = - IsIntPtrAdd(next_bytecode_offset_matcher, - IsIntPtrConstant(interpreter::Bytecodes::Size( - Bytecode::kStar, operand_scale))); - next_bytecode_offset_matcher = - IsPhi(MachineType::PointerRepresentation(), - next_bytecode_offset_matcher, after_lookahead_offset, _); - Matcher<Node*> after_lookahead_bytecode = - m.IsLoad(MachineType::Uint8(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - after_lookahead_offset); - after_lookahead_bytecode = IsChangeUint32ToWord(after_lookahead_bytecode); - target_bytecode_matcher = - IsPhi(MachineType::PointerRepresentation(), target_bytecode_matcher, - after_lookahead_bytecode, _); - code_target_matcher = - m.IsLoad(MachineType::Pointer(), - IsParameter(InterpreterDispatchDescriptor::kDispatchTable), - IsWordShl(target_bytecode_matcher, - IsIntPtrConstant(kPointerSizeLog2))); - } - - EXPECT_THAT( - tail_call_node, - IsTailCall(_, code_target_matcher, - IsParameter(InterpreterDispatchDescriptor::kAccumulator), - next_bytecode_offset_matcher, - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsParameter(InterpreterDispatchDescriptor::kDispatchTable), - _, _)); - } -} - TARGET_TEST_F(InterpreterAssemblerTest, Jump) { // If debug code is enabled we emit extra code in Jump. if (FLAG_debug_code) return; @@ -462,34 +416,6 @@ TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { } } -TARGET_TEST_F(InterpreterAssemblerTest, GetSetAccumulator) { - TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { - if (!interpreter::Bytecodes::ReadsAccumulator(bytecode) || - !interpreter::Bytecodes::WritesAccumulator(bytecode)) { - continue; - } - - InterpreterAssemblerTestState state(this, bytecode); - InterpreterAssemblerForTest m(&state, bytecode); - // Should be incoming accumulator if not set. - EXPECT_THAT(m.GetAccumulator(), - IsParameter(InterpreterDispatchDescriptor::kAccumulator)); - // Should be set by SetAccumulator. - Node* accumulator_value_1 = m.Int32Constant(0xdeadbeef); - m.SetAccumulator(accumulator_value_1); - EXPECT_THAT(m.GetAccumulator(), accumulator_value_1); - Node* accumulator_value_2 = m.Int32Constant(42); - m.SetAccumulator(accumulator_value_2); - EXPECT_THAT(m.GetAccumulator(), accumulator_value_2); - - // Should be passed to next bytecode handler on dispatch. - Node* tail_call_node = m.Dispatch(); - - EXPECT_THAT(tail_call_node, - IsTailCall(_, _, accumulator_value_2, _, _, _, _)); - } -} - TARGET_TEST_F(InterpreterAssemblerTest, GetContext) { TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { InterpreterAssemblerTestState state(this, bytecode); @@ -550,11 +476,12 @@ TARGET_TEST_F(InterpreterAssemblerTest, SmiTag) { InterpreterAssemblerTestState state(this, bytecode); InterpreterAssemblerForTest m(&state, bytecode); Node* value = m.Int32Constant(44); - EXPECT_THAT(m.SmiTag(value), IsBitcastWordToTaggedSigned(IsIntPtrConstant( - static_cast<intptr_t>(44) - << (kSmiShiftSize + kSmiTagSize)))); + EXPECT_THAT( + m.SmiTag(value), + IS_BITCAST_WORD_TO_TAGGED_SIGNED(IsIntPtrConstant( + static_cast<intptr_t>(44) << (kSmiShiftSize + kSmiTagSize)))); EXPECT_THAT(m.SmiUntag(value), - IsWordSar(IsBitcastTaggedToWord(value), + IsWordSar(IS_BITCAST_TAGGED_TO_WORD(value), IsIntPtrConstant(kSmiShiftSize + kSmiTagSize))); } } @@ -657,30 +584,33 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) { const int kResultSizes[] = {1, 2}; TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { TRACED_FOREACH(int, result_size, kResultSizes) { - InterpreterAssemblerTestState state(this, bytecode); - InterpreterAssemblerForTest m(&state, bytecode); - Callable builtin = CodeFactory::InterpreterCEntry(isolate(), result_size); - - Node* function_id = m.Int32Constant(0); - Node* first_arg = m.IntPtrConstant(1); - Node* arg_count = m.Int32Constant(2); - Node* context = m.IntPtrConstant(4); - - Matcher<Node*> function_table = IsExternalConstant( - ExternalReference::runtime_function_table_address(isolate())); - Matcher<Node*> function = IsIntPtrAdd( - function_table, - IsChangeUint32ToWord(IsInt32Mul( - function_id, IsInt32Constant(sizeof(Runtime::Function))))); - Matcher<Node*> function_entry = - m.IsLoad(MachineType::Pointer(), function, - IsIntPtrConstant(offsetof(Runtime::Function, entry))); - - Node* call_runtime = m.CallRuntimeN(function_id, context, first_arg, - arg_count, result_size); - EXPECT_THAT(call_runtime, - IsCall(_, IsHeapConstant(builtin.code()), arg_count, - first_arg, function_entry, context, _, _)); + if (Bytecodes::IsCallRuntime(bytecode)) { + InterpreterAssemblerTestState state(this, bytecode); + InterpreterAssemblerForTest m(&state, bytecode); + Callable builtin = + CodeFactory::InterpreterCEntry(isolate(), result_size); + + Node* function_id = m.Int32Constant(0); + Node* first_arg = m.IntPtrConstant(1); + Node* arg_count = m.Int32Constant(2); + Node* context = m.IntPtrConstant(4); + + Matcher<Node*> function_table = IsExternalConstant( + ExternalReference::runtime_function_table_address(isolate())); + Matcher<Node*> function = IsIntPtrAdd( + function_table, + IsChangeUint32ToWord(IsInt32Mul( + function_id, IsInt32Constant(sizeof(Runtime::Function))))); + Matcher<Node*> function_entry = + m.IsLoad(MachineType::Pointer(), function, + IsIntPtrConstant(offsetof(Runtime::Function, entry))); + + Node* call_runtime = m.CallRuntimeN(function_id, context, first_arg, + arg_count, result_size); + EXPECT_THAT(call_runtime, + IsCall(_, IsHeapConstant(builtin.code()), arg_count, + first_arg, function_entry, context, _, _)); + } } } } @@ -690,18 +620,21 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallJS) { TailCallMode::kAllow}; TRACED_FOREACH(TailCallMode, tail_call_mode, tail_call_modes) { TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { - InterpreterAssemblerTestState state(this, bytecode); - InterpreterAssemblerForTest m(&state, bytecode); - Callable builtin = - CodeFactory::InterpreterPushArgsAndCall(isolate(), tail_call_mode); - Node* function = m.IntPtrConstant(0); - Node* first_arg = m.IntPtrConstant(1); - Node* arg_count = m.Int32Constant(2); - Node* context = m.IntPtrConstant(3); - Node* call_js = - m.CallJS(function, context, first_arg, arg_count, tail_call_mode); - EXPECT_THAT(call_js, IsCall(_, IsHeapConstant(builtin.code()), arg_count, - first_arg, function, context, _, _)); + if (Bytecodes::IsCallOrConstruct(bytecode)) { + InterpreterAssemblerTestState state(this, bytecode); + InterpreterAssemblerForTest m(&state, bytecode); + Callable builtin = CodeFactory::InterpreterPushArgsAndCall( + isolate(), tail_call_mode, InterpreterPushArgsMode::kOther); + Node* function = m.IntPtrConstant(0); + Node* first_arg = m.IntPtrConstant(1); + Node* arg_count = m.Int32Constant(2); + Node* context = m.IntPtrConstant(3); + Node* call_js = + m.CallJS(function, context, first_arg, arg_count, tail_call_mode); + EXPECT_THAT(call_js, + IsCall(_, IsHeapConstant(builtin.code()), arg_count, + first_arg, function, context, _, _)); + } } } } @@ -716,14 +649,13 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadFeedbackVector) { m.IsLoad(MachineType::AnyTagged(), IsLoadParentFramePointer(), IsIntPtrConstant(Register::function_closure().ToOperand() << kPointerSizeLog2)); - Matcher<Node*> load_literals_matcher = m.IsLoad( + Matcher<Node*> load_vector_cell_matcher = m.IsLoad( MachineType::AnyTagged(), load_function_matcher, - IsIntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag)); - - EXPECT_THAT(feedback_vector, - m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, - IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - - kHeapObjectTag))); + IsIntPtrConstant(JSFunction::kFeedbackVectorOffset - kHeapObjectTag)); + EXPECT_THAT( + feedback_vector, + m.IsLoad(MachineType::AnyTagged(), load_vector_cell_matcher, + IsIntPtrConstant(Cell::kValueOffset - kHeapObjectTag))); } } diff --git a/deps/v8/test/unittests/test-utils.cc b/deps/v8/test/unittests/test-utils.cc index 1a06b36e24..5defa6dc90 100644 --- a/deps/v8/test/unittests/test-utils.cc +++ b/deps/v8/test/unittests/test-utils.cc @@ -6,9 +6,9 @@ #include "include/libplatform/libplatform.h" #include "src/base/platform/time.h" -#include "src/debug/debug.h" #include "src/flags.h" #include "src/isolate.h" +#include "src/objects-inl.h" #include "src/v8.h" namespace v8 { diff --git a/deps/v8/test/unittests/test-utils.h b/deps/v8/test/unittests/test-utils.h index ca7efc2a41..034fbe6bcb 100644 --- a/deps/v8/test/unittests/test-utils.h +++ b/deps/v8/test/unittests/test-utils.h @@ -24,6 +24,10 @@ class TestWithIsolate : public virtual ::testing::Test { Isolate* isolate() const { return isolate_; } + v8::internal::Isolate* i_isolate() const { + return reinterpret_cast<v8::internal::Isolate*>(isolate()); + } + static void SetUpTestCase(); static void TearDownTestCase(); @@ -44,10 +48,6 @@ class TestWithContext : public virtual TestWithIsolate { const Local<Context>& context() const { return context_; } - v8::internal::Isolate* i_isolate() const { - return reinterpret_cast<v8::internal::Isolate*>(isolate()); - } - private: Local<Context> context_; Context::Scope context_scope_; diff --git a/deps/v8/test/unittests/unittests.gyp b/deps/v8/test/unittests/unittests.gyp index e65f58dc83..d5731ccb18 100644 --- a/deps/v8/test/unittests/unittests.gyp +++ b/deps/v8/test/unittests/unittests.gyp @@ -9,6 +9,10 @@ 'v8_code': 1, 'unittests_sources': [ ### gcmole(all) ### 'api/access-check-unittest.cc', + 'api/exception-unittest.cc', + 'api/isolate-unittest.cc', + 'api/remote-object-unittest.cc', + 'api/v8-object-unittest.cc', 'base/atomic-utils-unittest.cc', 'base/bits-unittest.cc', 'base/cpu-unittest.cc', @@ -88,6 +92,7 @@ 'compiler-dispatcher/compiler-dispatcher-job-unittest.cc', 'compiler-dispatcher/compiler-dispatcher-tracer-unittest.cc', 'compiler-dispatcher/compiler-dispatcher-unittest.cc', + 'compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc', 'counters-unittest.cc', 'eh-frame-iterator-unittest.cc', 'eh-frame-writer-unittest.cc', @@ -142,6 +147,7 @@ 'wasm/switch-logic-unittest.cc', 'wasm/wasm-macro-gen-unittest.cc', 'wasm/wasm-module-builder-unittest.cc', + 'wasm/wasm-opcodes-unittest.cc', ], 'unittests_sources_arm': [ ### gcmole(arch:arm) ### 'compiler/arm/instruction-selector-arm-unittest.cc', diff --git a/deps/v8/test/unittests/value-serializer-unittest.cc b/deps/v8/test/unittests/value-serializer-unittest.cc index d068b93415..cd2afa09f1 100644 --- a/deps/v8/test/unittests/value-serializer-unittest.cc +++ b/deps/v8/test/unittests/value-serializer-unittest.cc @@ -54,6 +54,17 @@ class ValueSerializerTest : public TestWithIsolate { .ToChecked(); } host_object_constructor_template_ = function_template; + isolate_ = reinterpret_cast<i::Isolate*>(isolate()); + } + + ~ValueSerializerTest() { + // In some cases unhandled scheduled exceptions from current test produce + // that Context::New(isolate()) from next test's constructor returns NULL. + // In order to prevent that, we added destructor which will clear scheduled + // exceptions just for the current test from test case. + if (isolate_->has_scheduled_exception()) { + isolate_->clear_scheduled_exception(); + } } const Local<Context>& serialization_context() { @@ -263,6 +274,7 @@ class ValueSerializerTest : public TestWithIsolate { Local<Context> serialization_context_; Local<Context> deserialization_context_; Local<FunctionTemplate> host_object_constructor_template_; + i::Isolate* isolate_; DISALLOW_COPY_AND_ASSIGN(ValueSerializerTest); }; @@ -1217,7 +1229,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) { TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) { // Empty (sparse) array. DecodeTestForVersion0({0x40, 0x00, 0x00, 0x00}, - [this](Local<Value> value) { + [](Local<Value> value) { ASSERT_TRUE(value->IsArray()); ASSERT_EQ(0u, Array::Cast(*value)->Length()); }); @@ -1279,16 +1291,16 @@ TEST_F(ValueSerializerTest, DecodeDenseArrayContainingUndefined) { } TEST_F(ValueSerializerTest, RoundTripDate) { - RoundTripTest("new Date(1e6)", [this](Local<Value> value) { + RoundTripTest("new Date(1e6)", [](Local<Value> value) { ASSERT_TRUE(value->IsDate()); EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf()); EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype"); }); - RoundTripTest("new Date(Date.UTC(1867, 6, 1))", [this](Local<Value> value) { + RoundTripTest("new Date(Date.UTC(1867, 6, 1))", [](Local<Value> value) { ASSERT_TRUE(value->IsDate()); EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'"); }); - RoundTripTest("new Date(NaN)", [this](Local<Value> value) { + RoundTripTest("new Date(NaN)", [](Local<Value> value) { ASSERT_TRUE(value->IsDate()); EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf())); }); @@ -1304,7 +1316,7 @@ TEST_F(ValueSerializerTest, DecodeDate) { #if defined(V8_TARGET_LITTLE_ENDIAN) DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x80, 0x84, 0x2e, 0x41, 0x00}, - [this](Local<Value> value) { + [](Local<Value> value) { ASSERT_TRUE(value->IsDate()); EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf()); EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype"); @@ -1312,13 +1324,13 @@ TEST_F(ValueSerializerTest, DecodeDate) { DecodeTest( {0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x20, 0x45, 0x27, 0x89, 0x87, 0xc2, 0x00}, - [this](Local<Value> value) { + [](Local<Value> value) { ASSERT_TRUE(value->IsDate()); EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'"); }); DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f, 0x00}, - [this](Local<Value> value) { + [](Local<Value> value) { ASSERT_TRUE(value->IsDate()); EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf())); }); diff --git a/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc b/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc index 82fdaf9866..5e382f92de 100644 --- a/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc +++ b/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc @@ -8,10 +8,13 @@ #include "test/common/wasm/test-signatures.h" +#include "src/objects-inl.h" #include "src/objects.h" +#include "src/wasm/function-body-decoder-impl.h" #include "src/wasm/function-body-decoder.h" #include "src/wasm/signature-map.h" +#include "src/wasm/wasm-limits.h" #include "src/wasm/wasm-macro-gen.h" #include "src/wasm/wasm-module.h" #include "src/wasm/wasm-opcodes.h" @@ -372,22 +375,22 @@ TEST_F(FunctionBodyDecoderTest, GetLocal_off_end) { } TEST_F(FunctionBodyDecoderTest, NumLocalBelowLimit) { - AddLocals(kWasmI32, kMaxNumWasmLocals - 1); + AddLocals(kWasmI32, kV8MaxWasmFunctionLocals - 1); EXPECT_VERIFIES(v_v, WASM_NOP); } TEST_F(FunctionBodyDecoderTest, NumLocalAtLimit) { - AddLocals(kWasmI32, kMaxNumWasmLocals); + AddLocals(kWasmI32, kV8MaxWasmFunctionLocals); EXPECT_VERIFIES(v_v, WASM_NOP); } TEST_F(FunctionBodyDecoderTest, NumLocalAboveLimit) { - AddLocals(kWasmI32, kMaxNumWasmLocals + 1); + AddLocals(kWasmI32, kV8MaxWasmFunctionLocals + 1); EXPECT_FAILURE(v_v, WASM_NOP); } TEST_F(FunctionBodyDecoderTest, GetLocal_varint) { - const int kMaxLocals = kMaxNumWasmLocals - 1; + const int kMaxLocals = kV8MaxWasmFunctionLocals - 1; AddLocals(kWasmI32, kMaxLocals); EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_1(66)); @@ -408,7 +411,7 @@ TEST_F(FunctionBodyDecoderTest, GetLocal_varint) { } TEST_F(FunctionBodyDecoderTest, GetLocal_toomany) { - AddLocals(kWasmI32, kMaxNumWasmLocals - 100); + AddLocals(kWasmI32, kV8MaxWasmFunctionLocals - 100); AddLocals(kWasmI32, 100); EXPECT_VERIFIES(i_v, kExprGetLocal, U32V_1(66)); diff --git a/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc b/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc index 3f2d7665a3..9e1954d481 100644 --- a/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc +++ b/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc @@ -9,6 +9,7 @@ #include "test/common/wasm/test-signatures.h" #include "src/bit-vector.h" +#include "src/objects-inl.h" #include "src/objects.h" #include "src/wasm/function-body-decoder.h" diff --git a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc index 258ac7311a..3ad142bce0 100644 --- a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc +++ b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc @@ -1461,6 +1461,25 @@ TEST_F(WasmModuleVerifyTest, Names_two_empty) { EXPECT_VERIFIES(data); } +TEST_F(WasmModuleVerifyTest, Regression684855) { + static const byte data[] = { + SECTION_NAMES(12), + 0xfb, // functions count + 0x27, // | + 0x00, // function name length + 0xff, // local names count + 0xff, // | + 0xff, // | + 0xff, // | + 0xff, // | + 0xff, // error: "varint too large" + 0xff, // | + 0x00, // -- + 0x00 // -- + }; + EXPECT_VERIFIES(data); +} + #define EXPECT_INIT_EXPR(Type, type, value, ...) \ { \ static const byte data[] = {__VA_ARGS__, kExprEnd}; \ diff --git a/deps/v8/test/unittests/wasm/wasm-module-builder-unittest.cc b/deps/v8/test/unittests/wasm/wasm-module-builder-unittest.cc index 372f0ae922..28b35793f7 100644 --- a/deps/v8/test/unittests/wasm/wasm-module-builder-unittest.cc +++ b/deps/v8/test/unittests/wasm/wasm-module-builder-unittest.cc @@ -6,6 +6,7 @@ #include "src/v8.h" +#include "src/objects-inl.h" #include "src/wasm/function-body-decoder.h" #include "src/wasm/wasm-module-builder.h" diff --git a/deps/v8/test/unittests/wasm/wasm-opcodes-unittest.cc b/deps/v8/test/unittests/wasm/wasm-opcodes-unittest.cc new file mode 100644 index 0000000000..4bb04c7152 --- /dev/null +++ b/deps/v8/test/unittests/wasm/wasm-opcodes-unittest.cc @@ -0,0 +1,34 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "test/unittests/test-utils.h" + +#include "src/wasm/wasm-opcodes.h" + +namespace v8 { +namespace internal { +namespace wasm { + +class WasmOpcodesTest : public TestWithZone {}; + +TEST_F(WasmOpcodesTest, EveryOpcodeHasAName) { + static const struct { + WasmOpcode opcode; + const char* debug_name; + } kValues[] = { +#define DECLARE_ELEMENT(name, opcode, sig) {kExpr##name, "kExpr" #name}, + FOREACH_OPCODE(DECLARE_ELEMENT)}; + + for (size_t i = 0; i < arraysize(kValues); i++) { + const char* result = WasmOpcodes::OpcodeName(kValues[i].opcode); + if (strcmp("unknown", result) == 0) { + EXPECT_TRUE(false) << "WasmOpcodes::OpcodeName(" << kValues[i].debug_name + << ") == \"unknown\";" + " plazz halp in src/wasm/wasm-opcodes.cc"; + } + } +} +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/webkit/fast/js/parser-syntax-check-expected.txt b/deps/v8/test/webkit/fast/js/parser-syntax-check-expected.txt index 2ea2b08cc8..2a09635ebe 100644 --- a/deps/v8/test/webkit/fast/js/parser-syntax-check-expected.txt +++ b/deps/v8/test/webkit/fast/js/parser-syntax-check-expected.txt @@ -143,8 +143,8 @@ PASS Invalid: "a(5" PASS Invalid: "function f() { a(5 }" PASS Invalid: "a(5," PASS Invalid: "function f() { a(5, }" -PASS Invalid: "a(5,)" -PASS Invalid: "function f() { a(5,) }" +FAIL Invalid: "a(5,)" should throw undefined +FAIL Invalid: "function f() { a(5,) }" should throw undefined PASS Invalid: "a(5,6" PASS Invalid: "function f() { a(5,6 }" PASS Valid: "a(b[7], c <d> e.l, new a() > b)" @@ -178,8 +178,8 @@ PASS Invalid: "function () {}" PASS Invalid: "function f() { function () {} }" PASS Invalid: "function f(a b) {}" PASS Invalid: "function f() { function f(a b) {} }" -PASS Invalid: "function f(a,) {}" -PASS Invalid: "function f() { function f(a,) {} }" +FAIL Invalid: "function f(a,) {}" should throw undefined +FAIL Invalid: "function f() { function f(a,) {} }" should throw undefined PASS Invalid: "function f(a," PASS Invalid: "function f() { function f(a, }" PASS Invalid: "function f(a, 1) {}" diff --git a/deps/v8/test/webkit/fast/js/string-capitalization-expected.txt b/deps/v8/test/webkit/fast/js/string-capitalization-expected.txt index 817db11133..8d23c0e1f9 100644 --- a/deps/v8/test/webkit/fast/js/string-capitalization-expected.txt +++ b/deps/v8/test/webkit/fast/js/string-capitalization-expected.txt @@ -26,8 +26,8 @@ This test checks that toLowerCase and toUpperCase handle certain non-trivial cas On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". -FAIL String("A𐐀").toLowerCase() should be a𐐨. Was a𐐀. -FAIL String("a𐐨").toUpperCase() should be A𐐀. Was A𐐨. +PASS String("A𐐀").toLowerCase() is "a𐐨" +PASS String("a𐐨").toUpperCase() is "A𐐀" PASS String("ΚΟΣΜΟΣ ΚΟΣΜΟΣ").toLowerCase() is "κοσμος κοσμος" PASS String("ß").toUpperCase() is "SS" PASS String("ʼn").toUpperCase() is "ʼN" diff --git a/deps/v8/test/webkit/preventExtensions-expected.txt b/deps/v8/test/webkit/preventExtensions-expected.txt index 196b0a82b4..027f206ecd 100644 --- a/deps/v8/test/webkit/preventExtensions-expected.txt +++ b/deps/v8/test/webkit/preventExtensions-expected.txt @@ -39,7 +39,7 @@ PASS "use strict"; var o = {}; Object.preventExtensions(o); o.__proto__ = { newP PASS Object.preventExtensions(Math); Math.sqrt(4) is 2 PASS var arr = Object.preventExtensions([]); arr[0] = 42; arr[0] is undefined. PASS var arr = Object.preventExtensions([]); arr[0] = 42; arr.length is 0 -PASS "use strict"; var arr = Object.preventExtensions([]); arr[0] = 42; arr[0] threw exception TypeError: Can't add property 0, object is not extensible. +PASS "use strict"; var arr = Object.preventExtensions([]); arr[0] = 42; arr[0] threw exception TypeError: Cannot add property 0, object is not extensible. PASS obj.foo is 1 PASS Object.isFrozen(func) is true PASS func.prototype === 42 is false diff --git a/deps/v8/test/webkit/webkit.status b/deps/v8/test/webkit/webkit.status index afc504fb8d..d8477572c8 100644 --- a/deps/v8/test/webkit/webkit.status +++ b/deps/v8/test/webkit/webkit.status @@ -126,4 +126,9 @@ }], # variant == wasm_traps ############################################################################## +['no_i18n == True', { + 'fast/js/string-capitalization': [FAIL], +}], # variant == wasm_traps + +############################################################################## ] |