OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 | 1934 |
1935 v8::Local<Value> v8::TryCatch::StackTrace() const { | 1935 v8::Local<Value> v8::TryCatch::StackTrace() const { |
1936 ASSERT(isolate_ == i::Isolate::Current()); | 1936 ASSERT(isolate_ == i::Isolate::Current()); |
1937 if (HasCaught()) { | 1937 if (HasCaught()) { |
1938 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); | 1938 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); |
1939 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); | 1939 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); |
1940 i::HandleScope scope(isolate_); | 1940 i::HandleScope scope(isolate_); |
1941 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); | 1941 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); |
1942 i::Handle<i::String> name = isolate_->factory()->stack_string(); | 1942 i::Handle<i::String> name = isolate_->factory()->stack_string(); |
1943 if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>(); | 1943 if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>(); |
1944 i::Handle<i::Object> value = i::GetProperty(isolate_, obj, name); | 1944 i::Handle<i::Object> value = i::Object::GetProperty(obj, name); |
1945 if (value.is_null()) return v8::Local<Value>(); | 1945 if (value.is_null()) return v8::Local<Value>(); |
1946 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); | 1946 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); |
1947 } else { | 1947 } else { |
1948 return v8::Local<Value>(); | 1948 return v8::Local<Value>(); |
1949 } | 1949 } |
1950 } | 1950 } |
1951 | 1951 |
1952 | 1952 |
1953 v8::Local<v8::Message> v8::TryCatch::Message() const { | 1953 v8::Local<v8::Message> v8::TryCatch::Message() const { |
1954 ASSERT(isolate_ == i::Isolate::Current()); | 1954 ASSERT(isolate_ == i::Isolate::Current()); |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3136 } | 3136 } |
3137 | 3137 |
3138 | 3138 |
3139 Local<Value> v8::Object::Get(v8::Handle<Value> key) { | 3139 Local<Value> v8::Object::Get(v8::Handle<Value> key) { |
3140 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3140 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3141 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); | 3141 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); |
3142 ENTER_V8(isolate); | 3142 ENTER_V8(isolate); |
3143 i::Handle<i::Object> self = Utils::OpenHandle(this); | 3143 i::Handle<i::Object> self = Utils::OpenHandle(this); |
3144 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3144 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
3145 EXCEPTION_PREAMBLE(isolate); | 3145 EXCEPTION_PREAMBLE(isolate); |
3146 i::Handle<i::Object> result = i::GetProperty(isolate, self, key_obj); | 3146 i::Handle<i::Object> result = |
| 3147 i::Runtime::GetObjectProperty(isolate, self, key_obj); |
3147 has_pending_exception = result.is_null(); | 3148 has_pending_exception = result.is_null(); |
3148 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 3149 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
3149 return Utils::ToLocal(result); | 3150 return Utils::ToLocal(result); |
3150 } | 3151 } |
3151 | 3152 |
3152 | 3153 |
3153 Local<Value> v8::Object::Get(uint32_t index) { | 3154 Local<Value> v8::Object::Get(uint32_t index) { |
3154 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3155 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3155 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); | 3156 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); |
3156 ENTER_V8(isolate); | 3157 ENTER_V8(isolate); |
(...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6150 return Utils::ToLocal(result); | 6151 return Utils::ToLocal(result); |
6151 } | 6152 } |
6152 | 6153 |
6153 | 6154 |
6154 Local<Symbol> v8::Symbol::For(Isolate* isolate, Local<String> name) { | 6155 Local<Symbol> v8::Symbol::For(Isolate* isolate, Local<String> name) { |
6155 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6156 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6156 i::Handle<i::String> i_name = Utils::OpenHandle(*name); | 6157 i::Handle<i::String> i_name = Utils::OpenHandle(*name); |
6157 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); | 6158 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); |
6158 i::Handle<i::String> part = i_isolate->factory()->for_string(); | 6159 i::Handle<i::String> part = i_isolate->factory()->for_string(); |
6159 i::Handle<i::JSObject> symbols = | 6160 i::Handle<i::JSObject> symbols = |
6160 i::Handle<i::JSObject>::cast(i::JSObject::GetProperty(registry, part)); | 6161 i::Handle<i::JSObject>::cast( |
6161 i::Handle<i::Object> symbol = i::JSObject::GetProperty(symbols, i_name); | 6162 i::Object::GetPropertyOrElement(registry, part)); |
| 6163 i::Handle<i::Object> symbol = |
| 6164 i::Object::GetPropertyOrElement(symbols, i_name); |
6162 if (!symbol->IsSymbol()) { | 6165 if (!symbol->IsSymbol()) { |
6163 ASSERT(symbol->IsUndefined()); | 6166 ASSERT(symbol->IsUndefined()); |
6164 symbol = i_isolate->factory()->NewSymbol(); | 6167 symbol = i_isolate->factory()->NewSymbol(); |
6165 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); | 6168 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); |
6166 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT); | 6169 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT); |
6167 } | 6170 } |
6168 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); | 6171 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); |
6169 } | 6172 } |
6170 | 6173 |
6171 | 6174 |
6172 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) { | 6175 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) { |
6173 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6176 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6174 i::Handle<i::String> i_name = Utils::OpenHandle(*name); | 6177 i::Handle<i::String> i_name = Utils::OpenHandle(*name); |
6175 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); | 6178 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); |
6176 i::Handle<i::String> part = i_isolate->factory()->for_api_string(); | 6179 i::Handle<i::String> part = i_isolate->factory()->for_api_string(); |
6177 i::Handle<i::JSObject> symbols = | 6180 i::Handle<i::JSObject> symbols = |
6178 i::Handle<i::JSObject>::cast(i::JSObject::GetProperty(registry, part)); | 6181 i::Handle<i::JSObject>::cast( |
6179 i::Handle<i::Object> symbol = i::JSObject::GetProperty(symbols, i_name); | 6182 i::Object::GetPropertyOrElement(registry, part)); |
| 6183 i::Handle<i::Object> symbol = |
| 6184 i::Object::GetPropertyOrElement(symbols, i_name); |
6180 if (!symbol->IsSymbol()) { | 6185 if (!symbol->IsSymbol()) { |
6181 ASSERT(symbol->IsUndefined()); | 6186 ASSERT(symbol->IsUndefined()); |
6182 symbol = i_isolate->factory()->NewSymbol(); | 6187 symbol = i_isolate->factory()->NewSymbol(); |
6183 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); | 6188 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); |
6184 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT); | 6189 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT); |
6185 } | 6190 } |
6186 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); | 6191 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); |
6187 } | 6192 } |
6188 | 6193 |
6189 | 6194 |
6190 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { | 6195 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { |
6191 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6196 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6192 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); | 6197 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); |
6193 LOG_API(i_isolate, "Private::New()"); | 6198 LOG_API(i_isolate, "Private::New()"); |
6194 ENTER_V8(i_isolate); | 6199 ENTER_V8(i_isolate); |
6195 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); | 6200 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); |
6196 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); | 6201 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); |
6197 Local<Symbol> result = Utils::ToLocal(symbol); | 6202 Local<Symbol> result = Utils::ToLocal(symbol); |
6198 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); | 6203 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); |
6199 } | 6204 } |
6200 | 6205 |
6201 | 6206 |
6202 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { | 6207 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { |
6203 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6208 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6204 i::Handle<i::String> i_name = Utils::OpenHandle(*name); | 6209 i::Handle<i::String> i_name = Utils::OpenHandle(*name); |
6205 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); | 6210 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); |
6206 i::Handle<i::String> part = i_isolate->factory()->private_api_string(); | 6211 i::Handle<i::String> part = i_isolate->factory()->private_api_string(); |
6207 i::Handle<i::JSObject> privates = | 6212 i::Handle<i::JSObject> privates = |
6208 i::Handle<i::JSObject>::cast(i::JSObject::GetProperty(registry, part)); | 6213 i::Handle<i::JSObject>::cast( |
6209 i::Handle<i::Object> symbol = i::JSObject::GetProperty(privates, i_name); | 6214 i::Object::GetPropertyOrElement(registry, part)); |
| 6215 i::Handle<i::Object> symbol = |
| 6216 i::Object::GetPropertyOrElement(privates, i_name); |
6210 if (!symbol->IsSymbol()) { | 6217 if (!symbol->IsSymbol()) { |
6211 ASSERT(symbol->IsUndefined()); | 6218 ASSERT(symbol->IsUndefined()); |
6212 symbol = i_isolate->factory()->NewPrivateSymbol(); | 6219 symbol = i_isolate->factory()->NewPrivateSymbol(); |
6213 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); | 6220 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); |
6214 i::JSObject::SetProperty(privates, i_name, symbol, NONE, i::STRICT); | 6221 i::JSObject::SetProperty(privates, i_name, symbol, NONE, i::STRICT); |
6215 } | 6222 } |
6216 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); | 6223 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); |
6217 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); | 6224 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); |
6218 } | 6225 } |
6219 | 6226 |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6949 i::Isolate* isolate = i::Isolate::Current(); | 6956 i::Isolate* isolate = i::Isolate::Current(); |
6950 if (!isolate->IsInitialized()) return Local<Value>(); | 6957 if (!isolate->IsInitialized()) return Local<Value>(); |
6951 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>()); | 6958 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>()); |
6952 ENTER_V8(isolate); | 6959 ENTER_V8(isolate); |
6953 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 6960 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
6954 i::Debug* isolate_debug = isolate->debug(); | 6961 i::Debug* isolate_debug = isolate->debug(); |
6955 isolate_debug->Load(); | 6962 isolate_debug->Load(); |
6956 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); | 6963 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); |
6957 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString( | 6964 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString( |
6958 STATIC_ASCII_VECTOR("MakeMirror")); | 6965 STATIC_ASCII_VECTOR("MakeMirror")); |
6959 i::Handle<i::Object> fun_obj = i::GetProperty(isolate, debug, name); | 6966 i::Handle<i::Object> fun_obj = i::Object::GetProperty(debug, name); |
| 6967 ASSERT(!fun_obj.is_null()); |
6960 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); | 6968 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); |
6961 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); | 6969 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); |
6962 const int kArgc = 1; | 6970 const int kArgc = 1; |
6963 v8::Handle<v8::Value> argv[kArgc] = { obj }; | 6971 v8::Handle<v8::Value> argv[kArgc] = { obj }; |
6964 EXCEPTION_PREAMBLE(isolate); | 6972 EXCEPTION_PREAMBLE(isolate); |
6965 v8::Local<v8::Value> result = | 6973 v8::Local<v8::Value> result = |
6966 v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); | 6974 v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); |
6967 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 6975 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
6968 return scope.Escape(result); | 6976 return scope.Escape(result); |
6969 } | 6977 } |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7645 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7653 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7646 Address callback_address = | 7654 Address callback_address = |
7647 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7655 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7648 VMState<EXTERNAL> state(isolate); | 7656 VMState<EXTERNAL> state(isolate); |
7649 ExternalCallbackScope call_scope(isolate, callback_address); | 7657 ExternalCallbackScope call_scope(isolate, callback_address); |
7650 callback(info); | 7658 callback(info); |
7651 } | 7659 } |
7652 | 7660 |
7653 | 7661 |
7654 } } // namespace v8::internal | 7662 } } // namespace v8::internal |
OLD | NEW |