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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } else { | 55 } else { |
56 info = TypeInfo::Unknown(); | 56 info = TypeInfo::Unknown(); |
57 } | 57 } |
58 return info; | 58 return info; |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code, | 62 TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code, |
63 Handle<Context> native_context, | 63 Handle<Context> native_context, |
64 Isolate* isolate, | 64 Isolate* isolate, |
65 Zone* zone) { | 65 Zone* zone) |
66 native_context_ = native_context; | 66 : native_context_(native_context), |
67 isolate_ = isolate; | 67 isolate_(isolate), |
68 zone_ = zone; | 68 zone_(zone) { |
69 BuildDictionary(code); | 69 BuildDictionary(code); |
70 ASSERT(reinterpret_cast<Address>(*dictionary_.location()) != kHandleZapValue); | 70 ASSERT(reinterpret_cast<Address>(*dictionary_.location()) != kHandleZapValue); |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 static uint32_t IdToKey(TypeFeedbackId ast_id) { | 74 static uint32_t IdToKey(TypeFeedbackId ast_id) { |
75 return static_cast<uint32_t>(ast_id.ToInt()); | 75 return static_cast<uint32_t>(ast_id.ToInt()); |
76 } | 76 } |
77 | 77 |
78 | 78 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 Handle<Object> value = GetInfo(expr->CallFeedbackId()); | 160 Handle<Object> value = GetInfo(expr->CallFeedbackId()); |
161 return value->IsMap() || value->IsSmi() || value->IsJSFunction(); | 161 return value->IsMap() || value->IsSmi() || value->IsJSFunction(); |
162 } | 162 } |
163 | 163 |
164 | 164 |
165 bool TypeFeedbackOracle::CallNewIsMonomorphic(CallNew* expr) { | 165 bool TypeFeedbackOracle::CallNewIsMonomorphic(CallNew* expr) { |
166 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); | 166 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); |
167 if (info->IsSmi()) { | 167 if (info->IsSmi()) { |
168 ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <= | 168 ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <= |
169 LAST_FAST_ELEMENTS_KIND); | 169 LAST_FAST_ELEMENTS_KIND); |
170 return Isolate::Current()->global_context()->array_function(); | 170 return isolate_->global_context()->array_function(); |
171 } | 171 } |
172 return info->IsJSFunction(); | 172 return info->IsJSFunction(); |
173 } | 173 } |
174 | 174 |
175 | 175 |
176 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic( | 176 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic( |
177 ObjectLiteral::Property* prop) { | 177 ObjectLiteral::Property* prop) { |
178 Handle<Object> map_or_code = GetInfo(prop->key()->LiteralFeedbackId()); | 178 Handle<Object> map_or_code = GetInfo(prop->key()->LiteralFeedbackId()); |
179 return map_or_code->IsMap(); | 179 return map_or_code->IsMap(); |
180 } | 180 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(Call* expr) { | 303 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(Call* expr) { |
304 return Handle<JSFunction>::cast(GetInfo(expr->CallFeedbackId())); | 304 return Handle<JSFunction>::cast(GetInfo(expr->CallFeedbackId())); |
305 } | 305 } |
306 | 306 |
307 | 307 |
308 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(CallNew* expr) { | 308 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(CallNew* expr) { |
309 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); | 309 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); |
310 if (info->IsSmi()) { | 310 if (info->IsSmi()) { |
311 ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <= | 311 ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <= |
312 LAST_FAST_ELEMENTS_KIND); | 312 LAST_FAST_ELEMENTS_KIND); |
313 return Handle<JSFunction>(Isolate::Current()->global_context()-> | 313 return Handle<JSFunction>(isolate_->global_context()->array_function()); |
314 array_function()); | |
315 } else { | 314 } else { |
316 return Handle<JSFunction>::cast(info); | 315 return Handle<JSFunction>::cast(info); |
317 } | 316 } |
318 } | 317 } |
319 | 318 |
320 | 319 |
321 ElementsKind TypeFeedbackOracle::GetCallNewElementsKind(CallNew* expr) { | 320 ElementsKind TypeFeedbackOracle::GetCallNewElementsKind(CallNew* expr) { |
322 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); | 321 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); |
323 if (info->IsSmi()) { | 322 if (info->IsSmi()) { |
324 return static_cast<ElementsKind>(Smi::cast(*info)->value()); | 323 return static_cast<ElementsKind>(Smi::cast(*info)->value()); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 } | 630 } |
632 | 631 |
633 | 632 |
634 // Things are a bit tricky here: The iterator for the RelocInfos and the infos | 633 // Things are a bit tricky here: The iterator for the RelocInfos and the infos |
635 // themselves are not GC-safe, so we first get all infos, then we create the | 634 // themselves are not GC-safe, so we first get all infos, then we create the |
636 // dictionary (possibly triggering GC), and finally we relocate the collected | 635 // dictionary (possibly triggering GC), and finally we relocate the collected |
637 // infos before we process them. | 636 // infos before we process them. |
638 void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) { | 637 void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) { |
639 AssertNoAllocation no_allocation; | 638 AssertNoAllocation no_allocation; |
640 ZoneList<RelocInfo> infos(16, zone()); | 639 ZoneList<RelocInfo> infos(16, zone()); |
641 HandleScope scope(code->GetIsolate()); | 640 HandleScope scope(isolate_); |
642 GetRelocInfos(code, &infos); | 641 GetRelocInfos(code, &infos); |
643 CreateDictionary(code, &infos); | 642 CreateDictionary(code, &infos); |
644 ProcessRelocInfos(&infos); | 643 ProcessRelocInfos(&infos); |
645 ProcessTypeFeedbackCells(code); | 644 ProcessTypeFeedbackCells(code); |
646 // Allocate handle in the parent scope. | 645 // Allocate handle in the parent scope. |
647 dictionary_ = scope.CloseAndEscape(dictionary_); | 646 dictionary_ = scope.CloseAndEscape(dictionary_); |
648 } | 647 } |
649 | 648 |
650 | 649 |
651 void TypeFeedbackOracle::GetRelocInfos(Handle<Code> code, | 650 void TypeFeedbackOracle::GetRelocInfos(Handle<Code> code, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 USE(maybe_result); | 758 USE(maybe_result); |
760 #ifdef DEBUG | 759 #ifdef DEBUG |
761 Object* result = NULL; | 760 Object* result = NULL; |
762 // Dictionary has been allocated with sufficient size for all elements. | 761 // Dictionary has been allocated with sufficient size for all elements. |
763 ASSERT(maybe_result->ToObject(&result)); | 762 ASSERT(maybe_result->ToObject(&result)); |
764 ASSERT(*dictionary_ == result); | 763 ASSERT(*dictionary_ == result); |
765 #endif | 764 #endif |
766 } | 765 } |
767 | 766 |
768 } } // namespace v8::internal | 767 } } // namespace v8::internal |
OLD | NEW |