| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/cpu-profiler.h" | 9 #include "src/cpu-profiler.h" |
| 10 #include "src/factory.h" | 10 #include "src/factory.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 UnseededNumberDictionary* stubs = isolate()->heap()->code_stubs(); | 104 UnseededNumberDictionary* stubs = isolate()->heap()->code_stubs(); |
| 105 int index = stubs->FindEntry(GetKey()); | 105 int index = stubs->FindEntry(GetKey()); |
| 106 if (index != UnseededNumberDictionary::kNotFound) { | 106 if (index != UnseededNumberDictionary::kNotFound) { |
| 107 *code_out = Code::cast(stubs->ValueAt(index)); | 107 *code_out = Code::cast(stubs->ValueAt(index)); |
| 108 return true; | 108 return true; |
| 109 } | 109 } |
| 110 return false; | 110 return false; |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 SmartArrayPointer<const char> CodeStub::GetName() { | |
| 115 char buffer[100]; | |
| 116 NoAllocationStringAllocator allocator(buffer, | |
| 117 static_cast<unsigned>(sizeof(buffer))); | |
| 118 StringStream stream(&allocator); | |
| 119 PrintName(&stream); | |
| 120 return stream.ToCString(); | |
| 121 } | |
| 122 | |
| 123 | |
| 124 void CodeStub::RecordCodeGeneration(Handle<Code> code) { | 114 void CodeStub::RecordCodeGeneration(Handle<Code> code) { |
| 125 IC::RegisterWeakMapDependency(code); | 115 IC::RegisterWeakMapDependency(code); |
| 126 SmartArrayPointer<const char> name = GetName(); | 116 OStringStream os; |
| 127 PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, *code, name.get())); | 117 os << *this; |
| 128 GDBJIT(AddCode(GDBJITInterface::STUB, name.get(), *code)); | 118 PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, *code, os.c_str())); |
| 119 GDBJIT(AddCode(GDBJITInterface::STUB, os.c_str(), *code)); |
| 129 Counters* counters = isolate()->counters(); | 120 Counters* counters = isolate()->counters(); |
| 130 counters->total_stubs_code_size()->Increment(code->instruction_size()); | 121 counters->total_stubs_code_size()->Increment(code->instruction_size()); |
| 131 } | 122 } |
| 132 | 123 |
| 133 | 124 |
| 134 Code::Kind CodeStub::GetCodeKind() const { | 125 Code::Kind CodeStub::GetCodeKind() const { |
| 135 return Code::STUB; | 126 return Code::STUB; |
| 136 } | 127 } |
| 137 | 128 |
| 138 | 129 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 HandleScope scope(isolate()); | 182 HandleScope scope(isolate()); |
| 192 | 183 |
| 193 Handle<Code> new_object = GenerateCode(); | 184 Handle<Code> new_object = GenerateCode(); |
| 194 new_object->set_major_key(MajorKey()); | 185 new_object->set_major_key(MajorKey()); |
| 195 FinishCode(new_object); | 186 FinishCode(new_object); |
| 196 RecordCodeGeneration(new_object); | 187 RecordCodeGeneration(new_object); |
| 197 | 188 |
| 198 #ifdef ENABLE_DISASSEMBLER | 189 #ifdef ENABLE_DISASSEMBLER |
| 199 if (FLAG_print_code_stubs) { | 190 if (FLAG_print_code_stubs) { |
| 200 CodeTracer::Scope trace_scope(isolate()->GetCodeTracer()); | 191 CodeTracer::Scope trace_scope(isolate()->GetCodeTracer()); |
| 201 new_object->Disassemble(GetName().get(), trace_scope.file()); | 192 OStringStream os; |
| 193 os << *this; |
| 194 new_object->Disassemble(os.c_str(), trace_scope.file()); |
| 202 PrintF(trace_scope.file(), "\n"); | 195 PrintF(trace_scope.file(), "\n"); |
| 203 } | 196 } |
| 204 #endif | 197 #endif |
| 205 | 198 |
| 206 if (UseSpecialCache()) { | 199 if (UseSpecialCache()) { |
| 207 AddToSpecialCache(new_object); | 200 AddToSpecialCache(new_object); |
| 208 } else { | 201 } else { |
| 209 // Update the dictionary and the root in Heap. | 202 // Update the dictionary and the root in Heap. |
| 210 Handle<UnseededNumberDictionary> dict = | 203 Handle<UnseededNumberDictionary> dict = |
| 211 UnseededNumberDictionary::AtNumberPut( | 204 UnseededNumberDictionary::AtNumberPut( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 234 case UninitializedMajorKey: return "<UninitializedMajorKey>Stub"; | 227 case UninitializedMajorKey: return "<UninitializedMajorKey>Stub"; |
| 235 default: | 228 default: |
| 236 if (!allow_unknown_keys) { | 229 if (!allow_unknown_keys) { |
| 237 UNREACHABLE(); | 230 UNREACHABLE(); |
| 238 } | 231 } |
| 239 return NULL; | 232 return NULL; |
| 240 } | 233 } |
| 241 } | 234 } |
| 242 | 235 |
| 243 | 236 |
| 244 void CodeStub::PrintBaseName(StringStream* stream) { | 237 OStream& CodeStub::PrintBaseName(OStream& os) const { // NOLINT |
| 245 stream->Add("%s", MajorName(MajorKey(), false)); | 238 return os << MajorName(MajorKey(), false); |
| 246 } | 239 } |
| 247 | 240 |
| 248 | 241 |
| 249 void CodeStub::PrintName(StringStream* stream) { | 242 OStream& CodeStub::PrintName(OStream& os) const { // NOLINT |
| 250 PrintBaseName(stream); | 243 PrintBaseName(os); |
| 251 PrintState(stream); | 244 PrintState(os); |
| 245 return os; |
| 252 } | 246 } |
| 253 | 247 |
| 254 | 248 |
| 255 // static | 249 // static |
| 256 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) { | 250 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) { |
| 257 // Generate the uninitialized versions of the stub. | 251 // Generate the uninitialized versions of the stub. |
| 258 for (int op = Token::BIT_OR; op <= Token::MOD; ++op) { | 252 for (int op = Token::BIT_OR; op <= Token::MOD; ++op) { |
| 259 for (int mode = NO_OVERWRITE; mode <= OVERWRITE_RIGHT; ++mode) { | 253 for (int mode = NO_OVERWRITE; mode <= OVERWRITE_RIGHT; ++mode) { |
| 260 BinaryOpICStub stub(isolate, | 254 BinaryOpICStub stub(isolate, |
| 261 static_cast<Token::Value>(op), | 255 static_cast<Token::Value>(op), |
| 262 static_cast<OverwriteMode>(mode)); | 256 static_cast<OverwriteMode>(mode)); |
| 263 stub.GetCode(); | 257 stub.GetCode(); |
| 264 } | 258 } |
| 265 } | 259 } |
| 266 | 260 |
| 267 // Generate special versions of the stub. | 261 // Generate special versions of the stub. |
| 268 BinaryOpIC::State::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); | 262 BinaryOpIC::State::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); |
| 269 } | 263 } |
| 270 | 264 |
| 271 | 265 |
| 272 void BinaryOpICStub::PrintState(StringStream* stream) { | 266 OStream& BinaryOpICStub::PrintState(OStream& os) const { // NOLINT |
| 273 state_.Print(stream); | 267 return os << state_; |
| 274 } | 268 } |
| 275 | 269 |
| 276 | 270 |
| 277 // static | 271 // static |
| 278 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate, | 272 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate, |
| 279 const BinaryOpIC::State& state) { | 273 const BinaryOpIC::State& state) { |
| 280 BinaryOpICStub stub(isolate, state); | 274 BinaryOpICStub stub(isolate, state); |
| 281 stub.GetCode(); | 275 stub.GetCode(); |
| 282 } | 276 } |
| 283 | 277 |
| 284 | 278 |
| 285 // static | 279 // static |
| 286 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { | 280 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { |
| 287 // Generate special versions of the stub. | 281 // Generate special versions of the stub. |
| 288 BinaryOpIC::State::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); | 282 BinaryOpIC::State::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); |
| 289 } | 283 } |
| 290 | 284 |
| 291 | 285 |
| 292 void BinaryOpICWithAllocationSiteStub::PrintState(StringStream* stream) { | 286 OStream& BinaryOpICWithAllocationSiteStub::PrintState( |
| 293 state_.Print(stream); | 287 OStream& os) const { // NOLINT |
| 288 return os << state_; |
| 294 } | 289 } |
| 295 | 290 |
| 296 | 291 |
| 297 // static | 292 // static |
| 298 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime( | 293 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime( |
| 299 Isolate* isolate, const BinaryOpIC::State& state) { | 294 Isolate* isolate, const BinaryOpIC::State& state) { |
| 300 if (state.CouldCreateAllocationMementos()) { | 295 if (state.CouldCreateAllocationMementos()) { |
| 301 BinaryOpICWithAllocationSiteStub stub(isolate, state); | 296 BinaryOpICWithAllocationSiteStub stub(isolate, state); |
| 302 stub.GetCode(); | 297 stub.GetCode(); |
| 303 } | 298 } |
| 304 } | 299 } |
| 305 | 300 |
| 306 | 301 |
| 307 void StringAddStub::PrintBaseName(StringStream* stream) { | 302 OStream& StringAddStub::PrintBaseName(OStream& os) const { // NOLINT |
| 308 stream->Add("StringAddStub"); | 303 os << "StringAddStub"; |
| 309 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) { | 304 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) { |
| 310 stream->Add("_CheckBoth"); | 305 os << "_CheckBoth"; |
| 311 } else if ((flags() & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { | 306 } else if ((flags() & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { |
| 312 stream->Add("_CheckLeft"); | 307 os << "_CheckLeft"; |
| 313 } else if ((flags() & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { | 308 } else if ((flags() & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { |
| 314 stream->Add("_CheckRight"); | 309 os << "_CheckRight"; |
| 315 } | 310 } |
| 316 if (pretenure_flag() == TENURED) { | 311 if (pretenure_flag() == TENURED) { |
| 317 stream->Add("_Tenured"); | 312 os << "_Tenured"; |
| 318 } | 313 } |
| 314 return os; |
| 319 } | 315 } |
| 320 | 316 |
| 321 | 317 |
| 322 InlineCacheState ICCompareStub::GetICState() { | 318 InlineCacheState ICCompareStub::GetICState() { |
| 323 CompareIC::State state = Max(left_, right_); | 319 CompareIC::State state = Max(left_, right_); |
| 324 switch (state) { | 320 switch (state) { |
| 325 case CompareIC::UNINITIALIZED: | 321 case CompareIC::UNINITIALIZED: |
| 326 return ::v8::internal::UNINITIALIZED; | 322 return ::v8::internal::UNINITIALIZED; |
| 327 case CompareIC::SMI: | 323 case CompareIC::SMI: |
| 328 case CompareIC::NUMBER: | 324 case CompareIC::NUMBER: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 ICCompareStub::DecodeMinorKey((*code_out)->stub_info(), NULL, NULL, NULL, | 368 ICCompareStub::DecodeMinorKey((*code_out)->stub_info(), NULL, NULL, NULL, |
| 373 &cached_op); | 369 &cached_op); |
| 374 ASSERT(op_ == cached_op); | 370 ASSERT(op_ == cached_op); |
| 375 #endif | 371 #endif |
| 376 return true; | 372 return true; |
| 377 } | 373 } |
| 378 return false; | 374 return false; |
| 379 } | 375 } |
| 380 | 376 |
| 381 | 377 |
| 382 int ICCompareStub::MinorKey() { | 378 int ICCompareStub::MinorKey() const { |
| 383 return OpField::encode(op_ - Token::EQ) | | 379 return OpField::encode(op_ - Token::EQ) | |
| 384 LeftStateField::encode(left_) | | 380 LeftStateField::encode(left_) | |
| 385 RightStateField::encode(right_) | | 381 RightStateField::encode(right_) | |
| 386 HandlerStateField::encode(state_); | 382 HandlerStateField::encode(state_); |
| 387 } | 383 } |
| 388 | 384 |
| 389 | 385 |
| 390 void ICCompareStub::DecodeMinorKey(int minor_key, | 386 void ICCompareStub::DecodeMinorKey(int minor_key, |
| 391 CompareIC::State* left_state, | 387 CompareIC::State* left_state, |
| 392 CompareIC::State* right_state, | 388 CompareIC::State* right_state, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 TraceTransition(old_state, state_); | 461 TraceTransition(old_state, state_); |
| 466 } | 462 } |
| 467 | 463 |
| 468 | 464 |
| 469 template<class StateType> | 465 template<class StateType> |
| 470 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { | 466 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { |
| 471 // Note: Although a no-op transition is semantically OK, it is hinting at a | 467 // Note: Although a no-op transition is semantically OK, it is hinting at a |
| 472 // bug somewhere in our state transition machinery. | 468 // bug somewhere in our state transition machinery. |
| 473 ASSERT(from != to); | 469 ASSERT(from != to); |
| 474 if (!FLAG_trace_ic) return; | 470 if (!FLAG_trace_ic) return; |
| 475 char buffer[100]; | 471 OFStream os(stdout); |
| 476 NoAllocationStringAllocator allocator(buffer, | 472 os << "["; |
| 477 static_cast<unsigned>(sizeof(buffer))); | 473 PrintBaseName(os) << ": " << from << "=>" << to << "]" << endl; |
| 478 StringStream stream(&allocator); | |
| 479 stream.Add("["); | |
| 480 PrintBaseName(&stream); | |
| 481 stream.Add(": "); | |
| 482 from.Print(&stream); | |
| 483 stream.Add("=>"); | |
| 484 to.Print(&stream); | |
| 485 stream.Add("]\n"); | |
| 486 stream.OutputToStdOut(); | |
| 487 } | 474 } |
| 488 | 475 |
| 489 | 476 |
| 490 void CompareNilICStub::PrintBaseName(StringStream* stream) { | 477 OStream& CompareNilICStub::PrintBaseName(OStream& os) const { // NOLINT |
| 491 CodeStub::PrintBaseName(stream); | 478 return CodeStub::PrintBaseName(os) << |
| 492 stream->Add((nil_value_ == kNullValue) ? "(NullValue)": | 479 ((nil_value_ == kNullValue) ? "(NullValue)": "(UndefinedValue)"); |
| 493 "(UndefinedValue)"); | |
| 494 } | 480 } |
| 495 | 481 |
| 496 | 482 |
| 497 void CompareNilICStub::PrintState(StringStream* stream) { | 483 OStream& CompareNilICStub::PrintState(OStream& os) const { // NOLINT |
| 498 state_.Print(stream); | 484 return os << state_; |
| 499 } | 485 } |
| 500 | 486 |
| 501 | 487 |
| 502 void CompareNilICStub::State::Print(StringStream* stream) const { | 488 // TODO(svenpanne) Make this a real infix_ostream_iterator. |
| 503 stream->Add("("); | 489 class SimpleListPrinter { |
| 504 SimpleListPrinter printer(stream); | 490 public: |
| 505 if (IsEmpty()) printer.Add("None"); | 491 explicit SimpleListPrinter(OStream& os) : os_(os), first_(true) { } |
| 506 if (Contains(UNDEFINED)) printer.Add("Undefined"); | 492 |
| 507 if (Contains(NULL_TYPE)) printer.Add("Null"); | 493 void Add(const char* s) { |
| 508 if (Contains(MONOMORPHIC_MAP)) printer.Add("MonomorphicMap"); | 494 if (first_) { |
| 509 if (Contains(GENERIC)) printer.Add("Generic"); | 495 first_ = false; |
| 510 stream->Add(")"); | 496 } else { |
| 497 os_ << ","; |
| 498 } |
| 499 os_ << s; |
| 500 } |
| 501 |
| 502 private: |
| 503 OStream& os_; |
| 504 bool first_; |
| 505 }; |
| 506 |
| 507 |
| 508 OStream& operator<<(OStream& os, const CompareNilICStub::State& s) { |
| 509 os << "("; |
| 510 SimpleListPrinter p(os); |
| 511 if (s.IsEmpty()) p.Add("None"); |
| 512 if (s.Contains(CompareNilICStub::UNDEFINED)) p.Add("Undefined"); |
| 513 if (s.Contains(CompareNilICStub::NULL_TYPE)) p.Add("Null"); |
| 514 if (s.Contains(CompareNilICStub::MONOMORPHIC_MAP)) p.Add("MonomorphicMap"); |
| 515 if (s.Contains(CompareNilICStub::GENERIC)) p.Add("Generic"); |
| 516 return os << ")"; |
| 511 } | 517 } |
| 512 | 518 |
| 513 | 519 |
| 514 Type* CompareNilICStub::GetType(Zone* zone, Handle<Map> map) { | 520 Type* CompareNilICStub::GetType(Zone* zone, Handle<Map> map) { |
| 515 if (state_.Contains(CompareNilICStub::GENERIC)) { | 521 if (state_.Contains(CompareNilICStub::GENERIC)) { |
| 516 return Type::Any(zone); | 522 return Type::Any(zone); |
| 517 } | 523 } |
| 518 | 524 |
| 519 Type* result = Type::None(zone); | 525 Type* result = Type::None(zone); |
| 520 if (state_.Contains(CompareNilICStub::UNDEFINED)) { | 526 if (state_.Contains(CompareNilICStub::UNDEFINED)) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 534 | 540 |
| 535 | 541 |
| 536 Type* CompareNilICStub::GetInputType(Zone* zone, Handle<Map> map) { | 542 Type* CompareNilICStub::GetInputType(Zone* zone, Handle<Map> map) { |
| 537 Type* output_type = GetType(zone, map); | 543 Type* output_type = GetType(zone, map); |
| 538 Type* nil_type = | 544 Type* nil_type = |
| 539 nil_value_ == kNullValue ? Type::Null(zone) : Type::Undefined(zone); | 545 nil_value_ == kNullValue ? Type::Null(zone) : Type::Undefined(zone); |
| 540 return Type::Union(output_type, nil_type, zone); | 546 return Type::Union(output_type, nil_type, zone); |
| 541 } | 547 } |
| 542 | 548 |
| 543 | 549 |
| 544 void CallIC_ArrayStub::PrintState(StringStream* stream) { | 550 OStream& CallIC_ArrayStub::PrintState(OStream& os) const { // NOLINT |
| 545 state_.Print(stream); | 551 return os << state_ << " (Array)"; |
| 546 stream->Add(" (Array)"); | |
| 547 } | 552 } |
| 548 | 553 |
| 549 | 554 |
| 550 void CallICStub::PrintState(StringStream* stream) { | 555 OStream& CallICStub::PrintState(OStream& os) const { // NOLINT |
| 551 state_.Print(stream); | 556 return os << state_; |
| 552 } | 557 } |
| 553 | 558 |
| 554 | 559 |
| 555 void InstanceofStub::PrintName(StringStream* stream) { | 560 OStream& InstanceofStub::PrintName(OStream& os) const { // NOLINT |
| 556 const char* args = ""; | 561 os << "InstanceofStub"; |
| 557 if (HasArgsInRegisters()) { | 562 if (HasArgsInRegisters()) os << "_REGS"; |
| 558 args = "_REGS"; | 563 if (HasCallSiteInlineCheck()) os << "_INLINE"; |
| 559 } | 564 if (ReturnTrueFalseObject()) os << "_TRUEFALSE"; |
| 560 | 565 return os; |
| 561 const char* inline_check = ""; | |
| 562 if (HasCallSiteInlineCheck()) { | |
| 563 inline_check = "_INLINE"; | |
| 564 } | |
| 565 | |
| 566 const char* return_true_false_object = ""; | |
| 567 if (ReturnTrueFalseObject()) { | |
| 568 return_true_false_object = "_TRUEFALSE"; | |
| 569 } | |
| 570 | |
| 571 stream->Add("InstanceofStub%s%s%s", | |
| 572 args, | |
| 573 inline_check, | |
| 574 return_true_false_object); | |
| 575 } | 566 } |
| 576 | 567 |
| 577 | 568 |
| 578 void JSEntryStub::FinishCode(Handle<Code> code) { | 569 void JSEntryStub::FinishCode(Handle<Code> code) { |
| 579 Handle<FixedArray> handler_table = | 570 Handle<FixedArray> handler_table = |
| 580 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); | 571 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); |
| 581 handler_table->set(0, Smi::FromInt(handler_offset_)); | 572 handler_table->set(0, Smi::FromInt(handler_offset_)); |
| 582 code->set_handler_table(*handler_table); | 573 code->set_handler_table(*handler_table); |
| 583 } | 574 } |
| 584 | 575 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 case DICTIONARY_ELEMENTS: | 666 case DICTIONARY_ELEMENTS: |
| 676 KeyedStoreStubCompiler::GenerateStoreDictionaryElement(masm); | 667 KeyedStoreStubCompiler::GenerateStoreDictionaryElement(masm); |
| 677 break; | 668 break; |
| 678 case SLOPPY_ARGUMENTS_ELEMENTS: | 669 case SLOPPY_ARGUMENTS_ELEMENTS: |
| 679 UNREACHABLE(); | 670 UNREACHABLE(); |
| 680 break; | 671 break; |
| 681 } | 672 } |
| 682 } | 673 } |
| 683 | 674 |
| 684 | 675 |
| 685 void ArgumentsAccessStub::PrintName(StringStream* stream) { | 676 OStream& ArgumentsAccessStub::PrintName(OStream& os) const { // NOLINT |
| 686 stream->Add("ArgumentsAccessStub_"); | 677 os << "ArgumentsAccessStub_"; |
| 687 switch (type_) { | 678 switch (type_) { |
| 688 case READ_ELEMENT: stream->Add("ReadElement"); break; | 679 case READ_ELEMENT: return os << "ReadElement"; |
| 689 case NEW_SLOPPY_FAST: stream->Add("NewSloppyFast"); break; | 680 case NEW_SLOPPY_FAST: return os << "NewSloppyFast"; |
| 690 case NEW_SLOPPY_SLOW: stream->Add("NewSloppySlow"); break; | 681 case NEW_SLOPPY_SLOW: return os << "NewSloppySlow"; |
| 691 case NEW_STRICT: stream->Add("NewStrict"); break; | 682 case NEW_STRICT: return os << "NewStrict"; |
| 692 } | 683 } |
| 684 UNREACHABLE(); |
| 685 return os; |
| 693 } | 686 } |
| 694 | 687 |
| 695 | 688 |
| 696 void CallFunctionStub::PrintName(StringStream* stream) { | 689 OStream& CallFunctionStub::PrintName(OStream& os) const { // NOLINT |
| 697 stream->Add("CallFunctionStub_Args%d", argc_); | 690 return os << "CallFunctionStub_Args" << argc_; |
| 698 } | 691 } |
| 699 | 692 |
| 700 | 693 |
| 701 void CallConstructStub::PrintName(StringStream* stream) { | 694 OStream& CallConstructStub::PrintName(OStream& os) const { // NOLINT |
| 702 stream->Add("CallConstructStub"); | 695 os << "CallConstructStub"; |
| 703 if (RecordCallTarget()) stream->Add("_Recording"); | 696 if (RecordCallTarget()) os << "_Recording"; |
| 697 return os; |
| 704 } | 698 } |
| 705 | 699 |
| 706 | 700 |
| 707 void ArrayConstructorStub::PrintName(StringStream* stream) { | 701 OStream& ArrayConstructorStub::PrintName(OStream& os) const { // NOLINT |
| 708 stream->Add("ArrayConstructorStub"); | 702 os << "ArrayConstructorStub"; |
| 709 switch (argument_count_) { | 703 switch (argument_count_) { |
| 710 case ANY: stream->Add("_Any"); break; | 704 case ANY: return os << "_Any"; |
| 711 case NONE: stream->Add("_None"); break; | 705 case NONE: return os << "_None"; |
| 712 case ONE: stream->Add("_One"); break; | 706 case ONE: return os << "_One"; |
| 713 case MORE_THAN_ONE: stream->Add("_More_Than_One"); break; | 707 case MORE_THAN_ONE: return os << "_More_Than_One"; |
| 714 } | 708 } |
| 709 UNREACHABLE(); |
| 710 return os; |
| 715 } | 711 } |
| 716 | 712 |
| 717 | 713 |
| 718 void ArrayConstructorStubBase::BasePrintName(const char* name, | 714 OStream& ArrayConstructorStubBase::BasePrintName(OStream& os, // NOLINT |
| 719 StringStream* stream) { | 715 const char* name) const { |
| 720 stream->Add(name); | 716 os << name << "_" << ElementsKindToString(elements_kind()); |
| 721 stream->Add("_"); | |
| 722 stream->Add(ElementsKindToString(elements_kind())); | |
| 723 if (override_mode() == DISABLE_ALLOCATION_SITES) { | 717 if (override_mode() == DISABLE_ALLOCATION_SITES) { |
| 724 stream->Add("_DISABLE_ALLOCATION_SITES"); | 718 os << "_DISABLE_ALLOCATION_SITES"; |
| 725 } | 719 } |
| 720 return os; |
| 726 } | 721 } |
| 727 | 722 |
| 728 | 723 |
| 729 bool ToBooleanStub::UpdateStatus(Handle<Object> object) { | 724 bool ToBooleanStub::UpdateStatus(Handle<Object> object) { |
| 730 Types old_types(types_); | 725 Types old_types(types_); |
| 731 bool to_boolean_value = types_.UpdateStatus(object); | 726 bool to_boolean_value = types_.UpdateStatus(object); |
| 732 TraceTransition(old_types, types_); | 727 TraceTransition(old_types, types_); |
| 733 return to_boolean_value; | 728 return to_boolean_value; |
| 734 } | 729 } |
| 735 | 730 |
| 736 | 731 |
| 737 void ToBooleanStub::PrintState(StringStream* stream) { | 732 OStream& ToBooleanStub::PrintState(OStream& os) const { // NOLINT |
| 738 types_.Print(stream); | 733 return os << types_; |
| 739 } | 734 } |
| 740 | 735 |
| 741 | 736 |
| 742 void ToBooleanStub::Types::Print(StringStream* stream) const { | 737 OStream& operator<<(OStream& os, const ToBooleanStub::Types& s) { |
| 743 stream->Add("("); | 738 os << "("; |
| 744 SimpleListPrinter printer(stream); | 739 SimpleListPrinter p(os); |
| 745 if (IsEmpty()) printer.Add("None"); | 740 if (s.IsEmpty()) p.Add("None"); |
| 746 if (Contains(UNDEFINED)) printer.Add("Undefined"); | 741 if (s.Contains(ToBooleanStub::UNDEFINED)) p.Add("Undefined"); |
| 747 if (Contains(BOOLEAN)) printer.Add("Bool"); | 742 if (s.Contains(ToBooleanStub::BOOLEAN)) p.Add("Bool"); |
| 748 if (Contains(NULL_TYPE)) printer.Add("Null"); | 743 if (s.Contains(ToBooleanStub::NULL_TYPE)) p.Add("Null"); |
| 749 if (Contains(SMI)) printer.Add("Smi"); | 744 if (s.Contains(ToBooleanStub::SMI)) p.Add("Smi"); |
| 750 if (Contains(SPEC_OBJECT)) printer.Add("SpecObject"); | 745 if (s.Contains(ToBooleanStub::SPEC_OBJECT)) p.Add("SpecObject"); |
| 751 if (Contains(STRING)) printer.Add("String"); | 746 if (s.Contains(ToBooleanStub::STRING)) p.Add("String"); |
| 752 if (Contains(SYMBOL)) printer.Add("Symbol"); | 747 if (s.Contains(ToBooleanStub::SYMBOL)) p.Add("Symbol"); |
| 753 if (Contains(HEAP_NUMBER)) printer.Add("HeapNumber"); | 748 if (s.Contains(ToBooleanStub::HEAP_NUMBER)) p.Add("HeapNumber"); |
| 754 stream->Add(")"); | 749 return os << ")"; |
| 755 } | 750 } |
| 756 | 751 |
| 757 | 752 |
| 758 bool ToBooleanStub::Types::UpdateStatus(Handle<Object> object) { | 753 bool ToBooleanStub::Types::UpdateStatus(Handle<Object> object) { |
| 759 if (object->IsUndefined()) { | 754 if (object->IsUndefined()) { |
| 760 Add(UNDEFINED); | 755 Add(UNDEFINED); |
| 761 return false; | 756 return false; |
| 762 } else if (object->IsBoolean()) { | 757 } else if (object->IsBoolean()) { |
| 763 Add(BOOLEAN); | 758 Add(BOOLEAN); |
| 764 return object->IsTrue(); | 759 return object->IsTrue(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 InstallDescriptor(isolate, &stub3); | 929 InstallDescriptor(isolate, &stub3); |
| 935 } | 930 } |
| 936 | 931 |
| 937 InternalArrayConstructorStub::InternalArrayConstructorStub( | 932 InternalArrayConstructorStub::InternalArrayConstructorStub( |
| 938 Isolate* isolate) : PlatformCodeStub(isolate) { | 933 Isolate* isolate) : PlatformCodeStub(isolate) { |
| 939 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 934 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 940 } | 935 } |
| 941 | 936 |
| 942 | 937 |
| 943 } } // namespace v8::internal | 938 } } // namespace v8::internal |
| OLD | NEW |