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

Side by Side Diff: src/objects.cc

Issue 115267: Fix for issue 339:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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') | test/cctest/test-api.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 5127 matching lines...) Expand 10 before | Expand all | Expand 10 after
5138 Smi::cast(JSArray::cast(this)->length())->value()) : 5138 Smi::cast(JSArray::cast(this)->length())->value()) :
5139 static_cast<uint32_t>(FixedArray::cast(elements())->length()); 5139 static_cast<uint32_t>(FixedArray::cast(elements())->length());
5140 return (index < length) && 5140 return (index < length) &&
5141 !FixedArray::cast(elements())->get(index)->IsTheHole(); 5141 !FixedArray::cast(elements())->get(index)->IsTheHole();
5142 } else { 5142 } else {
5143 return element_dictionary()->FindNumberEntry(index) != -1; 5143 return element_dictionary()->FindNumberEntry(index) != -1;
5144 } 5144 }
5145 } 5145 }
5146 5146
5147 5147
5148 Object* JSObject::GetHiddenProperties(bool create_if_needed) {
5149 String* key = Heap::hidden_symbol();
5150 if (this->HasFastProperties()) {
5151 // If the object has fast properties, check whether the first slot
5152 // in the descriptor array matches the hidden symbol. Since the
5153 // hidden symbols hash code is zero (and no other string has hash
5154 // code zero) it will always occupy the first entry if present.
5155 DescriptorArray* descriptors = this->map()->instance_descriptors();
5156 DescriptorReader r(descriptors);
5157 if (!r.eos() && (r.GetKey() == key) && r.IsProperty()) {
5158 ASSERT(r.type() == FIELD);
5159 return FastPropertyAt(r.GetFieldIndex());
5160 }
5161 }
5162
5163 // Only attempt to find the hidden properties in the local object and not
5164 // in the prototype chain. Note that HasLocalProperty() can cause a GC in
5165 // the general case, but in this case we know it won't hit an interceptor.
5166 if (!this->HasLocalProperty(key)) {
5167 // Hidden properties object not found. Allocate a new hidden properties
5168 // object if requested. Otherwise return the undefined value.
5169 if (create_if_needed) {
5170 Object* obj = Heap::AllocateJSObject(
5171 Top::context()->global_context()->object_function());
5172 if (obj->IsFailure()) {
5173 return obj;
5174 }
5175 return this->SetProperty(key, obj, DONT_ENUM);
5176 } else {
5177 return Heap::undefined_value();
5178 }
5179 }
5180 return this->GetProperty(key);
5181 }
5182
5183
5184 bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) { 5148 bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) {
5185 // Check access rights if needed. 5149 // Check access rights if needed.
5186 if (IsAccessCheckNeeded() && 5150 if (IsAccessCheckNeeded() &&
5187 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) { 5151 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
5188 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 5152 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
5189 return false; 5153 return false;
5190 } 5154 }
5191 5155
5192 // Check for lookup interceptor 5156 // Check for lookup interceptor
5193 if (HasIndexedInterceptor()) { 5157 if (HasIndexedInterceptor()) {
(...skipping 2310 matching lines...) Expand 10 before | Expand all | Expand 10 after
7504 // No break point. 7468 // No break point.
7505 if (break_point_objects()->IsUndefined()) return 0; 7469 if (break_point_objects()->IsUndefined()) return 0;
7506 // Single beak point. 7470 // Single beak point.
7507 if (!break_point_objects()->IsFixedArray()) return 1; 7471 if (!break_point_objects()->IsFixedArray()) return 1;
7508 // Multiple break points. 7472 // Multiple break points.
7509 return FixedArray::cast(break_point_objects())->length(); 7473 return FixedArray::cast(break_point_objects())->length();
7510 } 7474 }
7511 #endif 7475 #endif
7512 7476
7513 } } // namespace v8::internal 7477 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698