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

Side by Side Diff: src/objects.cc

Issue 255153002: JSObject::GetHiddenProperty() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 "v8.h" 5 #include "v8.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "allocation-site-scopes.h" 8 #include "allocation-site-scopes.h"
9 #include "api.h" 9 #include "api.h"
10 #include "arguments.h" 10 #include "arguments.h"
(...skipping 5094 matching lines...) Expand 10 before | Expand all | Expand 10 after
5105 } 5105 }
5106 5106
5107 5107
5108 void JSObject::SetIdentityHash(Handle<JSObject> object, Handle<Smi> hash) { 5108 void JSObject::SetIdentityHash(Handle<JSObject> object, Handle<Smi> hash) {
5109 Isolate* isolate = object->GetIsolate(); 5109 Isolate* isolate = object->GetIsolate();
5110 SetHiddenProperty(object, isolate->factory()->identity_hash_string(), hash); 5110 SetHiddenProperty(object, isolate->factory()->identity_hash_string(), hash);
5111 } 5111 }
5112 5112
5113 5113
5114 Object* JSObject::GetIdentityHash() { 5114 Object* JSObject::GetIdentityHash() {
5115 Object* stored_value = GetHiddenProperty(GetHeap()->identity_hash_string()); 5115 DisallowHeapAllocation no_gc;
5116 return stored_value->IsSmi() ? stored_value : GetHeap()->undefined_value(); 5116 Isolate* isolate = GetIsolate();
5117 Object* stored_value =
5118 GetHiddenProperty(isolate->factory()->identity_hash_string());
5119 return stored_value->IsSmi()
5120 ? stored_value
5121 : isolate->heap()->undefined_value();
5117 } 5122 }
5118 5123
5119 5124
5120 Handle<Object> JSObject::GetOrCreateIdentityHash(Handle<JSObject> object) { 5125 Handle<Object> JSObject::GetOrCreateIdentityHash(Handle<JSObject> object) {
5121 Handle<Object> hash(object->GetIdentityHash(), object->GetIsolate()); 5126 Handle<Object> hash(object->GetIdentityHash(), object->GetIsolate());
5122 if (hash->IsSmi()) 5127 if (hash->IsSmi())
5123 return hash; 5128 return hash;
5124 5129
5125 Isolate* isolate = object->GetIsolate(); 5130 Isolate* isolate = object->GetIsolate();
5126 5131
(...skipping 21 matching lines...) Expand all
5148 Handle<Object> hash(proxy->GetIdentityHash(), isolate); 5153 Handle<Object> hash(proxy->GetIdentityHash(), isolate);
5149 if (hash->IsSmi()) 5154 if (hash->IsSmi())
5150 return hash; 5155 return hash;
5151 5156
5152 hash = handle(proxy->GenerateIdentityHash(), isolate); 5157 hash = handle(proxy->GenerateIdentityHash(), isolate);
5153 proxy->set_hash(*hash); 5158 proxy->set_hash(*hash);
5154 return hash; 5159 return hash;
5155 } 5160 }
5156 5161
5157 5162
5158 Object* JSObject::GetHiddenProperty(Name* key) { 5163 Object* JSObject::GetHiddenProperty(Handle<Name> key) {
5164 DisallowHeapAllocation no_gc;
5159 ASSERT(key->IsUniqueName()); 5165 ASSERT(key->IsUniqueName());
5160 if (IsJSGlobalProxy()) { 5166 if (IsJSGlobalProxy()) {
5161 // For a proxy, use the prototype as target object. 5167 // For a proxy, use the prototype as target object.
5162 Object* proxy_parent = GetPrototype(); 5168 Object* proxy_parent = GetPrototype();
5163 // If the proxy is detached, return undefined. 5169 // If the proxy is detached, return undefined.
5164 if (proxy_parent->IsNull()) return GetHeap()->the_hole_value(); 5170 if (proxy_parent->IsNull()) return GetHeap()->the_hole_value();
5165 ASSERT(proxy_parent->IsJSGlobalObject()); 5171 ASSERT(proxy_parent->IsJSGlobalObject());
5166 return JSObject::cast(proxy_parent)->GetHiddenProperty(key); 5172 return JSObject::cast(proxy_parent)->GetHiddenProperty(key);
5167 } 5173 }
5168 ASSERT(!IsJSGlobalProxy()); 5174 ASSERT(!IsJSGlobalProxy());
5169 Object* inline_value = GetHiddenPropertiesHashTable(); 5175 Object* inline_value = GetHiddenPropertiesHashTable();
5170 5176
5171 if (inline_value->IsSmi()) { 5177 if (inline_value->IsSmi()) {
5172 // Handle inline-stored identity hash. 5178 // Handle inline-stored identity hash.
5173 if (key == GetHeap()->identity_hash_string()) { 5179 if (*key == GetHeap()->identity_hash_string()) {
5174 return inline_value; 5180 return inline_value;
5175 } else { 5181 } else {
5176 return GetHeap()->the_hole_value(); 5182 return GetHeap()->the_hole_value();
5177 } 5183 }
5178 } 5184 }
5179 5185
5180 if (inline_value->IsUndefined()) return GetHeap()->the_hole_value(); 5186 if (inline_value->IsUndefined()) return GetHeap()->the_hole_value();
5181 5187
5182 ObjectHashTable* hashtable = ObjectHashTable::cast(inline_value); 5188 ObjectHashTable* hashtable = ObjectHashTable::cast(inline_value);
5183 Object* entry = hashtable->Lookup(key); 5189 Object* entry = hashtable->Lookup(*key);
5184 return entry; 5190 return entry;
5185 } 5191 }
5186 5192
5187 5193
5188 Handle<Object> JSObject::SetHiddenProperty(Handle<JSObject> object, 5194 Handle<Object> JSObject::SetHiddenProperty(Handle<JSObject> object,
5189 Handle<Name> key, 5195 Handle<Name> key,
5190 Handle<Object> value) { 5196 Handle<Object> value) {
5191 Isolate* isolate = object->GetIsolate(); 5197 Isolate* isolate = object->GetIsolate();
5192 5198
5193 ASSERT(key->IsUniqueName()); 5199 ASSERT(key->IsUniqueName());
(...skipping 12056 matching lines...) Expand 10 before | Expand all | Expand 10 after
17250 #define ERROR_MESSAGES_TEXTS(C, T) T, 17256 #define ERROR_MESSAGES_TEXTS(C, T) T,
17251 static const char* error_messages_[] = { 17257 static const char* error_messages_[] = {
17252 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17258 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17253 }; 17259 };
17254 #undef ERROR_MESSAGES_TEXTS 17260 #undef ERROR_MESSAGES_TEXTS
17255 return error_messages_[reason]; 17261 return error_messages_[reason];
17256 } 17262 }
17257 17263
17258 17264
17259 } } // namespace v8::internal 17265 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698