Commit 8bde6b19 authored by machenbach's avatar machenbach Committed by Commit bot

Revert of Make d8 stop using to-be-deprecated APIs (patchset #3 id:40001 of...

Revert of Make d8 stop using to-be-deprecated APIs (patchset #3 id:40001 of https://codereview.chromium.org/1239053004/)

Reason for revert:
[Sheriff] Breaks:
http://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20debug%20-%20code%20serializer/builds/3400

Original issue's description:
> Make d8 stop using to-be-deprecated APIs
>
> BUG=v8:4134
> LOG=n
> R=yangguo@chromium.org
>
> Committed: https://crrev.com/af82ef84b4f851411f00e69167ab29382c7499b8
> Cr-Commit-Position: refs/heads/master@{#29726}

TBR=yangguo@chromium.org,jochen@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:4134

Review URL: https://codereview.chromium.org/1240993003

Cr-Commit-Position: refs/heads/master@{#29730}
parent 362b3785
......@@ -29,30 +29,24 @@ void HandleDebugEvent(const Debug::EventDetails& event_details) {
// Get the toJSONProtocol function on the event and get the JSON format.
Local<String> to_json_fun_name =
String::NewFromUtf8(isolate, "toJSONProtocol", NewStringType::kNormal)
.ToLocalChecked();
Local<Object> event_data = event_details.GetEventData();
String::NewFromUtf8(isolate, "toJSONProtocol");
Handle<Object> event_data = event_details.GetEventData();
Local<Function> to_json_fun =
Local<Function>::Cast(event_data->Get(isolate->GetCurrentContext(),
to_json_fun_name).ToLocalChecked());
Local<Value> event_json;
if (!to_json_fun->Call(isolate->GetCurrentContext(), event_data, 0, NULL)
.ToLocal(&event_json)) {
Local<Function>::Cast(event_data->Get(to_json_fun_name));
Local<Value> event_json = to_json_fun->Call(event_data, 0, NULL);
if (try_catch.HasCaught()) {
Shell::ReportException(isolate, &try_catch);
return;
}
// Print the event details.
Local<Object> details =
Shell::DebugMessageDetails(isolate, Local<String>::Cast(event_json));
Handle<Object> details =
Shell::DebugMessageDetails(isolate, Handle<String>::Cast(event_json));
if (try_catch.HasCaught()) {
Shell::ReportException(isolate, &try_catch);
return;
}
String::Utf8Value str(
details->Get(isolate->GetCurrentContext(),
String::NewFromUtf8(isolate, "text", NewStringType::kNormal)
.ToLocalChecked()).ToLocalChecked());
String::Utf8Value str(details->Get(String::NewFromUtf8(isolate, "text")));
if (str.length() == 0) {
// Empty string is used to signal not to process this event.
return;
......@@ -61,18 +55,15 @@ void HandleDebugEvent(const Debug::EventDetails& event_details) {
// Get the debug command processor.
Local<String> fun_name =
String::NewFromUtf8(isolate, "debugCommandProcessor",
NewStringType::kNormal).ToLocalChecked();
Local<Object> exec_state = event_details.GetExecutionState();
Local<Function> fun = Local<Function>::Cast(
exec_state->Get(isolate->GetCurrentContext(), fun_name).ToLocalChecked());
Local<Value> cmd_processor_value;
if (!fun->Call(isolate->GetCurrentContext(), exec_state, 0, NULL)
.ToLocal(&cmd_processor_value)) {
String::NewFromUtf8(isolate, "debugCommandProcessor");
Handle<Object> exec_state = event_details.GetExecutionState();
Local<Function> fun = Local<Function>::Cast(exec_state->Get(fun_name));
Local<Object> cmd_processor =
Local<Object>::Cast(fun->Call(exec_state, 0, NULL));
if (try_catch.HasCaught()) {
Shell::ReportException(isolate, &try_catch);
return;
}
Local<Object> cmd_processor = Local<Object>::Cast(cmd_processor_value);
static const int kBufferSize = 256;
bool running = false;
......@@ -88,9 +79,8 @@ void HandleDebugEvent(const Debug::EventDetails& event_details) {
TryCatch try_catch(isolate);
// Convert the debugger command to a JSON debugger request.
Local<Value> request = Shell::DebugCommandToJSONRequest(
isolate, String::NewFromUtf8(isolate, command, NewStringType::kNormal)
.ToLocalChecked());
Handle<Value> request = Shell::DebugCommandToJSONRequest(
isolate, String::NewFromUtf8(isolate, command));
if (try_catch.HasCaught()) {
Shell::ReportException(isolate, &try_catch);
continue;
......@@ -102,50 +92,39 @@ void HandleDebugEvent(const Debug::EventDetails& event_details) {
continue;
}
Local<String> fun_name;
Local<Function> fun;
Handle<String> fun_name;
Handle<Function> fun;
// All the functions used below take one argument.
static const int kArgc = 1;
Local<Value> args[kArgc];
Handle<Value> args[kArgc];
// Invoke the JavaScript to convert the debug command line to a JSON
// request, invoke the JSON request and convert the JSON respose to a text
// representation.
fun_name = String::NewFromUtf8(isolate, "processDebugRequest",
NewStringType::kNormal).ToLocalChecked();
fun = Local<Function>::Cast(cmd_processor->Get(isolate->GetCurrentContext(),
fun_name).ToLocalChecked());
fun_name = String::NewFromUtf8(isolate, "processDebugRequest");
fun = Handle<Function>::Cast(cmd_processor->Get(fun_name));
args[0] = request;
Local<Value> response_val;
if (!fun->Call(isolate->GetCurrentContext(), cmd_processor, kArgc, args)
.ToLocal(&response_val)) {
Handle<Value> response_val = fun->Call(cmd_processor, kArgc, args);
if (try_catch.HasCaught()) {
Shell::ReportException(isolate, &try_catch);
continue;
}
Local<String> response = Local<String>::Cast(response_val);
Handle<String> response = Handle<String>::Cast(response_val);
// Convert the debugger response into text details and the running state.
Local<Object> response_details =
Handle<Object> response_details =
Shell::DebugMessageDetails(isolate, response);
if (try_catch.HasCaught()) {
Shell::ReportException(isolate, &try_catch);
continue;
}
String::Utf8Value text_str(
response_details->Get(isolate->GetCurrentContext(),
String::NewFromUtf8(isolate, "text",
NewStringType::kNormal)
.ToLocalChecked()).ToLocalChecked());
response_details->Get(String::NewFromUtf8(isolate, "text")));
if (text_str.length() > 0) {
printf("%s\n", *text_str);
}
running = response_details->Get(isolate->GetCurrentContext(),
String::NewFromUtf8(isolate, "running",
NewStringType::kNormal)
.ToLocalChecked())
.ToLocalChecked()
->ToBoolean(isolate->GetCurrentContext())
.ToLocalChecked()
running = response_details->Get(String::NewFromUtf8(isolate, "running"))
->ToBoolean(isolate)
->Value();
}
}
......
This diff is collapsed.
......@@ -25,7 +25,7 @@ namespace v8 {
class ReadLineEditor: public LineEditor {
public:
ReadLineEditor() : LineEditor(LineEditor::READLINE, "readline") { }
virtual Local<String> Prompt(const char* prompt);
virtual Handle<String> Prompt(const char* prompt);
virtual bool Open(Isolate* isolate);
virtual bool Close();
virtual void AddHistory(const char* str);
......@@ -80,10 +80,10 @@ bool ReadLineEditor::Close() {
}
Local<String> ReadLineEditor::Prompt(const char* prompt) {
Handle<String> ReadLineEditor::Prompt(const char* prompt) {
char* result = NULL;
result = readline(prompt);
if (result == NULL) return Local<String>();
if (result == NULL) return Handle<String>();
AddHistory(result);
return String::NewFromUtf8(isolate_, result);
}
......@@ -118,10 +118,10 @@ char** ReadLineEditor::AttemptedCompletion(const char* text,
char* ReadLineEditor::CompletionGenerator(const char* text, int state) {
static unsigned current_index;
static Global<Array> current_completions;
static Persistent<Array> current_completions;
Isolate* isolate = read_line_editor.isolate_;
HandleScope scope(isolate);
Local<Array> completions;
Handle<Array> completions;
if (state == 0) {
Local<String> full_text = String::NewFromUtf8(isolate,
rl_line_buffer,
......@@ -136,8 +136,8 @@ char* ReadLineEditor::CompletionGenerator(const char* text, int state) {
completions = Local<Array>::New(isolate, current_completions);
}
if (current_index < completions->Length()) {
Local<Integer> index = Integer::New(isolate, current_index);
Local<Value> str_obj = completions->Get(index);
Handle<Integer> index = Integer::New(isolate, current_index);
Handle<Value> str_obj = completions->Get(index);
current_index++;
String::Utf8Value str(str_obj);
return strdup(*str);
......
......@@ -8,7 +8,8 @@
namespace v8 {
void Shell::AddOSMethods(Isolate* isolate, Local<ObjectTemplate> os_templ) {}
void Shell::AddOSMethods(Isolate* isolate, Handle<ObjectTemplate> os_templ) {
}
} // namespace v8
This diff is collapsed.
......@@ -53,10 +53,6 @@
'startup-data-util.h',
'startup-data-util.cc'
],
'defines': [
# TODO(jochen): Remove again after this is globally turned on.
'V8_IMMINENT_DEPRECATION_WARNINGS',
],
'conditions': [
[ 'want_separate_host_toolset==1', {
'toolsets': [ '<(v8_toolset_for_d8)', ],
......
......@@ -99,7 +99,7 @@ class LineEditor {
LineEditor(Type type, const char* name);
virtual ~LineEditor() { }
virtual Local<String> Prompt(const char* prompt) = 0;
virtual Handle<String> Prompt(const char* prompt) = 0;
virtual bool Open(Isolate* isolate) { return true; }
virtual bool Close() { return true; }
virtual void AddHistory(const char* str) { }
......@@ -163,7 +163,7 @@ class SourceGroup {
#endif // !V8_SHARED
void ExitShell(int exit_code);
Local<String> ReadFile(Isolate* isolate, const char* name);
Handle<String> ReadFile(Isolate* isolate, const char* name);
const char** argv_;
int begin_offset_;
......@@ -349,17 +349,17 @@ class Shell : public i::AllStatic {
public:
enum SourceType { SCRIPT, MODULE };
static MaybeLocal<Script> CompileString(
static Local<Script> CompileString(
Isolate* isolate, Local<String> source, Local<Value> name,
v8::ScriptCompiler::CompileOptions compile_options,
SourceType source_type);
static bool ExecuteString(Isolate* isolate, Local<String> source,
Local<Value> name, bool print_result,
static bool ExecuteString(Isolate* isolate, Handle<String> source,
Handle<Value> name, bool print_result,
bool report_exceptions,
SourceType source_type = SCRIPT);
static const char* ToCString(const v8::String::Utf8Value& value);
static void ReportException(Isolate* isolate, TryCatch* try_catch);
static Local<String> ReadFile(Isolate* isolate, const char* name);
static Handle<String> ReadFile(Isolate* isolate, const char* name);
static Local<Context> CreateEvaluationContext(Isolate* isolate);
static int RunMain(Isolate* isolate, int argc, char* argv[]);
static int Main(int argc, char* argv[]);
......@@ -371,8 +371,8 @@ class Shell : public i::AllStatic {
#ifndef V8_SHARED
// TODO(binji): stupid implementation for now. Is there an easy way to hash an
// object for use in i::HashMap? By pointer?
typedef i::List<Local<Object>> ObjectList;
static bool SerializeValue(Isolate* isolate, Local<Value> value,
typedef i::List<Handle<Object>> ObjectList;
static bool SerializeValue(Isolate* isolate, Handle<Value> value,
const ObjectList& to_transfer,
ObjectList* seen_objects,
SerializationData* out_data);
......@@ -380,8 +380,9 @@ class Shell : public i::AllStatic {
const SerializationData& data,
int* offset);
static void CleanupWorkers();
static Local<Array> GetCompletions(Isolate* isolate, Local<String> text,
Local<String> full);
static Handle<Array> GetCompletions(Isolate* isolate,
Handle<String> text,
Handle<String> full);
static int* LookupCounter(const char* name);
static void* CreateHistogram(const char* name,
int min,
......@@ -391,9 +392,9 @@ class Shell : public i::AllStatic {
static void MapCounters(v8::Isolate* isolate, const char* name);
static Local<Object> DebugMessageDetails(Isolate* isolate,
Local<String> message);
Handle<String> message);
static Local<Value> DebugCommandToJSONRequest(Isolate* isolate,
Local<String> command);
Handle<String> command);
static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args);
#endif // !V8_SHARED
......@@ -418,7 +419,7 @@ class Shell : public i::AllStatic {
static void Version(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Read(const v8::FunctionCallbackInfo<v8::Value>& args);
static void ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args);
static Local<String> ReadFromStdin(Isolate* isolate);
static Handle<String> ReadFromStdin(Isolate* isolate);
static void ReadLine(const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetReturnValue().Set(ReadFromStdin(args.GetIsolate()));
}
......@@ -463,17 +464,17 @@ class Shell : public i::AllStatic {
static void RemoveDirectory(const v8::FunctionCallbackInfo<v8::Value>& args);
static void AddOSMethods(v8::Isolate* isolate,
Local<ObjectTemplate> os_template);
Handle<ObjectTemplate> os_template);
static const char* kPrompt;
static ShellOptions options;
static ArrayBuffer::Allocator* array_buffer_allocator;
private:
static Global<Context> evaluation_context_;
static Persistent<Context> evaluation_context_;
static base::OnceType quit_once_;
#ifndef V8_SHARED
static Global<Context> utility_context_;
static Persistent<Context> utility_context_;
static CounterMap* counter_map_;
// We statically allocate a set of local counters to be used if we
// don't want to store the stats in a memory-mapped file
......@@ -495,7 +496,7 @@ class Shell : public i::AllStatic {
static void InitializeDebugger(Isolate* isolate);
static void RunShell(Isolate* isolate);
static bool SetOptions(int argc, char* argv[]);
static Local<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate);
static Handle<ObjectTemplate> CreateGlobalTemplate(Isolate* 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