| OLD | NEW |
| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/ast.h" | 7 #include "src/ast.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/ic.h" | 10 #include "src/ic.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return Handle<AllocationSite>::null(); | 168 return Handle<AllocationSite>::null(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 | 171 |
| 172 bool TypeFeedbackOracle::LoadIsBuiltin( | 172 bool TypeFeedbackOracle::LoadIsBuiltin( |
| 173 TypeFeedbackId id, Builtins::Name builtin) { | 173 TypeFeedbackId id, Builtins::Name builtin) { |
| 174 return *GetInfo(id) == isolate()->builtins()->builtin(builtin); | 174 return *GetInfo(id) == isolate()->builtins()->builtin(builtin); |
| 175 } | 175 } |
| 176 | 176 |
| 177 | 177 |
| 178 bool TypeFeedbackOracle::LoadIsStub(TypeFeedbackId id, ICStub* stub) { | |
| 179 Handle<Object> object = GetInfo(id); | |
| 180 if (!object->IsCode()) return false; | |
| 181 Handle<Code> code = Handle<Code>::cast(object); | |
| 182 if (!code->is_load_stub()) return false; | |
| 183 if (code->ic_state() != MONOMORPHIC) return false; | |
| 184 return stub->Describes(*code); | |
| 185 } | |
| 186 | |
| 187 | |
| 188 void TypeFeedbackOracle::CompareType(TypeFeedbackId id, | 178 void TypeFeedbackOracle::CompareType(TypeFeedbackId id, |
| 189 Type** left_type, | 179 Type** left_type, |
| 190 Type** right_type, | 180 Type** right_type, |
| 191 Type** combined_type) { | 181 Type** combined_type) { |
| 192 Handle<Object> info = GetInfo(id); | 182 Handle<Object> info = GetInfo(id); |
| 193 if (!info->IsCode()) { | 183 if (!info->IsCode()) { |
| 194 // For some comparisons we don't have ICs, e.g. LiteralCompareTypeof. | 184 // For some comparisons we don't have ICs, e.g. LiteralCompareTypeof. |
| 195 *left_type = *right_type = *combined_type = Type::None(zone()); | 185 *left_type = *right_type = *combined_type = Type::None(zone()); |
| 196 return; | 186 return; |
| 197 } | 187 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 Type* TypeFeedbackOracle::CountType(TypeFeedbackId id) { | 247 Type* TypeFeedbackOracle::CountType(TypeFeedbackId id) { |
| 258 Handle<Object> object = GetInfo(id); | 248 Handle<Object> object = GetInfo(id); |
| 259 if (!object->IsCode()) return Type::None(zone()); | 249 if (!object->IsCode()) return Type::None(zone()); |
| 260 Handle<Code> code = Handle<Code>::cast(object); | 250 Handle<Code> code = Handle<Code>::cast(object); |
| 261 ASSERT_EQ(Code::BINARY_OP_IC, code->kind()); | 251 ASSERT_EQ(Code::BINARY_OP_IC, code->kind()); |
| 262 BinaryOpIC::State state(isolate(), code->extra_ic_state()); | 252 BinaryOpIC::State state(isolate(), code->extra_ic_state()); |
| 263 return state.GetLeftType(zone()); | 253 return state.GetLeftType(zone()); |
| 264 } | 254 } |
| 265 | 255 |
| 266 | 256 |
| 267 void TypeFeedbackOracle::PropertyReceiverTypes( | 257 void TypeFeedbackOracle::PropertyReceiverTypes(TypeFeedbackId id, |
| 268 TypeFeedbackId id, Handle<String> name, | 258 Handle<String> name, |
| 269 SmallMapList* receiver_types, bool* is_prototype) { | 259 SmallMapList* receiver_types) { |
| 270 receiver_types->Clear(); | 260 receiver_types->Clear(); |
| 271 FunctionPrototypeStub proto_stub(isolate(), Code::LOAD_IC); | 261 Code::Flags flags = Code::ComputeHandlerFlags(Code::LOAD_IC); |
| 272 *is_prototype = LoadIsStub(id, &proto_stub); | 262 CollectReceiverTypes(id, name, flags, receiver_types); |
| 273 if (!*is_prototype) { | |
| 274 Code::Flags flags = Code::ComputeHandlerFlags(Code::LOAD_IC); | |
| 275 CollectReceiverTypes(id, name, flags, receiver_types); | |
| 276 } | |
| 277 } | 263 } |
| 278 | 264 |
| 279 | 265 |
| 280 void TypeFeedbackOracle::KeyedPropertyReceiverTypes( | 266 void TypeFeedbackOracle::KeyedPropertyReceiverTypes( |
| 281 TypeFeedbackId id, SmallMapList* receiver_types, bool* is_string) { | 267 TypeFeedbackId id, SmallMapList* receiver_types, bool* is_string) { |
| 282 receiver_types->Clear(); | 268 receiver_types->Clear(); |
| 283 *is_string = false; | 269 *is_string = false; |
| 284 if (LoadIsBuiltin(id, Builtins::kKeyedLoadIC_String)) { | 270 if (LoadIsBuiltin(id, Builtins::kKeyedLoadIC_String)) { |
| 285 *is_string = true; | 271 *is_string = true; |
| 286 } else { | 272 } else { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 UnseededNumberDictionary::kNotFound); | 461 UnseededNumberDictionary::kNotFound); |
| 476 // Dictionary has been allocated with sufficient size for all elements. | 462 // Dictionary has been allocated with sufficient size for all elements. |
| 477 DisallowHeapAllocation no_need_to_resize_dictionary; | 463 DisallowHeapAllocation no_need_to_resize_dictionary; |
| 478 HandleScope scope(isolate()); | 464 HandleScope scope(isolate()); |
| 479 USE(UnseededNumberDictionary::AtNumberPut( | 465 USE(UnseededNumberDictionary::AtNumberPut( |
| 480 dictionary_, IdToKey(ast_id), handle(target, isolate()))); | 466 dictionary_, IdToKey(ast_id), handle(target, isolate()))); |
| 481 } | 467 } |
| 482 | 468 |
| 483 | 469 |
| 484 } } // namespace v8::internal | 470 } } // namespace v8::internal |
| OLD | NEW |