| 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 bool TypeFeedbackOracle::LoadIsStub(Property* expr, ICStub* stub) { | 334 bool TypeFeedbackOracle::LoadIsStub(Property* expr, ICStub* stub) { |
| 335 Handle<Object> object = GetInfo(expr->PropertyFeedbackId()); | 335 Handle<Object> object = GetInfo(expr->PropertyFeedbackId()); |
| 336 if (!object->IsCode()) return false; | 336 if (!object->IsCode()) return false; |
| 337 Handle<Code> code = Handle<Code>::cast(object); | 337 Handle<Code> code = Handle<Code>::cast(object); |
| 338 if (!code->is_load_stub()) return false; | 338 if (!code->is_load_stub()) return false; |
| 339 if (code->ic_state() != MONOMORPHIC) return false; | 339 if (code->ic_state() != MONOMORPHIC) return false; |
| 340 return stub->Describes(*code); | 340 return stub->Describes(*code); |
| 341 } | 341 } |
| 342 | 342 |
| 343 | 343 |
| 344 void TypeFeedbackOracle::CompareTypes(TypeFeedbackId id, | 344 void TypeFeedbackOracle::CompareType(TypeFeedbackId id, |
| 345 Handle<Type>* left_type, | 345 Handle<Type>* left_type, |
| 346 Handle<Type>* right_type, | 346 Handle<Type>* right_type, |
| 347 Handle<Type>* overall_type, | 347 Handle<Type>* combined_type) { |
| 348 Handle<Type>* compare_nil_type) { | 348 *left_type = *right_type = *combined_type = handle(Type::Any(), isolate_); |
| 349 *left_type = *right_type = *overall_type = *compare_nil_type = | |
| 350 handle(Type::Any(), isolate_); | |
| 351 Handle<Object> info = GetInfo(id); | 349 Handle<Object> info = GetInfo(id); |
| 352 if (!info->IsCode()) return; | 350 if (!info->IsCode()) return; |
| 353 Handle<Code> code = Handle<Code>::cast(info); | 351 Handle<Code> code = Handle<Code>::cast(info); |
| 354 | 352 |
| 355 Handle<Map> map; | 353 Handle<Map> map; |
| 356 Map* raw_map = code->FindFirstMap(); | 354 Map* raw_map = code->FindFirstMap(); |
| 357 if (raw_map != NULL) { | 355 if (raw_map != NULL) { |
| 358 raw_map = raw_map->CurrentMapForDeprecated(); | 356 raw_map = raw_map->CurrentMapForDeprecated(); |
| 359 if (raw_map != NULL && !CanRetainOtherContext(raw_map, *native_context_)) { | 357 if (raw_map != NULL && !CanRetainOtherContext(raw_map, *native_context_)) { |
| 360 map = handle(raw_map, isolate_); | 358 map = handle(raw_map, isolate_); |
| 361 } | 359 } |
| 362 } | 360 } |
| 363 | 361 |
| 364 if (code->is_compare_ic_stub()) { | 362 if (code->is_compare_ic_stub()) { |
| 365 int stub_minor_key = code->stub_info(); | 363 int stub_minor_key = code->stub_info(); |
| 366 CompareIC::StubInfoToType( | 364 CompareIC::StubInfoToType( |
| 367 stub_minor_key, left_type, right_type, overall_type, map, isolate()); | 365 stub_minor_key, left_type, right_type, combined_type, map, isolate()); |
| 368 } else if (code->is_compare_nil_ic_stub()) { | 366 } else if (code->is_compare_nil_ic_stub()) { |
| 369 CompareNilICStub::State state(code->compare_nil_state()); | 367 CompareNilICStub::State state(code->compare_nil_state()); |
| 370 *compare_nil_type = CompareNilICStub::StateToType(isolate_, state, map); | 368 *combined_type = CompareNilICStub::StateToType(isolate_, state, map); |
| 369 Handle<Type> nil_type = handle(code->compare_nil_value() == kNullValue |
| 370 ? Type::Null() : Type::Undefined(), isolate_); |
| 371 *left_type = *right_type = |
| 372 handle(Type::Union(*combined_type, nil_type), isolate_); |
| 371 } | 373 } |
| 372 } | 374 } |
| 373 | 375 |
| 374 | 376 |
| 375 Handle<Type> TypeFeedbackOracle::UnaryType(TypeFeedbackId id) { | 377 Handle<Type> TypeFeedbackOracle::UnaryType(TypeFeedbackId id) { |
| 376 Handle<Object> object = GetInfo(id); | 378 Handle<Object> object = GetInfo(id); |
| 377 if (!object->IsCode()) return handle(Type::Any(), isolate()); | 379 if (!object->IsCode()) return handle(Type::Any(), isolate()); |
| 378 Handle<Code> code = Handle<Code>::cast(object); | 380 Handle<Code> code = Handle<Code>::cast(object); |
| 379 ASSERT(code->is_unary_op_stub()); | 381 ASSERT(code->is_unary_op_stub()); |
| 380 return UnaryOpIC::TypeInfoToType( | 382 return UnaryOpIC::TypeInfoToType( |
| 381 static_cast<UnaryOpIC::TypeInfo>(code->unary_op_type()), isolate()); | 383 static_cast<UnaryOpIC::TypeInfo>(code->unary_op_type()), isolate()); |
| 382 } | 384 } |
| 383 | 385 |
| 384 | 386 |
| 385 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, | 387 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, |
| 386 Handle<Type>* left, | 388 Handle<Type>* left, |
| 387 Handle<Type>* right, | 389 Handle<Type>* right, |
| 388 Handle<Type>* result, | 390 Handle<Type>* result, |
| 389 bool* has_fixed_right_arg, | 391 Maybe<int>* fixed_right_arg) { |
| 390 int* fixed_right_arg_value) { | |
| 391 Handle<Object> object = GetInfo(id); | 392 Handle<Object> object = GetInfo(id); |
| 392 *left = *right = *result = handle(Type::Any(), isolate_); | 393 *left = *right = *result = handle(Type::Any(), isolate_); |
| 393 if (!object->IsCode()) return; | 394 if (!object->IsCode()) return; |
| 394 Handle<Code> code = Handle<Code>::cast(object); | 395 Handle<Code> code = Handle<Code>::cast(object); |
| 395 if (!code->is_binary_op_stub()) return; | 396 if (!code->is_binary_op_stub()) return; |
| 396 | 397 |
| 397 int minor_key = code->stub_info(); | 398 int minor_key = code->stub_info(); |
| 398 BinaryOpIC::StubInfoToType(minor_key, left, right, result, isolate()); | 399 BinaryOpIC::StubInfoToType(minor_key, left, right, result, isolate()); |
| 399 *has_fixed_right_arg = | 400 *fixed_right_arg = |
| 400 BinaryOpStub::decode_has_fixed_right_arg_from_minor_key(minor_key); | 401 BinaryOpStub::decode_fixed_right_arg_from_minor_key(minor_key); |
| 401 *fixed_right_arg_value = | |
| 402 BinaryOpStub::decode_fixed_right_arg_value_from_minor_key(minor_key); | |
| 403 } | 402 } |
| 404 | 403 |
| 405 | 404 |
| 406 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { | 405 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { |
| 407 Handle<Object> info = GetInfo(id); | 406 Handle<Object> info = GetInfo(id); |
| 408 Handle<Type> result(Type::None(), isolate_); | 407 Handle<Type> result(Type::None(), isolate_); |
| 409 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) { | 408 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) { |
| 410 Handle<Code> code = Handle<Code>::cast(info); | 409 Handle<Code> code = Handle<Code>::cast(info); |
| 411 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); | 410 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); |
| 412 result = CompareIC::StateToType(isolate_, state); | 411 result = CompareIC::StateToType(isolate_, state); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 USE(maybe_result); | 672 USE(maybe_result); |
| 674 #ifdef DEBUG | 673 #ifdef DEBUG |
| 675 Object* result = NULL; | 674 Object* result = NULL; |
| 676 // Dictionary has been allocated with sufficient size for all elements. | 675 // Dictionary has been allocated with sufficient size for all elements. |
| 677 ASSERT(maybe_result->ToObject(&result)); | 676 ASSERT(maybe_result->ToObject(&result)); |
| 678 ASSERT(*dictionary_ == result); | 677 ASSERT(*dictionary_ == result); |
| 679 #endif | 678 #endif |
| 680 } | 679 } |
| 681 | 680 |
| 682 } } // namespace v8::internal | 681 } } // namespace v8::internal |
| OLD | NEW |