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

Unified Diff: src/objects.cc

Issue 619006: Refactor the check for generating inline constructors... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | test/cctest/test-api.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
===================================================================
--- src/objects.cc (revision 3879)
+++ src/objects.cc (working copy)
@@ -4820,6 +4820,46 @@
}
+bool SharedFunctionInfo::CanGenerateInlineConstructor(Object* prototype) {
+ // Check the basic conditions for generating inline constructor code.
+ if (!FLAG_inline_new
+ || !has_only_simple_this_property_assignments()
+ || !this_property_assignments_count() > 0) {
+ return false;
+ }
+
+ // If the prototype is null inline constructors cause no problems.
+ if (!prototype->IsJSObject()) {
+ ASSERT(prototype->IsNull());
+ return true;
+ }
+
+ // Traverse the proposed prototype chain looking for setters for properties of
+ // the same names as are set by the inline constructor..
Mads Ager (chromium) 2010/02/18 09:19:35 .. -> .
Søren Thygesen Gjesse 2010/02/18 09:42:52 http://codereview.chromium.org/647007
+ for (Object* obj = prototype;
+ obj != Heap::null_value();
+ obj = obj->GetPrototype()) {
+ JSObject* js_object = JSObject::cast(obj);
+ if (!js_object->HasFastProperties()) {
+ // Only allow fast case objects, as the map check in the inline
+ // constructor which check for changes to the prototype chain cannot
+ // handle dictionary case objects.
+ return false;
+ }
+ for (int i = 0; i < this_property_assignments_count(); i++) {
+ LookupResult result;
+ String* name = GetThisPropertyAssignmentName(i);
+ js_object->LocalLookupRealNamedProperty(name, &result);
+ if (result.IsValid() && result.type() == CALLBACKS) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+
void SharedFunctionInfo::SetThisPropertyAssignmentsInfo(
bool only_simple_this_property_assignments,
FixedArray* assignments) {
@@ -4875,7 +4915,6 @@
}
-
// Support function for printing the source code to a StringStream
// without any allocation in the heap.
void SharedFunctionInfo::SourceCodePrint(StringStream* accumulator,
@@ -7230,61 +7269,6 @@
}
-static bool CallbacksObjectHasSetter(Object* callbacks) {
- if (!callbacks->IsFixedArray()) {
- ASSERT(callbacks->IsAccessorInfo() || callbacks->IsProxy());
- return true;
- } else {
- Object* setter = (FixedArray::cast(callbacks))->get(kSetterIndex);
- if (setter->IsJSFunction()) {
- return true;
- }
- }
-
- return false;
-}
-
-
-bool JSObject::HasSetter() {
- for (Object* obj = this;
- obj != Heap::null_value();
- obj = JSObject::cast(obj)->GetPrototype()) {
- JSObject* js_object = JSObject::cast(obj);
- if (js_object->HasFastProperties()) {
- DescriptorArray* descs = js_object->map()->instance_descriptors();
- for (int i = 0; i < descs->number_of_descriptors(); i++) {
- PropertyDetails details = descs->GetDetails(i);
- if (details.type() == CALLBACKS) {
- Object* callbacks = descs->GetCallbacksObject(i);
- if (CallbacksObjectHasSetter(callbacks)) {
- return true;
- }
- }
- }
- } else {
- StringDictionary* dict = js_object->property_dictionary();
- int capacity = dict->Capacity();
- for (int i = 0; i < capacity; i++) {
- Object* k = dict->KeyAt(i);
- if (dict->IsKey(k)) {
- PropertyType type = dict->DetailsAt(i).type();
- ASSERT(type != FIELD);
- if (type == CALLBACKS) {
- Object* callbacks = dict->ValueAt(i);
- if (CallbacksObjectHasSetter(callbacks)) {
- return true;
- }
- }
- }
- }
- }
- }
-
- return false;
-}
-
-
-
Object* PixelArray::SetValue(uint32_t index, Object* value) {
uint8_t clamped_value = 0;
if (index < static_cast<uint32_t>(length())) {
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698