Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: src/debug/debug.cc

Issue 1423723002: Map v8::Function to JSReceiver + IsCallable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug/debug.h ('k') | src/execution.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/debug/debug.h" 5 #include "src/debug/debug.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 568
569 569
570 MaybeHandle<Object> Debug::CallFunction(const char* name, int argc, 570 MaybeHandle<Object> Debug::CallFunction(const char* name, int argc,
571 Handle<Object> args[]) { 571 Handle<Object> args[]) {
572 PostponeInterruptsScope no_interrupts(isolate_); 572 PostponeInterruptsScope no_interrupts(isolate_);
573 AssertDebugContext(); 573 AssertDebugContext();
574 Handle<Object> holder = isolate_->natives_utils_object(); 574 Handle<Object> holder = isolate_->natives_utils_object();
575 Handle<JSFunction> fun = Handle<JSFunction>::cast( 575 Handle<JSFunction> fun = Handle<JSFunction>::cast(
576 Object::GetProperty(isolate_, holder, name, STRICT).ToHandleChecked()); 576 Object::GetProperty(isolate_, holder, name, STRICT).ToHandleChecked());
577 Handle<Object> undefined = isolate_->factory()->undefined_value(); 577 Handle<Object> undefined = isolate_->factory()->undefined_value();
578 return Execution::TryCall(fun, undefined, argc, args); 578 return Execution::TryCall(isolate_, fun, undefined, argc, args);
579 } 579 }
580 580
581 581
582 // Check whether a single break point object is triggered. 582 // Check whether a single break point object is triggered.
583 bool Debug::CheckBreakPoint(Handle<Object> break_point_object) { 583 bool Debug::CheckBreakPoint(Handle<Object> break_point_object) {
584 Factory* factory = isolate_->factory(); 584 Factory* factory = isolate_->factory();
585 HandleScope scope(isolate_); 585 HandleScope scope(isolate_);
586 586
587 // Ignore check if break point object is not a JSObject. 587 // Ignore check if break point object is not a JSObject.
588 if (!break_point_object->IsJSObject()) return true; 588 if (!break_point_object->IsJSObject()) return true;
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 callback(event_details); 1936 callback(event_details);
1937 DCHECK(!isolate_->has_scheduled_exception()); 1937 DCHECK(!isolate_->has_scheduled_exception());
1938 } else { 1938 } else {
1939 // Invoke the JavaScript debug event listener. 1939 // Invoke the JavaScript debug event listener.
1940 DCHECK(event_listener_->IsJSFunction()); 1940 DCHECK(event_listener_->IsJSFunction());
1941 Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event), isolate_), 1941 Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event), isolate_),
1942 exec_state, 1942 exec_state,
1943 event_data, 1943 event_data,
1944 event_listener_data_ }; 1944 event_listener_data_ };
1945 Handle<JSReceiver> global(isolate_->global_proxy()); 1945 Handle<JSReceiver> global(isolate_->global_proxy());
1946 Execution::TryCall(Handle<JSFunction>::cast(event_listener_), 1946 Execution::TryCall(isolate_, Handle<JSFunction>::cast(event_listener_),
1947 global, arraysize(argv), argv); 1947 global, arraysize(argv), argv);
1948 } 1948 }
1949 in_debug_event_listener_ = previous; 1949 in_debug_event_listener_ = previous;
1950 } 1950 }
1951 1951
1952 1952
1953 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) { 1953 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) {
1954 if (ignore_events()) return; 1954 if (ignore_events()) return;
1955 SuppressDebug while_processing(this); 1955 SuppressDebug while_processing(this);
1956 1956
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 Vector<const uc16> command_text( 2082 Vector<const uc16> command_text(
2083 const_cast<const uc16*>(command.text().start()), 2083 const_cast<const uc16*>(command.text().start()),
2084 command.text().length()); 2084 command.text().length());
2085 Handle<String> request_text = isolate_->factory()->NewStringFromTwoByte( 2085 Handle<String> request_text = isolate_->factory()->NewStringFromTwoByte(
2086 command_text).ToHandleChecked(); 2086 command_text).ToHandleChecked();
2087 Handle<Object> request_args[] = { request_text }; 2087 Handle<Object> request_args[] = { request_text };
2088 Handle<Object> answer_value; 2088 Handle<Object> answer_value;
2089 Handle<String> answer; 2089 Handle<String> answer;
2090 MaybeHandle<Object> maybe_exception; 2090 MaybeHandle<Object> maybe_exception;
2091 MaybeHandle<Object> maybe_result = 2091 MaybeHandle<Object> maybe_result =
2092 Execution::TryCall(process_debug_request, cmd_processor, 1, 2092 Execution::TryCall(isolate_, process_debug_request, cmd_processor, 1,
2093 request_args, &maybe_exception); 2093 request_args, &maybe_exception);
2094 2094
2095 if (maybe_result.ToHandle(&answer_value)) { 2095 if (maybe_result.ToHandle(&answer_value)) {
2096 if (answer_value->IsUndefined()) { 2096 if (answer_value->IsUndefined()) {
2097 answer = isolate_->factory()->empty_string(); 2097 answer = isolate_->factory()->empty_string();
2098 } else { 2098 } else {
2099 answer = Handle<String>::cast(answer_value); 2099 answer = Handle<String>::cast(answer_value);
2100 } 2100 }
2101 2101
2102 // Log the JSON request/response. 2102 // Log the JSON request/response.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2201 client_data); 2201 client_data);
2202 isolate_->logger()->DebugTag("Put command on command_queue."); 2202 isolate_->logger()->DebugTag("Put command on command_queue.");
2203 command_queue_.Put(message); 2203 command_queue_.Put(message);
2204 command_received_.Signal(); 2204 command_received_.Signal();
2205 2205
2206 // Set the debug command break flag to have the command processed. 2206 // Set the debug command break flag to have the command processed.
2207 if (!in_debug_scope()) isolate_->stack_guard()->RequestDebugCommand(); 2207 if (!in_debug_scope()) isolate_->stack_guard()->RequestDebugCommand();
2208 } 2208 }
2209 2209
2210 2210
2211 MaybeHandle<Object> Debug::Call(Handle<JSFunction> fun, Handle<Object> data) { 2211 MaybeHandle<Object> Debug::Call(Handle<Object> fun, Handle<Object> data) {
2212 DebugScope debug_scope(this); 2212 DebugScope debug_scope(this);
2213 if (debug_scope.failed()) return isolate_->factory()->undefined_value(); 2213 if (debug_scope.failed()) return isolate_->factory()->undefined_value();
2214 2214
2215 // Create the execution state. 2215 // Create the execution state.
2216 Handle<Object> exec_state; 2216 Handle<Object> exec_state;
2217 if (!MakeExecutionState().ToHandle(&exec_state)) { 2217 if (!MakeExecutionState().ToHandle(&exec_state)) {
2218 return isolate_->factory()->undefined_value(); 2218 return isolate_->factory()->undefined_value();
2219 } 2219 }
2220 2220
2221 Handle<Object> argv[] = { exec_state, data }; 2221 Handle<Object> argv[] = { exec_state, data };
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2412 2412
2413 if (IsEvent()) { 2413 if (IsEvent()) {
2414 // Call toJSONProtocol on the debug event object. 2414 // Call toJSONProtocol on the debug event object.
2415 Handle<Object> fun = Object::GetProperty( 2415 Handle<Object> fun = Object::GetProperty(
2416 isolate, event_data_, "toJSONProtocol").ToHandleChecked(); 2416 isolate, event_data_, "toJSONProtocol").ToHandleChecked();
2417 if (!fun->IsJSFunction()) { 2417 if (!fun->IsJSFunction()) {
2418 return v8::Local<v8::String>(); 2418 return v8::Local<v8::String>();
2419 } 2419 }
2420 2420
2421 MaybeHandle<Object> maybe_json = 2421 MaybeHandle<Object> maybe_json =
2422 Execution::TryCall(Handle<JSFunction>::cast(fun), event_data_, 0, NULL); 2422 Execution::TryCall(isolate, fun, event_data_, 0, NULL);
2423 Handle<Object> json; 2423 Handle<Object> json;
2424 if (!maybe_json.ToHandle(&json) || !json->IsString()) { 2424 if (!maybe_json.ToHandle(&json) || !json->IsString()) {
2425 return v8::Local<v8::String>(); 2425 return v8::Local<v8::String>();
2426 } 2426 }
2427 return scope.Escape(v8::Utils::ToLocal(Handle<String>::cast(json))); 2427 return scope.Escape(v8::Utils::ToLocal(Handle<String>::cast(json)));
2428 } else { 2428 } else {
2429 return v8::Utils::ToLocal(response_json_); 2429 return v8::Utils::ToLocal(response_json_);
2430 } 2430 }
2431 } 2431 }
2432 2432
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 } 2580 }
2581 2581
2582 2582
2583 void LockingCommandMessageQueue::Clear() { 2583 void LockingCommandMessageQueue::Clear() {
2584 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2584 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2585 queue_.Clear(); 2585 queue_.Clear();
2586 } 2586 }
2587 2587
2588 } // namespace internal 2588 } // namespace internal
2589 } // namespace v8 2589 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug.h ('k') | src/execution.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698