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

Side by Side Diff: src/api.cc

Issue 14425011: api: Object::CachedProperty Base URL: gh:v8/v8.git@master
Patch Set: globalize reference Created 7 years, 7 months 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
« no previous file with comments | « include/v8.h ('k') | src/handles.h » ('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 3054 matching lines...) Expand 10 before | Expand all | Expand 10 after
3065 index, 3065 index,
3066 value_obj, 3066 value_obj,
3067 NONE, 3067 NONE,
3068 i::kNonStrictMode); 3068 i::kNonStrictMode);
3069 has_pending_exception = obj.is_null(); 3069 has_pending_exception = obj.is_null();
3070 EXCEPTION_BAILOUT_CHECK(isolate, false); 3070 EXCEPTION_BAILOUT_CHECK(isolate, false);
3071 return true; 3071 return true;
3072 } 3072 }
3073 3073
3074 3074
3075 bool v8::Object::Set(v8::Object::CachedProperty key,
3076 v8::Handle<Value> value,
3077 v8::PropertyAttribute attribs) {
3078 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3079 ON_BAILOUT(isolate, "v8::Object::Set()", return false);
3080 ENTER_V8(isolate);
3081 i::HandleScope scope(isolate);
3082 i::Handle<i::Object> self = Utils::OpenHandle(this);
3083 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key.key_);
3084 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3085 EXCEPTION_PREAMBLE(isolate);
3086 i::Handle<i::Object> obj = i::SetProperty(
3087 isolate,
3088 self,
3089 key_obj,
3090 value_obj,
3091 static_cast<PropertyAttributes>(attribs),
3092 i::kNonStrictMode,
3093 key.cache_);
3094 has_pending_exception = obj.is_null();
3095 EXCEPTION_BAILOUT_CHECK(isolate, false);
3096 return true;
3097 }
3098
3099
3075 bool v8::Object::ForceSet(v8::Handle<Value> key, 3100 bool v8::Object::ForceSet(v8::Handle<Value> key,
3076 v8::Handle<Value> value, 3101 v8::Handle<Value> value,
3077 v8::PropertyAttribute attribs) { 3102 v8::PropertyAttribute attribs) {
3078 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3103 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3079 ON_BAILOUT(isolate, "v8::Object::ForceSet()", return false); 3104 ON_BAILOUT(isolate, "v8::Object::ForceSet()", return false);
3080 ENTER_V8(isolate); 3105 ENTER_V8(isolate);
3081 i::HandleScope scope(isolate); 3106 i::HandleScope scope(isolate);
3082 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3107 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3083 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3108 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3084 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3109 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3138 ENTER_V8(isolate); 3163 ENTER_V8(isolate);
3139 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3164 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3140 EXCEPTION_PREAMBLE(isolate); 3165 EXCEPTION_PREAMBLE(isolate);
3141 i::Handle<i::Object> result = i::Object::GetElement(self, index); 3166 i::Handle<i::Object> result = i::Object::GetElement(self, index);
3142 has_pending_exception = result.is_null(); 3167 has_pending_exception = result.is_null();
3143 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 3168 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
3144 return Utils::ToLocal(result); 3169 return Utils::ToLocal(result);
3145 } 3170 }
3146 3171
3147 3172
3173 Local<Value> v8::Object::Get(v8::Object::CachedProperty key) {
3174 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3175 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
3176 ENTER_V8(isolate);
3177 i::Handle<i::Object> self = Utils::OpenHandle(this);
3178 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key.key_);
3179 EXCEPTION_PREAMBLE(isolate);
3180 i::Handle<i::Object> result = i::GetProperty(isolate,
3181 self,
3182 key_obj,
3183 key.cache_);
3184 has_pending_exception = result.is_null();
3185 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
3186
3187 return Utils::ToLocal(result);
3188 }
3189
3190
3148 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) { 3191 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) {
3149 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3192 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3150 ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()", 3193 ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()",
3151 return static_cast<PropertyAttribute>(NONE)); 3194 return static_cast<PropertyAttribute>(NONE));
3152 ENTER_V8(isolate); 3195 ENTER_V8(isolate);
3153 i::HandleScope scope(isolate); 3196 i::HandleScope scope(isolate);
3154 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3197 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3155 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3198 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3156 if (!key_obj->IsName()) { 3199 if (!key_obj->IsName()) {
3157 EXCEPTION_PREAMBLE(isolate); 3200 EXCEPTION_PREAMBLE(isolate);
(...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after
5487 i::Isolate* isolate = obj->GetIsolate(); 5530 i::Isolate* isolate = obj->GetIsolate();
5488 if (IsDeadCheck(isolate, "v8::String::CanMakeExternal()")) return false; 5531 if (IsDeadCheck(isolate, "v8::String::CanMakeExternal()")) return false;
5489 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; 5532 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false;
5490 int size = obj->Size(); // Byte size of the original string. 5533 int size = obj->Size(); // Byte size of the original string.
5491 if (size < i::ExternalString::kShortSize) return false; 5534 if (size < i::ExternalString::kShortSize) return false;
5492 i::StringShape shape(*obj); 5535 i::StringShape shape(*obj);
5493 return !shape.IsExternal(); 5536 return !shape.IsExternal();
5494 } 5537 }
5495 5538
5496 5539
5540 v8::Object::CachedProperty::CachedProperty(v8::Handle<v8::String> key) {
5541 i::Isolate* isolate = Utils::OpenHandle(*key)->GetIsolate();
5542 key_ = Persistent<String>::New(reinterpret_cast<v8::Isolate*>(isolate), key);
5543 cache_ = new i::LookupCache(isolate);
5544 }
5545
5546
5497 Local<v8::Object> v8::Object::New() { 5547 Local<v8::Object> v8::Object::New() {
5498 i::Isolate* isolate = i::Isolate::Current(); 5548 i::Isolate* isolate = i::Isolate::Current();
5499 EnsureInitializedForIsolate(isolate, "v8::Object::New()"); 5549 EnsureInitializedForIsolate(isolate, "v8::Object::New()");
5500 LOG_API(isolate, "Object::New"); 5550 LOG_API(isolate, "Object::New");
5501 ENTER_V8(isolate); 5551 ENTER_V8(isolate);
5502 i::Handle<i::JSObject> obj = 5552 i::Handle<i::JSObject> obj =
5503 isolate->factory()->NewJSObject(isolate->object_function()); 5553 isolate->factory()->NewJSObject(isolate->object_function());
5504 return Utils::ToLocal(obj); 5554 return Utils::ToLocal(obj);
5505 } 5555 }
5506 5556
(...skipping 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after
7479 7529
7480 v->VisitPointers(blocks_.first(), first_block_limit_); 7530 v->VisitPointers(blocks_.first(), first_block_limit_);
7481 7531
7482 for (int i = 1; i < blocks_.length(); i++) { 7532 for (int i = 1; i < blocks_.length(); i++) {
7483 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 7533 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
7484 } 7534 }
7485 } 7535 }
7486 7536
7487 7537
7488 } } // namespace v8::internal 7538 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698