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

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

Issue 618643002: Replace OStream with std::ostream. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix Created 6 years, 2 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/code-stubs.h"
6
7 #include <sstream>
6 8
7 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
8 #include "src/code-stubs.h"
9 #include "src/cpu-profiler.h" 10 #include "src/cpu-profiler.h"
10 #include "src/factory.h" 11 #include "src/factory.h"
11 #include "src/gdb-jit.h" 12 #include "src/gdb-jit.h"
12 #include "src/ic/handler-compiler.h" 13 #include "src/ic/handler-compiler.h"
13 #include "src/ic/ic.h" 14 #include "src/ic/ic.h"
14 #include "src/macro-assembler.h" 15 #include "src/macro-assembler.h"
15 16
16 namespace v8 { 17 namespace v8 {
17 namespace internal { 18 namespace internal {
18 19
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (index != UnseededNumberDictionary::kNotFound) { 69 if (index != UnseededNumberDictionary::kNotFound) {
69 *code_out = Code::cast(stubs->ValueAt(index)); 70 *code_out = Code::cast(stubs->ValueAt(index));
70 return true; 71 return true;
71 } 72 }
72 return false; 73 return false;
73 } 74 }
74 75
75 76
76 void CodeStub::RecordCodeGeneration(Handle<Code> code) { 77 void CodeStub::RecordCodeGeneration(Handle<Code> code) {
77 IC::RegisterWeakMapDependency(code); 78 IC::RegisterWeakMapDependency(code);
78 OStringStream os; 79 std::ostringstream os;
79 os << *this; 80 os << *this;
80 PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, *code, os.c_str())); 81 PROFILE(isolate(),
82 CodeCreateEvent(Logger::STUB_TAG, *code, os.str().c_str()));
81 Counters* counters = isolate()->counters(); 83 Counters* counters = isolate()->counters();
82 counters->total_stubs_code_size()->Increment(code->instruction_size()); 84 counters->total_stubs_code_size()->Increment(code->instruction_size());
83 } 85 }
84 86
85 87
86 Code::Kind CodeStub::GetCodeKind() const { 88 Code::Kind CodeStub::GetCodeKind() const {
87 return Code::STUB; 89 return Code::STUB;
88 } 90 }
89 91
90 92
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 148
147 Handle<Code> new_object = GenerateCode(); 149 Handle<Code> new_object = GenerateCode();
148 new_object->set_stub_key(GetKey()); 150 new_object->set_stub_key(GetKey());
149 FinishCode(new_object); 151 FinishCode(new_object);
150 RecordCodeGeneration(new_object); 152 RecordCodeGeneration(new_object);
151 153
152 #ifdef ENABLE_DISASSEMBLER 154 #ifdef ENABLE_DISASSEMBLER
153 if (FLAG_print_code_stubs) { 155 if (FLAG_print_code_stubs) {
154 CodeTracer::Scope trace_scope(isolate()->GetCodeTracer()); 156 CodeTracer::Scope trace_scope(isolate()->GetCodeTracer());
155 OFStream os(trace_scope.file()); 157 OFStream os(trace_scope.file());
156 OStringStream name; 158 std::ostringstream name;
157 name << *this; 159 name << *this;
158 new_object->Disassemble(name.c_str(), os); 160 new_object->Disassemble(name.str().c_str(), os);
159 os << "\n"; 161 os << "\n";
160 } 162 }
161 #endif 163 #endif
162 164
163 if (UseSpecialCache()) { 165 if (UseSpecialCache()) {
164 AddToSpecialCache(new_object); 166 AddToSpecialCache(new_object);
165 } else { 167 } else {
166 // Update the dictionary and the root in Heap. 168 // Update the dictionary and the root in Heap.
167 Handle<UnseededNumberDictionary> dict = 169 Handle<UnseededNumberDictionary> dict =
168 UnseededNumberDictionary::AtNumberPut( 170 UnseededNumberDictionary::AtNumberPut(
(...skipping 22 matching lines...) Expand all
191 case NoCache: 193 case NoCache:
192 return "<NoCache>Stub"; 194 return "<NoCache>Stub";
193 case NUMBER_OF_IDS: 195 case NUMBER_OF_IDS:
194 UNREACHABLE(); 196 UNREACHABLE();
195 return NULL; 197 return NULL;
196 } 198 }
197 return NULL; 199 return NULL;
198 } 200 }
199 201
200 202
201 void CodeStub::PrintBaseName(OStream& os) const { // NOLINT 203 void CodeStub::PrintBaseName(std::ostream& os) const { // NOLINT
202 os << MajorName(MajorKey(), false); 204 os << MajorName(MajorKey(), false);
203 } 205 }
204 206
205 207
206 void CodeStub::PrintName(OStream& os) const { // NOLINT 208 void CodeStub::PrintName(std::ostream& os) const { // NOLINT
207 PrintBaseName(os); 209 PrintBaseName(os);
208 PrintState(os); 210 PrintState(os);
209 } 211 }
210 212
211 213
212 void CodeStub::Dispatch(Isolate* isolate, uint32_t key, void** value_out, 214 void CodeStub::Dispatch(Isolate* isolate, uint32_t key, void** value_out,
213 DispatchedCall call) { 215 DispatchedCall call) {
214 switch (MajorKeyFromKey(key)) { 216 switch (MajorKeyFromKey(key)) {
215 #define DEF_CASE(NAME) \ 217 #define DEF_CASE(NAME) \
216 case NAME: { \ 218 case NAME: { \
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 static_cast<OverwriteMode>(mode)); 274 static_cast<OverwriteMode>(mode));
273 stub.GetCode(); 275 stub.GetCode();
274 } 276 }
275 } 277 }
276 278
277 // Generate special versions of the stub. 279 // Generate special versions of the stub.
278 BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); 280 BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime);
279 } 281 }
280 282
281 283
282 void BinaryOpICStub::PrintState(OStream& os) const { // NOLINT 284 void BinaryOpICStub::PrintState(std::ostream& os) const { // NOLINT
283 os << state(); 285 os << state();
284 } 286 }
285 287
286 288
287 // static 289 // static
288 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate, 290 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate,
289 const BinaryOpICState& state) { 291 const BinaryOpICState& state) {
290 BinaryOpICStub stub(isolate, state); 292 BinaryOpICStub stub(isolate, state);
291 stub.GetCode(); 293 stub.GetCode();
292 } 294 }
293 295
294 296
295 // static 297 // static
296 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { 298 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) {
297 // Generate special versions of the stub. 299 // Generate special versions of the stub.
298 BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); 300 BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime);
299 } 301 }
300 302
301 303
302 void BinaryOpICWithAllocationSiteStub::PrintState( 304 void BinaryOpICWithAllocationSiteStub::PrintState(
303 OStream& os) const { // NOLINT 305 std::ostream& os) const { // NOLINT
304 os << state(); 306 os << state();
305 } 307 }
306 308
307 309
308 // static 310 // static
309 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime( 311 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(
310 Isolate* isolate, const BinaryOpICState& state) { 312 Isolate* isolate, const BinaryOpICState& state) {
311 if (state.CouldCreateAllocationMementos()) { 313 if (state.CouldCreateAllocationMementos()) {
312 BinaryOpICWithAllocationSiteStub stub(isolate, state); 314 BinaryOpICWithAllocationSiteStub stub(isolate, state);
313 stub.GetCode(); 315 stub.GetCode();
314 } 316 }
315 } 317 }
316 318
317 319
318 void StringAddStub::PrintBaseName(OStream& os) const { // NOLINT 320 void StringAddStub::PrintBaseName(std::ostream& os) const { // NOLINT
319 os << "StringAddStub"; 321 os << "StringAddStub";
320 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) { 322 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) {
321 os << "_CheckBoth"; 323 os << "_CheckBoth";
322 } else if ((flags() & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { 324 } else if ((flags() & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) {
323 os << "_CheckLeft"; 325 os << "_CheckLeft";
324 } else if ((flags() & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { 326 } else if ((flags() & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) {
325 os << "_CheckRight"; 327 os << "_CheckRight";
326 } 328 }
327 if (pretenure_flag() == TENURED) { 329 if (pretenure_flag() == TENURED) {
328 os << "_Tenured"; 330 os << "_Tenured";
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 458
457 template<class StateType> 459 template<class StateType>
458 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { 460 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) {
459 // Note: Although a no-op transition is semantically OK, it is hinting at a 461 // Note: Although a no-op transition is semantically OK, it is hinting at a
460 // bug somewhere in our state transition machinery. 462 // bug somewhere in our state transition machinery.
461 DCHECK(from != to); 463 DCHECK(from != to);
462 if (!FLAG_trace_ic) return; 464 if (!FLAG_trace_ic) return;
463 OFStream os(stdout); 465 OFStream os(stdout);
464 os << "["; 466 os << "[";
465 PrintBaseName(os); 467 PrintBaseName(os);
466 os << ": " << from << "=>" << to << "]" << endl; 468 os << ": " << from << "=>" << to << "]" << std::endl;
467 } 469 }
468 470
469 471
470 void CompareNilICStub::PrintBaseName(OStream& os) const { // NOLINT 472 void CompareNilICStub::PrintBaseName(std::ostream& os) const { // NOLINT
471 CodeStub::PrintBaseName(os); 473 CodeStub::PrintBaseName(os);
472 os << ((nil_value() == kNullValue) ? "(NullValue)" : "(UndefinedValue)"); 474 os << ((nil_value() == kNullValue) ? "(NullValue)" : "(UndefinedValue)");
473 } 475 }
474 476
475 477
476 void CompareNilICStub::PrintState(OStream& os) const { // NOLINT 478 void CompareNilICStub::PrintState(std::ostream& os) const { // NOLINT
477 os << state(); 479 os << state();
478 } 480 }
479 481
480 482
481 // TODO(svenpanne) Make this a real infix_ostream_iterator. 483 // TODO(svenpanne) Make this a real infix_ostream_iterator.
482 class SimpleListPrinter { 484 class SimpleListPrinter {
483 public: 485 public:
484 explicit SimpleListPrinter(OStream& os) : os_(os), first_(true) {} 486 explicit SimpleListPrinter(std::ostream& os) : os_(os), first_(true) {}
485 487
486 void Add(const char* s) { 488 void Add(const char* s) {
487 if (first_) { 489 if (first_) {
488 first_ = false; 490 first_ = false;
489 } else { 491 } else {
490 os_ << ","; 492 os_ << ",";
491 } 493 }
492 os_ << s; 494 os_ << s;
493 } 495 }
494 496
495 private: 497 private:
496 OStream& os_; 498 std::ostream& os_;
497 bool first_; 499 bool first_;
498 }; 500 };
499 501
500 502
501 OStream& operator<<(OStream& os, const CompareNilICStub::State& s) { 503 std::ostream& operator<<(std::ostream& os, const CompareNilICStub::State& s) {
502 os << "("; 504 os << "(";
503 SimpleListPrinter p(os); 505 SimpleListPrinter p(os);
504 if (s.IsEmpty()) p.Add("None"); 506 if (s.IsEmpty()) p.Add("None");
505 if (s.Contains(CompareNilICStub::UNDEFINED)) p.Add("Undefined"); 507 if (s.Contains(CompareNilICStub::UNDEFINED)) p.Add("Undefined");
506 if (s.Contains(CompareNilICStub::NULL_TYPE)) p.Add("Null"); 508 if (s.Contains(CompareNilICStub::NULL_TYPE)) p.Add("Null");
507 if (s.Contains(CompareNilICStub::MONOMORPHIC_MAP)) p.Add("MonomorphicMap"); 509 if (s.Contains(CompareNilICStub::MONOMORPHIC_MAP)) p.Add("MonomorphicMap");
508 if (s.Contains(CompareNilICStub::GENERIC)) p.Add("Generic"); 510 if (s.Contains(CompareNilICStub::GENERIC)) p.Add("Generic");
509 return os << ")"; 511 return os << ")";
510 } 512 }
511 513
(...skipping 20 matching lines...) Expand all
532 534
533 535
534 Type* CompareNilICStub::GetInputType(Zone* zone, Handle<Map> map) { 536 Type* CompareNilICStub::GetInputType(Zone* zone, Handle<Map> map) {
535 Type* output_type = GetType(zone, map); 537 Type* output_type = GetType(zone, map);
536 Type* nil_type = 538 Type* nil_type =
537 nil_value() == kNullValue ? Type::Null(zone) : Type::Undefined(zone); 539 nil_value() == kNullValue ? Type::Null(zone) : Type::Undefined(zone);
538 return Type::Union(output_type, nil_type, zone); 540 return Type::Union(output_type, nil_type, zone);
539 } 541 }
540 542
541 543
542 void CallIC_ArrayStub::PrintState(OStream& os) const { // NOLINT 544 void CallIC_ArrayStub::PrintState(std::ostream& os) const { // NOLINT
543 os << state() << " (Array)"; 545 os << state() << " (Array)";
544 } 546 }
545 547
546 548
547 void CallICStub::PrintState(OStream& os) const { // NOLINT 549 void CallICStub::PrintState(std::ostream& os) const { // NOLINT
548 os << state(); 550 os << state();
549 } 551 }
550 552
551 553
552 void InstanceofStub::PrintName(OStream& os) const { // NOLINT 554 void InstanceofStub::PrintName(std::ostream& os) const { // NOLINT
553 os << "InstanceofStub"; 555 os << "InstanceofStub";
554 if (HasArgsInRegisters()) os << "_REGS"; 556 if (HasArgsInRegisters()) os << "_REGS";
555 if (HasCallSiteInlineCheck()) os << "_INLINE"; 557 if (HasCallSiteInlineCheck()) os << "_INLINE";
556 if (ReturnTrueFalseObject()) os << "_TRUEFALSE"; 558 if (ReturnTrueFalseObject()) os << "_TRUEFALSE";
557 } 559 }
558 560
559 561
560 void JSEntryStub::FinishCode(Handle<Code> code) { 562 void JSEntryStub::FinishCode(Handle<Code> code) {
561 Handle<FixedArray> handler_table = 563 Handle<FixedArray> handler_table =
562 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); 564 code->GetIsolate()->factory()->NewFixedArray(1, TENURED);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 case NEW_SLOPPY_SLOW: 772 case NEW_SLOPPY_SLOW:
771 GenerateNewSloppySlow(masm); 773 GenerateNewSloppySlow(masm);
772 break; 774 break;
773 case NEW_STRICT: 775 case NEW_STRICT:
774 GenerateNewStrict(masm); 776 GenerateNewStrict(masm);
775 break; 777 break;
776 } 778 }
777 } 779 }
778 780
779 781
780 void ArgumentsAccessStub::PrintName(OStream& os) const { // NOLINT 782 void ArgumentsAccessStub::PrintName(std::ostream& os) const { // NOLINT
781 os << "ArgumentsAccessStub_"; 783 os << "ArgumentsAccessStub_";
782 switch (type()) { 784 switch (type()) {
783 case READ_ELEMENT: 785 case READ_ELEMENT:
784 os << "ReadElement"; 786 os << "ReadElement";
785 break; 787 break;
786 case NEW_SLOPPY_FAST: 788 case NEW_SLOPPY_FAST:
787 os << "NewSloppyFast"; 789 os << "NewSloppyFast";
788 break; 790 break;
789 case NEW_SLOPPY_SLOW: 791 case NEW_SLOPPY_SLOW:
790 os << "NewSloppySlow"; 792 os << "NewSloppySlow";
791 break; 793 break;
792 case NEW_STRICT: 794 case NEW_STRICT:
793 os << "NewStrict"; 795 os << "NewStrict";
794 break; 796 break;
795 } 797 }
796 return; 798 return;
797 } 799 }
798 800
799 801
800 void CallFunctionStub::PrintName(OStream& os) const { // NOLINT 802 void CallFunctionStub::PrintName(std::ostream& os) const { // NOLINT
801 os << "CallFunctionStub_Args" << argc(); 803 os << "CallFunctionStub_Args" << argc();
802 } 804 }
803 805
804 806
805 void CallConstructStub::PrintName(OStream& os) const { // NOLINT 807 void CallConstructStub::PrintName(std::ostream& os) const { // NOLINT
806 os << "CallConstructStub"; 808 os << "CallConstructStub";
807 if (RecordCallTarget()) os << "_Recording"; 809 if (RecordCallTarget()) os << "_Recording";
808 } 810 }
809 811
810 812
811 void ArrayConstructorStub::PrintName(OStream& os) const { // NOLINT 813 void ArrayConstructorStub::PrintName(std::ostream& os) const { // NOLINT
812 os << "ArrayConstructorStub"; 814 os << "ArrayConstructorStub";
813 switch (argument_count()) { 815 switch (argument_count()) {
814 case ANY: 816 case ANY:
815 os << "_Any"; 817 os << "_Any";
816 break; 818 break;
817 case NONE: 819 case NONE:
818 os << "_None"; 820 os << "_None";
819 break; 821 break;
820 case ONE: 822 case ONE:
821 os << "_One"; 823 os << "_One";
822 break; 824 break;
823 case MORE_THAN_ONE: 825 case MORE_THAN_ONE:
824 os << "_More_Than_One"; 826 os << "_More_Than_One";
825 break; 827 break;
826 } 828 }
827 return; 829 return;
828 } 830 }
829 831
830 832
831 OStream& ArrayConstructorStubBase::BasePrintName(OStream& os, // NOLINT 833 std::ostream& ArrayConstructorStubBase::BasePrintName(
832 const char* name) const { 834 std::ostream& os, // NOLINT
835 const char* name) const {
833 os << name << "_" << ElementsKindToString(elements_kind()); 836 os << name << "_" << ElementsKindToString(elements_kind());
834 if (override_mode() == DISABLE_ALLOCATION_SITES) { 837 if (override_mode() == DISABLE_ALLOCATION_SITES) {
835 os << "_DISABLE_ALLOCATION_SITES"; 838 os << "_DISABLE_ALLOCATION_SITES";
836 } 839 }
837 return os; 840 return os;
838 } 841 }
839 842
840 843
841 bool ToBooleanStub::UpdateStatus(Handle<Object> object) { 844 bool ToBooleanStub::UpdateStatus(Handle<Object> object) {
842 Types new_types = types(); 845 Types new_types = types();
843 Types old_types = new_types; 846 Types old_types = new_types;
844 bool to_boolean_value = new_types.UpdateStatus(object); 847 bool to_boolean_value = new_types.UpdateStatus(object);
845 TraceTransition(old_types, new_types); 848 TraceTransition(old_types, new_types);
846 set_sub_minor_key(TypesBits::update(sub_minor_key(), new_types.ToByte())); 849 set_sub_minor_key(TypesBits::update(sub_minor_key(), new_types.ToByte()));
847 return to_boolean_value; 850 return to_boolean_value;
848 } 851 }
849 852
850 853
851 void ToBooleanStub::PrintState(OStream& os) const { // NOLINT 854 void ToBooleanStub::PrintState(std::ostream& os) const { // NOLINT
852 os << types(); 855 os << types();
853 } 856 }
854 857
855 858
856 OStream& operator<<(OStream& os, const ToBooleanStub::Types& s) { 859 std::ostream& operator<<(std::ostream& os, const ToBooleanStub::Types& s) {
857 os << "("; 860 os << "(";
858 SimpleListPrinter p(os); 861 SimpleListPrinter p(os);
859 if (s.IsEmpty()) p.Add("None"); 862 if (s.IsEmpty()) p.Add("None");
860 if (s.Contains(ToBooleanStub::UNDEFINED)) p.Add("Undefined"); 863 if (s.Contains(ToBooleanStub::UNDEFINED)) p.Add("Undefined");
861 if (s.Contains(ToBooleanStub::BOOLEAN)) p.Add("Bool"); 864 if (s.Contains(ToBooleanStub::BOOLEAN)) p.Add("Bool");
862 if (s.Contains(ToBooleanStub::NULL_TYPE)) p.Add("Null"); 865 if (s.Contains(ToBooleanStub::NULL_TYPE)) p.Add("Null");
863 if (s.Contains(ToBooleanStub::SMI)) p.Add("Smi"); 866 if (s.Contains(ToBooleanStub::SMI)) p.Add("Smi");
864 if (s.Contains(ToBooleanStub::SPEC_OBJECT)) p.Add("SpecObject"); 867 if (s.Contains(ToBooleanStub::SPEC_OBJECT)) p.Add("SpecObject");
865 if (s.Contains(ToBooleanStub::STRING)) p.Add("String"); 868 if (s.Contains(ToBooleanStub::STRING)) p.Add("String");
866 if (s.Contains(ToBooleanStub::SYMBOL)) p.Add("Symbol"); 869 if (s.Contains(ToBooleanStub::SYMBOL)) p.Add("Symbol");
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 } 962 }
960 963
961 964
962 InternalArrayConstructorStub::InternalArrayConstructorStub( 965 InternalArrayConstructorStub::InternalArrayConstructorStub(
963 Isolate* isolate) : PlatformCodeStub(isolate) { 966 Isolate* isolate) : PlatformCodeStub(isolate) {
964 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); 967 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
965 } 968 }
966 969
967 970
968 } } // namespace v8::internal 971 } } // 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