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

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

Issue 7060010: Merge bleeding edge into the GC branch up to 7948. The asserts (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 7 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
« no previous file with comments | « src/type-info.h ('k') | src/unbound-queue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ? Handle<Object>(dictionary_->ValueAt(entry)) 75 ? Handle<Object>(dictionary_->ValueAt(entry))
76 : Isolate::Current()->factory()->undefined_value(); 76 : Isolate::Current()->factory()->undefined_value();
77 } 77 }
78 78
79 79
80 bool TypeFeedbackOracle::LoadIsMonomorphic(Property* expr) { 80 bool TypeFeedbackOracle::LoadIsMonomorphic(Property* expr) {
81 Handle<Object> map_or_code(GetInfo(expr->id())); 81 Handle<Object> map_or_code(GetInfo(expr->id()));
82 if (map_or_code->IsMap()) return true; 82 if (map_or_code->IsMap()) return true;
83 if (map_or_code->IsCode()) { 83 if (map_or_code->IsCode()) {
84 Handle<Code> code(Code::cast(*map_or_code)); 84 Handle<Code> code(Code::cast(*map_or_code));
85 return code->kind() == Code::KEYED_EXTERNAL_ARRAY_LOAD_IC && 85 return code->is_keyed_load_stub() &&
86 code->ic_state() == MONOMORPHIC &&
86 code->FindFirstMap() != NULL; 87 code->FindFirstMap() != NULL;
87 } 88 }
88 return false; 89 return false;
89 } 90 }
90 91
91 92
92 bool TypeFeedbackOracle::StoreIsMonomorphic(Expression* expr) { 93 bool TypeFeedbackOracle::StoreIsMonomorphic(Expression* expr) {
93 Handle<Object> map_or_code(GetInfo(expr->id())); 94 Handle<Object> map_or_code(GetInfo(expr->id()));
94 if (map_or_code->IsMap()) return true; 95 if (map_or_code->IsMap()) return true;
95 if (map_or_code->IsCode()) { 96 if (map_or_code->IsCode()) {
96 Handle<Code> code(Code::cast(*map_or_code)); 97 Handle<Code> code(Code::cast(*map_or_code));
97 return code->kind() == Code::KEYED_EXTERNAL_ARRAY_STORE_IC && 98 return code->is_keyed_store_stub() &&
98 code->FindFirstMap() != NULL; 99 code->ic_state() == MONOMORPHIC;
99 } 100 }
100 return false; 101 return false;
101 } 102 }
102 103
103 104
104 bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) { 105 bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) {
105 Handle<Object> value = GetInfo(expr->id()); 106 Handle<Object> value = GetInfo(expr->id());
106 return value->IsMap() || value->IsSmi(); 107 return value->IsMap() || value->IsSmi();
107 } 108 }
108 109
109 110
110 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) { 111 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) {
111 ASSERT(LoadIsMonomorphic(expr)); 112 ASSERT(LoadIsMonomorphic(expr));
112 Handle<Object> map_or_code( 113 Handle<Object> map_or_code(
113 Handle<HeapObject>::cast(GetInfo(expr->id()))); 114 Handle<HeapObject>::cast(GetInfo(expr->id())));
114 if (map_or_code->IsCode()) { 115 if (map_or_code->IsCode()) {
115 Handle<Code> code(Code::cast(*map_or_code)); 116 Handle<Code> code(Code::cast(*map_or_code));
116 return Handle<Map>(code->FindFirstMap()); 117 Map* first_map = code->FindFirstMap();
118 ASSERT(first_map != NULL);
119 return Handle<Map>(first_map);
117 } 120 }
118 return Handle<Map>(Map::cast(*map_or_code)); 121 return Handle<Map>(Map::cast(*map_or_code));
119 } 122 }
120 123
121 124
122 Handle<Map> TypeFeedbackOracle::StoreMonomorphicReceiverType(Expression* expr) { 125 Handle<Map> TypeFeedbackOracle::StoreMonomorphicReceiverType(Expression* expr) {
123 ASSERT(StoreIsMonomorphic(expr)); 126 ASSERT(StoreIsMonomorphic(expr));
124 Handle<HeapObject> map_or_code( 127 Handle<HeapObject> map_or_code(
125 Handle<HeapObject>::cast(GetInfo(expr->id()))); 128 Handle<HeapObject>::cast(GetInfo(expr->id())));
126 if (map_or_code->IsCode()) { 129 if (map_or_code->IsCode()) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 CompareIC::State state = static_cast<CompareIC::State>(code->compare_state()); 225 CompareIC::State state = static_cast<CompareIC::State>(code->compare_state());
223 switch (state) { 226 switch (state) {
224 case CompareIC::UNINITIALIZED: 227 case CompareIC::UNINITIALIZED:
225 // Uninitialized means never executed. 228 // Uninitialized means never executed.
226 // TODO(fschneider): Introduce a separate value for never-executed ICs. 229 // TODO(fschneider): Introduce a separate value for never-executed ICs.
227 return unknown; 230 return unknown;
228 case CompareIC::SMIS: 231 case CompareIC::SMIS:
229 return TypeInfo::Smi(); 232 return TypeInfo::Smi();
230 case CompareIC::HEAP_NUMBERS: 233 case CompareIC::HEAP_NUMBERS:
231 return TypeInfo::Number(); 234 return TypeInfo::Number();
235 case CompareIC::SYMBOLS:
236 case CompareIC::STRINGS:
237 return TypeInfo::String();
232 case CompareIC::OBJECTS: 238 case CompareIC::OBJECTS:
233 // TODO(kasperl): We really need a type for JS objects here. 239 // TODO(kasperl): We really need a type for JS objects here.
234 return TypeInfo::NonPrimitive(); 240 return TypeInfo::NonPrimitive();
235 case CompareIC::GENERIC: 241 case CompareIC::GENERIC:
236 default: 242 default:
237 return unknown; 243 return unknown;
238 } 244 }
239 } 245 }
240 246
241 247
248 bool TypeFeedbackOracle::IsSymbolCompare(CompareOperation* expr) {
249 Handle<Object> object = GetInfo(expr->id());
250 if (!object->IsCode()) return false;
251 Handle<Code> code = Handle<Code>::cast(object);
252 if (!code->is_compare_ic_stub()) return false;
253 CompareIC::State state = static_cast<CompareIC::State>(code->compare_state());
254 return state == CompareIC::SYMBOLS;
255 }
256
257
242 TypeInfo TypeFeedbackOracle::UnaryType(UnaryOperation* expr) { 258 TypeInfo TypeFeedbackOracle::UnaryType(UnaryOperation* expr) {
243 Handle<Object> object = GetInfo(expr->position()); 259 Handle<Object> object = GetInfo(expr->id());
244 TypeInfo unknown = TypeInfo::Unknown(); 260 TypeInfo unknown = TypeInfo::Unknown();
245 if (!object->IsCode()) return unknown; 261 if (!object->IsCode()) return unknown;
246 Handle<Code> code = Handle<Code>::cast(object); 262 Handle<Code> code = Handle<Code>::cast(object);
247 ASSERT(code->is_type_recording_unary_op_stub()); 263 ASSERT(code->is_type_recording_unary_op_stub());
248 TRUnaryOpIC::TypeInfo type = static_cast<TRUnaryOpIC::TypeInfo>( 264 TRUnaryOpIC::TypeInfo type = static_cast<TRUnaryOpIC::TypeInfo>(
249 code->type_recording_unary_op_type()); 265 code->type_recording_unary_op_type());
250 switch (type) { 266 switch (type) {
251 case TRUnaryOpIC::SMI: 267 case TRUnaryOpIC::SMI:
252 return TypeInfo::Smi(); 268 return TypeInfo::Smi();
253 case TRUnaryOpIC::HEAP_NUMBER: 269 case TRUnaryOpIC::HEAP_NUMBER:
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 for (int i = 0; i < length; i++) { 437 for (int i = 0; i < length; i++) {
422 AssertNoAllocation no_allocation; 438 AssertNoAllocation no_allocation;
423 RelocInfo info(code->instruction_start() + code_positions[i], 439 RelocInfo info(code->instruction_start() + code_positions[i],
424 RelocInfo::CODE_TARGET, 0); 440 RelocInfo::CODE_TARGET, 0);
425 Code* target = Code::GetCodeFromTargetAddress(info.target_address()); 441 Code* target = Code::GetCodeFromTargetAddress(info.target_address());
426 unsigned id = ast_ids[i]; 442 unsigned id = ast_ids[i];
427 InlineCacheState state = target->ic_state(); 443 InlineCacheState state = target->ic_state();
428 Code::Kind kind = target->kind(); 444 Code::Kind kind = target->kind();
429 445
430 if (kind == Code::TYPE_RECORDING_BINARY_OP_IC || 446 if (kind == Code::TYPE_RECORDING_BINARY_OP_IC ||
447 kind == Code::TYPE_RECORDING_UNARY_OP_IC ||
431 kind == Code::COMPARE_IC) { 448 kind == Code::COMPARE_IC) {
432 SetInfo(id, target); 449 SetInfo(id, target);
433 } else if (state == MONOMORPHIC) { 450 } else if (state == MONOMORPHIC) {
434 if (kind == Code::KEYED_EXTERNAL_ARRAY_LOAD_IC || 451 if (kind == Code::KEYED_LOAD_IC ||
435 kind == Code::KEYED_EXTERNAL_ARRAY_STORE_IC) { 452 kind == Code::KEYED_STORE_IC) {
436 SetInfo(id, target); 453 SetInfo(id, target);
437 } else if (kind != Code::CALL_IC || 454 } else if (kind != Code::CALL_IC ||
438 target->check_type() == RECEIVER_MAP_CHECK) { 455 target->check_type() == RECEIVER_MAP_CHECK) {
439 Map* map = target->FindFirstMap(); 456 Map* map = target->FindFirstMap();
440 if (map == NULL) { 457 if (map == NULL) {
441 SetInfo(id, target); 458 SetInfo(id, target);
442 } else { 459 } else {
443 SetInfo(id, map); 460 SetInfo(id, map);
444 } 461 }
445 } else { 462 } else {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 static_cast<int>(info->pc() - code->instruction_start())); 500 static_cast<int>(info->pc() - code->instruction_start()));
484 ASSERT(ast_ids->length() == 0 || 501 ASSERT(ast_ids->length() == 0 ||
485 (*ast_ids)[ast_ids->length()-1] != 502 (*ast_ids)[ast_ids->length()-1] !=
486 static_cast<unsigned>(info->data())); 503 static_cast<unsigned>(info->data()));
487 ast_ids->Add(static_cast<unsigned>(info->data())); 504 ast_ids->Add(static_cast<unsigned>(info->data()));
488 } 505 }
489 } 506 }
490 } 507 }
491 508
492 } } // namespace v8::internal 509 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/type-info.h ('k') | src/unbound-queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698