| OLD | NEW | 
|---|
| 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 9216 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 9227       i::handle(script->line_ends(), script->GetIsolate())); | 9227       i::handle(script->line_ends(), script->GetIsolate())); | 
| 9228   CHECK(line_ends->length()); | 9228   CHECK(line_ends->length()); | 
| 9229   if (line >= line_ends->length()) | 9229   if (line >= line_ends->length()) | 
| 9230     return GetSmiValue(line_ends, line_ends->length() - 1); | 9230     return GetSmiValue(line_ends, line_ends->length() - 1); | 
| 9231   int line_offset = GetSmiValue(line_ends, line); | 9231   int line_offset = GetSmiValue(line_ends, line); | 
| 9232   if (line == 0) return std::min(column, line_offset); | 9232   if (line == 0) return std::min(column, line_offset); | 
| 9233   int prev_line_offset = GetSmiValue(line_ends, line - 1); | 9233   int prev_line_offset = GetSmiValue(line_ends, line - 1); | 
| 9234   return std::min(prev_line_offset + column + 1, line_offset); | 9234   return std::min(prev_line_offset + column + 1, line_offset); | 
| 9235 } | 9235 } | 
| 9236 | 9236 | 
| 9237 MaybeLocal<debug::Script> debug::Script::Wrap(v8::Isolate* v8_isolate, |  | 
| 9238                                               v8::Local<v8::Object> script) { |  | 
| 9239   i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |  | 
| 9240   ENTER_V8(isolate); |  | 
| 9241   i::HandleScope handle_scope(isolate); |  | 
| 9242   i::Handle<i::JSReceiver> script_receiver(Utils::OpenHandle(*script)); |  | 
| 9243   if (!script_receiver->IsJSValue()) return MaybeLocal<Script>(); |  | 
| 9244   i::Handle<i::Object> script_value( |  | 
| 9245       i::Handle<i::JSValue>::cast(script_receiver)->value(), isolate); |  | 
| 9246   if (!script_value->IsScript()) { |  | 
| 9247     return MaybeLocal<Script>(); |  | 
| 9248   } |  | 
| 9249   i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value); |  | 
| 9250   if (script_obj->type() != i::Script::TYPE_NORMAL && |  | 
| 9251       script_obj->type() != i::Script::TYPE_WASM) { |  | 
| 9252     return MaybeLocal<Script>(); |  | 
| 9253   } |  | 
| 9254   return ToApiHandle<debug::Script>(handle_scope.CloseAndEscape(script_obj)); |  | 
| 9255 } |  | 
| 9256 |  | 
| 9257 debug::WasmScript* debug::WasmScript::Cast(debug::Script* script) { | 9237 debug::WasmScript* debug::WasmScript::Cast(debug::Script* script) { | 
| 9258   CHECK(script->IsWasm()); | 9238   CHECK(script->IsWasm()); | 
| 9259   return static_cast<WasmScript*>(script); | 9239   return static_cast<WasmScript*>(script); | 
| 9260 } | 9240 } | 
| 9261 | 9241 | 
| 9262 int debug::WasmScript::NumFunctions() const { | 9242 int debug::WasmScript::NumFunctions() const { | 
| 9263   i::DisallowHeapAllocation no_gc; | 9243   i::DisallowHeapAllocation no_gc; | 
| 9264   i::Handle<i::Script> script = Utils::OpenHandle(this); | 9244   i::Handle<i::Script> script = Utils::OpenHandle(this); | 
| 9265   DCHECK_EQ(i::Script::TYPE_WASM, script->type()); | 9245   DCHECK_EQ(i::Script::TYPE_WASM, script->type()); | 
| 9266   i::WasmCompiledModule* compiled_module = | 9246   i::WasmCompiledModule* compiled_module = | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 9352 } | 9332 } | 
| 9353 | 9333 | 
| 9354 void debug::SetAsyncTaskListener(Isolate* v8_isolate, | 9334 void debug::SetAsyncTaskListener(Isolate* v8_isolate, | 
| 9355                                  debug::AsyncTaskListener listener, | 9335                                  debug::AsyncTaskListener listener, | 
| 9356                                  void* data) { | 9336                                  void* data) { | 
| 9357   i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 9337   i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 
| 9358   ENTER_V8(isolate); | 9338   ENTER_V8(isolate); | 
| 9359   isolate->debug()->SetAsyncTaskListener(listener, data); | 9339   isolate->debug()->SetAsyncTaskListener(listener, data); | 
| 9360 } | 9340 } | 
| 9361 | 9341 | 
|  | 9342 void debug::SetCompileEventListener(Isolate* v8_isolate, | 
|  | 9343                                     debug::CompileEventListener listener, | 
|  | 9344                                     void* data) { | 
|  | 9345   i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 
|  | 9346   ENTER_V8(isolate); | 
|  | 9347   isolate->debug()->SetCompileEventListener(listener, data); | 
|  | 9348 } | 
|  | 9349 | 
| 9362 Local<String> CpuProfileNode::GetFunctionName() const { | 9350 Local<String> CpuProfileNode::GetFunctionName() const { | 
| 9363   const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 9351   const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 
| 9364   i::Isolate* isolate = node->isolate(); | 9352   i::Isolate* isolate = node->isolate(); | 
| 9365   const i::CodeEntry* entry = node->entry(); | 9353   const i::CodeEntry* entry = node->entry(); | 
| 9366   i::Handle<i::String> name = | 9354   i::Handle<i::String> name = | 
| 9367       isolate->factory()->InternalizeUtf8String(entry->name()); | 9355       isolate->factory()->InternalizeUtf8String(entry->name()); | 
| 9368   if (!entry->has_name_prefix()) { | 9356   if (!entry->has_name_prefix()) { | 
| 9369     return ToApiHandle<String>(name); | 9357     return ToApiHandle<String>(name); | 
| 9370   } else { | 9358   } else { | 
| 9371     // We do not expect this to fail. Change this if it does. | 9359     // We do not expect this to fail. Change this if it does. | 
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 10039   Address callback_address = | 10027   Address callback_address = | 
| 10040       reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10028       reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 
| 10041   VMState<EXTERNAL> state(isolate); | 10029   VMState<EXTERNAL> state(isolate); | 
| 10042   ExternalCallbackScope call_scope(isolate, callback_address); | 10030   ExternalCallbackScope call_scope(isolate, callback_address); | 
| 10043   callback(info); | 10031   callback(info); | 
| 10044 } | 10032 } | 
| 10045 | 10033 | 
| 10046 | 10034 | 
| 10047 }  // namespace internal | 10035 }  // namespace internal | 
| 10048 }  // namespace v8 | 10036 }  // namespace v8 | 
| OLD | NEW | 
|---|