Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 HeapObject* IC::GetCodeCacheHolder(Isolate* isolate, | 113 HeapObject* IC::GetCodeCacheHolder(Isolate* isolate, |
| 114 Object* object, | 114 Object* object, |
| 115 InlineCacheHolderFlag holder) { | 115 InlineCacheHolderFlag holder) { |
| 116 if (object->IsSmi()) holder = PROTOTYPE_MAP; | 116 if (object->IsSmi()) holder = PROTOTYPE_MAP; |
| 117 Object* map_owner = holder == OWN_MAP | 117 Object* map_owner = holder == OWN_MAP |
| 118 ? object : object->GetPrototype(isolate); | 118 ? object : object->GetPrototype(isolate); |
| 119 return HeapObject::cast(map_owner); | 119 return HeapObject::cast(map_owner); |
| 120 } | 120 } |
| 121 | 121 |
| 122 | 122 |
| 123 InlineCacheHolderFlag IC::GetCodeCacheFlag(Type* type) { | |
| 124 if (type->Is(Type::Boolean())) return PROTOTYPE_MAP; | |
|
rossberg
2013/11/18 17:02:06
Nit: why not use a disjunction?
| |
| 125 if (type->Is(Type::Number())) return PROTOTYPE_MAP; | |
| 126 if (type->Is(Type::String())) return PROTOTYPE_MAP; | |
| 127 if (type->Is(Type::Symbol())) return PROTOTYPE_MAP; | |
| 128 return OWN_MAP; | |
| 129 } | |
| 130 | |
| 131 | |
| 132 Handle<Map> IC::GetCodeCacheHolder(InlineCacheHolderFlag flag, | |
| 133 Type* type, | |
| 134 Isolate* isolate) { | |
| 135 if (flag == PROTOTYPE_MAP) { | |
| 136 Context* context = isolate->context()->native_context(); | |
| 137 JSFunction* constructor; | |
| 138 if (type->Is(Type::Boolean())) { | |
| 139 constructor = context->boolean_function(); | |
| 140 } else if (type->Is(Type::Number())) { | |
| 141 constructor = context->number_function(); | |
| 142 } else if (type->Is(Type::String())) { | |
| 143 constructor = context->string_function(); | |
| 144 } else { | |
| 145 ASSERT(type->Is(Type::Symbol())); | |
| 146 constructor = context->symbol_function(); | |
| 147 } | |
| 148 return handle(JSObject::cast(constructor->instance_prototype())->map()); | |
| 149 } | |
| 150 return type->AsClass(); | |
| 151 } | |
| 152 | |
| 153 | |
| 123 } } // namespace v8::internal | 154 } } // namespace v8::internal |
| 124 | 155 |
| 125 #endif // V8_IC_INL_H_ | 156 #endif // V8_IC_INL_H_ |
| OLD | NEW |