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

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

Issue 400523007: Cache IC handlers on the prototype's map if possible (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 6 years, 5 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/ic.cc ('k') | src/objects.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_IC_INL_H_ 5 #ifndef V8_IC_INL_H_
6 #define V8_IC_INL_H_ 6 #define V8_IC_INL_H_
7 7
8 #include "src/ic.h" 8 #include "src/ic.h"
9 9
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 address, constant_pool, target->instruction_start()); 112 address, constant_pool, target->instruction_start());
113 if (heap->gc_state() == Heap::MARK_COMPACT) { 113 if (heap->gc_state() == Heap::MARK_COMPACT) {
114 heap->mark_compact_collector()->RecordCodeTargetPatch(address, target); 114 heap->mark_compact_collector()->RecordCodeTargetPatch(address, target);
115 } else { 115 } else {
116 heap->incremental_marking()->RecordCodeTargetPatch(address, target); 116 heap->incremental_marking()->RecordCodeTargetPatch(address, target);
117 } 117 }
118 PostPatching(address, target, old_target); 118 PostPatching(address, target, old_target);
119 } 119 }
120 120
121 121
122 InlineCacheHolderFlag IC::GetCodeCacheForObject(Object* object) { 122 template <class TypeClass>
123 if (object->IsJSObject()) return OWN_MAP; 123 JSFunction* IC::GetRootConstructor(TypeClass* type, Context* native_context) {
124 124 if (type->Is(TypeClass::Boolean())) {
125 // If the object is a value, we use the prototype map for the cache. 125 return native_context->boolean_function();
126 ASSERT(object->IsString() || object->IsSymbol() || 126 } else if (type->Is(TypeClass::Number())) {
127 object->IsNumber() || object->IsBoolean()); 127 return native_context->number_function();
128 return PROTOTYPE_MAP; 128 } else if (type->Is(TypeClass::String())) {
129 return native_context->string_function();
130 } else if (type->Is(TypeClass::Symbol())) {
131 return native_context->symbol_function();
132 } else {
133 return NULL;
134 }
129 } 135 }
130 136
131 137
132 HeapObject* IC::GetCodeCacheHolder(Isolate* isolate, 138 Handle<Map> IC::GetHandlerCacheHolder(HeapType* type, bool receiver_is_holder,
133 Object* object, 139 Isolate* isolate, CacheHolderFlag* flag) {
134 InlineCacheHolderFlag holder) { 140 Handle<Map> receiver_map = TypeToMap(type, isolate);
135 if (object->IsSmi()) holder = PROTOTYPE_MAP; 141 if (receiver_is_holder) {
136 PrototypeIterator iter(isolate, object, 142 *flag = kCacheOnReceiver;
137 holder == OWN_MAP 143 return receiver_map;
138 ? PrototypeIterator::START_AT_RECEIVER 144 }
139 : PrototypeIterator::START_AT_PROTOTYPE); 145 Context* native_context = *isolate->native_context();
140 return HeapObject::cast(iter.GetCurrent()); 146 JSFunction* builtin_ctor = GetRootConstructor(type, native_context);
147 if (builtin_ctor != NULL) {
148 *flag = kCacheOnPrototypeReceiverIsPrimitive;
149 return handle(HeapObject::cast(builtin_ctor->instance_prototype())->map());
150 }
151 *flag = receiver_map->is_dictionary_map()
152 ? kCacheOnPrototypeReceiverIsDictionary
153 : kCacheOnPrototype;
154 // Callers must ensure that the prototype is non-null.
155 return handle(JSObject::cast(receiver_map->prototype())->map());
141 } 156 }
142 157
143 158
144 InlineCacheHolderFlag IC::GetCodeCacheFlag(HeapType* type) { 159 Handle<Map> IC::GetICCacheHolder(HeapType* type, Isolate* isolate,
145 if (type->Is(HeapType::Boolean()) || 160 CacheHolderFlag* flag) {
146 type->Is(HeapType::Number()) || 161 Context* native_context = *isolate->native_context();
147 type->Is(HeapType::String()) || 162 JSFunction* builtin_ctor = GetRootConstructor(type, native_context);
148 type->Is(HeapType::Symbol())) { 163 if (builtin_ctor != NULL) {
149 return PROTOTYPE_MAP; 164 *flag = kCacheOnPrototype;
165 return handle(builtin_ctor->initial_map());
150 } 166 }
151 return OWN_MAP; 167 *flag = kCacheOnReceiver;
152 }
153
154
155 Handle<Map> IC::GetCodeCacheHolder(InlineCacheHolderFlag flag,
156 HeapType* type,
157 Isolate* isolate) {
158 if (flag == PROTOTYPE_MAP) {
159 Context* context = *isolate->native_context();
160 JSFunction* constructor;
161 if (type->Is(HeapType::Boolean())) {
162 constructor = context->boolean_function();
163 } else if (type->Is(HeapType::Number())) {
164 constructor = context->number_function();
165 } else if (type->Is(HeapType::String())) {
166 constructor = context->string_function();
167 } else {
168 ASSERT(type->Is(HeapType::Symbol()));
169 constructor = context->symbol_function();
170 }
171 return handle(JSObject::cast(constructor->instance_prototype())->map());
172 }
173 return TypeToMap(type, isolate); 168 return TypeToMap(type, isolate);
174 } 169 }
175 170
176
177 } } // namespace v8::internal 171 } } // namespace v8::internal
178 172
179 #endif // V8_IC_INL_H_ 173 #endif // V8_IC_INL_H_
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698