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

Side by Side Diff: src/api.cc

Issue 2772093002: [inspector] exposed builtins for injected script source (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | src/debug/debug-interface.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/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 9538 matching lines...) Expand 10 before | Expand all | Expand 10 after
9549 if (object->IsJSSetIterator()) { 9549 if (object->IsJSSetIterator()) {
9550 i::Handle<i::JSSetIterator> it = i::Handle<i::JSSetIterator>::cast(object); 9550 i::Handle<i::JSSetIterator> it = i::Handle<i::JSSetIterator>::cast(object);
9551 *is_key_value = false; 9551 *is_key_value = false;
9552 if (!it->HasMore()) return v8::Array::New(v8_isolate); 9552 if (!it->HasMore()) return v8::Array::New(v8_isolate);
9553 return Utils::ToLocal( 9553 return Utils::ToLocal(
9554 SetAsArray(isolate, it->table(), i::Smi::cast(it->index())->value())); 9554 SetAsArray(isolate, it->table(), i::Smi::cast(it->index())->value()));
9555 } 9555 }
9556 return v8::MaybeLocal<v8::Array>(); 9556 return v8::MaybeLocal<v8::Array>();
9557 } 9557 }
9558 9558
9559 Local<Function> debug::GetBuiltin(Isolate* v8_isolate, Builtin builtin) {
9560 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9561 ENTER_V8(isolate);
9562 i::HandleScope handle_scope(isolate);
9563 i::Builtins::Name name;
9564 int len = 1;
9565 switch (builtin) {
9566 case kObjectKeys:
9567 name = i::Builtins::kObjectKeys;
9568 break;
9569 case kObjectGetPrototypeOf:
9570 name = i::Builtins::kObjectGetPrototypeOf;
9571 break;
9572 case kObjectGetOwnPropertyDescriptor:
9573 name = i::Builtins::kObjectGetOwnPropertyDescriptor;
9574 len = 2;
9575 break;
9576 case kObjectGetOwnPropertyNames:
9577 name = i::Builtins::kObjectGetOwnPropertyNames;
9578 break;
9579 case kObjectGetOwnPropertySymbols:
9580 name = i::Builtins::kObjectGetOwnPropertySymbols;
9581 break;
9582 }
9583 i::Handle<i::Code> call_code(isolate->builtins()->builtin(name));
9584 i::Handle<i::JSFunction> fun =
9585 isolate->factory()->NewFunctionWithoutPrototype(
9586 isolate->factory()->empty_string(), call_code, false);
9587 fun->shared()->set_native(true);
Yang 2017/03/24 21:19:31 No need to set this native. We only need this for
kozy 2017/03/24 21:39:55 Done.
9588 fun->shared()->DontAdaptArguments();
9589 fun->shared()->set_length(len);
Yang 2017/03/24 21:19:31 Also no need to set length, I think.
kozy 2017/03/24 21:39:55 Done.
9590 return Utils::ToLocal(handle_scope.CloseAndEscape(fun));
9591 }
9592
9559 MaybeLocal<debug::Script> debug::GeneratorObject::Script() { 9593 MaybeLocal<debug::Script> debug::GeneratorObject::Script() {
9560 i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this); 9594 i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this);
9561 i::Object* maybe_script = obj->function()->shared()->script(); 9595 i::Object* maybe_script = obj->function()->shared()->script();
9562 if (!maybe_script->IsScript()) return MaybeLocal<debug::Script>(); 9596 if (!maybe_script->IsScript()) return MaybeLocal<debug::Script>();
9563 i::Handle<i::Script> script(i::Script::cast(maybe_script), obj->GetIsolate()); 9597 i::Handle<i::Script> script(i::Script::cast(maybe_script), obj->GetIsolate());
9564 return ToApiHandle<debug::Script>(script); 9598 return ToApiHandle<debug::Script>(script);
9565 } 9599 }
9566 9600
9567 Local<Function> debug::GeneratorObject::Function() { 9601 Local<Function> debug::GeneratorObject::Function() {
9568 i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this); 9602 i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this);
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
10316 Address callback_address = 10350 Address callback_address =
10317 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10351 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10318 VMState<EXTERNAL> state(isolate); 10352 VMState<EXTERNAL> state(isolate);
10319 ExternalCallbackScope call_scope(isolate, callback_address); 10353 ExternalCallbackScope call_scope(isolate, callback_address);
10320 callback(info); 10354 callback(info);
10321 } 10355 }
10322 10356
10323 10357
10324 } // namespace internal 10358 } // namespace internal
10325 } // namespace v8 10359 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/debug/debug-interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698