diff options
author | Ryan <ry@tinyclouds.org> | 2009-08-19 16:37:15 +0200 |
---|---|---|
committer | Ryan <ry@tinyclouds.org> | 2009-08-19 16:37:15 +0200 |
commit | 0cec74d03dc6a1735e731fe06056a1731e14c0df (patch) | |
tree | 9606bcb9afeba305a7b2a1ac4c518ded63a25d89 /deps/v8/src/api.cc | |
parent | b590a45849307f5544b7a95854f45064527105ad (diff) | |
download | node-0cec74d03dc6a1735e731fe06056a1731e14c0df.tar.gz |
Upgrade v8 to 1.3.5
Diffstat (limited to 'deps/v8/src/api.cc')
-rw-r--r-- | deps/v8/src/api.cc | 88 |
1 files changed, 78 insertions, 10 deletions
diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 0dc4fd7c7..88cf2bcde 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -1046,7 +1046,7 @@ void ObjectTemplate::SetInternalFieldCount(int value) { ScriptData* ScriptData::PreCompile(const char* input, int length) { unibrow::Utf8InputBuffer<> buf(input, length); - return i::PreParse(&buf, NULL); + return i::PreParse(i::Handle<i::String>(), &buf, NULL); } @@ -1058,11 +1058,11 @@ ScriptData* ScriptData::New(unsigned* data, int length) { // --- S c r i p t --- -Local<Script> Script::Compile(v8::Handle<String> source, - v8::ScriptOrigin* origin, - v8::ScriptData* script_data) { - ON_BAILOUT("v8::Script::Compile()", return Local<Script>()); - LOG_API("Script::Compile"); +Local<Script> Script::New(v8::Handle<String> source, + v8::ScriptOrigin* origin, + v8::ScriptData* script_data) { + ON_BAILOUT("v8::Script::New()", return Local<Script>()); + LOG_API("Script::New"); ENTER_V8; i::Handle<i::String> str = Utils::OpenHandle(*source); i::Handle<i::Object> name_obj; @@ -1096,6 +1096,27 @@ Local<Script> Script::Compile(v8::Handle<String> source, pre_data); has_pending_exception = boilerplate.is_null(); EXCEPTION_BAILOUT_CHECK(Local<Script>()); + return Local<Script>(ToApi<Script>(boilerplate)); +} + + +Local<Script> Script::New(v8::Handle<String> source, + v8::Handle<Value> file_name) { + ScriptOrigin origin(file_name); + return New(source, &origin); +} + + +Local<Script> Script::Compile(v8::Handle<String> source, + v8::ScriptOrigin* origin, + v8::ScriptData* script_data) { + ON_BAILOUT("v8::Script::Compile()", return Local<Script>()); + LOG_API("Script::Compile"); + ENTER_V8; + Local<Script> generic = New(source, origin, script_data); + if (generic.IsEmpty()) + return generic; + i::Handle<i::JSFunction> boilerplate = Utils::OpenHandle(*generic); i::Handle<i::JSFunction> result = i::Factory::NewFunctionFromBoilerplate(boilerplate, i::Top::global_context()); @@ -1118,6 +1139,10 @@ Local<Value> Script::Run() { { HandleScope scope; i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); + if (fun->IsBoilerplate()) { + fun = i::Factory::NewFunctionFromBoilerplate(fun, + i::Top::global_context()); + } EXCEPTION_PREAMBLE(); i::Handle<i::Object> receiver(i::Top::context()->global_proxy()); i::Handle<i::Object> result = @@ -1194,6 +1219,22 @@ v8::Local<Value> v8::TryCatch::Exception() const { } +v8::Local<Value> v8::TryCatch::StackTrace() const { + if (HasCaught()) { + i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); + if (!raw_obj->IsJSObject()) return v8::Local<Value>(); + v8::HandleScope scope; + i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj)); + i::Handle<i::String> name = i::Factory::LookupAsciiSymbol("stack"); + if (!obj->HasProperty(*name)) + return v8::Local<Value>(); + return scope.Close(v8::Utils::ToLocal(i::GetProperty(obj, name))); + } else { + return v8::Local<Value>(); + } +} + + v8::Local<v8::Message> v8::TryCatch::Message() const { if (HasCaught() && message_ != i::Smi::FromInt(0)) { i::Object* message = reinterpret_cast<i::Object*>(message_); @@ -2593,8 +2634,13 @@ Persistent<Context> v8::Context::New( i::Handle<i::Context> env; { ENTER_V8; +#if defined(ANDROID) + // On mobile device, full GC is expensive, leave it to the system to + // decide when should make a full GC. +#else // Give the heap a chance to cleanup if we've disposed contexts. i::Heap::CollectAllGarbageIfContextDisposed(); +#endif v8::Handle<ObjectTemplate> proxy_template = global_template; i::Handle<i::FunctionTemplateInfo> proxy_constructor; i::Handle<i::FunctionTemplateInfo> global_constructor; @@ -3549,10 +3595,10 @@ void Debug::SetHostDispatchHandler(HostDispatchHandler handler, } -Handle<Value> Debug::Call(v8::Handle<v8::Function> fun, - v8::Handle<v8::Value> data) { - if (!i::V8::IsRunning()) return Handle<Value>(); - ON_BAILOUT("v8::Debug::Call()", return Handle<Value>()); +Local<Value> Debug::Call(v8::Handle<v8::Function> fun, + v8::Handle<v8::Value> data) { + if (!i::V8::IsRunning()) return Local<Value>(); + ON_BAILOUT("v8::Debug::Call()", return Local<Value>()); ENTER_V8; i::Handle<i::Object> result; EXCEPTION_PREAMBLE(); @@ -3570,6 +3616,28 @@ Handle<Value> Debug::Call(v8::Handle<v8::Function> fun, } +Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) { + if (!i::V8::IsRunning()) return Local<Value>(); + ON_BAILOUT("v8::Debug::GetMirror()", return Local<Value>()); + ENTER_V8; + v8::HandleScope scope; + i::Debug::Load(); + i::Handle<i::JSObject> debug(i::Debug::debug_context()->global()); + i::Handle<i::String> name = i::Factory::LookupAsciiSymbol("MakeMirror"); + i::Handle<i::Object> fun_obj = i::GetProperty(debug, name); + i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); + v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); + const int kArgc = 1; + v8::Handle<v8::Value> argv[kArgc] = { obj }; + EXCEPTION_PREAMBLE(); + v8::Handle<v8::Value> result = v8_fun->Call(Utils::ToLocal(debug), + kArgc, + argv); + EXCEPTION_BAILOUT_CHECK(Local<Value>()); + return scope.Close(result); +} + + bool Debug::EnableAgent(const char* name, int port) { return i::Debugger::StartAgent(name, port); } |