Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1009)

Side by Side Diff: src/api.cc

Issue 48923002: Provide private symbols through internal APIs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Mo comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/array-iterator.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3166 matching lines...) Expand 10 before | Expand all | Expand 10 after
3177 self, 3177 self,
3178 key_obj, 3178 key_obj,
3179 value_obj, 3179 value_obj,
3180 static_cast<PropertyAttributes>(attribs)); 3180 static_cast<PropertyAttributes>(attribs));
3181 has_pending_exception = obj.is_null(); 3181 has_pending_exception = obj.is_null();
3182 EXCEPTION_BAILOUT_CHECK(isolate, false); 3182 EXCEPTION_BAILOUT_CHECK(isolate, false);
3183 return true; 3183 return true;
3184 } 3184 }
3185 3185
3186 3186
3187 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) {
3188 return Set(*reinterpret_cast<v8::Handle<Value>*>(&key), value, DontEnum);
3189 }
3190
3191
3187 bool v8::Object::ForceDelete(v8::Handle<Value> key) { 3192 bool v8::Object::ForceDelete(v8::Handle<Value> key) {
3188 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3193 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3189 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false); 3194 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false);
3190 ENTER_V8(isolate); 3195 ENTER_V8(isolate);
3191 i::HandleScope scope(isolate); 3196 i::HandleScope scope(isolate);
3192 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3197 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3193 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3198 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3194 3199
3195 // When deleting a property on the global object using ForceDelete 3200 // When deleting a property on the global object using ForceDelete
3196 // deoptimize all functions as optimized code does not check for the hole 3201 // deoptimize all functions as optimized code does not check for the hole
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3228 ENTER_V8(isolate); 3233 ENTER_V8(isolate);
3229 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3234 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3230 EXCEPTION_PREAMBLE(isolate); 3235 EXCEPTION_PREAMBLE(isolate);
3231 i::Handle<i::Object> result = i::Object::GetElement(isolate, self, index); 3236 i::Handle<i::Object> result = i::Object::GetElement(isolate, self, index);
3232 has_pending_exception = result.is_null(); 3237 has_pending_exception = result.is_null();
3233 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 3238 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
3234 return Utils::ToLocal(result); 3239 return Utils::ToLocal(result);
3235 } 3240 }
3236 3241
3237 3242
3243 Local<Value> v8::Object::GetPrivate(v8::Handle<Private> key) {
3244 return Get(*reinterpret_cast<v8::Handle<Value>*>(&key));
3245 }
3246
3247
3238 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) { 3248 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) {
3239 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3249 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3240 ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()", 3250 ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()",
3241 return static_cast<PropertyAttribute>(NONE)); 3251 return static_cast<PropertyAttribute>(NONE));
3242 ENTER_V8(isolate); 3252 ENTER_V8(isolate);
3243 i::HandleScope scope(isolate); 3253 i::HandleScope scope(isolate);
3244 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3254 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3245 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3255 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3246 if (!key_obj->IsName()) { 3256 if (!key_obj->IsName()) {
3247 EXCEPTION_PREAMBLE(isolate); 3257 EXCEPTION_PREAMBLE(isolate);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3437 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3428 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3438 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3429 EXCEPTION_PREAMBLE(isolate); 3439 EXCEPTION_PREAMBLE(isolate);
3430 i::Handle<i::Object> obj = i::DeleteProperty(self, key_obj); 3440 i::Handle<i::Object> obj = i::DeleteProperty(self, key_obj);
3431 has_pending_exception = obj.is_null(); 3441 has_pending_exception = obj.is_null();
3432 EXCEPTION_BAILOUT_CHECK(isolate, false); 3442 EXCEPTION_BAILOUT_CHECK(isolate, false);
3433 return obj->IsTrue(); 3443 return obj->IsTrue();
3434 } 3444 }
3435 3445
3436 3446
3447 bool v8::Object::DeletePrivate(v8::Handle<Private> key) {
3448 return Delete(*reinterpret_cast<v8::Handle<Value>*>(&key));
3449 }
3450
3451
3437 bool v8::Object::Has(v8::Handle<Value> key) { 3452 bool v8::Object::Has(v8::Handle<Value> key) {
3438 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3453 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3439 ON_BAILOUT(isolate, "v8::Object::Has()", return false); 3454 ON_BAILOUT(isolate, "v8::Object::Has()", return false);
3440 ENTER_V8(isolate); 3455 ENTER_V8(isolate);
3441 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); 3456 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
3442 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3457 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3443 EXCEPTION_PREAMBLE(isolate); 3458 EXCEPTION_PREAMBLE(isolate);
3444 i::Handle<i::Object> obj = i::HasProperty(self, key_obj); 3459 i::Handle<i::Object> obj = i::HasProperty(self, key_obj);
3445 has_pending_exception = obj.is_null(); 3460 has_pending_exception = obj.is_null();
3446 EXCEPTION_BAILOUT_CHECK(isolate, false); 3461 EXCEPTION_BAILOUT_CHECK(isolate, false);
3447 return obj->IsTrue(); 3462 return obj->IsTrue();
3448 } 3463 }
3449 3464
3450 3465
3466 bool v8::Object::HasPrivate(v8::Handle<Private> key) {
3467 return Has(*reinterpret_cast<v8::Handle<Value>*>(&key));
3468 }
3469
3470
3451 bool v8::Object::Delete(uint32_t index) { 3471 bool v8::Object::Delete(uint32_t index) {
3452 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3472 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3453 ON_BAILOUT(isolate, "v8::Object::DeleteProperty()", 3473 ON_BAILOUT(isolate, "v8::Object::DeleteProperty()",
3454 return false); 3474 return false);
3455 ENTER_V8(isolate); 3475 ENTER_V8(isolate);
3456 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 3476 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
3457 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3477 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3458 return i::JSReceiver::DeleteElement(self, index)->IsTrue(); 3478 return i::JSReceiver::DeleteElement(self, index)->IsTrue();
3459 } 3479 }
3460 3480
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
4861 } 4881 }
4862 4882
4863 4883
4864 Local<Value> Symbol::Name() const { 4884 Local<Value> Symbol::Name() const {
4865 i::Handle<i::Symbol> sym = Utils::OpenHandle(this); 4885 i::Handle<i::Symbol> sym = Utils::OpenHandle(this);
4866 i::Handle<i::Object> name(sym->name(), sym->GetIsolate()); 4886 i::Handle<i::Object> name(sym->name(), sym->GetIsolate());
4867 return Utils::ToLocal(name); 4887 return Utils::ToLocal(name);
4868 } 4888 }
4869 4889
4870 4890
4891 Local<Value> Private::Name() const {
4892 return reinterpret_cast<const Symbol*>(this)->Name();
4893 }
4894
4895
4871 double Number::Value() const { 4896 double Number::Value() const {
4872 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4897 i::Handle<i::Object> obj = Utils::OpenHandle(this);
4873 return obj->Number(); 4898 return obj->Number();
4874 } 4899 }
4875 4900
4876 4901
4877 bool Boolean::Value() const { 4902 bool Boolean::Value() const {
4878 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4903 i::Handle<i::Object> obj = Utils::OpenHandle(this);
4879 return obj->IsTrue(); 4904 return obj->IsTrue();
4880 } 4905 }
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
6118 LOG_API(isolate, "v8::DataView::New(void*, size_t, size_t)"); 6143 LOG_API(isolate, "v8::DataView::New(void*, size_t, size_t)");
6119 ENTER_V8(isolate); 6144 ENTER_V8(isolate);
6120 i::Handle<i::JSDataView> obj = isolate->factory()->NewJSDataView(); 6145 i::Handle<i::JSDataView> obj = isolate->factory()->NewJSDataView();
6121 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); 6146 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
6122 SetupArrayBufferView( 6147 SetupArrayBufferView(
6123 isolate, obj, buffer, byte_offset, byte_length); 6148 isolate, obj, buffer, byte_offset, byte_length);
6124 return Utils::ToLocal(obj); 6149 return Utils::ToLocal(obj);
6125 } 6150 }
6126 6151
6127 6152
6128 Local<Symbol> v8::Symbol::New(Isolate* isolate) {
6129 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6130 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()");
6131 LOG_API(i_isolate, "Symbol::New()");
6132 ENTER_V8(i_isolate);
6133 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
6134 return Utils::ToLocal(result);
6135 }
6136
6137
6138 Local<Symbol> v8::Symbol::New(Isolate* isolate, const char* data, int length) { 6153 Local<Symbol> v8::Symbol::New(Isolate* isolate, const char* data, int length) {
6139 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6154 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6140 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); 6155 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()");
6141 LOG_API(i_isolate, "Symbol::New(char)"); 6156 LOG_API(i_isolate, "Symbol::New()");
6142 ENTER_V8(i_isolate); 6157 ENTER_V8(i_isolate);
6143 if (length == -1) length = i::StrLength(data);
6144 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8(
6145 i::Vector<const char>(data, length));
6146 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); 6158 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
6147 result->set_name(*name); 6159 if (data != NULL) {
6160 if (length == -1) length = i::StrLength(data);
6161 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8(
6162 i::Vector<const char>(data, length));
6163 result->set_name(*name);
6164 }
6148 return Utils::ToLocal(result); 6165 return Utils::ToLocal(result);
6149 } 6166 }
6150 6167
6151 6168
6169 Local<Private> v8::Private::New(
6170 Isolate* isolate, const char* data, int length) {
6171 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6172 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()");
6173 LOG_API(i_isolate, "Private::New()");
6174 ENTER_V8(i_isolate);
6175 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
6176 if (data != NULL) {
6177 if (length == -1) length = i::StrLength(data);
6178 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8(
6179 i::Vector<const char>(data, length));
6180 symbol->set_name(*name);
6181 }
6182 Local<Symbol> result = Utils::ToLocal(symbol);
6183 return *reinterpret_cast<Local<Private>*>(&result);
6184 }
6185
6186
6152 Local<Number> v8::Number::New(double value) { 6187 Local<Number> v8::Number::New(double value) {
6153 i::Isolate* isolate = i::Isolate::Current(); 6188 i::Isolate* isolate = i::Isolate::Current();
6154 EnsureInitializedForIsolate(isolate, "v8::Number::New()"); 6189 EnsureInitializedForIsolate(isolate, "v8::Number::New()");
6155 return Number::New(reinterpret_cast<Isolate*>(isolate), value); 6190 return Number::New(reinterpret_cast<Isolate*>(isolate), value);
6156 } 6191 }
6157 6192
6158 6193
6159 Local<Number> v8::Number::New(Isolate* isolate, double value) { 6194 Local<Number> v8::Number::New(Isolate* isolate, double value) {
6160 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 6195 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6161 ASSERT(internal_isolate->IsInitialized()); 6196 ASSERT(internal_isolate->IsInitialized());
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
7570 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7605 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7571 Address callback_address = 7606 Address callback_address =
7572 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7607 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7573 VMState<EXTERNAL> state(isolate); 7608 VMState<EXTERNAL> state(isolate);
7574 ExternalCallbackScope call_scope(isolate, callback_address); 7609 ExternalCallbackScope call_scope(isolate, callback_address);
7575 callback(info); 7610 callback(info);
7576 } 7611 }
7577 7612
7578 7613
7579 } } // namespace v8::internal 7614 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/array-iterator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698