Commit af82ef84 authored by jochen's avatar jochen Committed by Commit bot

Make d8 stop using to-be-deprecated APIs

BUG=v8:4134
LOG=n
R=yangguo@chromium.org

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

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