OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "ast.h" | 30 #include "ast.h" |
| 31 #include "code-stubs.h" |
31 #include "compiler.h" | 32 #include "compiler.h" |
32 #include "ic.h" | 33 #include "ic.h" |
33 #include "macro-assembler.h" | 34 #include "macro-assembler.h" |
34 #include "stub-cache.h" | 35 #include "stub-cache.h" |
35 #include "type-info.h" | 36 #include "type-info.h" |
36 | 37 |
37 #include "ic-inl.h" | 38 #include "ic-inl.h" |
38 #include "objects-inl.h" | 39 #include "objects-inl.h" |
39 | 40 |
40 namespace v8 { | 41 namespace v8 { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 Handle<Code> code = Handle<Code>::cast(map_or_code); | 82 Handle<Code> code = Handle<Code>::cast(map_or_code); |
82 return code->is_keyed_load_stub() && | 83 return code->is_keyed_load_stub() && |
83 code->ic_state() == MONOMORPHIC && | 84 code->ic_state() == MONOMORPHIC && |
84 Code::ExtractTypeFromFlags(code->flags()) == NORMAL && | 85 Code::ExtractTypeFromFlags(code->flags()) == NORMAL && |
85 code->FindFirstMap() != NULL; | 86 code->FindFirstMap() != NULL; |
86 } | 87 } |
87 return false; | 88 return false; |
88 } | 89 } |
89 | 90 |
90 | 91 |
| 92 bool TypeFeedbackOracle::LoadIsMegamorphicWithTypeInfo(Property* expr) { |
| 93 Handle<Object> map_or_code(GetInfo(expr->id())); |
| 94 if (map_or_code->IsCode()) { |
| 95 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 96 Builtins* builtins = Isolate::Current()->builtins(); |
| 97 return code->is_keyed_load_stub() && |
| 98 *code != builtins->builtin(Builtins::kKeyedLoadIC_Generic) && |
| 99 code->ic_state() == MEGAMORPHIC; |
| 100 } |
| 101 return false; |
| 102 } |
| 103 |
| 104 |
91 bool TypeFeedbackOracle::StoreIsMonomorphicNormal(Expression* expr) { | 105 bool TypeFeedbackOracle::StoreIsMonomorphicNormal(Expression* expr) { |
92 Handle<Object> map_or_code(GetInfo(expr->id())); | 106 Handle<Object> map_or_code(GetInfo(expr->id())); |
93 if (map_or_code->IsMap()) return true; | 107 if (map_or_code->IsMap()) return true; |
94 if (map_or_code->IsCode()) { | 108 if (map_or_code->IsCode()) { |
95 Handle<Code> code = Handle<Code>::cast(map_or_code); | 109 Handle<Code> code = Handle<Code>::cast(map_or_code); |
96 return code->is_keyed_store_stub() && | 110 return code->is_keyed_store_stub() && |
97 code->ic_state() == MONOMORPHIC && | 111 code->ic_state() == MONOMORPHIC && |
98 Code::ExtractTypeFromFlags(code->flags()) == NORMAL; | 112 Code::ExtractTypeFromFlags(code->flags()) == NORMAL; |
99 } | 113 } |
100 return false; | 114 return false; |
101 } | 115 } |
102 | 116 |
103 | 117 |
| 118 bool TypeFeedbackOracle::StoreIsMegamorphicWithTypeInfo(Expression* expr) { |
| 119 Handle<Object> map_or_code(GetInfo(expr->id())); |
| 120 if (map_or_code->IsCode()) { |
| 121 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 122 Builtins* builtins = Isolate::Current()->builtins(); |
| 123 return code->is_keyed_store_stub() && |
| 124 *code != builtins->builtin(Builtins::kKeyedStoreIC_Generic) && |
| 125 code->ic_state() == MEGAMORPHIC; |
| 126 } |
| 127 return false; |
| 128 } |
| 129 |
| 130 |
104 bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) { | 131 bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) { |
105 Handle<Object> value = GetInfo(expr->id()); | 132 Handle<Object> value = GetInfo(expr->id()); |
106 return value->IsMap() || value->IsSmi(); | 133 return value->IsMap() || value->IsSmi(); |
107 } | 134 } |
108 | 135 |
109 | 136 |
110 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) { | 137 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) { |
111 ASSERT(LoadIsMonomorphicNormal(expr)); | 138 ASSERT(LoadIsMonomorphicNormal(expr)); |
112 Handle<Object> map_or_code(GetInfo(expr->id())); | 139 Handle<Object> map_or_code(GetInfo(expr->id())); |
113 if (map_or_code->IsCode()) { | 140 if (map_or_code->IsCode()) { |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 ZoneMapList* types = new ZoneMapList(4); | 410 ZoneMapList* types = new ZoneMapList(4); |
384 ASSERT(object->IsCode()); | 411 ASSERT(object->IsCode()); |
385 isolate->stub_cache()->CollectMatchingMaps(types, *name, flags); | 412 isolate->stub_cache()->CollectMatchingMaps(types, *name, flags); |
386 return types->length() > 0 ? types : NULL; | 413 return types->length() > 0 ? types : NULL; |
387 } else { | 414 } else { |
388 return NULL; | 415 return NULL; |
389 } | 416 } |
390 } | 417 } |
391 | 418 |
392 | 419 |
| 420 void TypeFeedbackOracle::CollectKeyedReceiverTypes( |
| 421 unsigned ast_id, |
| 422 ZoneMapList* types) { |
| 423 Handle<Object> object = GetInfo(ast_id); |
| 424 if (!object->IsCode()) return; |
| 425 Handle<Code> code = Handle<Code>::cast(object); |
| 426 if (code->kind() == Code::KEYED_LOAD_IC || |
| 427 code->kind() == Code::KEYED_STORE_IC) { |
| 428 AssertNoAllocation no_allocation; |
| 429 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
| 430 for (RelocIterator it(*code, mask); !it.done(); it.next()) { |
| 431 RelocInfo* info = it.rinfo(); |
| 432 Object* object = info->target_object(); |
| 433 if (object->IsMap()) { |
| 434 types->Add(Handle<Map>(Map::cast(object))); |
| 435 } |
| 436 } |
| 437 } |
| 438 } |
| 439 |
| 440 |
393 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) { | 441 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) { |
394 ASSERT(dictionary_->FindEntry(ast_id) == NumberDictionary::kNotFound); | 442 ASSERT(dictionary_->FindEntry(ast_id) == NumberDictionary::kNotFound); |
395 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target); | 443 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target); |
396 USE(maybe_result); | 444 USE(maybe_result); |
397 #ifdef DEBUG | 445 #ifdef DEBUG |
398 Object* result = NULL; | 446 Object* result = NULL; |
399 // Dictionary has been allocated with sufficient size for all elements. | 447 // Dictionary has been allocated with sufficient size for all elements. |
400 ASSERT(maybe_result->ToObject(&result)); | 448 ASSERT(maybe_result->ToObject(&result)); |
401 ASSERT(*dictionary_ == result); | 449 ASSERT(*dictionary_ == result); |
402 #endif | 450 #endif |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 static_cast<int>(info->pc() - code->instruction_start())); | 532 static_cast<int>(info->pc() - code->instruction_start())); |
485 ASSERT(ast_ids->length() == 0 || | 533 ASSERT(ast_ids->length() == 0 || |
486 (*ast_ids)[ast_ids->length()-1] != | 534 (*ast_ids)[ast_ids->length()-1] != |
487 static_cast<unsigned>(info->data())); | 535 static_cast<unsigned>(info->data())); |
488 ast_ids->Add(static_cast<unsigned>(info->data())); | 536 ast_ids->Add(static_cast<unsigned>(info->data())); |
489 } | 537 } |
490 } | 538 } |
491 } | 539 } |
492 | 540 |
493 } } // namespace v8::internal | 541 } } // namespace v8::internal |
OLD | NEW |