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

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

Issue 148343005: A64: Synchronize with r18147. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/typedarray.js » ('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 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 TypeFeedbackId ast_id) { 92 TypeFeedbackId ast_id) {
93 int entry = dictionary_->FindEntry(IdToKey(ast_id)); 93 int entry = dictionary_->FindEntry(IdToKey(ast_id));
94 if (entry != UnseededNumberDictionary::kNotFound) { 94 if (entry != UnseededNumberDictionary::kNotFound) {
95 Cell* cell = Cell::cast(dictionary_->ValueAt(entry)); 95 Cell* cell = Cell::cast(dictionary_->ValueAt(entry));
96 return Handle<Cell>(cell, isolate_); 96 return Handle<Cell>(cell, isolate_);
97 } 97 }
98 return Handle<Cell>::null(); 98 return Handle<Cell>::null();
99 } 99 }
100 100
101 101
102 bool TypeFeedbackOracle::LoadIsUninitialized(Property* expr) { 102 bool TypeFeedbackOracle::LoadIsUninitialized(TypeFeedbackId id) {
103 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); 103 Handle<Object> map_or_code = GetInfo(id);
104 if (map_or_code->IsMap()) return false; 104 if (map_or_code->IsMap()) return false;
105 if (map_or_code->IsCode()) { 105 if (map_or_code->IsCode()) {
106 Handle<Code> code = Handle<Code>::cast(map_or_code); 106 Handle<Code> code = Handle<Code>::cast(map_or_code);
107 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED; 107 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED;
108 } 108 }
109 return false; 109 return false;
110 } 110 }
111 111
112 112
113 bool TypeFeedbackOracle::LoadIsMonomorphicNormal(Property* expr) { 113 bool TypeFeedbackOracle::LoadIsMonomorphicNormal(TypeFeedbackId id) {
114 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); 114 Handle<Object> map_or_code = GetInfo(id);
115 if (map_or_code->IsMap()) return true; 115 if (map_or_code->IsMap()) return true;
116 if (map_or_code->IsCode()) { 116 if (map_or_code->IsCode()) {
117 Handle<Code> code = Handle<Code>::cast(map_or_code); 117 Handle<Code> code = Handle<Code>::cast(map_or_code);
118 bool preliminary_checks = code->is_keyed_load_stub() && 118 bool preliminary_checks = code->is_keyed_load_stub() &&
119 code->ic_state() == MONOMORPHIC && 119 code->ic_state() == MONOMORPHIC &&
120 Code::ExtractTypeFromFlags(code->flags()) == Code::NORMAL; 120 Code::ExtractTypeFromFlags(code->flags()) == Code::NORMAL;
121 if (!preliminary_checks) return false; 121 if (!preliminary_checks) return false;
122 Map* map = code->FindFirstMap(); 122 Map* map = code->FindFirstMap();
123 if (map == NULL) return false; 123 if (map == NULL) return false;
124 map = map->CurrentMapForDeprecated(); 124 map = map->CurrentMapForDeprecated();
125 return map != NULL && !CanRetainOtherContext(map, *native_context_); 125 return map != NULL && !CanRetainOtherContext(map, *native_context_);
126 } 126 }
127 return false; 127 return false;
128 } 128 }
129 129
130 130
131 bool TypeFeedbackOracle::LoadIsPreMonomorphic(Property* expr) { 131 bool TypeFeedbackOracle::LoadIsPreMonomorphic(TypeFeedbackId id) {
132 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); 132 Handle<Object> map_or_code = GetInfo(id);
133 if (map_or_code->IsCode()) { 133 if (map_or_code->IsCode()) {
134 Handle<Code> code = Handle<Code>::cast(map_or_code); 134 Handle<Code> code = Handle<Code>::cast(map_or_code);
135 return code->is_inline_cache_stub() && code->ic_state() == PREMONOMORPHIC; 135 return code->is_inline_cache_stub() && code->ic_state() == PREMONOMORPHIC;
136 } 136 }
137 return false; 137 return false;
138 } 138 }
139 139
140 140
141 bool TypeFeedbackOracle::LoadIsPolymorphic(Property* expr) { 141 bool TypeFeedbackOracle::LoadIsPolymorphic(TypeFeedbackId id) {
142 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); 142 Handle<Object> map_or_code = GetInfo(id);
143 if (map_or_code->IsCode()) { 143 if (map_or_code->IsCode()) {
144 Handle<Code> code = Handle<Code>::cast(map_or_code); 144 Handle<Code> code = Handle<Code>::cast(map_or_code);
145 return code->is_keyed_load_stub() && code->ic_state() == POLYMORPHIC; 145 return code->is_keyed_load_stub() && code->ic_state() == POLYMORPHIC;
146 } 146 }
147 return false; 147 return false;
148 } 148 }
149 149
150 150
151 bool TypeFeedbackOracle::StoreIsUninitialized(TypeFeedbackId ast_id) { 151 bool TypeFeedbackOracle::StoreIsUninitialized(TypeFeedbackId ast_id) {
152 Handle<Object> map_or_code = GetInfo(ast_id); 152 Handle<Object> map_or_code = GetInfo(ast_id);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 218 }
219 219
220 220
221 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic( 221 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic(
222 ObjectLiteral::Property* prop) { 222 ObjectLiteral::Property* prop) {
223 Handle<Object> map_or_code = GetInfo(prop->key()->LiteralFeedbackId()); 223 Handle<Object> map_or_code = GetInfo(prop->key()->LiteralFeedbackId());
224 return map_or_code->IsMap(); 224 return map_or_code->IsMap();
225 } 225 }
226 226
227 227
228 byte TypeFeedbackOracle::ForInType(ForInStatement* stmt) { 228 byte TypeFeedbackOracle::ForInType(TypeFeedbackId id) {
229 Handle<Object> value = GetInfo(stmt->ForInFeedbackId()); 229 Handle<Object> value = GetInfo(id);
230 return value->IsSmi() && 230 return value->IsSmi() &&
231 Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker 231 Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker
232 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; 232 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN;
233 } 233 }
234 234
235 235
236 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) { 236 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(TypeFeedbackId id) {
237 ASSERT(LoadIsMonomorphicNormal(expr)); 237 ASSERT(LoadIsMonomorphicNormal(id));
238 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); 238 Handle<Object> map_or_code = GetInfo(id);
239 if (map_or_code->IsCode()) { 239 if (map_or_code->IsCode()) {
240 Handle<Code> code = Handle<Code>::cast(map_or_code); 240 Handle<Code> code = Handle<Code>::cast(map_or_code);
241 Map* map = code->FindFirstMap()->CurrentMapForDeprecated(); 241 Map* map = code->FindFirstMap()->CurrentMapForDeprecated();
242 return map == NULL || CanRetainOtherContext(map, *native_context_) 242 return map == NULL || CanRetainOtherContext(map, *native_context_)
243 ? Handle<Map>::null() 243 ? Handle<Map>::null()
244 : Handle<Map>(map); 244 : Handle<Map>(map);
245 } 245 }
246 return Handle<Map>::cast(map_or_code); 246 return Handle<Map>::cast(map_or_code);
247 } 247 }
248 248
(...skipping 12 matching lines...) Expand all
261 return Handle<Map>::cast(map_or_code); 261 return Handle<Map>::cast(map_or_code);
262 } 262 }
263 263
264 264
265 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode( 265 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode(
266 TypeFeedbackId ast_id) { 266 TypeFeedbackId ast_id) {
267 Handle<Object> map_or_code = GetInfo(ast_id); 267 Handle<Object> map_or_code = GetInfo(ast_id);
268 if (map_or_code->IsCode()) { 268 if (map_or_code->IsCode()) {
269 Handle<Code> code = Handle<Code>::cast(map_or_code); 269 Handle<Code> code = Handle<Code>::cast(map_or_code);
270 if (code->kind() == Code::KEYED_STORE_IC) { 270 if (code->kind() == Code::KEYED_STORE_IC) {
271 return Code::GetKeyedAccessStoreMode(code->extra_ic_state()); 271 return KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state());
272 } 272 }
273 } 273 }
274 return STANDARD_STORE; 274 return STANDARD_STORE;
275 } 275 }
276 276
277 277
278 void TypeFeedbackOracle::LoadReceiverTypes(Property* expr, 278 void TypeFeedbackOracle::LoadReceiverTypes(TypeFeedbackId id,
279 Handle<String> name, 279 Handle<String> name,
280 SmallMapList* types) { 280 SmallMapList* types) {
281 Code::Flags flags = Code::ComputeFlags( 281 Code::Flags flags = Code::ComputeFlags(
282 Code::HANDLER, MONOMORPHIC, Code::kNoExtraICState, 282 Code::HANDLER, MONOMORPHIC, kNoExtraICState,
283 Code::NORMAL, Code::LOAD_IC); 283 Code::NORMAL, Code::LOAD_IC);
284 CollectReceiverTypes(expr->PropertyFeedbackId(), name, flags, types); 284 CollectReceiverTypes(id, name, flags, types);
285 } 285 }
286 286
287 287
288 void TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr, 288 void TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr,
289 Handle<String> name, 289 Handle<String> name,
290 SmallMapList* types) { 290 SmallMapList* types) {
291 Code::Flags flags = Code::ComputeFlags( 291 Code::Flags flags = Code::ComputeFlags(
292 Code::HANDLER, MONOMORPHIC, Code::kNoExtraICState, 292 Code::HANDLER, MONOMORPHIC, kNoExtraICState,
293 Code::NORMAL, Code::STORE_IC); 293 Code::NORMAL, Code::STORE_IC);
294 CollectReceiverTypes(expr->AssignmentFeedbackId(), name, flags, types); 294 CollectReceiverTypes(expr->AssignmentFeedbackId(), name, flags, types);
295 } 295 }
296 296
297 297
298 void TypeFeedbackOracle::CallReceiverTypes(Call* expr, 298 void TypeFeedbackOracle::CallReceiverTypes(Call* expr,
299 Handle<String> name, 299 Handle<String> name,
300 CallKind call_kind, 300 CallKind call_kind,
301 SmallMapList* types) { 301 SmallMapList* types) {
302 int arity = expr->arguments()->length(); 302 int arity = expr->arguments()->length();
303 303
304 // Note: Currently we do not take string extra ic data into account 304 // Note: Currently we do not take string extra ic data into account
305 // here. 305 // here.
306 Code::ExtraICState extra_ic_state = 306 ContextualMode contextual_mode = call_kind == CALL_AS_FUNCTION
307 CallIC::Contextual::encode(call_kind == CALL_AS_FUNCTION); 307 ? CONTEXTUAL
308 : NOT_CONTEXTUAL;
309 ExtraICState extra_ic_state =
310 CallIC::Contextual::encode(contextual_mode);
308 311
309 Code::Flags flags = Code::ComputeMonomorphicFlags( 312 Code::Flags flags = Code::ComputeMonomorphicFlags(
310 Code::CALL_IC, extra_ic_state, OWN_MAP, Code::NORMAL, arity); 313 Code::CALL_IC, extra_ic_state, OWN_MAP, Code::NORMAL, arity);
311 CollectReceiverTypes(expr->CallFeedbackId(), name, flags, types); 314 CollectReceiverTypes(expr->CallFeedbackId(), name, flags, types);
312 } 315 }
313 316
314 317
315 CheckType TypeFeedbackOracle::GetCallCheckType(Call* expr) { 318 CheckType TypeFeedbackOracle::GetCallCheckType(Call* expr) {
316 Handle<Object> value = GetInfo(expr->CallFeedbackId()); 319 Handle<Object> value = GetInfo(expr->CallFeedbackId());
317 if (!value->IsSmi()) return RECEIVER_MAP_CHECK; 320 if (!value->IsSmi()) return RECEIVER_MAP_CHECK;
(...skipping 28 matching lines...) Expand all
346 } 349 }
347 350
348 351
349 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap( 352 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap(
350 ObjectLiteral::Property* prop) { 353 ObjectLiteral::Property* prop) {
351 ASSERT(ObjectLiteralStoreIsMonomorphic(prop)); 354 ASSERT(ObjectLiteralStoreIsMonomorphic(prop));
352 return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId())); 355 return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId()));
353 } 356 }
354 357
355 358
356 bool TypeFeedbackOracle::LoadIsBuiltin(Property* expr, Builtins::Name id) { 359 bool TypeFeedbackOracle::LoadIsBuiltin(
357 return *GetInfo(expr->PropertyFeedbackId()) == 360 TypeFeedbackId id, Builtins::Name builtin) {
358 isolate_->builtins()->builtin(id); 361 return *GetInfo(id) == isolate_->builtins()->builtin(builtin);
359 } 362 }
360 363
361 364
362 bool TypeFeedbackOracle::LoadIsStub(Property* expr, ICStub* stub) { 365 bool TypeFeedbackOracle::LoadIsStub(TypeFeedbackId id, ICStub* stub) {
363 Handle<Object> object = GetInfo(expr->PropertyFeedbackId()); 366 Handle<Object> object = GetInfo(id);
364 if (!object->IsCode()) return false; 367 if (!object->IsCode()) return false;
365 Handle<Code> code = Handle<Code>::cast(object); 368 Handle<Code> code = Handle<Code>::cast(object);
366 if (!code->is_load_stub()) return false; 369 if (!code->is_load_stub()) return false;
367 if (code->ic_state() != MONOMORPHIC) return false; 370 if (code->ic_state() != MONOMORPHIC) return false;
368 return stub->Describes(*code); 371 return stub->Describes(*code);
369 } 372 }
370 373
371 374
372 void TypeFeedbackOracle::CompareType(TypeFeedbackId id, 375 void TypeFeedbackOracle::CompareType(TypeFeedbackId id,
373 Handle<Type>* left_type, 376 Handle<Type>* left_type,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 Handle<Type> result(Type::None(), isolate_); 440 Handle<Type> result(Type::None(), isolate_);
438 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) { 441 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) {
439 Handle<Code> code = Handle<Code>::cast(info); 442 Handle<Code> code = Handle<Code>::cast(info);
440 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); 443 CompareIC::State state = ICCompareStub::CompareState(code->stub_info());
441 result = CompareIC::StateToType(isolate_, state); 444 result = CompareIC::StateToType(isolate_, state);
442 } 445 }
443 return result; 446 return result;
444 } 447 }
445 448
446 449
447 Handle<Type> TypeFeedbackOracle::IncrementType(CountOperation* expr) { 450 Handle<Type> TypeFeedbackOracle::CountType(TypeFeedbackId id) {
448 Handle<Object> object = GetInfo(expr->CountBinOpFeedbackId()); 451 Handle<Object> object = GetInfo(id);
449 Handle<Type> unknown(Type::None(), isolate_); 452 Handle<Type> unknown(Type::None(), isolate_);
450 if (!object->IsCode()) return unknown; 453 if (!object->IsCode()) return unknown;
451 Handle<Code> code = Handle<Code>::cast(object); 454 Handle<Code> code = Handle<Code>::cast(object);
452 if (!code->is_binary_op_stub()) return unknown; 455 if (!code->is_binary_op_stub()) return unknown;
453 456
454 BinaryOpStub stub(code->extended_extra_ic_state()); 457 BinaryOpStub stub(code->extended_extra_ic_state());
455 return stub.GetLeftType(isolate()); 458 return stub.GetLeftType(isolate());
456 } 459 }
457 460
458 461
462 void TypeFeedbackOracle::PropertyReceiverTypes(
463 TypeFeedbackId id, Handle<String> name,
464 SmallMapList* receiver_types, bool* is_prototype) {
465 receiver_types->Clear();
466 FunctionPrototypeStub proto_stub(Code::LOAD_IC);
467 *is_prototype = LoadIsStub(id, &proto_stub);
468 if (!*is_prototype) {
469 LoadReceiverTypes(id, name, receiver_types);
470 }
471 }
472
473
474 void TypeFeedbackOracle::KeyedPropertyReceiverTypes(
475 TypeFeedbackId id, SmallMapList* receiver_types, bool* is_string) {
476 receiver_types->Clear();
477 *is_string = false;
478 if (LoadIsBuiltin(id, Builtins::kKeyedLoadIC_String)) {
479 *is_string = true;
480 } else if (LoadIsMonomorphicNormal(id)) {
481 receiver_types->Add(LoadMonomorphicReceiverType(id), zone());
482 } else if (LoadIsPolymorphic(id)) {
483 receiver_types->Reserve(kMaxKeyedPolymorphism, zone());
484 CollectKeyedReceiverTypes(id, receiver_types);
485 }
486 }
487
488
489 void TypeFeedbackOracle::CountReceiverTypes(
490 TypeFeedbackId id, SmallMapList* receiver_types) {
491 receiver_types->Clear();
492 if (StoreIsMonomorphicNormal(id)) {
493 // Record receiver type for monomorphic keyed stores.
494 receiver_types->Add(StoreMonomorphicReceiverType(id), zone());
495 } else if (StoreIsKeyedPolymorphic(id)) {
496 receiver_types->Reserve(kMaxKeyedPolymorphism, zone());
497 CollectKeyedReceiverTypes(id, receiver_types);
498 } else {
499 CollectPolymorphicStoreReceiverTypes(id, receiver_types);
500 }
501 }
502
503
459 void TypeFeedbackOracle::CollectPolymorphicMaps(Handle<Code> code, 504 void TypeFeedbackOracle::CollectPolymorphicMaps(Handle<Code> code,
460 SmallMapList* types) { 505 SmallMapList* types) {
461 MapHandleList maps; 506 MapHandleList maps;
462 code->FindAllMaps(&maps); 507 code->FindAllMaps(&maps);
463 types->Reserve(maps.length(), zone()); 508 types->Reserve(maps.length(), zone());
464 for (int i = 0; i < maps.length(); i++) { 509 for (int i = 0; i < maps.length(); i++) {
465 Handle<Map> map(maps.at(i)); 510 Handle<Map> map(maps.at(i));
466 if (!CanRetainOtherContext(*map, *native_context_)) { 511 if (!CanRetainOtherContext(*map, *native_context_)) {
467 types->AddMapIfMissing(map, zone()); 512 types->AddMapIfMissing(map, zone());
468 } 513 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 if (info.IsUninitialized()) return Representation::None(); 744 if (info.IsUninitialized()) return Representation::None();
700 if (info.IsSmi()) return Representation::Smi(); 745 if (info.IsSmi()) return Representation::Smi();
701 if (info.IsInteger32()) return Representation::Integer32(); 746 if (info.IsInteger32()) return Representation::Integer32();
702 if (info.IsDouble()) return Representation::Double(); 747 if (info.IsDouble()) return Representation::Double();
703 if (info.IsNumber()) return Representation::Double(); 748 if (info.IsNumber()) return Representation::Double();
704 return Representation::Tagged(); 749 return Representation::Tagged();
705 } 750 }
706 751
707 752
708 } } // namespace v8::internal 753 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/type-info.h ('k') | src/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698