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