Commit 64e3912f authored by Ross Mcilroy's avatar Ross Mcilroy Committed by Commit Bot

[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 <delphick@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54604}
parent bc017d81
......@@ -184,7 +184,7 @@ void VTUNEJITInterface::event_handler(const v8::JitCodeEvent* event) {
Local<String>::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;
}
......
This diff is collapsed.
......@@ -294,7 +294,7 @@ class TestCodeEventHandler : public v8::CodeEventHandler {
if (name.empty()) {
v8::Local<v8::String> 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<v8::String> s = result->ToString(logger.env()).ToLocalChecked();
i::ScopedVector<char> data(s->Utf8Length(isolate) + 1);
CHECK(data.start());
s->WriteUtf8(data.start());
s->WriteUtf8(isolate, data.start());
FATAL("%s\n", data.start());
}
}
......
......@@ -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<uc16>(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());
......
......@@ -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<uint8_t*>(&buffer[0]), 0, kBufferLength);
isolate, reinterpret_cast<uint8_t*>(&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<v8::Value> result;
v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(args->isolate));
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(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<v8::Value> result;
v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(args->isolate));
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(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;
......
......@@ -38,10 +38,11 @@ void Exit() {
Terminate();
}
v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) {
v8::internal::Vector<uint16_t> ToVector(v8::Isolate* isolate,
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());
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<uint16_t>& expression,
v8::Local<v8::String> name,
v8::Local<v8::Integer> line_offset,
v8::Local<v8::Integer> column_offset,
v8::Local<v8::Boolean> is_module)
: expression_(expression),
name_(ToVector(name)),
name_(ToVector(isolate, name)),
line_offset_(line_offset.As<v8::Int32>()->Value()),
column_offset_(column_offset.As<v8::Int32>()->Value()),
is_module_(is_module->Value()),
......@@ -430,7 +431,8 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
}
backend_runner_->Append(new ExecuteStringTask(
args[0].As<v8::Int32>()->Value(), ToVector(args[1].As<v8::String>()),
args.GetIsolate(), args[0].As<v8::Int32>()->Value(),
ToVector(args.GetIsolate(), args[1].As<v8::String>()),
args[2].As<v8::String>(), args[3].As<v8::Int32>(),
args[4].As<v8::Int32>(), args[5].As<v8::Boolean>()));
}
......@@ -463,8 +465,10 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
"'reason', 'details').");
Exit();
}
v8::internal::Vector<uint16_t> reason = ToVector(args[1].As<v8::String>());
v8::internal::Vector<uint16_t> details = ToVector(args[2].As<v8::String>());
v8::internal::Vector<uint16_t> reason =
ToVector(args.GetIsolate(), args[1].As<v8::String>());
v8::internal::Vector<uint16_t> details =
ToVector(args.GetIsolate(), args[2].As<v8::String>());
int context_group_id = args[0].As<v8::Int32>()->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::Function>());
v8::internal::Vector<uint16_t> state = ToVector(args[1].As<v8::String>());
v8::internal::Vector<uint16_t> state =
ToVector(args.GetIsolate(), args[1].As<v8::String>());
int context_group_id = args[0].As<v8::Int32>()->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<v8::Int32>()->Value(), ToVector(args[1].As<v8::String>())));
args[0].As<v8::Int32>()->Value(),
ToVector(args.GetIsolate(), args[1].As<v8::String>())));
}
static std::map<int, std::unique_ptr<FrontendChannelImpl>> 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<v8::String>()),
isolate, context_group_id,
ToVector(isolate, args[0].As<v8::String>()),
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<v8::Context> context = args.GetIsolate()->GetCurrentContext();
IsolateData* data = IsolateData::FromContext(context);
v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>());
v8::internal::Vector<uint16_t> reason =
ToVector(args.GetIsolate(), 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::internal::Vector<uint16_t> details =
ToVector(args.GetIsolate(), args[1].As<v8::String>());
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<uint16_t> reason = ToVector(args[1].As<v8::String>());
v8::internal::Vector<uint16_t> reason =
ToVector(args.GetIsolate(), 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::internal::Vector<uint16_t> details =
ToVector(args.GetIsolate(), args[2].As<v8::String>());
v8_inspector::StringView details_view(details.start(), details.length());
v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
IsolateData* data = IsolateData::FromContext(context);
......@@ -903,7 +914,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
v8::Local<v8::Context> context = isolate->GetCurrentContext();
IsolateData* data = IsolateData::FromContext(context);
v8::internal::Vector<uint16_t> description =
ToVector(args[0].As<v8::String>());
ToVector(isolate, args[0].As<v8::String>());
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<uint16_t> task_name =
ToVector(args[1].As<v8::String>());
ToVector(isolate, args[1].As<v8::String>());
v8_inspector::StringView task_name_view(task_name.start(),
task_name.length());
......
......@@ -12,10 +12,11 @@ namespace {
const int kIsolateDataIndex = 2;
const int kContextGroupIdIndex = 3;
v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) {
v8::internal::Vector<uint16_t> ToVector(v8::Isolate* isolate,
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());
str->Write(isolate, buffer.start(), 0, str->Length());
return buffer;
}
......@@ -137,7 +138,8 @@ v8::MaybeLocal<v8::Module> IsolateData::ModuleResolveCallback(
v8::Local<v8::Module> 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<v8::Message> message,
column_number = message->GetStartColumn(context).FromJust() + 1;
v8_inspector::StringView detailed_message;
v8::internal::Vector<uint16_t> message_text_string = ToVector(message->Get());
v8::internal::Vector<uint16_t> message_text_string =
ToVector(isolate, message->Get());
v8_inspector::StringView message_text(message_text_string.start(),
message_text_string.length());
v8::internal::Vector<uint16_t> url_string;
if (message->GetScriptOrigin().ResourceName()->IsString()) {
url_string =
ToVector(message->GetScriptOrigin().ResourceName().As<v8::String>());
url_string = ToVector(
isolate, message->GetScriptOrigin().ResourceName().As<v8::String>());
}
v8_inspector::StringView url(url_string.start(), url_string.length());
......
......@@ -2514,7 +2514,8 @@ TEST_F(ValueSerializerTestWithWasm, DefaultSerializationDelegate) {
Local<Message> message = InvalidEncodeTest(MakeWasm());
size_t msg_len = static_cast<size_t>(message->Get()->Length());
std::unique_ptr<char[]> buff(new char[msg_len + 1]);
message->Get()->WriteOneByte(reinterpret_cast<uint8_t*>(buff.get()));
message->Get()->WriteOneByte(isolate(),
reinterpret_cast<uint8_t*>(buff.get()));
// the message ends with the custom error string
size_t custom_msg_len = strlen(kUnsupportedSerialization);
ASSERT_GE(msg_len, custom_msg_len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment