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

Side by Side Diff: src/code-stubs.cc

Issue 334763003: Start using OStreams. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Reformatted. Feedback addressed. Created 6 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/code-stubs.h ('k') | src/code-stubs-hydrogen.cc » ('j') | 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 // 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
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
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
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 void CodeStub::PrintBaseName(OStream& os) const { // NOLINT
245 stream->Add("%s", MajorName(MajorKey(), false)); 238 os << MajorName(MajorKey(), false);
246 } 239 }
247 240
248 241
249 void CodeStub::PrintName(StringStream* stream) { 242 void CodeStub::PrintName(OStream& os) const { // NOLINT
250 PrintBaseName(stream); 243 PrintBaseName(os);
251 PrintState(stream); 244 PrintState(os);
252 } 245 }
253 246
254 247
255 // static 248 // static
256 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) { 249 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) {
257 // Generate the uninitialized versions of the stub. 250 // Generate the uninitialized versions of the stub.
258 for (int op = Token::BIT_OR; op <= Token::MOD; ++op) { 251 for (int op = Token::BIT_OR; op <= Token::MOD; ++op) {
259 for (int mode = NO_OVERWRITE; mode <= OVERWRITE_RIGHT; ++mode) { 252 for (int mode = NO_OVERWRITE; mode <= OVERWRITE_RIGHT; ++mode) {
260 BinaryOpICStub stub(isolate, 253 BinaryOpICStub stub(isolate,
261 static_cast<Token::Value>(op), 254 static_cast<Token::Value>(op),
262 static_cast<OverwriteMode>(mode)); 255 static_cast<OverwriteMode>(mode));
263 stub.GetCode(); 256 stub.GetCode();
264 } 257 }
265 } 258 }
266 259
267 // Generate special versions of the stub. 260 // Generate special versions of the stub.
268 BinaryOpIC::State::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); 261 BinaryOpIC::State::GenerateAheadOfTime(isolate, &GenerateAheadOfTime);
269 } 262 }
270 263
271 264
272 void BinaryOpICStub::PrintState(StringStream* stream) { 265 void BinaryOpICStub::PrintState(OStream& os) const { // NOLINT
273 state_.Print(stream); 266 os << state_;
274 } 267 }
275 268
276 269
277 // static 270 // static
278 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate, 271 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate,
279 const BinaryOpIC::State& state) { 272 const BinaryOpIC::State& state) {
280 BinaryOpICStub stub(isolate, state); 273 BinaryOpICStub stub(isolate, state);
281 stub.GetCode(); 274 stub.GetCode();
282 } 275 }
283 276
284 277
285 // static 278 // static
286 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { 279 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) {
287 // Generate special versions of the stub. 280 // Generate special versions of the stub.
288 BinaryOpIC::State::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); 281 BinaryOpIC::State::GenerateAheadOfTime(isolate, &GenerateAheadOfTime);
289 } 282 }
290 283
291 284
292 void BinaryOpICWithAllocationSiteStub::PrintState(StringStream* stream) { 285 void BinaryOpICWithAllocationSiteStub::PrintState(
293 state_.Print(stream); 286 OStream& os) const { // NOLINT
287 os << state_;
294 } 288 }
295 289
296 290
297 // static 291 // static
298 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime( 292 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(
299 Isolate* isolate, const BinaryOpIC::State& state) { 293 Isolate* isolate, const BinaryOpIC::State& state) {
300 if (state.CouldCreateAllocationMementos()) { 294 if (state.CouldCreateAllocationMementos()) {
301 BinaryOpICWithAllocationSiteStub stub(isolate, state); 295 BinaryOpICWithAllocationSiteStub stub(isolate, state);
302 stub.GetCode(); 296 stub.GetCode();
303 } 297 }
304 } 298 }
305 299
306 300
307 void StringAddStub::PrintBaseName(StringStream* stream) { 301 void StringAddStub::PrintBaseName(OStream& os) const { // NOLINT
308 stream->Add("StringAddStub"); 302 os << "StringAddStub";
309 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) { 303 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) {
310 stream->Add("_CheckBoth"); 304 os << "_CheckBoth";
311 } else if ((flags() & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { 305 } else if ((flags() & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) {
312 stream->Add("_CheckLeft"); 306 os << "_CheckLeft";
313 } else if ((flags() & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { 307 } else if ((flags() & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) {
314 stream->Add("_CheckRight"); 308 os << "_CheckRight";
315 } 309 }
316 if (pretenure_flag() == TENURED) { 310 if (pretenure_flag() == TENURED) {
317 stream->Add("_Tenured"); 311 os << "_Tenured";
318 } 312 }
319 } 313 }
320 314
321 315
322 InlineCacheState ICCompareStub::GetICState() { 316 InlineCacheState ICCompareStub::GetICState() {
323 CompareIC::State state = Max(left_, right_); 317 CompareIC::State state = Max(left_, right_);
324 switch (state) { 318 switch (state) {
325 case CompareIC::UNINITIALIZED: 319 case CompareIC::UNINITIALIZED:
326 return ::v8::internal::UNINITIALIZED; 320 return ::v8::internal::UNINITIALIZED;
327 case CompareIC::SMI: 321 case CompareIC::SMI:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 ICCompareStub::DecodeMinorKey((*code_out)->stub_info(), NULL, NULL, NULL, 366 ICCompareStub::DecodeMinorKey((*code_out)->stub_info(), NULL, NULL, NULL,
373 &cached_op); 367 &cached_op);
374 ASSERT(op_ == cached_op); 368 ASSERT(op_ == cached_op);
375 #endif 369 #endif
376 return true; 370 return true;
377 } 371 }
378 return false; 372 return false;
379 } 373 }
380 374
381 375
382 int ICCompareStub::MinorKey() { 376 int ICCompareStub::MinorKey() const {
383 return OpField::encode(op_ - Token::EQ) | 377 return OpField::encode(op_ - Token::EQ) |
384 LeftStateField::encode(left_) | 378 LeftStateField::encode(left_) |
385 RightStateField::encode(right_) | 379 RightStateField::encode(right_) |
386 HandlerStateField::encode(state_); 380 HandlerStateField::encode(state_);
387 } 381 }
388 382
389 383
390 void ICCompareStub::DecodeMinorKey(int minor_key, 384 void ICCompareStub::DecodeMinorKey(int minor_key,
391 CompareIC::State* left_state, 385 CompareIC::State* left_state,
392 CompareIC::State* right_state, 386 CompareIC::State* right_state,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 TraceTransition(old_state, state_); 459 TraceTransition(old_state, state_);
466 } 460 }
467 461
468 462
469 template<class StateType> 463 template<class StateType>
470 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { 464 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) {
471 // Note: Although a no-op transition is semantically OK, it is hinting at a 465 // Note: Although a no-op transition is semantically OK, it is hinting at a
472 // bug somewhere in our state transition machinery. 466 // bug somewhere in our state transition machinery.
473 ASSERT(from != to); 467 ASSERT(from != to);
474 if (!FLAG_trace_ic) return; 468 if (!FLAG_trace_ic) return;
475 char buffer[100]; 469 OFStream os(stdout);
476 NoAllocationStringAllocator allocator(buffer, 470 os << "[";
477 static_cast<unsigned>(sizeof(buffer))); 471 PrintBaseName(os);
478 StringStream stream(&allocator); 472 os << ": " << from << "=>" << to << "]" << endl;
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 } 473 }
488 474
489 475
490 void CompareNilICStub::PrintBaseName(StringStream* stream) { 476 void CompareNilICStub::PrintBaseName(OStream& os) const { // NOLINT
491 CodeStub::PrintBaseName(stream); 477 CodeStub::PrintBaseName(os);
492 stream->Add((nil_value_ == kNullValue) ? "(NullValue)": 478 os << ((nil_value_ == kNullValue) ? "(NullValue)" : "(UndefinedValue)");
493 "(UndefinedValue)");
494 } 479 }
495 480
496 481
497 void CompareNilICStub::PrintState(StringStream* stream) { 482 void CompareNilICStub::PrintState(OStream& os) const { // NOLINT
498 state_.Print(stream); 483 os << state_;
499 } 484 }
500 485
501 486
502 void CompareNilICStub::State::Print(StringStream* stream) const { 487 // TODO(svenpanne) Make this a real infix_ostream_iterator.
503 stream->Add("("); 488 class SimpleListPrinter {
504 SimpleListPrinter printer(stream); 489 public:
505 if (IsEmpty()) printer.Add("None"); 490 explicit SimpleListPrinter(OStream& os) : os_(os), first_(true) {}
506 if (Contains(UNDEFINED)) printer.Add("Undefined"); 491
507 if (Contains(NULL_TYPE)) printer.Add("Null"); 492 void Add(const char* s) {
508 if (Contains(MONOMORPHIC_MAP)) printer.Add("MonomorphicMap"); 493 if (first_) {
509 if (Contains(GENERIC)) printer.Add("Generic"); 494 first_ = false;
510 stream->Add(")"); 495 } else {
496 os_ << ",";
497 }
498 os_ << s;
499 }
500
501 private:
502 OStream& os_;
503 bool first_;
504 };
505
506
507 OStream& operator<<(OStream& os, const CompareNilICStub::State& s) {
508 os << "(";
509 SimpleListPrinter p(os);
510 if (s.IsEmpty()) p.Add("None");
511 if (s.Contains(CompareNilICStub::UNDEFINED)) p.Add("Undefined");
512 if (s.Contains(CompareNilICStub::NULL_TYPE)) p.Add("Null");
513 if (s.Contains(CompareNilICStub::MONOMORPHIC_MAP)) p.Add("MonomorphicMap");
514 if (s.Contains(CompareNilICStub::GENERIC)) p.Add("Generic");
515 return os << ")";
511 } 516 }
512 517
513 518
514 Type* CompareNilICStub::GetType(Zone* zone, Handle<Map> map) { 519 Type* CompareNilICStub::GetType(Zone* zone, Handle<Map> map) {
515 if (state_.Contains(CompareNilICStub::GENERIC)) { 520 if (state_.Contains(CompareNilICStub::GENERIC)) {
516 return Type::Any(zone); 521 return Type::Any(zone);
517 } 522 }
518 523
519 Type* result = Type::None(zone); 524 Type* result = Type::None(zone);
520 if (state_.Contains(CompareNilICStub::UNDEFINED)) { 525 if (state_.Contains(CompareNilICStub::UNDEFINED)) {
(...skipping 13 matching lines...) Expand all
534 539
535 540
536 Type* CompareNilICStub::GetInputType(Zone* zone, Handle<Map> map) { 541 Type* CompareNilICStub::GetInputType(Zone* zone, Handle<Map> map) {
537 Type* output_type = GetType(zone, map); 542 Type* output_type = GetType(zone, map);
538 Type* nil_type = 543 Type* nil_type =
539 nil_value_ == kNullValue ? Type::Null(zone) : Type::Undefined(zone); 544 nil_value_ == kNullValue ? Type::Null(zone) : Type::Undefined(zone);
540 return Type::Union(output_type, nil_type, zone); 545 return Type::Union(output_type, nil_type, zone);
541 } 546 }
542 547
543 548
544 void CallIC_ArrayStub::PrintState(StringStream* stream) { 549 void CallIC_ArrayStub::PrintState(OStream& os) const { // NOLINT
545 state_.Print(stream); 550 os << state_ << " (Array)";
546 stream->Add(" (Array)");
547 } 551 }
548 552
549 553
550 void CallICStub::PrintState(StringStream* stream) { 554 void CallICStub::PrintState(OStream& os) const { // NOLINT
551 state_.Print(stream); 555 os << state_;
552 } 556 }
553 557
554 558
555 void InstanceofStub::PrintName(StringStream* stream) { 559 void InstanceofStub::PrintName(OStream& os) const { // NOLINT
556 const char* args = ""; 560 os << "InstanceofStub";
557 if (HasArgsInRegisters()) { 561 if (HasArgsInRegisters()) os << "_REGS";
558 args = "_REGS"; 562 if (HasCallSiteInlineCheck()) os << "_INLINE";
559 } 563 if (ReturnTrueFalseObject()) os << "_TRUEFALSE";
560
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 } 564 }
576 565
577 566
578 void JSEntryStub::FinishCode(Handle<Code> code) { 567 void JSEntryStub::FinishCode(Handle<Code> code) {
579 Handle<FixedArray> handler_table = 568 Handle<FixedArray> handler_table =
580 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); 569 code->GetIsolate()->factory()->NewFixedArray(1, TENURED);
581 handler_table->set(0, Smi::FromInt(handler_offset_)); 570 handler_table->set(0, Smi::FromInt(handler_offset_));
582 code->set_handler_table(*handler_table); 571 code->set_handler_table(*handler_table);
583 } 572 }
584 573
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 case DICTIONARY_ELEMENTS: 664 case DICTIONARY_ELEMENTS:
676 KeyedStoreStubCompiler::GenerateStoreDictionaryElement(masm); 665 KeyedStoreStubCompiler::GenerateStoreDictionaryElement(masm);
677 break; 666 break;
678 case SLOPPY_ARGUMENTS_ELEMENTS: 667 case SLOPPY_ARGUMENTS_ELEMENTS:
679 UNREACHABLE(); 668 UNREACHABLE();
680 break; 669 break;
681 } 670 }
682 } 671 }
683 672
684 673
685 void ArgumentsAccessStub::PrintName(StringStream* stream) { 674 void ArgumentsAccessStub::PrintName(OStream& os) const { // NOLINT
686 stream->Add("ArgumentsAccessStub_"); 675 os << "ArgumentsAccessStub_";
687 switch (type_) { 676 switch (type_) {
688 case READ_ELEMENT: stream->Add("ReadElement"); break; 677 case READ_ELEMENT:
689 case NEW_SLOPPY_FAST: stream->Add("NewSloppyFast"); break; 678 os << "ReadElement";
690 case NEW_SLOPPY_SLOW: stream->Add("NewSloppySlow"); break; 679 break;
691 case NEW_STRICT: stream->Add("NewStrict"); break; 680 case NEW_SLOPPY_FAST:
681 os << "NewSloppyFast";
682 break;
683 case NEW_SLOPPY_SLOW:
684 os << "NewSloppySlow";
685 break;
686 case NEW_STRICT:
687 os << "NewStrict";
688 break;
692 } 689 }
690 return;
693 } 691 }
694 692
695 693
696 void CallFunctionStub::PrintName(StringStream* stream) { 694 void CallFunctionStub::PrintName(OStream& os) const { // NOLINT
697 stream->Add("CallFunctionStub_Args%d", argc_); 695 os << "CallFunctionStub_Args" << argc_;
698 } 696 }
699 697
700 698
701 void CallConstructStub::PrintName(StringStream* stream) { 699 void CallConstructStub::PrintName(OStream& os) const { // NOLINT
702 stream->Add("CallConstructStub"); 700 os << "CallConstructStub";
703 if (RecordCallTarget()) stream->Add("_Recording"); 701 if (RecordCallTarget()) os << "_Recording";
704 } 702 }
705 703
706 704
707 void ArrayConstructorStub::PrintName(StringStream* stream) { 705 void ArrayConstructorStub::PrintName(OStream& os) const { // NOLINT
708 stream->Add("ArrayConstructorStub"); 706 os << "ArrayConstructorStub";
709 switch (argument_count_) { 707 switch (argument_count_) {
710 case ANY: stream->Add("_Any"); break; 708 case ANY:
711 case NONE: stream->Add("_None"); break; 709 os << "_Any";
712 case ONE: stream->Add("_One"); break; 710 break;
713 case MORE_THAN_ONE: stream->Add("_More_Than_One"); break; 711 case NONE:
712 os << "_None";
713 break;
714 case ONE:
715 os << "_One";
716 break;
717 case MORE_THAN_ONE:
718 os << "_More_Than_One";
719 break;
714 } 720 }
721 return;
715 } 722 }
716 723
717 724
718 void ArrayConstructorStubBase::BasePrintName(const char* name, 725 OStream& ArrayConstructorStubBase::BasePrintName(OStream& os, // NOLINT
719 StringStream* stream) { 726 const char* name) const {
720 stream->Add(name); 727 os << name << "_" << ElementsKindToString(elements_kind());
721 stream->Add("_");
722 stream->Add(ElementsKindToString(elements_kind()));
723 if (override_mode() == DISABLE_ALLOCATION_SITES) { 728 if (override_mode() == DISABLE_ALLOCATION_SITES) {
724 stream->Add("_DISABLE_ALLOCATION_SITES"); 729 os << "_DISABLE_ALLOCATION_SITES";
725 } 730 }
731 return os;
726 } 732 }
727 733
728 734
729 bool ToBooleanStub::UpdateStatus(Handle<Object> object) { 735 bool ToBooleanStub::UpdateStatus(Handle<Object> object) {
730 Types old_types(types_); 736 Types old_types(types_);
731 bool to_boolean_value = types_.UpdateStatus(object); 737 bool to_boolean_value = types_.UpdateStatus(object);
732 TraceTransition(old_types, types_); 738 TraceTransition(old_types, types_);
733 return to_boolean_value; 739 return to_boolean_value;
734 } 740 }
735 741
736 742
737 void ToBooleanStub::PrintState(StringStream* stream) { 743 void ToBooleanStub::PrintState(OStream& os) const { // NOLINT
738 types_.Print(stream); 744 os << types_;
739 } 745 }
740 746
741 747
742 void ToBooleanStub::Types::Print(StringStream* stream) const { 748 OStream& operator<<(OStream& os, const ToBooleanStub::Types& s) {
743 stream->Add("("); 749 os << "(";
744 SimpleListPrinter printer(stream); 750 SimpleListPrinter p(os);
745 if (IsEmpty()) printer.Add("None"); 751 if (s.IsEmpty()) p.Add("None");
746 if (Contains(UNDEFINED)) printer.Add("Undefined"); 752 if (s.Contains(ToBooleanStub::UNDEFINED)) p.Add("Undefined");
747 if (Contains(BOOLEAN)) printer.Add("Bool"); 753 if (s.Contains(ToBooleanStub::BOOLEAN)) p.Add("Bool");
748 if (Contains(NULL_TYPE)) printer.Add("Null"); 754 if (s.Contains(ToBooleanStub::NULL_TYPE)) p.Add("Null");
749 if (Contains(SMI)) printer.Add("Smi"); 755 if (s.Contains(ToBooleanStub::SMI)) p.Add("Smi");
750 if (Contains(SPEC_OBJECT)) printer.Add("SpecObject"); 756 if (s.Contains(ToBooleanStub::SPEC_OBJECT)) p.Add("SpecObject");
751 if (Contains(STRING)) printer.Add("String"); 757 if (s.Contains(ToBooleanStub::STRING)) p.Add("String");
752 if (Contains(SYMBOL)) printer.Add("Symbol"); 758 if (s.Contains(ToBooleanStub::SYMBOL)) p.Add("Symbol");
753 if (Contains(HEAP_NUMBER)) printer.Add("HeapNumber"); 759 if (s.Contains(ToBooleanStub::HEAP_NUMBER)) p.Add("HeapNumber");
754 stream->Add(")"); 760 return os << ")";
755 } 761 }
756 762
757 763
758 bool ToBooleanStub::Types::UpdateStatus(Handle<Object> object) { 764 bool ToBooleanStub::Types::UpdateStatus(Handle<Object> object) {
759 if (object->IsUndefined()) { 765 if (object->IsUndefined()) {
760 Add(UNDEFINED); 766 Add(UNDEFINED);
761 return false; 767 return false;
762 } else if (object->IsBoolean()) { 768 } else if (object->IsBoolean()) {
763 Add(BOOLEAN); 769 Add(BOOLEAN);
764 return object->IsTrue(); 770 return object->IsTrue();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 InstallDescriptor(isolate, &stub3); 940 InstallDescriptor(isolate, &stub3);
935 } 941 }
936 942
937 InternalArrayConstructorStub::InternalArrayConstructorStub( 943 InternalArrayConstructorStub::InternalArrayConstructorStub(
938 Isolate* isolate) : PlatformCodeStub(isolate) { 944 Isolate* isolate) : PlatformCodeStub(isolate) {
939 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); 945 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
940 } 946 }
941 947
942 948
943 } } // namespace v8::internal 949 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698