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 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1937 ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>()); | 1937 ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>()); |
1938 ENTER_V8(isolate); | 1938 ENTER_V8(isolate); |
1939 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 1939 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
1940 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1940 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1941 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj); | 1941 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj); |
1942 Local<String> result = Utils::ToLocal(raw_result); | 1942 Local<String> result = Utils::ToLocal(raw_result); |
1943 return scope.Escape(result); | 1943 return scope.Escape(result); |
1944 } | 1944 } |
1945 | 1945 |
1946 | 1946 |
| 1947 ScriptOrigin Message::GetScriptOrigin() const { |
| 1948 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1949 i::Handle<i::JSMessageObject> message = |
| 1950 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 1951 i::Handle<i::Object> script_wraper = |
| 1952 i::Handle<i::Object>(message->script(), isolate); |
| 1953 i::Handle<i::JSValue> script_value = |
| 1954 i::Handle<i::JSValue>::cast(script_wraper); |
| 1955 i::Handle<i::Script> script(i::Script::cast(script_value->value())); |
| 1956 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); |
| 1957 v8::Isolate* v8_isolate = |
| 1958 reinterpret_cast<v8::Isolate*>(script->GetIsolate()); |
| 1959 v8::ScriptOrigin origin( |
| 1960 Utils::ToLocal(scriptName), |
| 1961 v8::Integer::New(v8_isolate, script->line_offset()->value()), |
| 1962 v8::Integer::New(v8_isolate, script->column_offset()->value())); |
| 1963 return origin; |
| 1964 } |
| 1965 |
| 1966 |
1947 v8::Handle<Value> Message::GetScriptResourceName() const { | 1967 v8::Handle<Value> Message::GetScriptResourceName() const { |
1948 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1968 return GetScriptOrigin().ResourceName(); |
1949 ENTER_V8(isolate); | |
1950 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | |
1951 i::Handle<i::JSMessageObject> message = | |
1952 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | |
1953 // Return this.script.name. | |
1954 i::Handle<i::JSValue> script = | |
1955 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), | |
1956 isolate)); | |
1957 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(), | |
1958 isolate); | |
1959 return scope.Escape(Utils::ToLocal(resource_name)); | |
1960 } | 1969 } |
1961 | 1970 |
1962 | 1971 |
1963 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { | 1972 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { |
1964 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1973 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1965 ENTER_V8(isolate); | 1974 ENTER_V8(isolate); |
1966 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 1975 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
1967 i::Handle<i::JSMessageObject> message = | 1976 i::Handle<i::JSMessageObject> message = |
1968 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 1977 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
1969 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); | 1978 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); |
(...skipping 5608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7578 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7587 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7579 Address callback_address = | 7588 Address callback_address = |
7580 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7589 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7581 VMState<EXTERNAL> state(isolate); | 7590 VMState<EXTERNAL> state(isolate); |
7582 ExternalCallbackScope call_scope(isolate, callback_address); | 7591 ExternalCallbackScope call_scope(isolate, callback_address); |
7583 callback(info); | 7592 callback(info); |
7584 } | 7593 } |
7585 | 7594 |
7586 | 7595 |
7587 } } // namespace v8::internal | 7596 } } // namespace v8::internal |
OLD | NEW |