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

Side by Side Diff: src/objects-inl.h

Issue 10448011: Keep track of which maps are associated with prototype objects (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 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
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 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 offset += kPointerSize; 1604 offset += kPointerSize;
1605 } 1605 }
1606 } 1606 }
1607 1607
1608 1608
1609 bool JSObject::HasFastProperties() { 1609 bool JSObject::HasFastProperties() {
1610 return !properties()->IsDictionary(); 1610 return !properties()->IsDictionary();
1611 } 1611 }
1612 1612
1613 1613
1614 int JSObject::MaxFastProperties() { 1614 bool JSObject::TooManyFastProperties(int properties) {
1615 // Allow extra fast properties if the object has more than 1615 // Allow extra fast properties if the object has more than
1616 // kMaxFastProperties in-object properties. When this is the case, 1616 // kFastPropertiesSoftLimit in-object properties. When this is the case,
1617 // it is very unlikely that the object is being used as a dictionary 1617 // it is very unlikely that the object is being used as a dictionary
1618 // and there is a good chance that allowing more map transitions 1618 // and there is a good chance that allowing more map transitions
1619 // will be worth it. 1619 // will be worth it.
1620 return Max(map()->inobject_properties(), kMaxFastProperties); 1620 int inobject = map()->inobject_properties();
1621
1622 int limit;
1623 if (map()->used_for_prototype()) {
1624 limit = Max(inobject, kMaxFastProperties);
1625 } else {
1626 limit = Max(inobject, kFastPropertiesSoftLimit);
1627 }
1628 return properties >= limit;
1621 } 1629 }
1622 1630
1623 1631
1624 void Struct::InitializeBody(int object_size) { 1632 void Struct::InitializeBody(int object_size) {
1625 Object* value = GetHeap()->undefined_value(); 1633 Object* value = GetHeap()->undefined_value();
1626 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { 1634 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) {
1627 WRITE_FIELD(this, offset, value); 1635 WRITE_FIELD(this, offset, value);
1628 } 1636 }
1629 } 1637 }
1630 1638
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 } else { 2925 } else {
2918 set_bit_field3(bit_field3() & ~(1 << kIsShared)); 2926 set_bit_field3(bit_field3() & ~(1 << kIsShared));
2919 } 2927 }
2920 } 2928 }
2921 2929
2922 bool Map::is_shared() { 2930 bool Map::is_shared() {
2923 return ((1 << kIsShared) & bit_field3()) != 0; 2931 return ((1 << kIsShared) & bit_field3()) != 0;
2924 } 2932 }
2925 2933
2926 2934
2935 void Map::set_used_for_prototype(bool value) {
2936 if (value) {
2937 set_bit_field3(bit_field3() | (1 << kUsedForPrototype));
2938 } else {
2939 set_bit_field3(bit_field3() & ~(1 << kUsedForPrototype));
2940 }
2941 }
2942
2943
2944 bool Map::used_for_prototype() {
2945 return ((1 << kUsedForPrototype) & bit_field3()) != 0;
2946 }
2947
2948
2927 JSFunction* Map::unchecked_constructor() { 2949 JSFunction* Map::unchecked_constructor() {
2928 return reinterpret_cast<JSFunction*>(READ_FIELD(this, kConstructorOffset)); 2950 return reinterpret_cast<JSFunction*>(READ_FIELD(this, kConstructorOffset));
2929 } 2951 }
2930 2952
2931 2953
2932 Code::Flags Code::flags() { 2954 Code::Flags Code::flags() {
2933 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); 2955 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset));
2934 } 2956 }
2935 2957
2936 2958
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
4067 4089
4068 4090
4069 Object* JSFunction::prototype() { 4091 Object* JSFunction::prototype() {
4070 ASSERT(has_prototype()); 4092 ASSERT(has_prototype());
4071 // If the function's prototype property has been set to a non-JSObject 4093 // If the function's prototype property has been set to a non-JSObject
4072 // value, that value is stored in the constructor field of the map. 4094 // value, that value is stored in the constructor field of the map.
4073 if (map()->has_non_instance_prototype()) return map()->constructor(); 4095 if (map()->has_non_instance_prototype()) return map()->constructor();
4074 return instance_prototype(); 4096 return instance_prototype();
4075 } 4097 }
4076 4098
4099
4077 bool JSFunction::should_have_prototype() { 4100 bool JSFunction::should_have_prototype() {
4078 return map()->function_with_prototype(); 4101 return map()->function_with_prototype();
4079 } 4102 }
4080 4103
4081 4104
4082 bool JSFunction::is_compiled() { 4105 bool JSFunction::is_compiled() {
4083 return code() != GetIsolate()->builtins()->builtin(Builtins::kLazyCompile); 4106 return code() != GetIsolate()->builtins()->builtin(Builtins::kLazyCompile);
4084 } 4107 }
4085 4108
4086 4109
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
5037 #undef WRITE_UINT32_FIELD 5060 #undef WRITE_UINT32_FIELD
5038 #undef READ_SHORT_FIELD 5061 #undef READ_SHORT_FIELD
5039 #undef WRITE_SHORT_FIELD 5062 #undef WRITE_SHORT_FIELD
5040 #undef READ_BYTE_FIELD 5063 #undef READ_BYTE_FIELD
5041 #undef WRITE_BYTE_FIELD 5064 #undef WRITE_BYTE_FIELD
5042 5065
5043 5066
5044 } } // namespace v8::internal 5067 } } // namespace v8::internal
5045 5068
5046 #endif // V8_OBJECTS_INL_H_ 5069 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698