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

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

Issue 136643008: A64: Synchronize with r18256. (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/typing.cc » ('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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 Handle<Object> map_or_code = GetInfo(ast_id); 190 Handle<Object> map_or_code = GetInfo(ast_id);
191 if (map_or_code->IsCode()) { 191 if (map_or_code->IsCode()) {
192 Handle<Code> code = Handle<Code>::cast(map_or_code); 192 Handle<Code> code = Handle<Code>::cast(map_or_code);
193 return code->is_keyed_store_stub() && 193 return code->is_keyed_store_stub() &&
194 code->ic_state() == POLYMORPHIC; 194 code->ic_state() == POLYMORPHIC;
195 } 195 }
196 return false; 196 return false;
197 } 197 }
198 198
199 199
200 bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) { 200 bool TypeFeedbackOracle::CallIsMonomorphic(TypeFeedbackId id) {
201 Handle<Object> value = GetInfo(expr->CallFeedbackId()); 201 Handle<Object> value = GetInfo(id);
202 return value->IsMap() || value->IsAllocationSite() || value->IsJSFunction() || 202 return value->IsMap() || value->IsAllocationSite() || value->IsJSFunction() ||
203 value->IsSmi() || 203 value->IsSmi() ||
204 (value->IsCode() && Handle<Code>::cast(value)->ic_state() == MONOMORPHIC); 204 (value->IsCode() && Handle<Code>::cast(value)->ic_state() == MONOMORPHIC);
205 } 205 }
206 206
207 207
208 bool TypeFeedbackOracle::KeyedArrayCallIsHoley(Call* expr) { 208 bool TypeFeedbackOracle::KeyedArrayCallIsHoley(TypeFeedbackId id) {
209 Handle<Object> value = GetInfo(expr->CallFeedbackId()); 209 Handle<Object> value = GetInfo(id);
210 Handle<Code> code = Handle<Code>::cast(value); 210 Handle<Code> code = Handle<Code>::cast(value);
211 return KeyedArrayCallStub::IsHoley(code); 211 return KeyedArrayCallStub::IsHoley(code);
212 } 212 }
213 213
214 214
215 bool TypeFeedbackOracle::CallNewIsMonomorphic(CallNew* expr) { 215 bool TypeFeedbackOracle::CallNewIsMonomorphic(TypeFeedbackId id) {
216 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); 216 Handle<Object> info = GetInfo(id);
217 return info->IsAllocationSite() || info->IsJSFunction(); 217 return info->IsAllocationSite() || info->IsJSFunction();
218 } 218 }
219 219
220 220
221 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic( 221 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic(TypeFeedbackId id) {
222 ObjectLiteral::Property* prop) { 222 Handle<Object> map_or_code = GetInfo(id);
223 Handle<Object> map_or_code = GetInfo(prop->key()->LiteralFeedbackId());
224 return map_or_code->IsMap(); 223 return map_or_code->IsMap();
225 } 224 }
226 225
227 226
228 byte TypeFeedbackOracle::ForInType(TypeFeedbackId id) { 227 byte TypeFeedbackOracle::ForInType(TypeFeedbackId id) {
229 Handle<Object> value = GetInfo(id); 228 Handle<Object> value = GetInfo(id);
230 return value->IsSmi() && 229 return value->IsSmi() &&
231 Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker 230 Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker
232 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; 231 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN;
233 } 232 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 void TypeFeedbackOracle::LoadReceiverTypes(TypeFeedbackId id, 277 void TypeFeedbackOracle::LoadReceiverTypes(TypeFeedbackId id,
279 Handle<String> name, 278 Handle<String> name,
280 SmallMapList* types) { 279 SmallMapList* types) {
281 Code::Flags flags = Code::ComputeFlags( 280 Code::Flags flags = Code::ComputeFlags(
282 Code::HANDLER, MONOMORPHIC, kNoExtraICState, 281 Code::HANDLER, MONOMORPHIC, kNoExtraICState,
283 Code::NORMAL, Code::LOAD_IC); 282 Code::NORMAL, Code::LOAD_IC);
284 CollectReceiverTypes(id, name, flags, types); 283 CollectReceiverTypes(id, name, flags, types);
285 } 284 }
286 285
287 286
288 void TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr, 287 void TypeFeedbackOracle::StoreReceiverTypes(TypeFeedbackId id,
289 Handle<String> name, 288 Handle<String> name,
290 SmallMapList* types) { 289 SmallMapList* types) {
291 Code::Flags flags = Code::ComputeFlags( 290 Code::Flags flags = Code::ComputeFlags(
292 Code::HANDLER, MONOMORPHIC, kNoExtraICState, 291 Code::HANDLER, MONOMORPHIC, kNoExtraICState,
293 Code::NORMAL, Code::STORE_IC); 292 Code::NORMAL, Code::STORE_IC);
294 CollectReceiverTypes(expr->AssignmentFeedbackId(), name, flags, types); 293 CollectReceiverTypes(id, name, flags, types);
295 } 294 }
296 295
297 296
298 void TypeFeedbackOracle::CallReceiverTypes(Call* expr, 297 void TypeFeedbackOracle::CallReceiverTypes(TypeFeedbackId id,
299 Handle<String> name, 298 Handle<String> name,
299 int arity,
300 CallKind call_kind, 300 CallKind call_kind,
301 SmallMapList* types) { 301 SmallMapList* types) {
302 int arity = expr->arguments()->length();
303
304 // Note: Currently we do not take string extra ic data into account 302 // Note: Currently we do not take string extra ic data into account
305 // here. 303 // here.
306 ContextualMode contextual_mode = call_kind == CALL_AS_FUNCTION 304 ContextualMode contextual_mode = call_kind == CALL_AS_FUNCTION
307 ? CONTEXTUAL 305 ? CONTEXTUAL
308 : NOT_CONTEXTUAL; 306 : NOT_CONTEXTUAL;
309 ExtraICState extra_ic_state = 307 ExtraICState extra_ic_state =
310 CallIC::Contextual::encode(contextual_mode); 308 CallIC::Contextual::encode(contextual_mode);
311 309
312 Code::Flags flags = Code::ComputeMonomorphicFlags( 310 Code::Flags flags = Code::ComputeMonomorphicFlags(
313 Code::CALL_IC, extra_ic_state, OWN_MAP, Code::NORMAL, arity); 311 Code::CALL_IC, extra_ic_state, OWN_MAP, Code::NORMAL, arity);
314 CollectReceiverTypes(expr->CallFeedbackId(), name, flags, types); 312 CollectReceiverTypes(id, name, flags, types);
315 } 313 }
316 314
317 315
318 CheckType TypeFeedbackOracle::GetCallCheckType(Call* expr) { 316 CheckType TypeFeedbackOracle::GetCallCheckType(TypeFeedbackId id) {
319 Handle<Object> value = GetInfo(expr->CallFeedbackId()); 317 Handle<Object> value = GetInfo(id);
320 if (!value->IsSmi()) return RECEIVER_MAP_CHECK; 318 if (!value->IsSmi()) return RECEIVER_MAP_CHECK;
321 CheckType check = static_cast<CheckType>(Smi::cast(*value)->value()); 319 CheckType check = static_cast<CheckType>(Smi::cast(*value)->value());
322 ASSERT(check != RECEIVER_MAP_CHECK); 320 ASSERT(check != RECEIVER_MAP_CHECK);
323 return check; 321 return check;
324 } 322 }
325 323
326 324
327 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(Call* expr) { 325 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(TypeFeedbackId id) {
328 Handle<Object> info = GetInfo(expr->CallFeedbackId()); 326 Handle<Object> info = GetInfo(id);
329 if (info->IsAllocationSite()) { 327 if (info->IsAllocationSite()) {
330 return Handle<JSFunction>(isolate_->global_context()->array_function()); 328 return Handle<JSFunction>(isolate_->global_context()->array_function());
331 } else { 329 } else {
332 return Handle<JSFunction>::cast(info); 330 return Handle<JSFunction>::cast(info);
333 } 331 }
334 } 332 }
335 333
336 334
337 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(CallNew* expr) { 335 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(TypeFeedbackId id) {
338 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); 336 Handle<Object> info = GetInfo(id);
339 if (info->IsAllocationSite()) { 337 if (info->IsAllocationSite()) {
340 return Handle<JSFunction>(isolate_->global_context()->array_function()); 338 return Handle<JSFunction>(isolate_->global_context()->array_function());
341 } else { 339 } else {
342 return Handle<JSFunction>::cast(info); 340 return Handle<JSFunction>::cast(info);
343 } 341 }
344 } 342 }
345 343
346 344
347 Handle<Cell> TypeFeedbackOracle::GetCallNewAllocationInfoCell(CallNew* expr) { 345 Handle<Cell> TypeFeedbackOracle::GetCallNewAllocationInfoCell(
348 return GetInfoCell(expr->CallNewFeedbackId()); 346 TypeFeedbackId id) {
347 return GetInfoCell(id);
349 } 348 }
350 349
351 350
352 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap( 351 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap(TypeFeedbackId id) {
353 ObjectLiteral::Property* prop) { 352 ASSERT(ObjectLiteralStoreIsMonomorphic(id));
354 ASSERT(ObjectLiteralStoreIsMonomorphic(prop)); 353 return Handle<Map>::cast(GetInfo(id));
355 return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId()));
356 } 354 }
357 355
358 356
359 bool TypeFeedbackOracle::LoadIsBuiltin( 357 bool TypeFeedbackOracle::LoadIsBuiltin(
360 TypeFeedbackId id, Builtins::Name builtin) { 358 TypeFeedbackId id, Builtins::Name builtin) {
361 return *GetInfo(id) == isolate_->builtins()->builtin(builtin); 359 return *GetInfo(id) == isolate_->builtins()->builtin(builtin);
362 } 360 }
363 361
364 362
365 bool TypeFeedbackOracle::LoadIsStub(TypeFeedbackId id, ICStub* stub) { 363 bool TypeFeedbackOracle::LoadIsStub(TypeFeedbackId id, ICStub* stub) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 *left_type = *right_type = stub.GetInputType(isolate_, map); 401 *left_type = *right_type = stub.GetInputType(isolate_, map);
404 } 402 }
405 } 403 }
406 404
407 405
408 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, 406 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id,
409 Handle<Type>* left, 407 Handle<Type>* left,
410 Handle<Type>* right, 408 Handle<Type>* right,
411 Handle<Type>* result, 409 Handle<Type>* result,
412 Maybe<int>* fixed_right_arg, 410 Maybe<int>* fixed_right_arg,
413 Token::Value operation) { 411 Token::Value op) {
414 Handle<Object> object = GetInfo(id); 412 Handle<Object> object = GetInfo(id);
415 if (!object->IsCode()) { 413 if (!object->IsCode()) {
416 // For some binary ops we don't have ICs, e.g. Token::COMMA, but for the 414 // For some binary ops we don't have ICs, e.g. Token::COMMA, but for the
417 // operations covered by the BinaryOpStub we should always have them. 415 // operations covered by the BinaryOpIC we should always have them.
418 ASSERT(!(operation >= BinaryOpStub::FIRST_TOKEN && 416 ASSERT(op < BinaryOpIC::State::FIRST_TOKEN ||
419 operation <= BinaryOpStub::LAST_TOKEN)); 417 op > BinaryOpIC::State::LAST_TOKEN);
420 *left = *right = *result = handle(Type::None(), isolate_); 418 *left = *right = *result = handle(Type::None(), isolate_);
419 *fixed_right_arg = Maybe<int>();
421 return; 420 return;
422 } 421 }
423 Handle<Code> code = Handle<Code>::cast(object); 422 Handle<Code> code = Handle<Code>::cast(object);
424 ASSERT(code->is_binary_op_stub()); 423 ASSERT_EQ(Code::BINARY_OP_IC, code->kind());
424 BinaryOpIC::State state(code->extended_extra_ic_state());
425 ASSERT_EQ(op, state.op());
425 426
426 BinaryOpStub stub(code->extended_extra_ic_state()); 427 *left = state.GetLeftType(isolate());
427 428 *right = state.GetRightType(isolate());
428 // Sanity check. 429 *result = state.GetResultType(isolate());
429 ASSERT(stub.operation() == operation); 430 *fixed_right_arg = state.fixed_right_arg();
430
431 *left = stub.GetLeftType(isolate());
432 *right = stub.GetRightType(isolate());
433 *result = stub.GetResultType(isolate());
434 *fixed_right_arg = stub.fixed_right_arg();
435 } 431 }
436 432
437 433
438 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { 434 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) {
439 Handle<Object> info = GetInfo(id); 435 Handle<Object> info = GetInfo(id);
440 Handle<Type> result(Type::None(), isolate_); 436 Handle<Type> result(Type::None(), isolate_);
441 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) { 437 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) {
442 Handle<Code> code = Handle<Code>::cast(info); 438 Handle<Code> code = Handle<Code>::cast(info);
443 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); 439 CompareIC::State state = ICCompareStub::CompareState(code->stub_info());
444 result = CompareIC::StateToType(isolate_, state); 440 result = CompareIC::StateToType(isolate_, state);
445 } 441 }
446 return result; 442 return result;
447 } 443 }
448 444
449 445
450 Handle<Type> TypeFeedbackOracle::CountType(TypeFeedbackId id) { 446 Handle<Type> TypeFeedbackOracle::CountType(TypeFeedbackId id) {
451 Handle<Object> object = GetInfo(id); 447 Handle<Object> object = GetInfo(id);
452 Handle<Type> unknown(Type::None(), isolate_); 448 if (!object->IsCode()) return handle(Type::None(), isolate_);
453 if (!object->IsCode()) return unknown;
454 Handle<Code> code = Handle<Code>::cast(object); 449 Handle<Code> code = Handle<Code>::cast(object);
455 if (!code->is_binary_op_stub()) return unknown; 450 ASSERT_EQ(Code::BINARY_OP_IC, code->kind());
456 451 BinaryOpIC::State state(code->extended_extra_ic_state());
457 BinaryOpStub stub(code->extended_extra_ic_state()); 452 return state.GetLeftType(isolate());
458 return stub.GetLeftType(isolate());
459 } 453 }
460 454
461 455
462 void TypeFeedbackOracle::PropertyReceiverTypes( 456 void TypeFeedbackOracle::PropertyReceiverTypes(
463 TypeFeedbackId id, Handle<String> name, 457 TypeFeedbackId id, Handle<String> name,
464 SmallMapList* receiver_types, bool* is_prototype) { 458 SmallMapList* receiver_types, bool* is_prototype) {
465 receiver_types->Clear(); 459 receiver_types->Clear();
466 FunctionPrototypeStub proto_stub(Code::LOAD_IC); 460 FunctionPrototypeStub proto_stub(Code::LOAD_IC);
467 *is_prototype = LoadIsStub(id, &proto_stub); 461 *is_prototype = LoadIsStub(id, &proto_stub);
468 if (!*is_prototype) { 462 if (!*is_prototype) {
(...skipping 10 matching lines...) Expand all
479 *is_string = true; 473 *is_string = true;
480 } else if (LoadIsMonomorphicNormal(id)) { 474 } else if (LoadIsMonomorphicNormal(id)) {
481 receiver_types->Add(LoadMonomorphicReceiverType(id), zone()); 475 receiver_types->Add(LoadMonomorphicReceiverType(id), zone());
482 } else if (LoadIsPolymorphic(id)) { 476 } else if (LoadIsPolymorphic(id)) {
483 receiver_types->Reserve(kMaxKeyedPolymorphism, zone()); 477 receiver_types->Reserve(kMaxKeyedPolymorphism, zone());
484 CollectKeyedReceiverTypes(id, receiver_types); 478 CollectKeyedReceiverTypes(id, receiver_types);
485 } 479 }
486 } 480 }
487 481
488 482
483 void TypeFeedbackOracle::AssignmentReceiverTypes(
484 TypeFeedbackId id, Handle<String> name, SmallMapList* receiver_types) {
485 receiver_types->Clear();
486 StoreReceiverTypes(id, name, receiver_types);
487 }
488
489
490 void TypeFeedbackOracle::KeyedAssignmentReceiverTypes(
491 TypeFeedbackId id, SmallMapList* receiver_types,
492 KeyedAccessStoreMode* store_mode) {
493 receiver_types->Clear();
494 if (StoreIsMonomorphicNormal(id)) {
495 // Record receiver type for monomorphic keyed stores.
496 receiver_types->Add(StoreMonomorphicReceiverType(id), zone());
497 } else if (StoreIsKeyedPolymorphic(id)) {
498 receiver_types->Reserve(kMaxKeyedPolymorphism, zone());
499 CollectKeyedReceiverTypes(id, receiver_types);
500 }
501 *store_mode = GetStoreMode(id);
502 }
503
504
489 void TypeFeedbackOracle::CountReceiverTypes( 505 void TypeFeedbackOracle::CountReceiverTypes(
490 TypeFeedbackId id, SmallMapList* receiver_types) { 506 TypeFeedbackId id, SmallMapList* receiver_types) {
491 receiver_types->Clear(); 507 receiver_types->Clear();
492 if (StoreIsMonomorphicNormal(id)) { 508 if (StoreIsMonomorphicNormal(id)) {
493 // Record receiver type for monomorphic keyed stores. 509 // Record receiver type for monomorphic keyed stores.
494 receiver_types->Add(StoreMonomorphicReceiverType(id), zone()); 510 receiver_types->Add(StoreMonomorphicReceiverType(id), zone());
495 } else if (StoreIsKeyedPolymorphic(id)) { 511 } else if (StoreIsKeyedPolymorphic(id)) {
496 receiver_types->Reserve(kMaxKeyedPolymorphism, zone()); 512 receiver_types->Reserve(kMaxKeyedPolymorphism, zone());
497 CollectKeyedReceiverTypes(id, receiver_types); 513 CollectKeyedReceiverTypes(id, receiver_types);
498 } else { 514 } else {
(...skipping 16 matching lines...) Expand all
515 } 531 }
516 532
517 533
518 void TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id, 534 void TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id,
519 Handle<String> name, 535 Handle<String> name,
520 Code::Flags flags, 536 Code::Flags flags,
521 SmallMapList* types) { 537 SmallMapList* types) {
522 Handle<Object> object = GetInfo(ast_id); 538 Handle<Object> object = GetInfo(ast_id);
523 if (object->IsUndefined() || object->IsSmi()) return; 539 if (object->IsUndefined() || object->IsSmi()) return;
524 540
525 if (object.is_identical_to(isolate_->builtins()->StoreIC_GlobalProxy())) { 541 if (object->IsMap()) {
526 // TODO(fschneider): We could collect the maps and signal that
527 // we need a generic store (or load) here.
528 ASSERT(Handle<Code>::cast(object)->ic_state() == GENERIC);
529 } else if (object->IsMap()) {
530 types->AddMapIfMissing(Handle<Map>::cast(object), zone()); 542 types->AddMapIfMissing(Handle<Map>::cast(object), zone());
531 } else if (Handle<Code>::cast(object)->ic_state() == POLYMORPHIC || 543 } else if (Handle<Code>::cast(object)->ic_state() == POLYMORPHIC ||
532 Handle<Code>::cast(object)->ic_state() == MONOMORPHIC) { 544 Handle<Code>::cast(object)->ic_state() == MONOMORPHIC) {
533 CollectPolymorphicMaps(Handle<Code>::cast(object), types); 545 CollectPolymorphicMaps(Handle<Code>::cast(object), types);
534 } else if (FLAG_collect_megamorphic_maps_from_stub_cache && 546 } else if (FLAG_collect_megamorphic_maps_from_stub_cache &&
535 Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { 547 Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) {
536 types->Reserve(4, zone()); 548 types->Reserve(4, zone());
537 ASSERT(object->IsCode()); 549 ASSERT(object->IsCode());
538 isolate_->stub_cache()->CollectMatchingMaps(types, 550 isolate_->stub_cache()->CollectMatchingMaps(types,
539 name, 551 name,
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 if (info.IsUninitialized()) return Representation::None(); 756 if (info.IsUninitialized()) return Representation::None();
745 if (info.IsSmi()) return Representation::Smi(); 757 if (info.IsSmi()) return Representation::Smi();
746 if (info.IsInteger32()) return Representation::Integer32(); 758 if (info.IsInteger32()) return Representation::Integer32();
747 if (info.IsDouble()) return Representation::Double(); 759 if (info.IsDouble()) return Representation::Double();
748 if (info.IsNumber()) return Representation::Double(); 760 if (info.IsNumber()) return Representation::Double();
749 return Representation::Tagged(); 761 return Representation::Tagged();
750 } 762 }
751 763
752 764
753 } } // namespace v8::internal 765 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/type-info.h ('k') | src/typing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698