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

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

Issue 16957004: Migrate BinaryOpICs and UnaryOpICs to new type rep (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 6 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
« src/hydrogen.cc ('K') | « src/type-info.h ('k') | no next file » | 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 Map* raw_map = code->FindFirstMap(); 356 Map* raw_map = code->FindFirstMap();
357 if (raw_map != NULL) { 357 if (raw_map != NULL) {
358 raw_map = raw_map->CurrentMapForDeprecated(); 358 raw_map = raw_map->CurrentMapForDeprecated();
359 if (!CanRetainOtherContext(raw_map, *native_context_)) { 359 if (!CanRetainOtherContext(raw_map, *native_context_)) {
360 map = handle(raw_map, isolate_); 360 map = handle(raw_map, isolate_);
361 } 361 }
362 } 362 }
363 363
364 if (code->is_compare_ic_stub()) { 364 if (code->is_compare_ic_stub()) {
365 int stub_minor_key = code->stub_info(); 365 int stub_minor_key = code->stub_info();
366 CompareIC::State left_state, right_state, handler_state; 366 CompareIC::StubInfoToType(
367 ICCompareStub::DecodeMinorKey(stub_minor_key, &left_state, &right_state, 367 stub_minor_key, left_type, right_type, overall_type, map, isolate());
368 &handler_state, NULL);
369 *left_type = CompareIC::StateToType(isolate_, left_state);
370 *right_type = CompareIC::StateToType(isolate_, right_state);
371 *overall_type = CompareIC::StateToType(isolate_, handler_state, map);
372 } else if (code->is_compare_nil_ic_stub()) { 368 } else if (code->is_compare_nil_ic_stub()) {
373 CompareNilICStub::State state(code->compare_nil_state()); 369 CompareNilICStub::State state(code->compare_nil_state());
374 *compare_nil_type = CompareNilICStub::StateToType(isolate_, state, map); 370 *compare_nil_type = CompareNilICStub::StateToType(isolate_, state, map);
375 } 371 }
376 } 372 }
377 373
378 374
379 TypeInfo TypeFeedbackOracle::UnaryType(UnaryOperation* expr) { 375 Handle<Type> TypeFeedbackOracle::UnaryType(TypeFeedbackId id) {
380 Handle<Object> object = GetInfo(expr->UnaryOperationFeedbackId()); 376 Handle<Object> object = GetInfo(id);
381 TypeInfo unknown = TypeInfo::Unknown(); 377 if (!object->IsCode()) return handle(Type::Any(), isolate());
382 if (!object->IsCode()) return unknown;
383 Handle<Code> code = Handle<Code>::cast(object); 378 Handle<Code> code = Handle<Code>::cast(object);
384 ASSERT(code->is_unary_op_stub()); 379 ASSERT(code->is_unary_op_stub());
385 UnaryOpIC::TypeInfo type = static_cast<UnaryOpIC::TypeInfo>( 380 return UnaryOpIC::TypeInfoToType(
386 code->unary_op_type()); 381 static_cast<UnaryOpIC::TypeInfo>(code->unary_op_type()), isolate());
387 switch (type) {
388 case UnaryOpIC::SMI:
389 return TypeInfo::Smi();
390 case UnaryOpIC::NUMBER:
391 return TypeInfo::Double();
392 default:
393 return unknown;
394 }
395 } 382 }
396 383
397 384
398 static TypeInfo TypeFromBinaryOpType(BinaryOpIC::TypeInfo binary_type) { 385 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id,
399 switch (binary_type) { 386 Handle<Type>* left,
400 // Uninitialized means never executed. 387 Handle<Type>* right,
401 case BinaryOpIC::UNINITIALIZED: return TypeInfo::Uninitialized(); 388 Handle<Type>* result,
402 case BinaryOpIC::SMI: return TypeInfo::Smi(); 389 bool* has_fixed_right_arg,
403 case BinaryOpIC::INT32: return TypeInfo::Integer32(); 390 int* fixed_right_arg_value) {
404 case BinaryOpIC::NUMBER: return TypeInfo::Double(); 391 Handle<Object> object = GetInfo(id);
405 case BinaryOpIC::ODDBALL: return TypeInfo::Unknown(); 392 *left = *right = *result = handle(Type::Any(), isolate_);
406 case BinaryOpIC::STRING: return TypeInfo::String(); 393 if (!object->IsCode()) return;
407 case BinaryOpIC::GENERIC: return TypeInfo::Unknown(); 394 Handle<Code> code = Handle<Code>::cast(object);
408 } 395 if (!code->is_binary_op_stub()) return;
409 UNREACHABLE(); 396
410 return TypeInfo::Unknown(); 397 int minor_key = code->stub_info();
398 BinaryOpIC::StubInfoToType(minor_key, left, right, result, isolate());
399 *has_fixed_right_arg =
400 BinaryOpStub::decode_has_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);
411 } 403 }
412 404
413 405
414 void TypeFeedbackOracle::BinaryType(BinaryOperation* expr,
415 TypeInfo* left,
416 TypeInfo* right,
417 TypeInfo* result,
418 bool* has_fixed_right_arg,
419 int* fixed_right_arg_value) {
420 Handle<Object> object = GetInfo(expr->BinaryOperationFeedbackId());
421 TypeInfo unknown = TypeInfo::Unknown();
422 if (!object->IsCode()) {
423 *left = *right = *result = unknown;
424 return;
425 }
426 Handle<Code> code = Handle<Code>::cast(object);
427 if (code->is_binary_op_stub()) {
428 int minor_key = code->stub_info();
429 BinaryOpIC::TypeInfo left_type, right_type, result_type;
430 BinaryOpStub::decode_types_from_minor_key(
431 minor_key, &left_type, &right_type, &result_type);
432 *left = TypeFromBinaryOpType(left_type);
433 *right = TypeFromBinaryOpType(right_type);
434 *result = TypeFromBinaryOpType(result_type);
435 *has_fixed_right_arg =
436 BinaryOpStub::decode_has_fixed_right_arg_from_minor_key(minor_key);
437 *fixed_right_arg_value =
438 BinaryOpStub::decode_fixed_right_arg_value_from_minor_key(minor_key);
439 return;
440 }
441 // Not a binary op stub.
442 *left = *right = *result = unknown;
443 }
444
445
446 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { 406 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) {
447 Handle<Object> info = GetInfo(id); 407 Handle<Object> info = GetInfo(id);
448 Handle<Type> result(Type::None(), isolate_); 408 Handle<Type> result(Type::None(), isolate_);
449 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) { 409 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) {
450 Handle<Code> code = Handle<Code>::cast(info); 410 Handle<Code> code = Handle<Code>::cast(info);
451 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); 411 CompareIC::State state = ICCompareStub::CompareState(code->stub_info());
452 result = CompareIC::StateToType(isolate_, state); 412 result = CompareIC::StateToType(isolate_, state);
453 } 413 }
454 return result; 414 return result;
455 } 415 }
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 USE(maybe_result); 673 USE(maybe_result);
714 #ifdef DEBUG 674 #ifdef DEBUG
715 Object* result = NULL; 675 Object* result = NULL;
716 // Dictionary has been allocated with sufficient size for all elements. 676 // Dictionary has been allocated with sufficient size for all elements.
717 ASSERT(maybe_result->ToObject(&result)); 677 ASSERT(maybe_result->ToObject(&result));
718 ASSERT(*dictionary_ == result); 678 ASSERT(*dictionary_ == result);
719 #endif 679 #endif
720 } 680 }
721 681
722 } } // namespace v8::internal 682 } } // namespace v8::internal
OLDNEW
« src/hydrogen.cc ('K') | « src/type-info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698