Chromium Code Reviews| 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 2431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2442 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2442 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2443 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2443 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 2444 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); | 2444 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); |
| 2445 if (!stackFramesObj->IsJSArray()) return v8::Local<v8::StackTrace>(); | 2445 if (!stackFramesObj->IsJSArray()) return v8::Local<v8::StackTrace>(); |
| 2446 auto stackTrace = i::Handle<i::JSArray>::cast(stackFramesObj); | 2446 auto stackTrace = i::Handle<i::JSArray>::cast(stackFramesObj); |
| 2447 return scope.Escape(Utils::StackTraceToLocal(stackTrace)); | 2447 return scope.Escape(Utils::StackTraceToLocal(stackTrace)); |
| 2448 } | 2448 } |
| 2449 | 2449 |
| 2450 | 2450 |
| 2451 Maybe<int> Message::GetLineNumber(Local<Context> context) const { | 2451 Maybe<int> Message::GetLineNumber(Local<Context> context) const { |
| 2452 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Message, GetLineNumber, int); | 2452 auto self = Utils::OpenHandle(this); |
| 2453 i::Handle<i::JSFunction> fun = isolate->message_get_line_number(); | 2453 i::Isolate* isolate = self->GetIsolate(); |
| 2454 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2454 ENTER_V8(isolate); |
| 2455 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; | 2455 EscapableHandleScope handle_scope(reinterpret_cast<Isolate*>(isolate)); |
| 2456 i::Handle<i::Object> result; | 2456 auto msg = i::Handle<i::JSMessageObject>::cast(self); |
| 2457 has_pending_exception = | 2457 return Just(msg->GetLineNumber()); |
|
jgruber
2016/08/08 14:00:18
Here and all other cases below: even though this i
jgruber
2016/08/08 14:04:06
The failing test is test-api/PromiseRejectCallback
Yang
2016/08/10 09:03:18
As discussed, let's leave the API.
| |
| 2458 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | |
| 2459 .ToHandle(&result); | |
| 2460 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | |
| 2461 return Just(static_cast<int>(result->Number())); | |
| 2462 } | 2458 } |
| 2463 | 2459 |
| 2464 | 2460 |
| 2465 int Message::GetLineNumber() const { | 2461 int Message::GetLineNumber() const { |
| 2466 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 2462 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 2467 return GetLineNumber(context).FromMaybe(0); | 2463 return GetLineNumber(context).FromMaybe(0); |
| 2468 } | 2464 } |
| 2469 | 2465 |
| 2470 | 2466 |
| 2471 int Message::GetStartPosition() const { | 2467 int Message::GetStartPosition() const { |
| 2472 auto self = Utils::OpenHandle(this); | 2468 auto self = Utils::OpenHandle(this); |
| 2473 return self->start_position(); | 2469 return self->start_position(); |
| 2474 } | 2470 } |
| 2475 | 2471 |
| 2476 | 2472 |
| 2477 int Message::GetEndPosition() const { | 2473 int Message::GetEndPosition() const { |
| 2478 auto self = Utils::OpenHandle(this); | 2474 auto self = Utils::OpenHandle(this); |
| 2479 return self->end_position(); | 2475 return self->end_position(); |
| 2480 } | 2476 } |
| 2481 | 2477 |
| 2482 | 2478 |
| 2483 Maybe<int> Message::GetStartColumn(Local<Context> context) const { | 2479 Maybe<int> Message::GetStartColumn(Local<Context> context) const { |
| 2484 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Message, GetStartColumn, int); | 2480 auto self = Utils::OpenHandle(this); |
| 2485 i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); | 2481 i::Isolate* isolate = self->GetIsolate(); |
| 2486 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2482 ENTER_V8(isolate); |
| 2487 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; | 2483 EscapableHandleScope handle_scope(reinterpret_cast<Isolate*>(isolate)); |
| 2488 i::Handle<i::Object> result; | 2484 auto msg = i::Handle<i::JSMessageObject>::cast(self); |
| 2489 has_pending_exception = | 2485 return Just(msg->GetColumnNumber()); |
| 2490 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | |
| 2491 .ToHandle(&result); | |
| 2492 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | |
| 2493 return Just(static_cast<int>(result->Number())); | |
| 2494 } | 2486 } |
| 2495 | 2487 |
| 2496 | 2488 |
| 2497 int Message::GetStartColumn() const { | 2489 int Message::GetStartColumn() const { |
| 2498 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 2490 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 2499 const int default_value = kNoColumnInfo; | 2491 const int default_value = kNoColumnInfo; |
| 2500 return GetStartColumn(context).FromMaybe(default_value); | 2492 return GetStartColumn(context).FromMaybe(default_value); |
| 2501 } | 2493 } |
| 2502 | 2494 |
| 2503 | 2495 |
| 2504 Maybe<int> Message::GetEndColumn(Local<Context> context) const { | 2496 Maybe<int> Message::GetEndColumn(Local<Context> context) const { |
| 2505 auto self = Utils::OpenHandle(this); | 2497 auto self = Utils::OpenHandle(this); |
| 2506 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Message, GetEndColumn, int); | 2498 i::Isolate* isolate = self->GetIsolate(); |
| 2507 i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); | 2499 ENTER_V8(isolate); |
| 2508 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2500 EscapableHandleScope handle_scope(reinterpret_cast<Isolate*>(isolate)); |
| 2509 i::Handle<i::Object> args[] = {self}; | 2501 auto msg = i::Handle<i::JSMessageObject>::cast(self); |
| 2510 i::Handle<i::Object> result; | 2502 const int column_number = msg->GetColumnNumber(); |
| 2511 has_pending_exception = | 2503 if (column_number == -1) return Just(-1); |
|
jgruber
2016/08/08 14:00:18
This is a behavior change. Previously any error wa
| |
| 2512 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | 2504 const int start = self->start_position(); |
| 2513 .ToHandle(&result); | 2505 const int end = self->end_position(); |
| 2514 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | 2506 return Just(column_number + (end - start)); |
| 2515 int start = self->start_position(); | |
| 2516 int end = self->end_position(); | |
| 2517 return Just(static_cast<int>(result->Number()) + (end - start)); | |
| 2518 } | 2507 } |
| 2519 | 2508 |
| 2520 | 2509 |
| 2521 int Message::GetEndColumn() const { | 2510 int Message::GetEndColumn() const { |
| 2522 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 2511 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 2523 const int default_value = kNoColumnInfo; | 2512 const int default_value = kNoColumnInfo; |
| 2524 return GetEndColumn(context).FromMaybe(default_value); | 2513 return GetEndColumn(context).FromMaybe(default_value); |
| 2525 } | 2514 } |
| 2526 | 2515 |
| 2527 | 2516 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2540 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2529 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2541 ENTER_V8(isolate); | 2530 ENTER_V8(isolate); |
| 2542 auto self = Utils::OpenHandle(this); | 2531 auto self = Utils::OpenHandle(this); |
| 2543 auto script = i::Handle<i::JSValue>::cast( | 2532 auto script = i::Handle<i::JSValue>::cast( |
| 2544 i::Handle<i::Object>(self->script(), isolate)); | 2533 i::Handle<i::Object>(self->script(), isolate)); |
| 2545 return i::Script::cast(script->value())->origin_options().IsOpaque(); | 2534 return i::Script::cast(script->value())->origin_options().IsOpaque(); |
| 2546 } | 2535 } |
| 2547 | 2536 |
| 2548 | 2537 |
| 2549 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { | 2538 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { |
| 2550 PREPARE_FOR_EXECUTION(context, Message, GetSourceLine, String); | 2539 auto self = Utils::OpenHandle(this); |
| 2551 i::Handle<i::JSFunction> fun = isolate->message_get_source_line(); | 2540 i::Isolate* isolate = self->GetIsolate(); |
| 2552 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2541 ENTER_V8(isolate); |
| 2553 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; | 2542 EscapableHandleScope handle_scope(reinterpret_cast<Isolate*>(isolate)); |
| 2554 i::Handle<i::Object> result; | 2543 auto msg = i::Handle<i::JSMessageObject>::cast(self); |
| 2555 has_pending_exception = | 2544 RETURN_ESCAPED(Utils::ToLocal(msg->GetSourceLine())); |
| 2556 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | |
| 2557 .ToHandle(&result); | |
| 2558 RETURN_ON_FAILED_EXECUTION(String); | |
| 2559 Local<String> str; | |
| 2560 if (result->IsString()) { | |
| 2561 str = Utils::ToLocal(i::Handle<i::String>::cast(result)); | |
| 2562 } | |
| 2563 RETURN_ESCAPED(str); | |
| 2564 } | 2545 } |
| 2565 | 2546 |
| 2566 | 2547 |
| 2567 Local<String> Message::GetSourceLine() const { | 2548 Local<String> Message::GetSourceLine() const { |
| 2568 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 2549 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 2569 RETURN_TO_LOCAL_UNCHECKED(GetSourceLine(context), String) | 2550 RETURN_TO_LOCAL_UNCHECKED(GetSourceLine(context), String) |
| 2570 } | 2551 } |
| 2571 | 2552 |
| 2572 | 2553 |
| 2573 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { | 2554 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { |
| (...skipping 6415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8989 Address callback_address = | 8970 Address callback_address = |
| 8990 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8971 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8991 VMState<EXTERNAL> state(isolate); | 8972 VMState<EXTERNAL> state(isolate); |
| 8992 ExternalCallbackScope call_scope(isolate, callback_address); | 8973 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8993 callback(info); | 8974 callback(info); |
| 8994 } | 8975 } |
| 8995 | 8976 |
| 8996 | 8977 |
| 8997 } // namespace internal | 8978 } // namespace internal |
| 8998 } // namespace v8 | 8979 } // namespace v8 |
| OLD | NEW |