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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 314 } |
315 | 315 |
316 | 316 |
317 static TypeInfo TypeFromCompareType(CompareIC::State state) { | 317 static TypeInfo TypeFromCompareType(CompareIC::State state) { |
318 switch (state) { | 318 switch (state) { |
319 case CompareIC::UNINITIALIZED: | 319 case CompareIC::UNINITIALIZED: |
320 // Uninitialized means never executed. | 320 // Uninitialized means never executed. |
321 return TypeInfo::Uninitialized(); | 321 return TypeInfo::Uninitialized(); |
322 case CompareIC::SMI: | 322 case CompareIC::SMI: |
323 return TypeInfo::Smi(); | 323 return TypeInfo::Smi(); |
324 case CompareIC::HEAP_NUMBER: | 324 case CompareIC::NUMBER: |
325 return TypeInfo::Number(); | 325 return TypeInfo::Number(); |
326 case CompareIC::SYMBOL: | 326 case CompareIC::SYMBOL: |
327 return TypeInfo::Symbol(); | 327 return TypeInfo::Symbol(); |
328 case CompareIC::STRING: | 328 case CompareIC::STRING: |
329 return TypeInfo::String(); | 329 return TypeInfo::String(); |
330 case CompareIC::OBJECT: | 330 case CompareIC::OBJECT: |
331 case CompareIC::KNOWN_OBJECTS: | 331 case CompareIC::KNOWN_OBJECT: |
332 // TODO(kasperl): We really need a type for JS objects here. | 332 // TODO(kasperl): We really need a type for JS objects here. |
333 return TypeInfo::NonPrimitive(); | 333 return TypeInfo::NonPrimitive(); |
334 case CompareIC::GENERIC: | 334 case CompareIC::GENERIC: |
335 default: | 335 default: |
336 return TypeInfo::Unknown(); | 336 return TypeInfo::Unknown(); |
337 } | 337 } |
338 } | 338 } |
339 | 339 |
340 | 340 |
341 void TypeFeedbackOracle::CompareType(CompareOperation* expr, | 341 void TypeFeedbackOracle::CompareType(CompareOperation* expr, |
(...skipping 21 matching lines...) Expand all Loading... |
363 *overall_type = TypeFromCompareType(handler_state); | 363 *overall_type = TypeFromCompareType(handler_state); |
364 } | 364 } |
365 | 365 |
366 | 366 |
367 Handle<Map> TypeFeedbackOracle::GetCompareMap(CompareOperation* expr) { | 367 Handle<Map> TypeFeedbackOracle::GetCompareMap(CompareOperation* expr) { |
368 Handle<Object> object = GetInfo(expr->CompareOperationFeedbackId()); | 368 Handle<Object> object = GetInfo(expr->CompareOperationFeedbackId()); |
369 if (!object->IsCode()) return Handle<Map>::null(); | 369 if (!object->IsCode()) return Handle<Map>::null(); |
370 Handle<Code> code = Handle<Code>::cast(object); | 370 Handle<Code> code = Handle<Code>::cast(object); |
371 if (!code->is_compare_ic_stub()) return Handle<Map>::null(); | 371 if (!code->is_compare_ic_stub()) return Handle<Map>::null(); |
372 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); | 372 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); |
373 if (state != CompareIC::KNOWN_OBJECTS) { | 373 if (state != CompareIC::KNOWN_OBJECT) { |
374 return Handle<Map>::null(); | 374 return Handle<Map>::null(); |
375 } | 375 } |
376 Map* first_map = code->FindFirstMap(); | 376 Map* first_map = code->FindFirstMap(); |
377 ASSERT(first_map != NULL); | 377 ASSERT(first_map != NULL); |
378 return CanRetainOtherContext(first_map, *native_context_) | 378 return CanRetainOtherContext(first_map, *native_context_) |
379 ? Handle<Map>::null() | 379 ? Handle<Map>::null() |
380 : Handle<Map>(first_map); | 380 : Handle<Map>(first_map); |
381 } | 381 } |
382 | 382 |
383 | 383 |
384 TypeInfo TypeFeedbackOracle::UnaryType(UnaryOperation* expr) { | 384 TypeInfo TypeFeedbackOracle::UnaryType(UnaryOperation* expr) { |
385 Handle<Object> object = GetInfo(expr->UnaryOperationFeedbackId()); | 385 Handle<Object> object = GetInfo(expr->UnaryOperationFeedbackId()); |
386 TypeInfo unknown = TypeInfo::Unknown(); | 386 TypeInfo unknown = TypeInfo::Unknown(); |
387 if (!object->IsCode()) return unknown; | 387 if (!object->IsCode()) return unknown; |
388 Handle<Code> code = Handle<Code>::cast(object); | 388 Handle<Code> code = Handle<Code>::cast(object); |
389 ASSERT(code->is_unary_op_stub()); | 389 ASSERT(code->is_unary_op_stub()); |
390 UnaryOpIC::TypeInfo type = static_cast<UnaryOpIC::TypeInfo>( | 390 UnaryOpIC::TypeInfo type = static_cast<UnaryOpIC::TypeInfo>( |
391 code->unary_op_type()); | 391 code->unary_op_type()); |
392 switch (type) { | 392 switch (type) { |
393 case UnaryOpIC::SMI: | 393 case UnaryOpIC::SMI: |
394 return TypeInfo::Smi(); | 394 return TypeInfo::Smi(); |
395 case UnaryOpIC::HEAP_NUMBER: | 395 case UnaryOpIC::NUMBER: |
396 return TypeInfo::Double(); | 396 return TypeInfo::Double(); |
397 default: | 397 default: |
398 return unknown; | 398 return unknown; |
399 } | 399 } |
400 } | 400 } |
401 | 401 |
402 | 402 |
403 static TypeInfo TypeFromBinaryOpType(BinaryOpIC::TypeInfo binary_type) { | 403 static TypeInfo TypeFromBinaryOpType(BinaryOpIC::TypeInfo binary_type) { |
404 switch (binary_type) { | 404 switch (binary_type) { |
405 // Uninitialized means never executed. | 405 // Uninitialized means never executed. |
406 case BinaryOpIC::UNINITIALIZED: return TypeInfo::Uninitialized(); | 406 case BinaryOpIC::UNINITIALIZED: return TypeInfo::Uninitialized(); |
407 case BinaryOpIC::SMI: return TypeInfo::Smi(); | 407 case BinaryOpIC::SMI: return TypeInfo::Smi(); |
408 case BinaryOpIC::INT32: return TypeInfo::Integer32(); | 408 case BinaryOpIC::INT32: return TypeInfo::Integer32(); |
409 case BinaryOpIC::HEAP_NUMBER: return TypeInfo::Double(); | 409 case BinaryOpIC::NUMBER: return TypeInfo::Double(); |
410 case BinaryOpIC::ODDBALL: return TypeInfo::Unknown(); | 410 case BinaryOpIC::ODDBALL: return TypeInfo::Unknown(); |
411 case BinaryOpIC::STRING: return TypeInfo::String(); | 411 case BinaryOpIC::STRING: return TypeInfo::String(); |
412 case BinaryOpIC::GENERIC: return TypeInfo::Unknown(); | 412 case BinaryOpIC::GENERIC: return TypeInfo::Unknown(); |
413 } | 413 } |
414 UNREACHABLE(); | 414 UNREACHABLE(); |
415 return TypeInfo::Unknown(); | 415 return TypeInfo::Unknown(); |
416 } | 416 } |
417 | 417 |
418 | 418 |
419 void TypeFeedbackOracle::BinaryType(BinaryOperation* expr, | 419 void TypeFeedbackOracle::BinaryType(BinaryOperation* expr, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 // CountOperations should always have +1 or -1 as their right input. | 466 // CountOperations should always have +1 or -1 as their right input. |
467 ASSERT(right_type == BinaryOpIC::SMI || | 467 ASSERT(right_type == BinaryOpIC::SMI || |
468 right_type == BinaryOpIC::UNINITIALIZED); | 468 right_type == BinaryOpIC::UNINITIALIZED); |
469 | 469 |
470 switch (left_type) { | 470 switch (left_type) { |
471 case BinaryOpIC::UNINITIALIZED: | 471 case BinaryOpIC::UNINITIALIZED: |
472 case BinaryOpIC::SMI: | 472 case BinaryOpIC::SMI: |
473 return TypeInfo::Smi(); | 473 return TypeInfo::Smi(); |
474 case BinaryOpIC::INT32: | 474 case BinaryOpIC::INT32: |
475 return TypeInfo::Integer32(); | 475 return TypeInfo::Integer32(); |
476 case BinaryOpIC::HEAP_NUMBER: | 476 case BinaryOpIC::NUMBER: |
477 return TypeInfo::Double(); | 477 return TypeInfo::Double(); |
478 case BinaryOpIC::STRING: | 478 case BinaryOpIC::STRING: |
479 case BinaryOpIC::GENERIC: | 479 case BinaryOpIC::GENERIC: |
480 return unknown; | 480 return unknown; |
481 default: | 481 default: |
482 return unknown; | 482 return unknown; |
483 } | 483 } |
484 UNREACHABLE(); | 484 UNREACHABLE(); |
485 return unknown; | 485 return unknown; |
486 } | 486 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 USE(maybe_result); | 712 USE(maybe_result); |
713 #ifdef DEBUG | 713 #ifdef DEBUG |
714 Object* result = NULL; | 714 Object* result = NULL; |
715 // Dictionary has been allocated with sufficient size for all elements. | 715 // Dictionary has been allocated with sufficient size for all elements. |
716 ASSERT(maybe_result->ToObject(&result)); | 716 ASSERT(maybe_result->ToObject(&result)); |
717 ASSERT(*dictionary_ == result); | 717 ASSERT(*dictionary_ == result); |
718 #endif | 718 #endif |
719 } | 719 } |
720 | 720 |
721 } } // namespace v8::internal | 721 } } // namespace v8::internal |
OLD | NEW |