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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 *combined_type = stub.GetType(isolate_, map); | 374 *combined_type = stub.GetType(isolate_, map); |
375 *left_type = *right_type = stub.GetInputType(isolate_, map); | 375 *left_type = *right_type = stub.GetInputType(isolate_, map); |
376 } | 376 } |
377 } | 377 } |
378 | 378 |
379 | 379 |
380 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, | 380 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, |
381 Handle<Type>* left, | 381 Handle<Type>* left, |
382 Handle<Type>* right, | 382 Handle<Type>* right, |
383 Handle<Type>* result, | 383 Handle<Type>* result, |
384 Maybe<int>* fixed_right_arg) { | 384 Maybe<int>* fixed_right_arg, |
| 385 Token::Value operation) { |
385 Handle<Object> object = GetInfo(id); | 386 Handle<Object> object = GetInfo(id); |
386 if (!object->IsCode()) { | 387 if (!object->IsCode()) { |
387 // For some binary ops we don't have ICs, e.g. Token::COMMA. | 388 // For some binary ops we don't have ICs, e.g. Token::COMMA, but for the |
| 389 // operations covered by the BinaryOpStub we should always have them. |
| 390 ASSERT(!(operation >= BinaryOpStub::FIRST_TOKEN && |
| 391 operation <= BinaryOpStub::LAST_TOKEN)); |
388 *left = *right = *result = handle(Type::None(), isolate_); | 392 *left = *right = *result = handle(Type::None(), isolate_); |
389 return; | 393 return; |
390 } | 394 } |
391 Handle<Code> code = Handle<Code>::cast(object); | 395 Handle<Code> code = Handle<Code>::cast(object); |
392 ASSERT(code->is_binary_op_stub()); | 396 ASSERT(code->is_binary_op_stub()); |
393 | 397 |
394 int minor_key = code->stub_info(); | 398 BinaryOpStub stub(code->extended_extra_ic_state()); |
395 BinaryOpIC::StubInfoToType(minor_key, left, right, result, isolate()); | 399 |
396 *fixed_right_arg = | 400 // Sanity check. |
397 BinaryOpStub::decode_fixed_right_arg_from_minor_key(minor_key); | 401 ASSERT(stub.operation() == operation); |
| 402 |
| 403 *left = stub.GetLeftType(isolate()); |
| 404 *right = stub.GetRightType(isolate()); |
| 405 *result = stub.GetResultType(isolate()); |
| 406 *fixed_right_arg = stub.fixed_right_arg(); |
398 } | 407 } |
399 | 408 |
400 | 409 |
401 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { | 410 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { |
402 Handle<Object> info = GetInfo(id); | 411 Handle<Object> info = GetInfo(id); |
403 Handle<Type> result(Type::None(), isolate_); | 412 Handle<Type> result(Type::None(), isolate_); |
404 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) { | 413 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) { |
405 Handle<Code> code = Handle<Code>::cast(info); | 414 Handle<Code> code = Handle<Code>::cast(info); |
406 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); | 415 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); |
407 result = CompareIC::StateToType(isolate_, state); | 416 result = CompareIC::StateToType(isolate_, state); |
408 } | 417 } |
409 return result; | 418 return result; |
410 } | 419 } |
411 | 420 |
412 | 421 |
413 TypeInfo TypeFeedbackOracle::IncrementType(CountOperation* expr) { | 422 Handle<Type> TypeFeedbackOracle::IncrementType(CountOperation* expr) { |
414 Handle<Object> object = GetInfo(expr->CountBinOpFeedbackId()); | 423 Handle<Object> object = GetInfo(expr->CountBinOpFeedbackId()); |
415 TypeInfo unknown = TypeInfo::Unknown(); | 424 Handle<Type> unknown(Type::None(), isolate_); |
416 if (!object->IsCode()) return unknown; | 425 if (!object->IsCode()) return unknown; |
417 Handle<Code> code = Handle<Code>::cast(object); | 426 Handle<Code> code = Handle<Code>::cast(object); |
418 if (!code->is_binary_op_stub()) return unknown; | 427 if (!code->is_binary_op_stub()) return unknown; |
419 | 428 |
420 BinaryOpIC::TypeInfo left_type, right_type, unused_result_type; | 429 BinaryOpStub stub(code->extended_extra_ic_state()); |
421 BinaryOpStub::decode_types_from_minor_key(code->stub_info(), &left_type, | 430 return stub.GetLeftType(isolate()); |
422 &right_type, &unused_result_type); | |
423 // CountOperations should always have +1 or -1 as their right input. | |
424 ASSERT(right_type == BinaryOpIC::SMI || | |
425 right_type == BinaryOpIC::UNINITIALIZED); | |
426 | |
427 switch (left_type) { | |
428 case BinaryOpIC::UNINITIALIZED: | |
429 case BinaryOpIC::SMI: | |
430 return TypeInfo::Smi(); | |
431 case BinaryOpIC::INT32: | |
432 return TypeInfo::Integer32(); | |
433 case BinaryOpIC::NUMBER: | |
434 return TypeInfo::Double(); | |
435 case BinaryOpIC::STRING: | |
436 case BinaryOpIC::GENERIC: | |
437 return unknown; | |
438 default: | |
439 return unknown; | |
440 } | |
441 UNREACHABLE(); | |
442 return unknown; | |
443 } | 431 } |
444 | 432 |
445 | 433 |
446 void TypeFeedbackOracle::CollectPolymorphicMaps(Handle<Code> code, | 434 void TypeFeedbackOracle::CollectPolymorphicMaps(Handle<Code> code, |
447 SmallMapList* types) { | 435 SmallMapList* types) { |
448 MapHandleList maps; | 436 MapHandleList maps; |
449 code->FindAllMaps(&maps); | 437 code->FindAllMaps(&maps); |
450 types->Reserve(maps.length(), zone()); | 438 types->Reserve(maps.length(), zone()); |
451 for (int i = 0; i < maps.length(); i++) { | 439 for (int i = 0; i < maps.length(); i++) { |
452 Handle<Map> map(maps.at(i)); | 440 Handle<Map> map(maps.at(i)); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 if (info.IsUninitialized()) return Representation::None(); | 680 if (info.IsUninitialized()) return Representation::None(); |
693 if (info.IsSmi()) return Representation::Smi(); | 681 if (info.IsSmi()) return Representation::Smi(); |
694 if (info.IsInteger32()) return Representation::Integer32(); | 682 if (info.IsInteger32()) return Representation::Integer32(); |
695 if (info.IsDouble()) return Representation::Double(); | 683 if (info.IsDouble()) return Representation::Double(); |
696 if (info.IsNumber()) return Representation::Double(); | 684 if (info.IsNumber()) return Representation::Double(); |
697 return Representation::Tagged(); | 685 return Representation::Tagged(); |
698 } | 686 } |
699 | 687 |
700 | 688 |
701 } } // namespace v8::internal | 689 } } // namespace v8::internal |
OLD | NEW |