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 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2264 i::Handle<i::Object> argv[] = { data }; | 2264 i::Handle<i::Object> argv[] = { data }; |
2265 return CallV8HeapFunction(isolate, name, isolate->js_builtins_object(), | 2265 return CallV8HeapFunction(isolate, name, isolate->js_builtins_object(), |
2266 arraysize(argv), argv); | 2266 arraysize(argv), argv); |
2267 } | 2267 } |
2268 | 2268 |
2269 | 2269 |
2270 Maybe<int> Message::GetLineNumber(Local<Context> context) const { | 2270 Maybe<int> Message::GetLineNumber(Local<Context> context) const { |
2271 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetLineNumber()", int); | 2271 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetLineNumber()", int); |
2272 i::Handle<i::Object> result; | 2272 i::Handle<i::Object> result; |
2273 has_pending_exception = | 2273 has_pending_exception = |
2274 !CallV8HeapFunction(isolate, "GetLineNumber", Utils::OpenHandle(this)) | 2274 !CallV8HeapFunction(isolate, "$messageGetLineNumber", |
2275 .ToHandle(&result); | 2275 Utils::OpenHandle(this)).ToHandle(&result); |
2276 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | 2276 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
2277 return Just(static_cast<int>(result->Number())); | 2277 return Just(static_cast<int>(result->Number())); |
2278 } | 2278 } |
2279 | 2279 |
2280 | 2280 |
2281 int Message::GetLineNumber() const { | 2281 int Message::GetLineNumber() const { |
2282 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 2282 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
2283 return GetLineNumber(context).FromMaybe(0); | 2283 return GetLineNumber(context).FromMaybe(0); |
2284 } | 2284 } |
2285 | 2285 |
2286 | 2286 |
2287 int Message::GetStartPosition() const { | 2287 int Message::GetStartPosition() const { |
2288 auto self = Utils::OpenHandle(this); | 2288 auto self = Utils::OpenHandle(this); |
2289 return self->start_position(); | 2289 return self->start_position(); |
2290 } | 2290 } |
2291 | 2291 |
2292 | 2292 |
2293 int Message::GetEndPosition() const { | 2293 int Message::GetEndPosition() const { |
2294 auto self = Utils::OpenHandle(this); | 2294 auto self = Utils::OpenHandle(this); |
2295 return self->end_position(); | 2295 return self->end_position(); |
2296 } | 2296 } |
2297 | 2297 |
2298 | 2298 |
2299 Maybe<int> Message::GetStartColumn(Local<Context> context) const { | 2299 Maybe<int> Message::GetStartColumn(Local<Context> context) const { |
2300 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetStartColumn()", | 2300 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetStartColumn()", |
2301 int); | 2301 int); |
2302 auto self = Utils::OpenHandle(this); | 2302 auto self = Utils::OpenHandle(this); |
2303 i::Handle<i::Object> start_col_obj; | 2303 i::Handle<i::Object> start_col_obj; |
2304 has_pending_exception = !CallV8HeapFunction(isolate, "GetPositionInLine", | 2304 has_pending_exception = |
2305 self).ToHandle(&start_col_obj); | 2305 !CallV8HeapFunction(isolate, "$messageGetPositionInLine", self) |
| 2306 .ToHandle(&start_col_obj); |
2306 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | 2307 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
2307 return Just(static_cast<int>(start_col_obj->Number())); | 2308 return Just(static_cast<int>(start_col_obj->Number())); |
2308 } | 2309 } |
2309 | 2310 |
2310 | 2311 |
2311 int Message::GetStartColumn() const { | 2312 int Message::GetStartColumn() const { |
2312 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 2313 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
2313 const int default_value = kNoColumnInfo; | 2314 const int default_value = kNoColumnInfo; |
2314 return GetStartColumn(context).FromMaybe(default_value); | 2315 return GetStartColumn(context).FromMaybe(default_value); |
2315 } | 2316 } |
2316 | 2317 |
2317 | 2318 |
2318 Maybe<int> Message::GetEndColumn(Local<Context> context) const { | 2319 Maybe<int> Message::GetEndColumn(Local<Context> context) const { |
2319 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetEndColumn()", int); | 2320 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetEndColumn()", int); |
2320 auto self = Utils::OpenHandle(this); | 2321 auto self = Utils::OpenHandle(this); |
2321 i::Handle<i::Object> start_col_obj; | 2322 i::Handle<i::Object> start_col_obj; |
2322 has_pending_exception = !CallV8HeapFunction(isolate, "GetPositionInLine", | 2323 has_pending_exception = |
2323 self).ToHandle(&start_col_obj); | 2324 !CallV8HeapFunction(isolate, "$messageGetPositionInLine", self) |
| 2325 .ToHandle(&start_col_obj); |
2324 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | 2326 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
2325 int start = self->start_position(); | 2327 int start = self->start_position(); |
2326 int end = self->end_position(); | 2328 int end = self->end_position(); |
2327 return Just(static_cast<int>(start_col_obj->Number()) + (end - start)); | 2329 return Just(static_cast<int>(start_col_obj->Number()) + (end - start)); |
2328 } | 2330 } |
2329 | 2331 |
2330 | 2332 |
2331 int Message::GetEndColumn() const { | 2333 int Message::GetEndColumn() const { |
2332 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 2334 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
2333 const int default_value = kNoColumnInfo; | 2335 const int default_value = kNoColumnInfo; |
2334 return GetEndColumn(context).FromMaybe(default_value); | 2336 return GetEndColumn(context).FromMaybe(default_value); |
2335 } | 2337 } |
2336 | 2338 |
2337 | 2339 |
2338 bool Message::IsSharedCrossOrigin() const { | 2340 bool Message::IsSharedCrossOrigin() const { |
2339 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2341 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2340 ENTER_V8(isolate); | 2342 ENTER_V8(isolate); |
2341 auto self = Utils::OpenHandle(this); | 2343 auto self = Utils::OpenHandle(this); |
2342 auto script = i::Handle<i::JSValue>::cast( | 2344 auto script = i::Handle<i::JSValue>::cast( |
2343 i::Handle<i::Object>(self->script(), isolate)); | 2345 i::Handle<i::Object>(self->script(), isolate)); |
2344 return i::Script::cast(script->value())->is_shared_cross_origin(); | 2346 return i::Script::cast(script->value())->is_shared_cross_origin(); |
2345 } | 2347 } |
2346 | 2348 |
2347 | 2349 |
2348 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { | 2350 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { |
2349 PREPARE_FOR_EXECUTION(context, "v8::Message::GetSourceLine()", String); | 2351 PREPARE_FOR_EXECUTION(context, "v8::Message::GetSourceLine()", String); |
2350 i::Handle<i::Object> result; | 2352 i::Handle<i::Object> result; |
2351 has_pending_exception = | 2353 has_pending_exception = |
2352 !CallV8HeapFunction(isolate, "GetSourceLine", Utils::OpenHandle(this)) | 2354 !CallV8HeapFunction(isolate, "$messageGetSourceLine", |
2353 .ToHandle(&result); | 2355 Utils::OpenHandle(this)).ToHandle(&result); |
2354 RETURN_ON_FAILED_EXECUTION(String); | 2356 RETURN_ON_FAILED_EXECUTION(String); |
2355 Local<String> str; | 2357 Local<String> str; |
2356 if (result->IsString()) { | 2358 if (result->IsString()) { |
2357 str = Utils::ToLocal(i::Handle<i::String>::cast(result)); | 2359 str = Utils::ToLocal(i::Handle<i::String>::cast(result)); |
2358 } | 2360 } |
2359 RETURN_ESCAPED(str); | 2361 RETURN_ESCAPED(str); |
2360 } | 2362 } |
2361 | 2363 |
2362 | 2364 |
2363 Local<String> Message::GetSourceLine() const { | 2365 Local<String> Message::GetSourceLine() const { |
(...skipping 5645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8009 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8011 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8010 Address callback_address = | 8012 Address callback_address = |
8011 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8013 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8012 VMState<EXTERNAL> state(isolate); | 8014 VMState<EXTERNAL> state(isolate); |
8013 ExternalCallbackScope call_scope(isolate, callback_address); | 8015 ExternalCallbackScope call_scope(isolate, callback_address); |
8014 callback(info); | 8016 callback(info); |
8015 } | 8017 } |
8016 | 8018 |
8017 | 8019 |
8018 } } // namespace v8::internal | 8020 } } // namespace v8::internal |
OLD | NEW |