From 64e3912f108b0ab63fde1f5127789fd277ffc87b Mon Sep 17 00:00:00 2001 From: Ross Mcilroy Date: Sun, 22 Jul 2018 19:35:30 -0700 Subject: [PATCH] [cleanup] Remove deprecated calls to Write[OneByte/Utf8]. Replace with isolate version. BUG=v8:7754 Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel Change-Id: Iac7091b983960d22b892074c5fd0a97dee9025c9 Reviewed-on: https://chromium-review.googlesource.com/1146332 Commit-Queue: Dan Elphick Reviewed-by: Dan Elphick Cr-Commit-Position: refs/heads/master@{#54604} --- src/third_party/vtune/vtune-jit.cc | 2 +- test/cctest/test-api.cc | 112 +++++++++----------- test/cctest/test-log.cc | 4 +- test/cctest/test-strings.cc | 5 +- test/fuzzer/regexp-builtins.cc | 14 +-- test/inspector/inspector-test.cc | 43 +++++--- test/inspector/isolate-data.cc | 15 +-- test/unittests/value-serializer-unittest.cc | 3 +- 8 files changed, 105 insertions(+), 93 deletions(-) diff --git a/src/third_party/vtune/vtune-jit.cc b/src/third_party/vtune/vtune-jit.cc index 53fc289351..5c49855359 100644 --- a/src/third_party/vtune/vtune-jit.cc +++ b/src/third_party/vtune/vtune-jit.cc @@ -184,7 +184,7 @@ void VTUNEJITInterface::event_handler(const v8::JitCodeEvent* event) { Local::Cast(script->GetScriptName()); temp_file_name = new char[script_name->Utf8Length(event->isolate) + 1]; - script_name->WriteUtf8(temp_file_name); + script_name->WriteUtf8(event->isolate, temp_file_name); jmethod.source_file_name = temp_file_name; } diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index db2403d237..e3096bd832 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -374,7 +374,7 @@ THREADED_TEST(HulIgennem) { v8::Local undef = v8::Undefined(isolate); Local undef_str = undef->ToString(env.local()).ToLocalChecked(); char* value = i::NewArray(undef_str->Utf8Length(isolate) + 1); - undef_str->WriteUtf8(value); + undef_str->WriteUtf8(isolate, value); CHECK_EQ(0, strcmp(value, "undefined")); i::DeleteArray(value); } @@ -8286,7 +8286,8 @@ int GetUtf8Length(v8::Isolate* isolate, Local str) { THREADED_TEST(StringWrite) { LocalContext context; - v8::HandleScope scope(context->GetIsolate()); + v8::Isolate* isolate = context->GetIsolate(); + v8::HandleScope scope(isolate); v8::Local str = v8_str("abcde"); // abc. v8::Local str2 = v8_str("abc\xC3\xB0\xE2\x98\x83"); @@ -8348,65 +8349,63 @@ THREADED_TEST(StringWrite) { int charlen; memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen); + len = str2->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen); CHECK_EQ(9, len); CHECK_EQ(5, charlen); CHECK_EQ(0, strcmp(utf8buf, "abc\xC3\xB0\xE2\x98\x83")); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 8, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 8, &charlen); CHECK_EQ(8, len); CHECK_EQ(5, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\xE2\x98\x83\x01", 9)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 7, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 7, &charlen); CHECK_EQ(5, len); CHECK_EQ(4, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\x01", 5)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 6, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 6, &charlen); CHECK_EQ(5, len); CHECK_EQ(4, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\x01", 5)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 5, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 5, &charlen); CHECK_EQ(5, len); CHECK_EQ(4, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\x01", 5)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 4, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 4, &charlen); CHECK_EQ(3, len); CHECK_EQ(3, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\x01", 4)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 3, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 3, &charlen); CHECK_EQ(3, len); CHECK_EQ(3, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\x01", 4)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 2, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 2, &charlen); CHECK_EQ(2, len); CHECK_EQ(2, charlen); CHECK_EQ(0, strncmp(utf8buf, "ab\x01", 3)); // allow orphan surrogates by default memset(utf8buf, 0x1, 1000); - len = orphans_str->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen); + len = orphans_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen); CHECK_EQ(13, len); CHECK_EQ(8, charlen); CHECK_EQ(0, strcmp(utf8buf, "ab\xED\xA0\x80wx\xED\xB0\x80yz")); // replace orphan surrogates with Unicode replacement character memset(utf8buf, 0x1, 1000); - len = orphans_str->WriteUtf8(utf8buf, - sizeof(utf8buf), - &charlen, + len = orphans_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen, String::REPLACE_INVALID_UTF8); CHECK_EQ(13, len); CHECK_EQ(8, charlen); @@ -8414,9 +8413,7 @@ THREADED_TEST(StringWrite) { // replace single lead surrogate with Unicode replacement character memset(utf8buf, 0x1, 1000); - len = lead_str->WriteUtf8(utf8buf, - sizeof(utf8buf), - &charlen, + len = lead_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen, String::REPLACE_INVALID_UTF8); CHECK_EQ(4, len); CHECK_EQ(1, charlen); @@ -8424,9 +8421,7 @@ THREADED_TEST(StringWrite) { // replace single trail surrogate with Unicode replacement character memset(utf8buf, 0x1, 1000); - len = trail_str->WriteUtf8(utf8buf, - sizeof(utf8buf), - &charlen, + len = trail_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen, String::REPLACE_INVALID_UTF8); CHECK_EQ(4, len); CHECK_EQ(1, charlen); @@ -8435,19 +8430,17 @@ THREADED_TEST(StringWrite) { // do not replace / write anything if surrogate pair does not fit the buffer // space memset(utf8buf, 0x1, 1000); - len = pair_str->WriteUtf8(utf8buf, - 3, - &charlen, - String::REPLACE_INVALID_UTF8); + len = pair_str->WriteUtf8(isolate, utf8buf, 3, &charlen, + String::REPLACE_INVALID_UTF8); CHECK_EQ(0, len); CHECK_EQ(0, charlen); memset(utf8buf, 0x1, sizeof(utf8buf)); - len = GetUtf8Length(context->GetIsolate(), left_tree); + len = GetUtf8Length(isolate, left_tree); int utf8_expected = (0x80 + (0x800 - 0x80) * 2 + (0xD800 - 0x800) * 3) / kStride; CHECK_EQ(utf8_expected, len); - len = left_tree->WriteUtf8(utf8buf, utf8_expected, &charlen); + len = left_tree->WriteUtf8(isolate, utf8buf, utf8_expected, &charlen); CHECK_EQ(utf8_expected, len); CHECK_EQ(0xD800 / kStride, charlen); CHECK_EQ(0xED, static_cast(utf8buf[utf8_expected - 3])); @@ -8457,9 +8450,9 @@ THREADED_TEST(StringWrite) { CHECK_EQ(1, utf8buf[utf8_expected]); memset(utf8buf, 0x1, sizeof(utf8buf)); - len = GetUtf8Length(context->GetIsolate(), right_tree); + len = GetUtf8Length(isolate, right_tree); CHECK_EQ(utf8_expected, len); - len = right_tree->WriteUtf8(utf8buf, utf8_expected, &charlen); + len = right_tree->WriteUtf8(isolate, utf8buf, utf8_expected, &charlen); CHECK_EQ(utf8_expected, len); CHECK_EQ(0xD800 / kStride, charlen); CHECK_EQ(0xED, static_cast(utf8buf[0])); @@ -8469,9 +8462,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast(buf)); + len = str->WriteOneByte(isolate, reinterpret_cast(buf)); CHECK_EQ(5, len); - len = str->Write(wbuf); + len = str->Write(isolate, wbuf); CHECK_EQ(5, len); CHECK_EQ(0, strcmp("abcde", buf)); uint16_t answer1[] = {'a', 'b', 'c', 'd', 'e', '\0'}; @@ -8479,9 +8472,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast(buf), 0, 4); + len = str->WriteOneByte(isolate, reinterpret_cast(buf), 0, 4); CHECK_EQ(4, len); - len = str->Write(wbuf, 0, 4); + len = str->Write(isolate, wbuf, 0, 4); CHECK_EQ(4, len); CHECK_EQ(0, strncmp("abcd\x01", buf, 5)); uint16_t answer2[] = {'a', 'b', 'c', 'd', 0x101}; @@ -8489,9 +8482,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast(buf), 0, 5); + len = str->WriteOneByte(isolate, reinterpret_cast(buf), 0, 5); CHECK_EQ(5, len); - len = str->Write(wbuf, 0, 5); + len = str->Write(isolate, wbuf, 0, 5); CHECK_EQ(5, len); CHECK_EQ(0, strncmp("abcde\x01", buf, 6)); uint16_t answer3[] = {'a', 'b', 'c', 'd', 'e', 0x101}; @@ -8499,9 +8492,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast(buf), 0, 6); + len = str->WriteOneByte(isolate, reinterpret_cast(buf), 0, 6); CHECK_EQ(5, len); - len = str->Write(wbuf, 0, 6); + len = str->Write(isolate, wbuf, 0, 6); CHECK_EQ(5, len); CHECK_EQ(0, strcmp("abcde", buf)); uint16_t answer4[] = {'a', 'b', 'c', 'd', 'e', '\0'}; @@ -8509,9 +8502,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast(buf), 4, -1); + len = str->WriteOneByte(isolate, reinterpret_cast(buf), 4, -1); CHECK_EQ(1, len); - len = str->Write(wbuf, 4, -1); + len = str->Write(isolate, wbuf, 4, -1); CHECK_EQ(1, len); CHECK_EQ(0, strcmp("e", buf)); uint16_t answer5[] = {'e', '\0'}; @@ -8519,18 +8512,18 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast(buf), 4, 6); + len = str->WriteOneByte(isolate, reinterpret_cast(buf), 4, 6); CHECK_EQ(1, len); - len = str->Write(wbuf, 4, 6); + len = str->Write(isolate, wbuf, 4, 6); CHECK_EQ(1, len); CHECK_EQ(0, strcmp("e", buf)); CHECK_EQ(0, StrCmp16(answer5, wbuf)); memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast(buf), 4, 1); + len = str->WriteOneByte(isolate, reinterpret_cast(buf), 4, 1); CHECK_EQ(1, len); - len = str->Write(wbuf, 4, 1); + len = str->Write(isolate, wbuf, 4, 1); CHECK_EQ(1, len); CHECK_EQ(0, strncmp("e\x01", buf, 2)); uint16_t answer6[] = {'e', 0x101}; @@ -8538,9 +8531,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast(buf), 3, 1); + len = str->WriteOneByte(isolate, reinterpret_cast(buf), 3, 1); CHECK_EQ(1, len); - len = str->Write(wbuf, 3, 1); + len = str->Write(isolate, wbuf, 3, 1); CHECK_EQ(1, len); CHECK_EQ(0, strncmp("d\x01", buf, 2)); uint16_t answer7[] = {'d', 0x101}; @@ -8548,7 +8541,7 @@ THREADED_TEST(StringWrite) { memset(wbuf, 0x1, sizeof(wbuf)); wbuf[5] = 'X'; - len = str->Write(wbuf, 0, 6, String::NO_NULL_TERMINATION); + len = str->Write(isolate, wbuf, 0, 6, String::NO_NULL_TERMINATION); CHECK_EQ(5, len); CHECK_EQ('X', wbuf[5]); uint16_t answer8a[] = {'a', 'b', 'c', 'd', 'e'}; @@ -8560,9 +8553,7 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); buf[5] = 'X'; - len = str->WriteOneByte(reinterpret_cast(buf), - 0, - 6, + len = str->WriteOneByte(isolate, reinterpret_cast(buf), 0, 6, String::NO_NULL_TERMINATION); CHECK_EQ(5, len); CHECK_EQ('X', buf[5]); @@ -8573,7 +8564,7 @@ THREADED_TEST(StringWrite) { memset(utf8buf, 0x1, sizeof(utf8buf)); utf8buf[8] = 'X'; - len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen, + len = str2->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen, String::NO_NULL_TERMINATION); CHECK_EQ(8, len); CHECK_EQ('X', utf8buf[8]); @@ -8585,8 +8576,8 @@ THREADED_TEST(StringWrite) { memset(utf8buf, 0x1, sizeof(utf8buf)); utf8buf[5] = 'X'; - len = str->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen, - String::NO_NULL_TERMINATION); + len = str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen, + String::NO_NULL_TERMINATION); CHECK_EQ(5, len); CHECK_EQ('X', utf8buf[5]); // Test that the sixth character is untouched. CHECK_EQ(5, charlen); @@ -8594,15 +8585,17 @@ THREADED_TEST(StringWrite) { CHECK_EQ(0, strcmp(utf8buf, "abcde")); memset(buf, 0x1, sizeof(buf)); - len = str3->WriteOneByte(reinterpret_cast(buf)); + len = str3->WriteOneByte(isolate, reinterpret_cast(buf)); CHECK_EQ(7, len); CHECK_EQ(0, strcmp("abc", buf)); CHECK_EQ(0, buf[3]); CHECK_EQ(0, strcmp("def", buf + 4)); - CHECK_EQ(0, str->WriteOneByte(nullptr, 0, 0, String::NO_NULL_TERMINATION)); - CHECK_EQ(0, str->WriteUtf8(nullptr, 0, 0, String::NO_NULL_TERMINATION)); - CHECK_EQ(0, str->Write(nullptr, 0, 0, String::NO_NULL_TERMINATION)); + CHECK_EQ(0, str->WriteOneByte(isolate, nullptr, 0, 0, + String::NO_NULL_TERMINATION)); + CHECK_EQ(0, + str->WriteUtf8(isolate, nullptr, 0, 0, String::NO_NULL_TERMINATION)); + CHECK_EQ(0, str->Write(isolate, nullptr, 0, 0, String::NO_NULL_TERMINATION)); } @@ -8628,14 +8621,14 @@ static void Utf16Helper( } void TestUtf8DecodingAgainstReference( - const char* cases[], + v8::Isolate* isolate, const char* cases[], const std::vector>& unicode_expected) { for (size_t test_ix = 0; test_ix < unicode_expected.size(); ++test_ix) { v8::Local str = v8_str(cases[test_ix]); CHECK_EQ(unicode_expected[test_ix].size(), str->Length()); std::unique_ptr buffer(new uint16_t[str->Length()]); - str->Write(buffer.get(), 0, -1, String::NO_NULL_TERMINATION); + str->Write(isolate, buffer.get(), 0, -1, String::NO_NULL_TERMINATION); for (size_t i = 0; i < unicode_expected[test_ix].size(); ++i) { CHECK_EQ(unicode_expected[test_ix][i], buffer[i]); @@ -8685,7 +8678,8 @@ THREADED_TEST(OverlongSequencesAndSurrogates) { {0x58, 0xFFFD, 0xFFFD, 0xFFFD, 0x59}, }; CHECK_EQ(unicode_expected.size(), arraysize(cases)); - TestUtf8DecodingAgainstReference(cases, unicode_expected); + TestUtf8DecodingAgainstReference(context->GetIsolate(), cases, + unicode_expected); } THREADED_TEST(Utf16) { @@ -15713,7 +15707,7 @@ THREADED_TEST(MorphCompositeStringTest) { v8_compile("cons")->Run(env.local()).ToLocalChecked().As(); CHECK_EQ(128, cons->Utf8Length(isolate)); int nchars = -1; - CHECK_EQ(129, cons->WriteUtf8(utf_buffer, -1, &nchars)); + CHECK_EQ(129, cons->WriteUtf8(isolate, utf_buffer, -1, &nchars)); CHECK_EQ(128, nchars); CHECK_EQ(0, strcmp( utf_buffer, diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc index 0b13a7e660..f8e0673b5b 100644 --- a/test/cctest/test-log.cc +++ b/test/cctest/test-log.cc @@ -294,7 +294,7 @@ class TestCodeEventHandler : public v8::CodeEventHandler { if (name.empty()) { v8::Local functionName = code_event->GetFunctionName(); std::string buffer(functionName->Utf8Length(isolate_) + 1, 0); - functionName->WriteUtf8(&buffer[0], + functionName->WriteUtf8(isolate_, &buffer[0], functionName->Utf8Length(isolate_) + 1); // Sanitize name, removing unwanted \0 resulted from WriteUtf8 name = std::string(buffer.c_str()); @@ -716,7 +716,7 @@ TEST(EquivalenceOfLoggingAndTraversal) { v8::Local s = result->ToString(logger.env()).ToLocalChecked(); i::ScopedVector data(s->Utf8Length(isolate) + 1); CHECK(data.start()); - s->WriteUtf8(data.start()); + s->WriteUtf8(isolate, data.start()); FATAL("%s\n", data.start()); } } diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc index 322201b5e6..0feb498997 100644 --- a/test/cctest/test-strings.cc +++ b/test/cctest/test-strings.cc @@ -951,7 +951,8 @@ TEST(Utf8Conversion) { for (int j = 0; j < 11; j++) buffer[j] = kNoChar; int chars_written; - int written = mixed->WriteUtf8(buffer, i, &chars_written); + int written = + mixed->WriteUtf8(CcTest::isolate(), buffer, i, &chars_written); CHECK_EQ(lengths[i], written); CHECK_EQ(char_lengths[i], chars_written); // Check that the contents are correct @@ -1095,7 +1096,7 @@ TEST(JSONStringifySliceMadeExternal) { int length = underlying->Length(); uc16* two_byte = NewArray(length + 1); - underlying->Write(two_byte); + underlying->Write(CcTest::isolate(), two_byte); Resource* resource = new Resource(two_byte, length); CHECK(underlying->MakeExternal(resource)); CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString()); diff --git a/test/fuzzer/regexp-builtins.cc b/test/fuzzer/regexp-builtins.cc index 495604b071..c4ff115d72 100644 --- a/test/fuzzer/regexp-builtins.cc +++ b/test/fuzzer/regexp-builtins.cc @@ -319,12 +319,12 @@ std::string GenerateSourceString(FuzzerArgs* args, const std::string& test) { return ss.str(); } -void PrintExceptionMessage(v8::TryCatch* try_catch) { +void PrintExceptionMessage(v8::Isolate* isolate, v8::TryCatch* try_catch) { CHECK(try_catch->HasCaught()); static const int kBufferLength = 256; char buffer[kBufferLength + 1]; try_catch->Message()->Get()->WriteOneByte( - reinterpret_cast(&buffer[0]), 0, kBufferLength); + isolate, reinterpret_cast(&buffer[0]), 0, kBufferLength); fprintf(stderr, "%s\n", buffer); } @@ -337,9 +337,10 @@ bool ResultsAreIdentical(FuzzerArgs* args) { "assertEquals(fast.re.lastIndex, slow.re.lastIndex);\n"; v8::Local result; - v8::TryCatch try_catch(reinterpret_cast(args->isolate)); + v8::Isolate* isolate = reinterpret_cast(args->isolate); + v8::TryCatch try_catch(isolate); if (!CompileRun(args->context, source.c_str()).ToLocal(&result)) { - PrintExceptionMessage(&try_catch); + PrintExceptionMessage(isolate, &try_catch); args->isolate->clear_pending_exception(); return false; } @@ -349,14 +350,15 @@ bool ResultsAreIdentical(FuzzerArgs* args) { void CompileRunAndVerify(FuzzerArgs* args, const std::string& source) { v8::Local result; - v8::TryCatch try_catch(reinterpret_cast(args->isolate)); + v8::Isolate* isolate = reinterpret_cast(args->isolate); + v8::TryCatch try_catch(isolate); if (!CompileRun(args->context, source.c_str()).ToLocal(&result)) { args->isolate->clear_pending_exception(); // No need to verify result if an exception was thrown here, since that // implies a syntax error somewhere in the pattern or string. We simply // ignore those. if (kVerbose) { - PrintExceptionMessage(&try_catch); + PrintExceptionMessage(isolate, &try_catch); fprintf(stderr, "Failed to run script:\n```\n%s\n```\n", source.c_str()); } return; diff --git a/test/inspector/inspector-test.cc b/test/inspector/inspector-test.cc index 23559bd2a1..ba1d856ae9 100644 --- a/test/inspector/inspector-test.cc +++ b/test/inspector/inspector-test.cc @@ -38,10 +38,11 @@ void Exit() { Terminate(); } -v8::internal::Vector ToVector(v8::Local str) { +v8::internal::Vector ToVector(v8::Isolate* isolate, + v8::Local str) { v8::internal::Vector buffer = v8::internal::Vector::New(str->Length()); - str->Write(buffer.start(), 0, str->Length()); + str->Write(isolate, buffer.start(), 0, str->Length()); return buffer; } @@ -200,14 +201,14 @@ void RunAsyncTask(TaskRunner* task_runner, class ExecuteStringTask : public TaskRunner::Task { public: - ExecuteStringTask(int context_group_id, + ExecuteStringTask(v8::Isolate* isolate, int context_group_id, const v8::internal::Vector& expression, v8::Local name, v8::Local line_offset, v8::Local column_offset, v8::Local is_module) : expression_(expression), - name_(ToVector(name)), + name_(ToVector(isolate, name)), line_offset_(line_offset.As()->Value()), column_offset_(column_offset.As()->Value()), is_module_(is_module->Value()), @@ -430,7 +431,8 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { } backend_runner_->Append(new ExecuteStringTask( - args[0].As()->Value(), ToVector(args[1].As()), + args.GetIsolate(), args[0].As()->Value(), + ToVector(args.GetIsolate(), args[1].As()), args[2].As(), args[3].As(), args[4].As(), args[5].As())); } @@ -463,8 +465,10 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { "'reason', 'details')."); Exit(); } - v8::internal::Vector reason = ToVector(args[1].As()); - v8::internal::Vector details = ToVector(args[2].As()); + v8::internal::Vector reason = + ToVector(args.GetIsolate(), args[1].As()); + v8::internal::Vector details = + ToVector(args.GetIsolate(), args[2].As()); int context_group_id = args[0].As()->Value(); RunSyncTask(backend_runner_, [&context_group_id, &reason, &details](IsolateData* data) { @@ -537,7 +541,8 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { IsolateData::FromContext(context)->GetContextGroupId(context), args.GetIsolate(), args[2].As()); - v8::internal::Vector state = ToVector(args[1].As()); + v8::internal::Vector state = + ToVector(args.GetIsolate(), args[1].As()); int context_group_id = args[0].As()->Value(); int session_id = 0; RunSyncTask(backend_runner_, [&context_group_id, &session_id, &channel, @@ -575,7 +580,8 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { Exit(); } backend_runner_->Append(new SendMessageToBackendTask( - args[0].As()->Value(), ToVector(args[1].As()))); + args[0].As()->Value(), + ToVector(args.GetIsolate(), args[1].As()))); } static std::map> channels_; @@ -643,7 +649,8 @@ class SetTimeoutExtension : public IsolateData::SetupGlobalTask { RunAsyncTask( data->task_runner(), task_name_view, new ExecuteStringTask( - context_group_id, ToVector(args[0].As()), + isolate, context_group_id, + ToVector(isolate, args[0].As()), v8::String::Empty(isolate), v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0), v8::Boolean::New(isolate, false))); } @@ -782,9 +789,11 @@ class InspectorExtension : public IsolateData::SetupGlobalTask { } v8::Local context = args.GetIsolate()->GetCurrentContext(); IsolateData* data = IsolateData::FromContext(context); - v8::internal::Vector reason = ToVector(args[0].As()); + v8::internal::Vector reason = + ToVector(args.GetIsolate(), args[0].As()); v8_inspector::StringView reason_view(reason.start(), reason.length()); - v8::internal::Vector details = ToVector(args[1].As()); + v8::internal::Vector details = + ToVector(args.GetIsolate(), args[1].As()); v8_inspector::StringView details_view(details.start(), details.length()); data->BreakProgram(data->GetContextGroupId(context), reason_view, details_view); @@ -812,9 +821,11 @@ class InspectorExtension : public IsolateData::SetupGlobalTask { "Internal error: callWithScheduledBreak('reason', 'details')."); Exit(); } - v8::internal::Vector reason = ToVector(args[1].As()); + v8::internal::Vector reason = + ToVector(args.GetIsolate(), args[1].As()); v8_inspector::StringView reason_view(reason.start(), reason.length()); - v8::internal::Vector details = ToVector(args[2].As()); + v8::internal::Vector details = + ToVector(args.GetIsolate(), args[2].As()); v8_inspector::StringView details_view(details.start(), details.length()); v8::Local context = args.GetIsolate()->GetCurrentContext(); IsolateData* data = IsolateData::FromContext(context); @@ -903,7 +914,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask { v8::Local context = isolate->GetCurrentContext(); IsolateData* data = IsolateData::FromContext(context); v8::internal::Vector description = - ToVector(args[0].As()); + ToVector(isolate, args[0].As()); v8_inspector::StringView description_view(description.start(), description.length()); v8_inspector::V8StackTraceId id = @@ -960,7 +971,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask { if (with_empty_stack) context->Exit(); v8::internal::Vector task_name = - ToVector(args[1].As()); + ToVector(isolate, args[1].As()); v8_inspector::StringView task_name_view(task_name.start(), task_name.length()); diff --git a/test/inspector/isolate-data.cc b/test/inspector/isolate-data.cc index 15eee89a61..6ddeff8450 100644 --- a/test/inspector/isolate-data.cc +++ b/test/inspector/isolate-data.cc @@ -12,10 +12,11 @@ namespace { const int kIsolateDataIndex = 2; const int kContextGroupIdIndex = 3; -v8::internal::Vector ToVector(v8::Local str) { +v8::internal::Vector ToVector(v8::Isolate* isolate, + v8::Local str) { v8::internal::Vector buffer = v8::internal::Vector::New(str->Length()); - str->Write(buffer.start(), 0, str->Length()); + str->Write(isolate, buffer.start(), 0, str->Length()); return buffer; } @@ -137,7 +138,8 @@ v8::MaybeLocal IsolateData::ModuleResolveCallback( v8::Local referrer) { IsolateData* data = IsolateData::FromContext(context); std::string str = *v8::String::Utf8Value(data->isolate(), specifier); - return data->modules_[ToVector(specifier)].Get(data->isolate()); + return data->modules_[ToVector(data->isolate(), specifier)].Get( + data->isolate()); } int IsolateData::ConnectSession(int context_group_id, @@ -258,13 +260,14 @@ int IsolateData::HandleMessage(v8::Local message, column_number = message->GetStartColumn(context).FromJust() + 1; v8_inspector::StringView detailed_message; - v8::internal::Vector message_text_string = ToVector(message->Get()); + v8::internal::Vector message_text_string = + ToVector(isolate, message->Get()); v8_inspector::StringView message_text(message_text_string.start(), message_text_string.length()); v8::internal::Vector url_string; if (message->GetScriptOrigin().ResourceName()->IsString()) { - url_string = - ToVector(message->GetScriptOrigin().ResourceName().As()); + url_string = ToVector( + isolate, message->GetScriptOrigin().ResourceName().As()); } v8_inspector::StringView url(url_string.start(), url_string.length()); diff --git a/test/unittests/value-serializer-unittest.cc b/test/unittests/value-serializer-unittest.cc index 92603b588a..c2dce7cdfa 100644 --- a/test/unittests/value-serializer-unittest.cc +++ b/test/unittests/value-serializer-unittest.cc @@ -2514,7 +2514,8 @@ TEST_F(ValueSerializerTestWithWasm, DefaultSerializationDelegate) { Local message = InvalidEncodeTest(MakeWasm()); size_t msg_len = static_cast(message->Get()->Length()); std::unique_ptr buff(new char[msg_len + 1]); - message->Get()->WriteOneByte(reinterpret_cast(buff.get())); + message->Get()->WriteOneByte(isolate(), + reinterpret_cast(buff.get())); // the message ends with the custom error string size_t custom_msg_len = strlen(kUnsupportedSerialization); ASSERT_GE(msg_len, custom_msg_len);