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

Side by Side Diff: src/type-info.cc

Issue 16408005: CallNewArray sites need the original feedback cell at crankshaft time. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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
« src/ast.cc ('K') | « src/type-info.h ('k') | no next file » | 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 // 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
79 Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) { 79 Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) {
80 int entry = dictionary_->FindEntry(IdToKey(ast_id)); 80 int entry = dictionary_->FindEntry(IdToKey(ast_id));
81 return entry != UnseededNumberDictionary::kNotFound 81 if (entry != UnseededNumberDictionary::kNotFound) {
82 ? Handle<Object>(dictionary_->ValueAt(entry), isolate_) 82 Object* value = dictionary_->ValueAt(entry);
83 : Handle<Object>::cast(isolate_->factory()->undefined_value()); 83 if (value->IsJSGlobalPropertyCell()) {
84 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(value);
85 return Handle<Object>(cell->value(), isolate_);
86 } else {
87 return Handle<Object>(value, isolate_);
88 }
89 }
90 return Handle<Object>::cast(isolate_->factory()->undefined_value());
84 } 91 }
85 92
86 93
94 Handle<JSGlobalPropertyCell> TypeFeedbackOracle::GetInfoCell(
95 TypeFeedbackId ast_id) {
96 int entry = dictionary_->FindEntry(IdToKey(ast_id));
97 if (entry != UnseededNumberDictionary::kNotFound) {
98 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(
99 dictionary_->ValueAt(entry));
100 return Handle<JSGlobalPropertyCell>(cell, isolate_);
101 }
102 return Handle<JSGlobalPropertyCell>::null();
103 }
104
105
87 bool TypeFeedbackOracle::LoadIsUninitialized(Property* expr) { 106 bool TypeFeedbackOracle::LoadIsUninitialized(Property* expr) {
88 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); 107 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId());
89 if (map_or_code->IsMap()) return false; 108 if (map_or_code->IsMap()) return false;
90 if (map_or_code->IsCode()) { 109 if (map_or_code->IsCode()) {
91 Handle<Code> code = Handle<Code>::cast(map_or_code); 110 Handle<Code> code = Handle<Code>::cast(map_or_code);
92 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED; 111 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED;
93 } 112 }
94 return false; 113 return false;
95 } 114 }
96 115
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (info->IsSmi()) { 328 if (info->IsSmi()) {
310 ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <= 329 ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <=
311 LAST_FAST_ELEMENTS_KIND); 330 LAST_FAST_ELEMENTS_KIND);
312 return Handle<JSFunction>(isolate_->global_context()->array_function()); 331 return Handle<JSFunction>(isolate_->global_context()->array_function());
313 } else { 332 } else {
314 return Handle<JSFunction>::cast(info); 333 return Handle<JSFunction>::cast(info);
315 } 334 }
316 } 335 }
317 336
318 337
319 ElementsKind TypeFeedbackOracle::GetCallNewElementsKind(CallNew* expr) { 338 Handle<JSGlobalPropertyCell> TypeFeedbackOracle::GetCallNewAllocationInfoCell(
320 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); 339 CallNew* expr) {
321 if (info->IsSmi()) { 340 return GetInfoCell(expr->CallNewFeedbackId());
322 return static_cast<ElementsKind>(Smi::cast(*info)->value());
323 } else {
324 // TODO(mvstanton): avoided calling GetInitialFastElementsKind() for perf
325 // reasons. Is there a better fix?
326 if (FLAG_packed_arrays) {
327 return FAST_SMI_ELEMENTS;
328 } else {
329 return FAST_HOLEY_SMI_ELEMENTS;
330 }
331 }
332 } 341 }
333 342
343
334 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap( 344 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap(
335 ObjectLiteral::Property* prop) { 345 ObjectLiteral::Property* prop) {
336 ASSERT(ObjectLiteralStoreIsMonomorphic(prop)); 346 ASSERT(ObjectLiteralStoreIsMonomorphic(prop));
337 return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId())); 347 return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId()));
338 } 348 }
339 349
340 350
341 bool TypeFeedbackOracle::LoadIsBuiltin(Property* expr, Builtins::Name id) { 351 bool TypeFeedbackOracle::LoadIsBuiltin(Property* expr, Builtins::Name id) {
342 return *GetInfo(expr->PropertyFeedbackId()) == 352 return *GetInfo(expr->PropertyFeedbackId()) ==
343 isolate_->builtins()->builtin(id); 353 isolate_->builtins()->builtin(id);
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 } 752 }
743 753
744 754
745 void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) { 755 void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) {
746 Object* raw_info = code->type_feedback_info(); 756 Object* raw_info = code->type_feedback_info();
747 if (!raw_info->IsTypeFeedbackInfo()) return; 757 if (!raw_info->IsTypeFeedbackInfo()) return;
748 Handle<TypeFeedbackCells> cache( 758 Handle<TypeFeedbackCells> cache(
749 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells()); 759 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells());
750 for (int i = 0; i < cache->CellCount(); i++) { 760 for (int i = 0; i < cache->CellCount(); i++) {
751 TypeFeedbackId ast_id = cache->AstId(i); 761 TypeFeedbackId ast_id = cache->AstId(i);
752 Object* value = cache->Cell(i)->value(); 762 JSGlobalPropertyCell* cell = cache->Cell(i);
763 Object* value = cell->value();
753 if (value->IsSmi() || 764 if (value->IsSmi() ||
754 (value->IsJSFunction() && 765 (value->IsJSFunction() &&
755 !CanRetainOtherContext(JSFunction::cast(value), 766 !CanRetainOtherContext(JSFunction::cast(value),
756 *native_context_))) { 767 *native_context_))) {
757 SetInfo(ast_id, value); 768 SetInfo(ast_id, cell);
758 } 769 }
759 } 770 }
760 } 771 }
761 772
762 773
763 void TypeFeedbackOracle::SetInfo(TypeFeedbackId ast_id, Object* target) { 774 void TypeFeedbackOracle::SetInfo(TypeFeedbackId ast_id, Object* target) {
764 ASSERT(dictionary_->FindEntry(IdToKey(ast_id)) == 775 ASSERT(dictionary_->FindEntry(IdToKey(ast_id)) ==
765 UnseededNumberDictionary::kNotFound); 776 UnseededNumberDictionary::kNotFound);
766 MaybeObject* maybe_result = dictionary_->AtNumberPut(IdToKey(ast_id), target); 777 MaybeObject* maybe_result = dictionary_->AtNumberPut(IdToKey(ast_id), target);
767 USE(maybe_result); 778 USE(maybe_result);
768 #ifdef DEBUG 779 #ifdef DEBUG
769 Object* result = NULL; 780 Object* result = NULL;
770 // Dictionary has been allocated with sufficient size for all elements. 781 // Dictionary has been allocated with sufficient size for all elements.
771 ASSERT(maybe_result->ToObject(&result)); 782 ASSERT(maybe_result->ToObject(&result));
772 ASSERT(*dictionary_ == result); 783 ASSERT(*dictionary_ == result);
773 #endif 784 #endif
774 } 785 }
775 786
776 } } // namespace v8::internal 787 } } // namespace v8::internal
OLDNEW
« src/ast.cc ('K') | « src/type-info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698