Chromium Code Reviews| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 CODE_STUB_LIST(DEF_CASE) | 176 CODE_STUB_LIST(DEF_CASE) |
| 177 #undef DEF_CASE | 177 #undef DEF_CASE |
| 178 default: | 178 default: |
| 179 if (!allow_unknown_keys) { | 179 if (!allow_unknown_keys) { |
| 180 UNREACHABLE(); | 180 UNREACHABLE(); |
| 181 } | 181 } |
| 182 return NULL; | 182 return NULL; |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 void CodeStub::PrintBaseName(StringStream* stream) { | |
| 187 stream->Add("%s", MajorName(MajorKey(), false)); | |
| 188 } | |
| 189 | |
| 190 | |
| 191 void CodeStub::PrintName(StringStream* stream) { | |
| 192 PrintBaseName(stream); | |
| 193 PrintState(stream); | |
| 194 } | |
| 195 | |
| 196 | |
| 197 Builtins::JavaScript UnaryOpStub::ToJSBuiltin() { | |
| 198 switch (operation_) { | |
| 199 default: | |
| 200 UNREACHABLE(); | |
| 201 case Token::SUB: | |
| 202 return Builtins::UNARY_MINUS; | |
| 203 case Token::BIT_NOT: | |
| 204 return Builtins::BIT_NOT; | |
| 205 } | |
| 206 } | |
| 207 | |
| 186 | 208 |
| 187 void CodeStub::PrintName(StringStream* stream) { | 209 Handle<JSFunction> UnaryOpStub::ToJSFunction(Isolate* isolate) { |
| 188 stream->Add("%s", MajorName(MajorKey(), false)); | 210 Handle<JSBuiltinsObject> builtins(isolate->js_builtins_object()); |
| 211 Object* builtin = builtins->javascript_builtin(ToJSBuiltin()); | |
| 212 return Handle<JSFunction>(JSFunction::cast(builtin), isolate); | |
| 213 } | |
| 214 | |
|
danno
2013/06/21 16:38:04
nit: two empty lines, please
| |
| 215 MaybeObject* UnaryOpStub::Result(Handle<Object> object, Isolate* isolate) { | |
| 216 Handle<JSFunction> builtin_function = ToJSFunction(isolate); | |
| 217 bool caught_exception; | |
| 218 Handle<Object> result = Execution::Call(builtin_function, object, | |
| 219 0, NULL, &caught_exception); | |
| 220 if (caught_exception) { | |
| 221 return Failure::Exception(); | |
| 222 } | |
| 223 return *result; | |
| 189 } | 224 } |
| 190 | 225 |
| 191 | 226 |
| 227 void UnaryOpStub::Record(Handle<Object> object) { | |
|
danno
2013/06/21 16:38:04
UpdateState?
| |
| 228 State old_state(state_); | |
| 229 if (object->IsSmi()) { | |
| 230 state_.Add(SMI); | |
| 231 if (operation_ == Token::SUB && *object == 0) { | |
| 232 // The result (-0) has to be represented as double. | |
| 233 state_.Add(HEAP_NUMBER); | |
| 234 } | |
| 235 } else if (object->IsHeapNumber()) { | |
| 236 state_.Add(HEAP_NUMBER); | |
| 237 } else { | |
| 238 state_.Add(GENERIC); | |
| 239 } | |
| 240 TraceTransition(old_state, state_); | |
| 241 } | |
| 242 | |
|
danno
2013/06/21 16:38:04
nit: two spaces between functions
| |
| 243 Handle<Type> UnaryOpStub::GetType(Isolate* isolate) { | |
| 244 if (state_.Contains(GENERIC)) { | |
| 245 return handle(Type::Any(), isolate); | |
| 246 } | |
| 247 Handle<Type> type = handle(Type::None(), isolate); | |
| 248 if (state_.Contains(SMI)) { | |
| 249 type = handle( | |
| 250 Type::Union(type, handle(Type::Integer31(), isolate)), isolate); | |
| 251 } | |
| 252 if (state_.Contains(HEAP_NUMBER)) { | |
| 253 type = handle( | |
| 254 Type::Union(type, handle(Type::Double(), isolate)), isolate); | |
| 255 } | |
| 256 return type; | |
| 257 } | |
| 258 | |
| 259 | |
| 192 void BinaryOpStub::Generate(MacroAssembler* masm) { | 260 void BinaryOpStub::Generate(MacroAssembler* masm) { |
| 193 // Explicitly allow generation of nested stubs. It is safe here because | 261 // Explicitly allow generation of nested stubs. It is safe here because |
| 194 // generation code does not use any raw pointers. | 262 // generation code does not use any raw pointers. |
| 195 AllowStubCallsScope allow_stub_calls(masm, true); | 263 AllowStubCallsScope allow_stub_calls(masm, true); |
| 196 | 264 |
| 197 BinaryOpIC::TypeInfo operands_type = Max(left_type_, right_type_); | 265 BinaryOpIC::TypeInfo operands_type = Max(left_type_, right_type_); |
| 198 if (left_type_ == BinaryOpIC::ODDBALL && right_type_ == BinaryOpIC::ODDBALL) { | 266 if (left_type_ == BinaryOpIC::ODDBALL && right_type_ == BinaryOpIC::ODDBALL) { |
| 199 // The OddballStub handles a number and an oddball, not two oddballs. | 267 // The OddballStub handles a number and an oddball, not two oddballs. |
| 200 operands_type = BinaryOpIC::GENERIC; | 268 operands_type = BinaryOpIC::GENERIC; |
| 201 } | 269 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 break; | 335 break; |
| 268 default: | 336 default: |
| 269 UNREACHABLE(); | 337 UNREACHABLE(); |
| 270 } | 338 } |
| 271 } | 339 } |
| 272 | 340 |
| 273 | 341 |
| 274 #undef __ | 342 #undef __ |
| 275 | 343 |
| 276 | 344 |
| 345 void UnaryOpStub::PrintBaseName(StringStream* stream) { | |
| 346 CodeStub::PrintBaseName(stream); | |
| 347 if (operation_ == Token::SUB) stream->Add("Minus"); | |
| 348 if (operation_ == Token::BIT_NOT) stream->Add("Not"); | |
| 349 } | |
| 350 | |
| 351 | |
| 352 void UnaryOpStub::PrintState(StringStream* stream) { | |
| 353 state_.Print(stream); | |
| 354 } | |
| 355 | |
| 356 | |
| 357 void UnaryOpStub::State::Print(StringStream* stream) const { | |
| 358 stream->Add("("); | |
| 359 SimpleListPrinter printer(stream); | |
| 360 if (IsEmpty()) printer.Add("None"); | |
| 361 if (Contains(GENERIC)) printer.Add("Generic"); | |
| 362 if (Contains(HEAP_NUMBER)) printer.Add("HeapNumber"); | |
| 363 if (Contains(SMI)) printer.Add("Smi"); | |
| 364 stream->Add(")"); | |
| 365 } | |
| 366 | |
| 367 | |
| 277 void BinaryOpStub::PrintName(StringStream* stream) { | 368 void BinaryOpStub::PrintName(StringStream* stream) { |
| 278 const char* op_name = Token::Name(op_); | 369 const char* op_name = Token::Name(op_); |
| 279 const char* overwrite_name; | 370 const char* overwrite_name; |
| 280 switch (mode_) { | 371 switch (mode_) { |
| 281 case NO_OVERWRITE: overwrite_name = "Alloc"; break; | 372 case NO_OVERWRITE: overwrite_name = "Alloc"; break; |
| 282 case OVERWRITE_RIGHT: overwrite_name = "OverwriteRight"; break; | 373 case OVERWRITE_RIGHT: overwrite_name = "OverwriteRight"; break; |
| 283 case OVERWRITE_LEFT: overwrite_name = "OverwriteLeft"; break; | 374 case OVERWRITE_LEFT: overwrite_name = "OverwriteLeft"; break; |
| 284 default: overwrite_name = "UnknownOverwrite"; break; | 375 default: overwrite_name = "UnknownOverwrite"; break; |
| 285 } | 376 } |
| 286 stream->Add("BinaryOpStub_%s_%s_%s+%s", | 377 stream->Add("BinaryOpStub_%s_%s_%s+%s", |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 break; | 516 break; |
| 426 case CompareIC::GENERIC: | 517 case CompareIC::GENERIC: |
| 427 GenerateGeneric(masm); | 518 GenerateGeneric(masm); |
| 428 break; | 519 break; |
| 429 } | 520 } |
| 430 } | 521 } |
| 431 | 522 |
| 432 | 523 |
| 433 void CompareNilICStub::Record(Handle<Object> object) { | 524 void CompareNilICStub::Record(Handle<Object> object) { |
| 434 ASSERT(state_ != State::Generic()); | 525 ASSERT(state_ != State::Generic()); |
| 526 State old_state(state_); | |
| 435 if (object->IsNull()) { | 527 if (object->IsNull()) { |
| 436 state_.Add(NULL_TYPE); | 528 state_.Add(NULL_TYPE); |
| 437 } else if (object->IsUndefined()) { | 529 } else if (object->IsUndefined()) { |
| 438 state_.Add(UNDEFINED); | 530 state_.Add(UNDEFINED); |
| 439 } else if (object->IsUndetectableObject() || | 531 } else if (object->IsUndetectableObject() || |
| 440 object->IsOddball() || | 532 object->IsOddball() || |
| 441 !object->IsHeapObject()) { | 533 !object->IsHeapObject()) { |
| 442 state_ = State::Generic(); | 534 state_ = State::Generic(); |
| 443 } else if (IsMonomorphic()) { | 535 } else if (IsMonomorphic()) { |
| 444 state_ = State::Generic(); | 536 state_ = State::Generic(); |
| 445 } else { | 537 } else { |
| 446 state_.Add(MONOMORPHIC_MAP); | 538 state_.Add(MONOMORPHIC_MAP); |
| 447 } | 539 } |
| 540 TraceTransition(old_state, state_); | |
| 448 } | 541 } |
| 449 | 542 |
| 450 | 543 |
| 451 void CompareNilICStub::State::TraceTransition(State to) const { | 544 template<class StateType> |
| 545 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { | |
| 452 #ifdef DEBUG | 546 #ifdef DEBUG |
| 453 if (!FLAG_trace_ic) return; | 547 if (!FLAG_trace_ic) return; |
| 454 char buffer[100]; | 548 char buffer[100]; |
| 455 NoAllocationStringAllocator allocator(buffer, | 549 NoAllocationStringAllocator allocator(buffer, |
| 456 static_cast<unsigned>(sizeof(buffer))); | 550 static_cast<unsigned>(sizeof(buffer))); |
| 457 StringStream stream(&allocator); | 551 StringStream stream(&allocator); |
| 458 stream.Add("[CompareNilIC : "); | 552 stream.Add("["); |
| 459 Print(&stream); | 553 PrintBaseName(&stream); |
| 554 stream.Add(": "); | |
| 555 from.Print(&stream); | |
| 460 stream.Add("=>"); | 556 stream.Add("=>"); |
| 461 to.Print(&stream); | 557 to.Print(&stream); |
| 462 stream.Add("]\n"); | 558 stream.Add("]\n"); |
| 463 stream.OutputToStdOut(); | 559 stream.OutputToStdOut(); |
| 464 #endif | 560 #endif |
| 465 } | 561 } |
| 466 | 562 |
| 563 void CompareNilICStub::PrintBaseName(StringStream* stream) { | |
| 564 CodeStub::PrintBaseName(stream); | |
| 565 stream->Add((nil_value_ == kNullValue) ? "(NullValue)": | |
| 566 "(UndefinedValue)"); | |
| 567 } | |
| 467 | 568 |
| 468 void CompareNilICStub::PrintName(StringStream* stream) { | 569 void CompareNilICStub::PrintState(StringStream* stream) { |
| 469 stream->Add("CompareNilICStub_"); | |
| 470 state_.Print(stream); | 570 state_.Print(stream); |
| 471 stream->Add((nil_value_ == kNullValue) ? "(NullValue|": | |
| 472 "(UndefinedValue|"); | |
| 473 } | 571 } |
| 474 | 572 |
| 475 | 573 |
| 476 void CompareNilICStub::State::Print(StringStream* stream) const { | 574 void CompareNilICStub::State::Print(StringStream* stream) const { |
| 477 stream->Add("("); | 575 stream->Add("("); |
| 478 SimpleListPrinter printer(stream); | 576 SimpleListPrinter printer(stream); |
| 479 if (IsEmpty()) printer.Add("None"); | 577 if (IsEmpty()) printer.Add("None"); |
| 480 if (Contains(UNDEFINED)) printer.Add("Undefined"); | 578 if (Contains(UNDEFINED)) printer.Add("Undefined"); |
| 481 if (Contains(NULL_TYPE)) printer.Add("Null"); | 579 if (Contains(NULL_TYPE)) printer.Add("Null"); |
| 482 if (Contains(MONOMORPHIC_MAP)) printer.Add("MonomorphicMap"); | 580 if (Contains(MONOMORPHIC_MAP)) printer.Add("MonomorphicMap"); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 | 708 |
| 611 void CallConstructStub::PrintName(StringStream* stream) { | 709 void CallConstructStub::PrintName(StringStream* stream) { |
| 612 stream->Add("CallConstructStub"); | 710 stream->Add("CallConstructStub"); |
| 613 if (RecordCallTarget()) stream->Add("_Recording"); | 711 if (RecordCallTarget()) stream->Add("_Recording"); |
| 614 } | 712 } |
| 615 | 713 |
| 616 | 714 |
| 617 bool ToBooleanStub::Record(Handle<Object> object) { | 715 bool ToBooleanStub::Record(Handle<Object> object) { |
| 618 Types old_types(types_); | 716 Types old_types(types_); |
| 619 bool to_boolean_value = types_.Record(object); | 717 bool to_boolean_value = types_.Record(object); |
| 620 old_types.TraceTransition(types_); | 718 TraceTransition(old_types, types_); |
| 621 return to_boolean_value; | 719 return to_boolean_value; |
| 622 } | 720 } |
| 623 | 721 |
| 624 | 722 |
| 625 void ToBooleanStub::PrintName(StringStream* stream) { | 723 void ToBooleanStub::PrintState(StringStream* stream) { |
| 626 stream->Add("ToBooleanStub_"); | |
| 627 types_.Print(stream); | 724 types_.Print(stream); |
| 628 } | 725 } |
| 629 | 726 |
| 630 | 727 |
| 631 void ToBooleanStub::Types::Print(StringStream* stream) const { | 728 void ToBooleanStub::Types::Print(StringStream* stream) const { |
| 632 stream->Add("("); | 729 stream->Add("("); |
| 633 SimpleListPrinter printer(stream); | 730 SimpleListPrinter printer(stream); |
| 634 if (IsEmpty()) printer.Add("None"); | 731 if (IsEmpty()) printer.Add("None"); |
| 635 if (Contains(UNDEFINED)) printer.Add("Undefined"); | 732 if (Contains(UNDEFINED)) printer.Add("Undefined"); |
| 636 if (Contains(BOOLEAN)) printer.Add("Bool"); | 733 if (Contains(BOOLEAN)) printer.Add("Bool"); |
| 637 if (Contains(NULL_TYPE)) printer.Add("Null"); | 734 if (Contains(NULL_TYPE)) printer.Add("Null"); |
| 638 if (Contains(SMI)) printer.Add("Smi"); | 735 if (Contains(SMI)) printer.Add("Smi"); |
| 639 if (Contains(SPEC_OBJECT)) printer.Add("SpecObject"); | 736 if (Contains(SPEC_OBJECT)) printer.Add("SpecObject"); |
| 640 if (Contains(STRING)) printer.Add("String"); | 737 if (Contains(STRING)) printer.Add("String"); |
| 641 if (Contains(SYMBOL)) printer.Add("Symbol"); | 738 if (Contains(SYMBOL)) printer.Add("Symbol"); |
| 642 if (Contains(HEAP_NUMBER)) printer.Add("HeapNumber"); | 739 if (Contains(HEAP_NUMBER)) printer.Add("HeapNumber"); |
| 643 stream->Add(")"); | 740 stream->Add(")"); |
| 644 } | 741 } |
| 645 | 742 |
| 646 | 743 |
| 647 void ToBooleanStub::Types::TraceTransition(Types to) const { | |
| 648 #ifdef DEBUG | |
| 649 if (!FLAG_trace_ic) return; | |
| 650 char buffer[100]; | |
| 651 NoAllocationStringAllocator allocator(buffer, | |
| 652 static_cast<unsigned>(sizeof(buffer))); | |
| 653 StringStream stream(&allocator); | |
| 654 stream.Add("[ToBooleanIC : "); | |
| 655 Print(&stream); | |
| 656 stream.Add("=>"); | |
| 657 to.Print(&stream); | |
| 658 stream.Add("]\n"); | |
| 659 stream.OutputToStdOut(); | |
| 660 #endif | |
| 661 } | |
| 662 | |
| 663 | |
| 664 bool ToBooleanStub::Types::Record(Handle<Object> object) { | 744 bool ToBooleanStub::Types::Record(Handle<Object> object) { |
| 665 if (object->IsUndefined()) { | 745 if (object->IsUndefined()) { |
| 666 Add(UNDEFINED); | 746 Add(UNDEFINED); |
| 667 return false; | 747 return false; |
| 668 } else if (object->IsBoolean()) { | 748 } else if (object->IsBoolean()) { |
| 669 Add(BOOLEAN); | 749 Add(BOOLEAN); |
| 670 return object->IsTrue(); | 750 return object->IsTrue(); |
| 671 } else if (object->IsNull()) { | 751 } else if (object->IsNull()) { |
| 672 Add(NULL_TYPE); | 752 Add(NULL_TYPE); |
| 673 return false; | 753 return false; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 828 InstallDescriptor(isolate, &stub3); | 908 InstallDescriptor(isolate, &stub3); |
| 829 } | 909 } |
| 830 | 910 |
| 831 InternalArrayConstructorStub::InternalArrayConstructorStub( | 911 InternalArrayConstructorStub::InternalArrayConstructorStub( |
| 832 Isolate* isolate) { | 912 Isolate* isolate) { |
| 833 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 913 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 834 } | 914 } |
| 835 | 915 |
| 836 | 916 |
| 837 } } // namespace v8::internal | 917 } } // namespace v8::internal |
| OLD | NEW |