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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate, | 189 static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate, |
190 i::Handle<i::Script> script) { | 190 i::Handle<i::Script> script) { |
191 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); | 191 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); |
192 i::Handle<i::Object> source_map_url(script->source_mapping_url(), isolate); | 192 i::Handle<i::Object> source_map_url(script->source_mapping_url(), isolate); |
193 v8::Isolate* v8_isolate = | 193 v8::Isolate* v8_isolate = |
194 reinterpret_cast<v8::Isolate*>(script->GetIsolate()); | 194 reinterpret_cast<v8::Isolate*>(script->GetIsolate()); |
195 ScriptOriginOptions options(script->origin_options()); | 195 ScriptOriginOptions options(script->origin_options()); |
196 v8::ScriptOrigin origin( | 196 v8::ScriptOrigin origin( |
197 Utils::ToLocal(scriptName), | 197 Utils::ToLocal(scriptName), |
198 v8::Integer::New(v8_isolate, script->line_offset()->value()), | 198 v8::Integer::New(v8_isolate, script->line_offset()), |
199 v8::Integer::New(v8_isolate, script->column_offset()->value()), | 199 v8::Integer::New(v8_isolate, script->column_offset()), |
200 v8::Boolean::New(v8_isolate, options.IsSharedCrossOrigin()), | 200 v8::Boolean::New(v8_isolate, options.IsSharedCrossOrigin()), |
201 v8::Integer::New(v8_isolate, script->id()->value()), | 201 v8::Integer::New(v8_isolate, script->id()), |
202 v8::Boolean::New(v8_isolate, options.IsEmbedderDebugScript()), | 202 v8::Boolean::New(v8_isolate, options.IsEmbedderDebugScript()), |
203 Utils::ToLocal(source_map_url), | 203 Utils::ToLocal(source_map_url), |
204 v8::Boolean::New(v8_isolate, options.IsOpaque())); | 204 v8::Boolean::New(v8_isolate, options.IsOpaque())); |
205 return origin; | 205 return origin; |
206 } | 206 } |
207 | 207 |
208 | 208 |
209 // --- E x c e p t i o n B e h a v i o r --- | 209 // --- E x c e p t i o n B e h a v i o r --- |
210 | 210 |
211 | 211 |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 | 1604 |
1605 int UnboundScript::GetId() { | 1605 int UnboundScript::GetId() { |
1606 i::Handle<i::HeapObject> obj = | 1606 i::Handle<i::HeapObject> obj = |
1607 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | 1607 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); |
1608 i::Isolate* isolate = obj->GetIsolate(); | 1608 i::Isolate* isolate = obj->GetIsolate(); |
1609 LOG_API(isolate, "v8::UnboundScript::GetId"); | 1609 LOG_API(isolate, "v8::UnboundScript::GetId"); |
1610 i::HandleScope scope(isolate); | 1610 i::HandleScope scope(isolate); |
1611 i::Handle<i::SharedFunctionInfo> function_info( | 1611 i::Handle<i::SharedFunctionInfo> function_info( |
1612 i::SharedFunctionInfo::cast(*obj)); | 1612 i::SharedFunctionInfo::cast(*obj)); |
1613 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | 1613 i::Handle<i::Script> script(i::Script::cast(function_info->script())); |
1614 return script->id()->value(); | 1614 return script->id(); |
1615 } | 1615 } |
1616 | 1616 |
1617 | 1617 |
1618 int UnboundScript::GetLineNumber(int code_pos) { | 1618 int UnboundScript::GetLineNumber(int code_pos) { |
1619 i::Handle<i::SharedFunctionInfo> obj = | 1619 i::Handle<i::SharedFunctionInfo> obj = |
1620 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1620 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
1621 i::Isolate* isolate = obj->GetIsolate(); | 1621 i::Isolate* isolate = obj->GetIsolate(); |
1622 LOG_API(isolate, "UnboundScript::GetLineNumber"); | 1622 LOG_API(isolate, "UnboundScript::GetLineNumber"); |
1623 if (obj->script()->IsScript()) { | 1623 if (obj->script()->IsScript()) { |
1624 i::Handle<i::Script> script(i::Script::cast(obj->script())); | 1624 i::Handle<i::Script> script(i::Script::cast(obj->script())); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1977 Local<String> full_source_string, | 1977 Local<String> full_source_string, |
1978 const ScriptOrigin& origin) { | 1978 const ScriptOrigin& origin) { |
1979 PREPARE_FOR_EXECUTION(context, "v8::ScriptCompiler::Compile()", Script); | 1979 PREPARE_FOR_EXECUTION(context, "v8::ScriptCompiler::Compile()", Script); |
1980 i::StreamedSource* source = v8_source->impl(); | 1980 i::StreamedSource* source = v8_source->impl(); |
1981 i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string)); | 1981 i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string)); |
1982 i::Handle<i::Script> script = isolate->factory()->NewScript(str); | 1982 i::Handle<i::Script> script = isolate->factory()->NewScript(str); |
1983 if (!origin.ResourceName().IsEmpty()) { | 1983 if (!origin.ResourceName().IsEmpty()) { |
1984 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); | 1984 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); |
1985 } | 1985 } |
1986 if (!origin.ResourceLineOffset().IsEmpty()) { | 1986 if (!origin.ResourceLineOffset().IsEmpty()) { |
1987 script->set_line_offset(i::Smi::FromInt( | 1987 script->set_line_offset( |
1988 static_cast<int>(origin.ResourceLineOffset()->Value()))); | 1988 static_cast<int>(origin.ResourceLineOffset()->Value())); |
1989 } | 1989 } |
1990 if (!origin.ResourceColumnOffset().IsEmpty()) { | 1990 if (!origin.ResourceColumnOffset().IsEmpty()) { |
1991 script->set_column_offset(i::Smi::FromInt( | 1991 script->set_column_offset( |
1992 static_cast<int>(origin.ResourceColumnOffset()->Value()))); | 1992 static_cast<int>(origin.ResourceColumnOffset()->Value())); |
1993 } | 1993 } |
1994 script->set_origin_options(origin.Options()); | 1994 script->set_origin_options(origin.Options()); |
1995 if (!origin.SourceMapUrl().IsEmpty()) { | 1995 if (!origin.SourceMapUrl().IsEmpty()) { |
1996 script->set_source_mapping_url( | 1996 script->set_source_mapping_url( |
1997 *Utils::OpenHandle(*(origin.SourceMapUrl()))); | 1997 *Utils::OpenHandle(*(origin.SourceMapUrl()))); |
1998 } | 1998 } |
1999 | 1999 |
2000 source->info->set_script(script); | 2000 source->info->set_script(script); |
2001 source->info->set_context(isolate->native_context()); | 2001 source->info->set_context(isolate->native_context()); |
2002 | 2002 |
(...skipping 2427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4430 return func->IsBuiltin(); | 4430 return func->IsBuiltin(); |
4431 } | 4431 } |
4432 | 4432 |
4433 | 4433 |
4434 int Function::ScriptId() const { | 4434 int Function::ScriptId() const { |
4435 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4435 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4436 if (!func->shared()->script()->IsScript()) { | 4436 if (!func->shared()->script()->IsScript()) { |
4437 return v8::UnboundScript::kNoScriptId; | 4437 return v8::UnboundScript::kNoScriptId; |
4438 } | 4438 } |
4439 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4439 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
4440 return script->id()->value(); | 4440 return script->id(); |
4441 } | 4441 } |
4442 | 4442 |
4443 | 4443 |
4444 Local<v8::Value> Function::GetBoundFunction() const { | 4444 Local<v8::Value> Function::GetBoundFunction() const { |
4445 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4445 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4446 if (!func->shared()->bound()) { | 4446 if (!func->shared()->bound()) { |
4447 return v8::Undefined(reinterpret_cast<v8::Isolate*>(func->GetIsolate())); | 4447 return v8::Undefined(reinterpret_cast<v8::Isolate*>(func->GetIsolate())); |
4448 } | 4448 } |
4449 i::Handle<i::FixedArray> bound_args = i::Handle<i::FixedArray>( | 4449 i::Handle<i::FixedArray> bound_args = i::Handle<i::FixedArray>( |
4450 i::FixedArray::cast(func->function_bindings())); | 4450 i::FixedArray::cast(func->function_bindings())); |
(...skipping 3909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8360 Address callback_address = | 8360 Address callback_address = |
8361 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8361 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8362 VMState<EXTERNAL> state(isolate); | 8362 VMState<EXTERNAL> state(isolate); |
8363 ExternalCallbackScope call_scope(isolate, callback_address); | 8363 ExternalCallbackScope call_scope(isolate, callback_address); |
8364 callback(info); | 8364 callback(info); |
8365 } | 8365 } |
8366 | 8366 |
8367 | 8367 |
8368 } // namespace internal | 8368 } // namespace internal |
8369 } // namespace v8 | 8369 } // namespace v8 |
OLD | NEW |