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

Unified Diff: src/objects.cc

Issue 93004: Adding hidden values always turned the object slow case because the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
===================================================================
--- src/objects.cc (revision 1756)
+++ src/objects.cc (working copy)
@@ -1129,9 +1129,10 @@
Object* JSObject::AddFastProperty(String* name,
Object* value,
PropertyAttributes attributes) {
- // Normalize the object if the name is not a real identifier.
+ // Normalize the object if the name is an actual string (not the
+ // hidden symbols) and is not a real identifier.
StringInputBuffer buffer(name);
- if (!Scanner::IsIdentifier(&buffer)) {
+ if (!Scanner::IsIdentifier(&buffer) && name != Heap::hidden_symbol()) {
Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES);
if (obj->IsFailure()) return obj;
return AddSlowProperty(name, value, attributes);
@@ -5172,19 +5173,15 @@
Object* JSObject::GetHiddenProperties(bool create_if_needed) {
String* key = Heap::hidden_symbol();
if (this->HasFastProperties()) {
- // If the object has fast properties, check whether the first slot in the
- // descriptor array matches the hidden symbol. Since the hidden symbols
- // hash code is zero it will always occupy the first entry if present.
+ // If the object has fast properties, check whether the first slot
+ // in the descriptor array matches the hidden symbol. Since the
+ // hidden symbols hash code is zero (and no other string has hash
+ // code zero) it will always occupy the first entry if present.
DescriptorArray* descriptors = this->map()->instance_descriptors();
- if (descriptors->number_of_descriptors() > 0) {
- if (descriptors->GetKey(0) == key) {
-#ifdef DEBUG
- PropertyDetails details(descriptors->GetDetails(0));
- ASSERT(details.type() == FIELD);
-#endif // DEBUG
- Object* value = descriptors->GetValue(0);
- return FastPropertyAt(Descriptor::IndexFromValue(value));
- }
+ DescriptorReader r(descriptors);
+ if (!r.eos() && (r.GetKey() == key) && r.IsProperty()) {
+ ASSERT(r.type() == FIELD);
+ return FastPropertyAt(r.GetFieldIndex());
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698