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

Side by Side Diff: src/runtime.cc

Issue 9317119: Consolidated property counting methods a bit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (value->IsJSObject()) { 158 if (value->IsJSObject()) {
159 JSObject* js_object = JSObject::cast(value); 159 JSObject* js_object = JSObject::cast(value);
160 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object); 160 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
161 if (!maybe_result->ToObject(&result)) return maybe_result; 161 if (!maybe_result->ToObject(&result)) return maybe_result;
162 } 162 }
163 copy->InObjectPropertyAtPut(i, result); 163 copy->InObjectPropertyAtPut(i, result);
164 } 164 }
165 } 165 }
166 } else { 166 } else {
167 { MaybeObject* maybe_result = 167 { MaybeObject* maybe_result =
168 heap->AllocateFixedArray(copy->NumberOfLocalProperties(NONE)); 168 heap->AllocateFixedArray(copy->NumberOfLocalProperties());
169 if (!maybe_result->ToObject(&result)) return maybe_result; 169 if (!maybe_result->ToObject(&result)) return maybe_result;
170 } 170 }
171 FixedArray* names = FixedArray::cast(result); 171 FixedArray* names = FixedArray::cast(result);
172 copy->GetLocalPropertyNames(names, 0); 172 copy->GetLocalPropertyNames(names, 0);
173 for (int i = 0; i < names->length(); i++) { 173 for (int i = 0; i < names->length(); i++) {
174 ASSERT(names->get(i)->IsString()); 174 ASSERT(names->get(i)->IsString());
175 String* key_string = String::cast(names->get(i)); 175 String* key_string = String::cast(names->get(i));
176 PropertyAttributes attributes = 176 PropertyAttributes attributes =
177 copy->GetLocalPropertyAttribute(key_string); 177 copy->GetLocalPropertyAttribute(key_string);
178 // Only deep copy fields from the object literal expression. 178 // Only deep copy fields from the object literal expression.
(...skipping 4824 matching lines...) Expand 10 before | Expand all | Expand 10 after
5003 for (int i = 0; i < length; i++) { 5003 for (int i = 0; i < length; i++) {
5004 // Only collect names if access is permitted. 5004 // Only collect names if access is permitted.
5005 if (jsproto->IsAccessCheckNeeded() && 5005 if (jsproto->IsAccessCheckNeeded() &&
5006 !isolate->MayNamedAccess(*jsproto, 5006 !isolate->MayNamedAccess(*jsproto,
5007 isolate->heap()->undefined_value(), 5007 isolate->heap()->undefined_value(),
5008 v8::ACCESS_KEYS)) { 5008 v8::ACCESS_KEYS)) {
5009 isolate->ReportFailedAccessCheck(*jsproto, v8::ACCESS_KEYS); 5009 isolate->ReportFailedAccessCheck(*jsproto, v8::ACCESS_KEYS);
5010 return *isolate->factory()->NewJSArray(0); 5010 return *isolate->factory()->NewJSArray(0);
5011 } 5011 }
5012 int n; 5012 int n;
5013 n = jsproto->NumberOfLocalProperties(static_cast<PropertyAttributes>(NONE)); 5013 n = jsproto->NumberOfLocalProperties();
5014 local_property_count[i] = n; 5014 local_property_count[i] = n;
5015 total_property_count += n; 5015 total_property_count += n;
5016 if (i < length - 1) { 5016 if (i < length - 1) {
5017 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 5017 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
5018 } 5018 }
5019 } 5019 }
5020 5020
5021 // Allocate an array with storage for all the property names. 5021 // Allocate an array with storage for all the property names.
5022 Handle<FixedArray> names = 5022 Handle<FixedArray> names =
5023 isolate->factory()->NewFixedArray(total_property_count); 5023 isolate->factory()->NewFixedArray(total_property_count);
(...skipping 8629 matching lines...) Expand 10 before | Expand all | Expand 10 after
13653 // Handle last resort GC and make sure to allow future allocations 13653 // Handle last resort GC and make sure to allow future allocations
13654 // to grow the heap without causing GCs (if possible). 13654 // to grow the heap without causing GCs (if possible).
13655 isolate->counters()->gc_last_resort_from_js()->Increment(); 13655 isolate->counters()->gc_last_resort_from_js()->Increment();
13656 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13656 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13657 "Runtime::PerformGC"); 13657 "Runtime::PerformGC");
13658 } 13658 }
13659 } 13659 }
13660 13660
13661 13661
13662 } } // namespace v8::internal 13662 } } // namespace v8::internal
OLDNEW
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698