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

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

Issue 18465003: Fix default type feedback returned from the oracle (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: added comments Created 7 years, 5 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
« no previous file with comments | « src/hydrogen.cc ('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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (!code->is_load_stub()) return false; 349 if (!code->is_load_stub()) return false;
350 if (code->ic_state() != MONOMORPHIC) return false; 350 if (code->ic_state() != MONOMORPHIC) return false;
351 return stub->Describes(*code); 351 return stub->Describes(*code);
352 } 352 }
353 353
354 354
355 void TypeFeedbackOracle::CompareType(TypeFeedbackId id, 355 void TypeFeedbackOracle::CompareType(TypeFeedbackId id,
356 Handle<Type>* left_type, 356 Handle<Type>* left_type,
357 Handle<Type>* right_type, 357 Handle<Type>* right_type,
358 Handle<Type>* combined_type) { 358 Handle<Type>* combined_type) {
359 *left_type = *right_type = *combined_type = handle(Type::Any(), isolate_);
360 Handle<Object> info = GetInfo(id); 359 Handle<Object> info = GetInfo(id);
361 if (!info->IsCode()) return; 360 if (!info->IsCode()) {
361 // For some comparisons we don't have ICs, e.g. LiteralCompareTypeof.
362 *left_type = *right_type = *combined_type = handle(Type::None(), isolate_);
363 return;
364 }
362 Handle<Code> code = Handle<Code>::cast(info); 365 Handle<Code> code = Handle<Code>::cast(info);
363 366
364 Handle<Map> map; 367 Handle<Map> map;
365 Map* raw_map = code->FindFirstMap(); 368 Map* raw_map = code->FindFirstMap();
366 if (raw_map != NULL) { 369 if (raw_map != NULL) {
367 raw_map = raw_map->CurrentMapForDeprecated(); 370 raw_map = raw_map->CurrentMapForDeprecated();
368 if (raw_map != NULL && !CanRetainOtherContext(raw_map, *native_context_)) { 371 if (raw_map != NULL && !CanRetainOtherContext(raw_map, *native_context_)) {
369 map = handle(raw_map, isolate_); 372 map = handle(raw_map, isolate_);
370 } 373 }
371 } 374 }
372 375
373 if (code->is_compare_ic_stub()) { 376 if (code->is_compare_ic_stub()) {
374 int stub_minor_key = code->stub_info(); 377 int stub_minor_key = code->stub_info();
375 CompareIC::StubInfoToType( 378 CompareIC::StubInfoToType(
376 stub_minor_key, left_type, right_type, combined_type, map, isolate()); 379 stub_minor_key, left_type, right_type, combined_type, map, isolate());
377 } else if (code->is_compare_nil_ic_stub()) { 380 } else if (code->is_compare_nil_ic_stub()) {
378 CompareNilICStub::State state(code->compare_nil_state()); 381 CompareNilICStub::State state(code->compare_nil_state());
379 *combined_type = CompareNilICStub::StateToType(isolate_, state, map); 382 *combined_type = CompareNilICStub::StateToType(isolate_, state, map);
380 Handle<Type> nil_type = handle(code->compare_nil_value() == kNullValue 383 Handle<Type> nil_type = handle(code->compare_nil_value() == kNullValue
381 ? Type::Null() : Type::Undefined(), isolate_); 384 ? Type::Null() : Type::Undefined(), isolate_);
382 *left_type = *right_type = 385 *left_type = *right_type =
383 handle(Type::Union(*combined_type, nil_type), isolate_); 386 handle(Type::Union(*combined_type, nil_type), isolate_);
384 } 387 }
385 } 388 }
386 389
387 390
388 Handle<Type> TypeFeedbackOracle::UnaryType(TypeFeedbackId id) { 391 Handle<Type> TypeFeedbackOracle::UnaryType(TypeFeedbackId id) {
389 Handle<Object> object = GetInfo(id); 392 Handle<Object> object = GetInfo(id);
390 if (!object->IsCode()) return handle(Type::Any(), isolate()); 393 if (!object->IsCode()) {
394 return handle(Type::None(), isolate());
395 }
391 Handle<Code> code = Handle<Code>::cast(object); 396 Handle<Code> code = Handle<Code>::cast(object);
392 ASSERT(code->is_unary_op_stub()); 397 ASSERT(code->is_unary_op_stub());
393 return UnaryOpIC::TypeInfoToType( 398 return UnaryOpIC::TypeInfoToType(
394 static_cast<UnaryOpIC::TypeInfo>(code->unary_op_type()), isolate()); 399 static_cast<UnaryOpIC::TypeInfo>(code->unary_op_type()), isolate());
395 } 400 }
396 401
397 402
398 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, 403 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id,
399 Handle<Type>* left, 404 Handle<Type>* left,
400 Handle<Type>* right, 405 Handle<Type>* right,
401 Handle<Type>* result, 406 Handle<Type>* result,
402 Maybe<int>* fixed_right_arg) { 407 Maybe<int>* fixed_right_arg) {
403 Handle<Object> object = GetInfo(id); 408 Handle<Object> object = GetInfo(id);
404 *left = *right = *result = handle(Type::Any(), isolate_); 409 if (!object->IsCode()) {
405 if (!object->IsCode()) return; 410 // For some binary ops we don't have ICs, e.g. Token::COMMA.
411 *left = *right = *result = handle(Type::None(), isolate_);
412 return;
413 }
406 Handle<Code> code = Handle<Code>::cast(object); 414 Handle<Code> code = Handle<Code>::cast(object);
407 if (!code->is_binary_op_stub()) return; 415 ASSERT(code->is_binary_op_stub());
408 416
409 int minor_key = code->stub_info(); 417 int minor_key = code->stub_info();
410 BinaryOpIC::StubInfoToType(minor_key, left, right, result, isolate()); 418 BinaryOpIC::StubInfoToType(minor_key, left, right, result, isolate());
411 *fixed_right_arg = 419 *fixed_right_arg =
412 BinaryOpStub::decode_fixed_right_arg_from_minor_key(minor_key); 420 BinaryOpStub::decode_fixed_right_arg_from_minor_key(minor_key);
413 } 421 }
414 422
415 423
416 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { 424 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) {
417 Handle<Object> info = GetInfo(id); 425 Handle<Object> info = GetInfo(id);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 USE(maybe_result); 692 USE(maybe_result);
685 #ifdef DEBUG 693 #ifdef DEBUG
686 Object* result = NULL; 694 Object* result = NULL;
687 // Dictionary has been allocated with sufficient size for all elements. 695 // Dictionary has been allocated with sufficient size for all elements.
688 ASSERT(maybe_result->ToObject(&result)); 696 ASSERT(maybe_result->ToObject(&result));
689 ASSERT(*dictionary_ == result); 697 ASSERT(*dictionary_ == result);
690 #endif 698 #endif
691 } 699 }
692 700
693 } } // namespace v8::internal 701 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698