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

Side by Side Diff: src/api.cc

Issue 2678143002: [inspector] introduced debug::GeneratorObject (Closed)
Patch Set: addressed comments Created 3 years, 10 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/api.h ('k') | 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 9272 matching lines...) Expand 10 before | Expand all | Expand 10 after
9283 i::WasmCompiledModule::cast(script->wasm_compiled_module()); 9283 i::WasmCompiledModule::cast(script->wasm_compiled_module());
9284 return compiled_module->DisassembleFunction(function_index); 9284 return compiled_module->DisassembleFunction(function_index);
9285 } 9285 }
9286 9286
9287 debug::Location::Location(int line_number, int column_number) 9287 debug::Location::Location(int line_number, int column_number)
9288 : line_number_(line_number), column_number_(column_number) { 9288 : line_number_(line_number), column_number_(column_number) {
9289 CHECK(line_number >= 0); 9289 CHECK(line_number >= 0);
9290 CHECK(column_number >= 0); 9290 CHECK(column_number >= 0);
9291 } 9291 }
9292 9292
9293 debug::Location::Location() : line_number_(-1), column_number_(-1) {} 9293 debug::Location::Location()
9294 : line_number_(v8::Function::kLineOffsetNotFound),
9295 column_number_(v8::Function::kLineOffsetNotFound) {}
9294 9296
9295 int debug::Location::GetLineNumber() const { 9297 int debug::Location::GetLineNumber() const {
9296 CHECK(line_number_ >= 0); 9298 CHECK(line_number_ >= 0);
9297 return line_number_; 9299 return line_number_;
9298 } 9300 }
9299 9301
9300 int debug::Location::GetColumnNumber() const { 9302 int debug::Location::GetColumnNumber() const {
9301 CHECK(column_number_ >= 0); 9303 CHECK(column_number_ >= 0);
9302 return column_number_; 9304 return column_number_;
9303 } 9305 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
9407 if (object->IsJSSetIterator()) { 9409 if (object->IsJSSetIterator()) {
9408 i::Handle<i::JSSetIterator> it = i::Handle<i::JSSetIterator>::cast(object); 9410 i::Handle<i::JSSetIterator> it = i::Handle<i::JSSetIterator>::cast(object);
9409 *is_key_value = false; 9411 *is_key_value = false;
9410 if (!it->HasMore()) return v8::Array::New(v8_isolate); 9412 if (!it->HasMore()) return v8::Array::New(v8_isolate);
9411 return Utils::ToLocal( 9413 return Utils::ToLocal(
9412 SetAsArray(isolate, it->table(), i::Smi::cast(it->index())->value())); 9414 SetAsArray(isolate, it->table(), i::Smi::cast(it->index())->value()));
9413 } 9415 }
9414 return v8::MaybeLocal<v8::Array>(); 9416 return v8::MaybeLocal<v8::Array>();
9415 } 9417 }
9416 9418
9419 MaybeLocal<debug::Script> debug::GeneratorObject::Script() {
9420 i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this);
9421 i::Object* maybe_script = obj->function()->shared()->script();
9422 if (!maybe_script->IsScript()) return MaybeLocal<debug::Script>();
9423 i::Handle<i::Script> script(i::Script::cast(maybe_script), obj->GetIsolate());
9424 return ToApiHandle<debug::Script>(script);
9425 }
9426
9427 Local<Function> debug::GeneratorObject::Function() {
9428 i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this);
9429 return Utils::ToLocal(handle(obj->function()));
9430 }
9431
9432 debug::Location debug::GeneratorObject::SuspendedLocation() {
9433 i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this);
9434 CHECK(obj->is_suspended());
9435 i::Object* maybe_script = obj->function()->shared()->script();
9436 if (!maybe_script->IsScript()) return debug::Location();
9437 i::Handle<i::Script> script(i::Script::cast(maybe_script), obj->GetIsolate());
9438 i::Script::PositionInfo info;
9439 i::Script::GetPositionInfo(script, obj->source_position(), &info,
9440 i::Script::WITH_OFFSET);
9441 return debug::Location(info.line, info.column);
9442 }
9443
9444 bool debug::GeneratorObject::IsSuspended() {
9445 return Utils::OpenHandle(this)->is_suspended();
9446 }
9447
9448 v8::Local<debug::GeneratorObject> debug::GeneratorObject::Cast(
9449 v8::Local<v8::Value> value) {
9450 CHECK(value->IsGeneratorObject());
9451 return ToApiHandle<debug::GeneratorObject>(Utils::OpenHandle(*value));
9452 }
9453
9417 Local<String> CpuProfileNode::GetFunctionName() const { 9454 Local<String> CpuProfileNode::GetFunctionName() const {
9418 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 9455 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
9419 i::Isolate* isolate = node->isolate(); 9456 i::Isolate* isolate = node->isolate();
9420 const i::CodeEntry* entry = node->entry(); 9457 const i::CodeEntry* entry = node->entry();
9421 i::Handle<i::String> name = 9458 i::Handle<i::String> name =
9422 isolate->factory()->InternalizeUtf8String(entry->name()); 9459 isolate->factory()->InternalizeUtf8String(entry->name());
9423 if (!entry->has_name_prefix()) { 9460 if (!entry->has_name_prefix()) {
9424 return ToApiHandle<String>(name); 9461 return ToApiHandle<String>(name);
9425 } else { 9462 } else {
9426 // We do not expect this to fail. Change this if it does. 9463 // We do not expect this to fail. Change this if it does.
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
10099 Address callback_address = 10136 Address callback_address =
10100 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10137 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10101 VMState<EXTERNAL> state(isolate); 10138 VMState<EXTERNAL> state(isolate);
10102 ExternalCallbackScope call_scope(isolate, callback_address); 10139 ExternalCallbackScope call_scope(isolate, callback_address);
10103 callback(info); 10140 callback(info);
10104 } 10141 }
10105 10142
10106 10143
10107 } // namespace internal 10144 } // namespace internal
10108 } // namespace v8 10145 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/debug/debug-interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698