Commit ec52bf56 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Fix use of deprecated methods

Uses the new Isolate version of methods.

Bug: v8:7754
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: I1a38dd61d10899ae33ef796f4f443b11640315c2
Reviewed-on: https://chromium-review.googlesource.com/1143861
Commit-Queue: Dan Elphick <delphick@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54563}
parent af0bd711
......@@ -5820,11 +5820,12 @@ int String::WriteUtf8(Isolate* v8_isolate, char* buffer, int capacity,
if (success) return writer.CompleteWrite(write_null, nchars_ref);
} else if (capacity >= string_length) {
// First check that the buffer is large enough.
int utf8_bytes = Utf8Length(reinterpret_cast<Isolate*>(isolate));
int utf8_bytes = Utf8Length(v8_isolate);
if (utf8_bytes <= capacity) {
// one-byte fast path.
if (utf8_bytes == string_length) {
WriteOneByte(reinterpret_cast<uint8_t*>(buffer), 0, capacity, options);
WriteOneByte(v8_isolate, reinterpret_cast<uint8_t*>(buffer), 0,
capacity, options);
if (nchars_ref != nullptr) *nchars_ref = string_length;
if (write_null && (utf8_bytes+1 <= capacity)) {
return string_length + 1;
......@@ -5837,7 +5838,7 @@ int String::WriteUtf8(Isolate* v8_isolate, char* buffer, int capacity,
// Recurse once without a capacity limit.
// This will get into the first branch above.
// TODO(dcarney) Check max left rec. in Utf8Length and fall through.
return WriteUtf8(buffer, -1, nchars_ref, options);
return WriteUtf8(v8_isolate, buffer, -1, nchars_ref, options);
}
}
Utf8WriterVisitor writer(buffer, capacity, false, replace_invalid_utf8);
......@@ -9202,7 +9203,7 @@ String::Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local<v8::Value> obj)
if (!obj->ToString(context).ToLocal(&str)) return;
length_ = str->Utf8Length(isolate);
str_ = i::NewArray<char>(length_ + 1);
str->WriteUtf8(str_);
str->WriteUtf8(isolate, str_);
}
String::Utf8Value::Utf8Value(v8::Local<v8::Value> obj)
......@@ -9224,7 +9225,7 @@ String::Value::Value(v8::Isolate* isolate, v8::Local<v8::Value> obj)
if (!obj->ToString(context).ToLocal(&str)) return;
length_ = str->Length();
str_ = i::NewArray<uint16_t>(length_ + 1);
str->Write(str_);
str->Write(isolate, str_);
}
String::Value::Value(v8::Local<v8::Value> obj)
......
......@@ -38,10 +38,11 @@ class MaybeUtf8 {
}
} else {
Local<v8::String> local = Utils::ToLocal(string);
len = local->Utf8Length(reinterpret_cast<v8::Isolate*>(isolate));
auto* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
len = local->Utf8Length(v8_isolate);
AllocateSufficientSpace(len);
if (len > 0) {
local->WriteUtf8(reinterpret_cast<char*>(buf_));
local->WriteUtf8(v8_isolate, reinterpret_cast<char*>(buf_));
}
}
buf_[len] = 0;
......
......@@ -428,7 +428,7 @@ class DummySourceStream : public v8::ScriptCompiler::ExternalSourceStream {
DummySourceStream(Local<String> source, Isolate* isolate) : done_(false) {
source_length_ = source->Utf8Length(isolate);
source_buffer_.reset(new uint8_t[source_length_]);
source->WriteUtf8(reinterpret_cast<char*>(source_buffer_.get()),
source->WriteUtf8(isolate, reinterpret_cast<char*>(source_buffer_.get()),
source_length_);
}
......@@ -1339,20 +1339,22 @@ Local<String> Shell::ReadFromStdin(Isolate* isolate) {
return accumulator;
} else if (buffer[length-1] != '\n') {
accumulator = String::Concat(
accumulator,
isolate, accumulator,
String::NewFromUtf8(isolate, buffer, NewStringType::kNormal, length)
.ToLocalChecked());
} else if (length > 1 && buffer[length-2] == '\\') {
buffer[length-2] = '\n';
accumulator = String::Concat(
accumulator,
String::NewFromUtf8(isolate, buffer, NewStringType::kNormal,
length - 1).ToLocalChecked());
accumulator =
String::Concat(isolate, accumulator,
String::NewFromUtf8(isolate, buffer,
NewStringType::kNormal, length - 1)
.ToLocalChecked());
} else {
return String::Concat(
accumulator,
isolate, accumulator,
String::NewFromUtf8(isolate, buffer, NewStringType::kNormal,
length - 1).ToLocalChecked());
length - 1)
.ToLocalChecked());
}
}
}
......@@ -2403,7 +2405,7 @@ class InspectorClient : public v8_inspector::V8InspectorClient {
InspectorClient::GetSession(context);
int length = message->Length();
std::unique_ptr<uint16_t[]> buffer(new uint16_t[length]);
message->Write(buffer.get(), 0, length);
message->Write(isolate, buffer.get(), 0, length);
v8_inspector::StringView message_view(buffer.get(), length);
session->dispatchProtocolMessage(message_view);
args.GetReturnValue().Set(True(isolate));
......
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