class ModeBits: public BitField<OverwriteMode, 0, 2> {};
class OpBits: public BitField<Token::Value, 2, 14> {};
- Major MajorKey() { return ConvertToDouble; }
- int MinorKey() {
+ Major MajorKey() const { return ConvertToDouble; }
+ int MinorKey() const {
// Encode the parameters in a unique 16 bit value.
return result1_.code() +
(result2_.code() << 4) +
private:
SaveFPRegsMode save_doubles_;
- Major MajorKey() { return StoreBufferOverflow; }
- int MinorKey() { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
+ Major MajorKey() const { return StoreBufferOverflow; }
+ int MinorKey() const { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
};
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
private:
- Major MajorKey() { return SubString; }
- int MinorKey() { return 0; }
+ Major MajorKey() const { return SubString; }
+ int MinorKey() const { return 0; }
void Generate(MacroAssembler* masm);
};
Register scratch3);
private:
- virtual Major MajorKey() { return StringCompare; }
- virtual int MinorKey() { return 0; }
+ virtual Major MajorKey() const { return StringCompare; }
+ virtual int MinorKey() const { return 0; }
virtual void Generate(MacroAssembler* masm);
static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm,
class HeapNumberRegisterBits: public BitField<int, 4, 4> {};
class ScratchRegisterBits: public BitField<int, 8, 4> {};
- Major MajorKey() { return WriteInt32ToHeapNumber; }
- int MinorKey() {
+ Major MajorKey() const { return WriteInt32ToHeapNumber; }
+ int MinorKey() const {
// Encode the parameters in a unique 16 bit value.
return IntRegisterBits::encode(the_int_.code())
| HeapNumberRegisterBits::encode(the_heap_number_.code())
Mode mode);
void InformIncrementalMarker(MacroAssembler* masm);
- Major MajorKey() { return RecordWrite; }
+ Major MajorKey() const { return RecordWrite; }
- int MinorKey() {
+ int MinorKey() const {
return ObjectBits::encode(object_.code()) |
ValueBits::encode(value_.code()) |
AddressBits::encode(address_.code()) |
void GenerateCall(MacroAssembler* masm, Register target);
private:
- Major MajorKey() { return DirectCEntry; }
- int MinorKey() { return 0; }
+ Major MajorKey() const { return DirectCEntry; }
+ int MinorKey() const { return 0; }
bool NeedsImmovableCode() { return true; }
};
NameDictionary::kHeaderSize +
NameDictionary::kElementsStartIndex * kPointerSize;
- Major MajorKey() { return NameDictionaryLookup; }
+ Major MajorKey() const { return NameDictionaryLookup; }
- int MinorKey() {
- return LookupModeBits::encode(mode_);
- }
+ int MinorKey() const { return LookupModeBits::encode(mode_); }
class LookupModeBits: public BitField<LookupMode, 0, 1> {};
private:
SaveFPRegsMode save_doubles_;
- Major MajorKey() { return StoreBufferOverflow; }
- int MinorKey() { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
+ Major MajorKey() const { return StoreBufferOverflow; }
+ int MinorKey() const { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
};
static Register to_be_pushed_lr() { return ip0; }
static void GenerateAheadOfTime(Isolate* isolate);
private:
- Major MajorKey() { return StoreRegistersState; }
- int MinorKey() { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
+ Major MajorKey() const { return StoreRegistersState; }
+ int MinorKey() const { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
SaveFPRegsMode save_doubles_;
void Generate(MacroAssembler* masm);
static void GenerateAheadOfTime(Isolate* isolate);
private:
- Major MajorKey() { return RestoreRegistersState; }
- int MinorKey() { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
+ Major MajorKey() const { return RestoreRegistersState; }
+ int MinorKey() const { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
SaveFPRegsMode save_doubles_;
void Generate(MacroAssembler* masm);
Mode mode);
void InformIncrementalMarker(MacroAssembler* masm);
- Major MajorKey() { return RecordWrite; }
+ Major MajorKey() const { return RecordWrite; }
- int MinorKey() {
+ int MinorKey() const {
return MinorKeyFor(object_, value_, address_, remembered_set_action_,
save_fp_regs_mode_);
}
void GenerateCall(MacroAssembler* masm, Register target);
private:
- Major MajorKey() { return DirectCEntry; }
- int MinorKey() { return 0; }
+ Major MajorKey() const { return DirectCEntry; }
+ int MinorKey() const { return 0; }
bool NeedsImmovableCode() { return true; }
};
NameDictionary::kHeaderSize +
NameDictionary::kElementsStartIndex * kPointerSize;
- Major MajorKey() { return NameDictionaryLookup; }
+ Major MajorKey() const { return NameDictionaryLookup; }
- int MinorKey() {
- return LookupModeBits::encode(mode_);
- }
+ int MinorKey() const { return LookupModeBits::encode(mode_); }
class LookupModeBits: public BitField<LookupMode, 0, 1> {};
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
private:
- Major MajorKey() { return SubString; }
- int MinorKey() { return 0; }
+ Major MajorKey() const { return SubString; }
+ int MinorKey() const { return 0; }
void Generate(MacroAssembler* masm);
};
Register scratch3);
private:
- virtual Major MajorKey() { return StringCompare; }
- virtual int MinorKey() { return 0; }
+ virtual Major MajorKey() const { return StringCompare; }
+ virtual int MinorKey() const { return 0; }
virtual void Generate(MacroAssembler* masm);
static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm,
LChunk* chunk = OptimizeGraph(builder.CreateGraph());
Handle<Code> code = chunk->Codegen();
if (FLAG_profile_hydrogen_code_stub_compilation) {
- double ms = timer.Elapsed().InMillisecondsF();
- PrintF("[Lazy compilation of %s took %0.3f ms]\n",
- stub->GetName().get(), ms);
+ OFStream os(stdout);
+ os << "[Lazy compilation of " << stub << " took "
+ << timer.Elapsed().InMillisecondsF() << " ms]" << endl;
}
return code;
}
}
-SmartArrayPointer<const char> CodeStub::GetName() {
- char buffer[100];
- NoAllocationStringAllocator allocator(buffer,
- static_cast<unsigned>(sizeof(buffer)));
- StringStream stream(&allocator);
- PrintName(&stream);
- return stream.ToCString();
-}
-
-
void CodeStub::RecordCodeGeneration(Handle<Code> code) {
IC::RegisterWeakMapDependency(code);
- SmartArrayPointer<const char> name = GetName();
- PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, *code, name.get()));
- GDBJIT(AddCode(GDBJITInterface::STUB, name.get(), *code));
+ OStringStream os;
+ os << *this;
+ PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, *code, os.c_str()));
+ GDBJIT(AddCode(GDBJITInterface::STUB, os.c_str(), *code));
Counters* counters = isolate()->counters();
counters->total_stubs_code_size()->Increment(code->instruction_size());
}
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_code_stubs) {
CodeTracer::Scope trace_scope(isolate()->GetCodeTracer());
- new_object->Disassemble(GetName().get(), trace_scope.file());
+ OStringStream os;
+ os << *this;
+ new_object->Disassemble(os.c_str(), trace_scope.file());
PrintF(trace_scope.file(), "\n");
}
#endif
}
-void CodeStub::PrintBaseName(StringStream* stream) {
- stream->Add("%s", MajorName(MajorKey(), false));
+void CodeStub::PrintBaseName(OStream& os) const { // NOLINT
+ os << MajorName(MajorKey(), false);
}
-void CodeStub::PrintName(StringStream* stream) {
- PrintBaseName(stream);
- PrintState(stream);
+void CodeStub::PrintName(OStream& os) const { // NOLINT
+ PrintBaseName(os);
+ PrintState(os);
}
}
-void BinaryOpICStub::PrintState(StringStream* stream) {
- state_.Print(stream);
+void BinaryOpICStub::PrintState(OStream& os) const { // NOLINT
+ os << state_;
}
}
-void BinaryOpICWithAllocationSiteStub::PrintState(StringStream* stream) {
- state_.Print(stream);
+void BinaryOpICWithAllocationSiteStub::PrintState(
+ OStream& os) const { // NOLINT
+ os << state_;
}
}
-void StringAddStub::PrintBaseName(StringStream* stream) {
- stream->Add("StringAddStub");
+void StringAddStub::PrintBaseName(OStream& os) const { // NOLINT
+ os << "StringAddStub";
if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) {
- stream->Add("_CheckBoth");
+ os << "_CheckBoth";
} else if ((flags() & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) {
- stream->Add("_CheckLeft");
+ os << "_CheckLeft";
} else if ((flags() & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) {
- stream->Add("_CheckRight");
+ os << "_CheckRight";
}
if (pretenure_flag() == TENURED) {
- stream->Add("_Tenured");
+ os << "_Tenured";
}
}
}
-int ICCompareStub::MinorKey() {
+int ICCompareStub::MinorKey() const {
return OpField::encode(op_ - Token::EQ) |
LeftStateField::encode(left_) |
RightStateField::encode(right_) |
// bug somewhere in our state transition machinery.
ASSERT(from != to);
if (!FLAG_trace_ic) return;
- char buffer[100];
- NoAllocationStringAllocator allocator(buffer,
- static_cast<unsigned>(sizeof(buffer)));
- StringStream stream(&allocator);
- stream.Add("[");
- PrintBaseName(&stream);
- stream.Add(": ");
- from.Print(&stream);
- stream.Add("=>");
- to.Print(&stream);
- stream.Add("]\n");
- stream.OutputToStdOut();
+ OFStream os(stdout);
+ os << "[";
+ PrintBaseName(os);
+ os << ": " << from << "=>" << to << "]" << endl;
}
-void CompareNilICStub::PrintBaseName(StringStream* stream) {
- CodeStub::PrintBaseName(stream);
- stream->Add((nil_value_ == kNullValue) ? "(NullValue)":
- "(UndefinedValue)");
+void CompareNilICStub::PrintBaseName(OStream& os) const { // NOLINT
+ CodeStub::PrintBaseName(os);
+ os << ((nil_value_ == kNullValue) ? "(NullValue)" : "(UndefinedValue)");
}
-void CompareNilICStub::PrintState(StringStream* stream) {
- state_.Print(stream);
+void CompareNilICStub::PrintState(OStream& os) const { // NOLINT
+ os << state_;
}
-void CompareNilICStub::State::Print(StringStream* stream) const {
- stream->Add("(");
- SimpleListPrinter printer(stream);
- if (IsEmpty()) printer.Add("None");
- if (Contains(UNDEFINED)) printer.Add("Undefined");
- if (Contains(NULL_TYPE)) printer.Add("Null");
- if (Contains(MONOMORPHIC_MAP)) printer.Add("MonomorphicMap");
- if (Contains(GENERIC)) printer.Add("Generic");
- stream->Add(")");
+// TODO(svenpanne) Make this a real infix_ostream_iterator.
+class SimpleListPrinter {
+ public:
+ explicit SimpleListPrinter(OStream& os) : os_(os), first_(true) {}
+
+ void Add(const char* s) {
+ if (first_) {
+ first_ = false;
+ } else {
+ os_ << ",";
+ }
+ os_ << s;
+ }
+
+ private:
+ OStream& os_;
+ bool first_;
+};
+
+
+OStream& operator<<(OStream& os, const CompareNilICStub::State& s) {
+ os << "(";
+ SimpleListPrinter p(os);
+ if (s.IsEmpty()) p.Add("None");
+ if (s.Contains(CompareNilICStub::UNDEFINED)) p.Add("Undefined");
+ if (s.Contains(CompareNilICStub::NULL_TYPE)) p.Add("Null");
+ if (s.Contains(CompareNilICStub::MONOMORPHIC_MAP)) p.Add("MonomorphicMap");
+ if (s.Contains(CompareNilICStub::GENERIC)) p.Add("Generic");
+ return os << ")";
}
}
-void CallIC_ArrayStub::PrintState(StringStream* stream) {
- state_.Print(stream);
- stream->Add(" (Array)");
+void CallIC_ArrayStub::PrintState(OStream& os) const { // NOLINT
+ os << state_ << " (Array)";
}
-void CallICStub::PrintState(StringStream* stream) {
- state_.Print(stream);
+void CallICStub::PrintState(OStream& os) const { // NOLINT
+ os << state_;
}
-void InstanceofStub::PrintName(StringStream* stream) {
- const char* args = "";
- if (HasArgsInRegisters()) {
- args = "_REGS";
- }
-
- const char* inline_check = "";
- if (HasCallSiteInlineCheck()) {
- inline_check = "_INLINE";
- }
-
- const char* return_true_false_object = "";
- if (ReturnTrueFalseObject()) {
- return_true_false_object = "_TRUEFALSE";
- }
-
- stream->Add("InstanceofStub%s%s%s",
- args,
- inline_check,
- return_true_false_object);
+void InstanceofStub::PrintName(OStream& os) const { // NOLINT
+ os << "InstanceofStub";
+ if (HasArgsInRegisters()) os << "_REGS";
+ if (HasCallSiteInlineCheck()) os << "_INLINE";
+ if (ReturnTrueFalseObject()) os << "_TRUEFALSE";
}
}
-void ArgumentsAccessStub::PrintName(StringStream* stream) {
- stream->Add("ArgumentsAccessStub_");
+void ArgumentsAccessStub::PrintName(OStream& os) const { // NOLINT
+ os << "ArgumentsAccessStub_";
switch (type_) {
- case READ_ELEMENT: stream->Add("ReadElement"); break;
- case NEW_SLOPPY_FAST: stream->Add("NewSloppyFast"); break;
- case NEW_SLOPPY_SLOW: stream->Add("NewSloppySlow"); break;
- case NEW_STRICT: stream->Add("NewStrict"); break;
+ case READ_ELEMENT:
+ os << "ReadElement";
+ break;
+ case NEW_SLOPPY_FAST:
+ os << "NewSloppyFast";
+ break;
+ case NEW_SLOPPY_SLOW:
+ os << "NewSloppySlow";
+ break;
+ case NEW_STRICT:
+ os << "NewStrict";
+ break;
}
+ return;
}
-void CallFunctionStub::PrintName(StringStream* stream) {
- stream->Add("CallFunctionStub_Args%d", argc_);
+void CallFunctionStub::PrintName(OStream& os) const { // NOLINT
+ os << "CallFunctionStub_Args" << argc_;
}
-void CallConstructStub::PrintName(StringStream* stream) {
- stream->Add("CallConstructStub");
- if (RecordCallTarget()) stream->Add("_Recording");
+void CallConstructStub::PrintName(OStream& os) const { // NOLINT
+ os << "CallConstructStub";
+ if (RecordCallTarget()) os << "_Recording";
}
-void ArrayConstructorStub::PrintName(StringStream* stream) {
- stream->Add("ArrayConstructorStub");
+void ArrayConstructorStub::PrintName(OStream& os) const { // NOLINT
+ os << "ArrayConstructorStub";
switch (argument_count_) {
- case ANY: stream->Add("_Any"); break;
- case NONE: stream->Add("_None"); break;
- case ONE: stream->Add("_One"); break;
- case MORE_THAN_ONE: stream->Add("_More_Than_One"); break;
+ case ANY:
+ os << "_Any";
+ break;
+ case NONE:
+ os << "_None";
+ break;
+ case ONE:
+ os << "_One";
+ break;
+ case MORE_THAN_ONE:
+ os << "_More_Than_One";
+ break;
}
+ return;
}
-void ArrayConstructorStubBase::BasePrintName(const char* name,
- StringStream* stream) {
- stream->Add(name);
- stream->Add("_");
- stream->Add(ElementsKindToString(elements_kind()));
+OStream& ArrayConstructorStubBase::BasePrintName(OStream& os, // NOLINT
+ const char* name) const {
+ os << name << "_" << ElementsKindToString(elements_kind());
if (override_mode() == DISABLE_ALLOCATION_SITES) {
- stream->Add("_DISABLE_ALLOCATION_SITES");
+ os << "_DISABLE_ALLOCATION_SITES";
}
+ return os;
}
}
-void ToBooleanStub::PrintState(StringStream* stream) {
- types_.Print(stream);
+void ToBooleanStub::PrintState(OStream& os) const { // NOLINT
+ os << types_;
}
-void ToBooleanStub::Types::Print(StringStream* stream) const {
- stream->Add("(");
- SimpleListPrinter printer(stream);
- if (IsEmpty()) printer.Add("None");
- if (Contains(UNDEFINED)) printer.Add("Undefined");
- if (Contains(BOOLEAN)) printer.Add("Bool");
- if (Contains(NULL_TYPE)) printer.Add("Null");
- if (Contains(SMI)) printer.Add("Smi");
- if (Contains(SPEC_OBJECT)) printer.Add("SpecObject");
- if (Contains(STRING)) printer.Add("String");
- if (Contains(SYMBOL)) printer.Add("Symbol");
- if (Contains(HEAP_NUMBER)) printer.Add("HeapNumber");
- stream->Add(")");
+OStream& operator<<(OStream& os, const ToBooleanStub::Types& s) {
+ os << "(";
+ SimpleListPrinter p(os);
+ if (s.IsEmpty()) p.Add("None");
+ if (s.Contains(ToBooleanStub::UNDEFINED)) p.Add("Undefined");
+ if (s.Contains(ToBooleanStub::BOOLEAN)) p.Add("Bool");
+ if (s.Contains(ToBooleanStub::NULL_TYPE)) p.Add("Null");
+ if (s.Contains(ToBooleanStub::SMI)) p.Add("Smi");
+ if (s.Contains(ToBooleanStub::SPEC_OBJECT)) p.Add("SpecObject");
+ if (s.Contains(ToBooleanStub::STRING)) p.Add("String");
+ if (s.Contains(ToBooleanStub::SYMBOL)) p.Add("Symbol");
+ if (s.Contains(ToBooleanStub::HEAP_NUMBER)) p.Add("HeapNumber");
+ return os << ")";
}
bool FindCodeInCache(Code** code_out);
// Returns information for computing the number key.
- virtual Major MajorKey() = 0;
- virtual int MinorKey() = 0;
+ virtual Major MajorKey() const = 0;
+ virtual int MinorKey() const = 0;
virtual InlineCacheState GetICState() {
return UNINITIALIZED;
}
- virtual ExtraICState GetExtraICState() {
- return kNoExtraICState;
- }
+ virtual ExtraICState GetExtraICState() const { return kNoExtraICState; }
virtual Code::StubType GetStubType() {
return Code::NORMAL;
}
- virtual void PrintName(StringStream* stream);
-
- // Returns a name for logging/debugging purposes.
- SmartArrayPointer<const char> GetName();
+ friend OStream& operator<<(OStream& os, const CodeStub& s) {
+ s.PrintName(os);
+ return os;
+ }
Isolate* isolate() const { return isolate_; }
// a fixed (non-moveable) code object.
virtual bool NeedsImmovableCode() { return false; }
- virtual void PrintBaseName(StringStream* stream);
- virtual void PrintState(StringStream* stream) { }
+ virtual void PrintName(OStream& os) const; // NOLINT
+ virtual void PrintBaseName(OStream& os) const; // NOLINT
+ virtual void PrintState(OStream& os) const { ; } // NOLINT
private:
// Perform bookkeeping required after code generation when stub code is
// Retrieve the code for the stub. Generate the code if needed.
virtual Handle<Code> GenerateCode() = 0;
- virtual int NotMissMinorKey() = 0;
+ virtual int NotMissMinorKey() const = 0;
Handle<Code> GenerateLightweightMissCode();
class IsMissBits: public BitField<bool, kStubMinorKeyBits - 1, 1> {};
void GenerateLightweightMiss(MacroAssembler* masm);
- virtual int MinorKey() {
+ virtual int MinorKey() const {
return IsMissBits::encode(is_uninitialized_) |
MinorKeyBits::encode(NotMissMinorKey());
}
}
private:
- Major MajorKey() { return ToNumber; }
- int NotMissMinorKey() { return 0; }
+ Major MajorKey() const { return ToNumber; }
+ int NotMissMinorKey() const { return 0; }
};
static const int kNumber = 0;
private:
- virtual Major MajorKey() V8_OVERRIDE { return NumberToString; }
- virtual int NotMissMinorKey() V8_OVERRIDE { return 0; }
+ virtual Major MajorKey() const V8_OVERRIDE { return NumberToString; }
+ virtual int NotMissMinorKey() const V8_OVERRIDE { return 0; }
};
class StrictModeBits: public BitField<bool, 0, 1> {};
class IsGeneratorBits: public BitField<bool, 1, 1> {};
- Major MajorKey() { return FastNewClosure; }
- int NotMissMinorKey() {
+ Major MajorKey() const { return FastNewClosure; }
+ int NotMissMinorKey() const {
return StrictModeBits::encode(strict_mode_ == STRICT) |
IsGeneratorBits::encode(is_generator_);
}
int slots() const { return slots_; }
- virtual Major MajorKey() V8_OVERRIDE { return FastNewContext; }
- virtual int NotMissMinorKey() V8_OVERRIDE { return slots_; }
+ virtual Major MajorKey() const V8_OVERRIDE { return FastNewContext; }
+ virtual int NotMissMinorKey() const V8_OVERRIDE { return slots_; }
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kFunction = 0;
class AllocationSiteModeBits: public BitField<AllocationSiteMode, 0, 1> {};
// Ensure data fits within available bits.
- Major MajorKey() { return FastCloneShallowArray; }
- int NotMissMinorKey() {
+ Major MajorKey() const { return FastCloneShallowArray; }
+ int NotMissMinorKey() const {
return AllocationSiteModeBits::encode(allocation_site_mode_);
}
};
private:
int length_;
- Major MajorKey() { return FastCloneShallowObject; }
- int NotMissMinorKey() { return length_; }
+ Major MajorKey() const { return FastCloneShallowObject; }
+ int NotMissMinorKey() const { return length_; }
DISALLOW_COPY_AND_ASSIGN(FastCloneShallowObjectStub);
};
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
private:
- Major MajorKey() { return CreateAllocationSite; }
- int NotMissMinorKey() { return 0; }
+ Major MajorKey() const { return CreateAllocationSite; }
+ int NotMissMinorKey() const { return 0; }
DISALLOW_COPY_AND_ASSIGN(CreateAllocationSiteStub);
};
void Generate(MacroAssembler* masm);
private:
- Major MajorKey() { return Instanceof; }
- int MinorKey() { return static_cast<int>(flags_); }
+ Major MajorKey() const { return Instanceof; }
+ int MinorKey() const { return static_cast<int>(flags_); }
bool HasArgsInRegisters() const {
return (flags_ & kArgsInRegisters) != 0;
return (flags_ & kReturnTrueFalseObject) != 0;
}
- virtual void PrintName(StringStream* stream);
+ virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT
Flags flags_;
};
private:
void GenerateDispatchToArrayStub(MacroAssembler* masm,
AllocationSiteOverrideMode mode);
- virtual void PrintName(StringStream* stream);
+ virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT
- virtual CodeStub::Major MajorKey() { return ArrayConstructor; }
- virtual int MinorKey() { return argument_count_; }
+ virtual CodeStub::Major MajorKey() const { return ArrayConstructor; }
+ virtual int MinorKey() const { return argument_count_; }
ArgumentCountKey argument_count_;
};
void Generate(MacroAssembler* masm);
private:
- virtual CodeStub::Major MajorKey() { return InternalArrayConstructor; }
- virtual int MinorKey() { return 0; }
+ virtual CodeStub::Major MajorKey() const { return InternalArrayConstructor; }
+ virtual int MinorKey() const { return 0; }
void GenerateCase(MacroAssembler* masm, ElementsKind kind);
};
virtual void Generate(MacroAssembler* masm);
private:
- virtual CodeStub::Major MajorKey() { return MathPow; }
- virtual int MinorKey() { return exponent_type_; }
+ virtual CodeStub::Major MajorKey() const { return MathPow; }
+ virtual int MinorKey() const { return exponent_type_; }
ExponentType exponent_type_;
};
virtual void FinishCode(Handle<Code> code) {
code->set_stub_info(MinorKey());
}
- Code::Kind kind() { return kind_; }
+ Code::Kind kind() const { return kind_; }
- virtual int MinorKey() {
- return KindBits::encode(kind_);
- }
+ virtual int MinorKey() const { return KindBits::encode(kind_); }
private:
Code::Kind kind_;
return state_.GetICState();
}
- virtual ExtraICState GetExtraICState() V8_FINAL V8_OVERRIDE {
+ virtual ExtraICState GetExtraICState() const V8_FINAL V8_OVERRIDE {
return state_.GetExtraICState();
}
protected:
- virtual int MinorKey() { return GetExtraICState(); }
- virtual void PrintState(StringStream* stream) V8_OVERRIDE;
+ virtual int MinorKey() const { return GetExtraICState(); }
+ virtual void PrintState(OStream& os) const V8_OVERRIDE; // NOLINT
- virtual CodeStub::Major MajorKey() { return CallIC; }
+ virtual CodeStub::Major MajorKey() const { return CallIC; }
// Code generation helpers.
void GenerateMiss(MacroAssembler* masm, IC::UtilityId id);
virtual void Generate(MacroAssembler* masm);
protected:
- virtual void PrintState(StringStream* stream) V8_OVERRIDE;
+ virtual void PrintState(OStream& os) const V8_OVERRIDE; // NOLINT
- virtual CodeStub::Major MajorKey() { return CallIC_Array; }
+ virtual CodeStub::Major MajorKey() const { return CallIC_Array; }
};
virtual void Generate(MacroAssembler* masm);
private:
- virtual CodeStub::Major MajorKey() { return FunctionPrototype; }
+ virtual CodeStub::Major MajorKey() const { return FunctionPrototype; }
};
: ICStub(isolate, kind), strict_mode_(strict_mode) { }
protected:
- virtual ExtraICState GetExtraICState() {
+ virtual ExtraICState GetExtraICState() const {
return StoreIC::ComputeExtraICState(strict_mode_);
}
private:
STATIC_ASSERT(KindBits::kSize == 4);
class StrictModeBits: public BitField<bool, 4, 1> {};
- virtual int MinorKey() {
+ virtual int MinorKey() const {
return KindBits::encode(kind()) | StrictModeBits::encode(strict_mode_);
}
class HandlerStub: public HICStub {
public:
virtual Code::Kind GetCodeKind() const { return Code::HANDLER; }
- virtual ExtraICState GetExtraICState() { return kind(); }
+ virtual ExtraICState GetExtraICState() const { return kind(); }
protected:
explicit HandlerStub(Isolate* isolate) : HICStub(isolate) { }
- virtual int NotMissMinorKey() { return bit_field_; }
+ virtual int NotMissMinorKey() const { return bit_field_; }
int bit_field_;
};
private:
STATIC_ASSERT(KindBits::kSize == 4);
class EncodedLoadFieldByIndexBits: public BitField<int, 4, 13> {};
- virtual CodeStub::Major MajorKey() { return LoadField; }
+ virtual CodeStub::Major MajorKey() const { return LoadField; }
FieldIndex index_;
};
}
private:
- virtual CodeStub::Major MajorKey() { return StringLength; }
+ virtual CodeStub::Major MajorKey() const { return StringLength; }
};
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
private:
- virtual CodeStub::Major MajorKey() { return KeyedStringLength; }
+ virtual CodeStub::Major MajorKey() const { return KeyedStringLength; }
};
}
private:
- Major MajorKey() { return StoreGlobal; }
+ Major MajorKey() const { return StoreGlobal; }
class IsConstantBits: public BitField<bool, 0, 1> {};
class RepresentationBits: public BitField<Representation::Kind, 1, 8> {};
private:
virtual void Generate(MacroAssembler* masm) V8_OVERRIDE;
- virtual Major MajorKey() V8_OVERRIDE { return CallApiFunction; }
- virtual int MinorKey() V8_OVERRIDE { return bit_field_; }
+ virtual Major MajorKey() const V8_OVERRIDE { return CallApiFunction; }
+ virtual int MinorKey() const V8_OVERRIDE { return bit_field_; }
class IsStoreBits: public BitField<bool, 0, 1> {};
class CallDataUndefinedBits: public BitField<bool, 1, 1> {};
private:
virtual void Generate(MacroAssembler* masm) V8_OVERRIDE;
- virtual Major MajorKey() V8_OVERRIDE { return CallApiGetter; }
- virtual int MinorKey() V8_OVERRIDE { return 0; }
+ virtual Major MajorKey() const V8_OVERRIDE { return CallApiGetter; }
+ virtual int MinorKey() const V8_OVERRIDE { return 0; }
DISALLOW_COPY_AND_ASSIGN(CallApiGetterStub);
};
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
private:
- virtual CodeStub::Major MajorKey() { return KeyedLoadField; }
+ virtual CodeStub::Major MajorKey() const { return KeyedLoadField; }
};
return state_.GetICState();
}
- virtual ExtraICState GetExtraICState() V8_FINAL V8_OVERRIDE {
+ virtual ExtraICState GetExtraICState() const V8_FINAL V8_OVERRIDE {
return state_.GetExtraICState();
}
const BinaryOpIC::State& state() const { return state_; }
- virtual void PrintState(StringStream* stream) V8_FINAL V8_OVERRIDE;
+ virtual void PrintState(OStream& os) const V8_FINAL V8_OVERRIDE; // NOLINT
- virtual Major MajorKey() V8_OVERRIDE { return BinaryOpIC; }
- virtual int NotMissMinorKey() V8_FINAL V8_OVERRIDE {
+ virtual Major MajorKey() const V8_OVERRIDE { return BinaryOpIC; }
+ virtual int NotMissMinorKey() const V8_FINAL V8_OVERRIDE {
return GetExtraICState();
}
return state_.GetICState();
}
- virtual ExtraICState GetExtraICState() V8_OVERRIDE {
+ virtual ExtraICState GetExtraICState() const V8_OVERRIDE {
return state_.GetExtraICState();
}
virtual void Generate(MacroAssembler* masm) V8_OVERRIDE;
- virtual void PrintState(StringStream* stream) V8_OVERRIDE;
+ virtual void PrintState(OStream& os) const V8_OVERRIDE; // NOLINT
- virtual Major MajorKey() V8_OVERRIDE { return BinaryOpICWithAllocationSite; }
- virtual int MinorKey() V8_OVERRIDE { return GetExtraICState(); }
+ virtual Major MajorKey() const V8_OVERRIDE {
+ return BinaryOpICWithAllocationSite;
+ }
+ virtual int MinorKey() const V8_OVERRIDE { return GetExtraICState(); }
private:
static void GenerateAheadOfTime(Isolate* isolate,
virtual Handle<Code> GenerateCode() V8_OVERRIDE;
- virtual Major MajorKey() V8_OVERRIDE {
+ virtual Major MajorKey() const V8_OVERRIDE {
return BinaryOpWithAllocationSite;
}
class PretenureFlagBits: public BitField<PretenureFlag, 2, 1> {};
uint32_t bit_field_;
- virtual Major MajorKey() V8_OVERRIDE { return StringAdd; }
- virtual int NotMissMinorKey() V8_OVERRIDE { return bit_field_; }
+ virtual Major MajorKey() const V8_OVERRIDE { return StringAdd; }
+ virtual int NotMissMinorKey() const V8_OVERRIDE { return bit_field_; }
- virtual void PrintBaseName(StringStream* stream) V8_OVERRIDE;
+ virtual void PrintBaseName(OStream& os) const V8_OVERRIDE; // NOLINT
DISALLOW_COPY_AND_ASSIGN(StringAddStub);
};
code->set_stub_info(MinorKey());
}
- virtual CodeStub::Major MajorKey() { return CompareIC; }
- virtual int MinorKey();
+ virtual CodeStub::Major MajorKey() const { return CompareIC; }
+ virtual int MinorKey() const;
virtual Code::Kind GetCodeKind() const { return Code::COMPARE_IC; }
virtual Handle<Code> GenerateCode() V8_OVERRIDE;
- virtual ExtraICState GetExtraICState() {
+ virtual ExtraICState GetExtraICState() const {
return NilValueField::encode(nil_value_) |
TypesField::encode(state_.ToIntegral());
}
NilValue GetNilValue() const { return nil_value_; }
void ClearState() { state_.RemoveAll(); }
- virtual void PrintState(StringStream* stream);
- virtual void PrintBaseName(StringStream* stream);
+ virtual void PrintState(OStream& os) const V8_OVERRIDE; // NOLINT
+ virtual void PrintBaseName(OStream& os) const V8_OVERRIDE; // NOLINT
private:
friend class CompareNilIC;
public:
State() : EnumSet<CompareNilType, byte>(0) { }
explicit State(byte bits) : EnumSet<CompareNilType, byte>(bits) { }
-
- void Print(StringStream* stream) const;
};
+ friend OStream& operator<<(OStream& os, const State& s);
CompareNilICStub(Isolate* isolate,
NilValue nil,
class NilValueField : public BitField<NilValue, 0, 1> {};
class TypesField : public BitField<byte, 1, NUMBER_OF_TYPES> {};
- virtual CodeStub::Major MajorKey() { return CompareNilIC; }
- virtual int NotMissMinorKey() { return GetExtraICState(); }
+ virtual CodeStub::Major MajorKey() const { return CompareNilIC; }
+ virtual int NotMissMinorKey() const { return GetExtraICState(); }
NilValue nil_value_;
State state_;
};
+OStream& operator<<(OStream& os, const CompareNilICStub::State& s);
+
+
class CEntryStub : public PlatformCodeStub {
public:
CEntryStub(Isolate* isolate,
const int result_size_;
SaveFPRegsMode save_doubles_;
- Major MajorKey() { return CEntry; }
- int MinorKey();
+ Major MajorKey() const { return CEntry; }
+ int MinorKey() const;
bool NeedsImmovableCode();
};
void GenerateBody(MacroAssembler* masm, bool is_construct);
private:
- Major MajorKey() { return JSEntry; }
- int MinorKey() { return 0; }
+ Major MajorKey() const { return JSEntry; }
+ int MinorKey() const { return 0; }
virtual void FinishCode(Handle<Code> code);
void Generate(MacroAssembler* masm) { GenerateBody(masm, true); }
private:
- int MinorKey() { return 1; }
+ int MinorKey() const { return 1; }
- virtual void PrintName(StringStream* stream) {
- stream->Add("JSConstructEntryStub");
+ virtual void PrintName(OStream& os) const V8_OVERRIDE { // NOLINT
+ os << "JSConstructEntryStub";
}
};
private:
Type type_;
- Major MajorKey() { return ArgumentsAccess; }
- int MinorKey() { return type_; }
+ Major MajorKey() const { return ArgumentsAccess; }
+ int MinorKey() const { return type_; }
void Generate(MacroAssembler* masm);
void GenerateReadElement(MacroAssembler* masm);
void GenerateNewSloppyFast(MacroAssembler* masm);
void GenerateNewSloppySlow(MacroAssembler* masm);
- virtual void PrintName(StringStream* stream);
+ virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT
};
explicit RegExpExecStub(Isolate* isolate) : PlatformCodeStub(isolate) { }
private:
- Major MajorKey() { return RegExpExec; }
- int MinorKey() { return 0; }
+ Major MajorKey() const { return RegExpExec; }
+ int MinorKey() const { return 0; }
void Generate(MacroAssembler* masm);
};
virtual void InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
- virtual Major MajorKey() V8_OVERRIDE { return RegExpConstructResult; }
- virtual int NotMissMinorKey() V8_OVERRIDE { return 0; }
+ virtual Major MajorKey() const V8_OVERRIDE { return RegExpConstructResult; }
+ virtual int NotMissMinorKey() const V8_OVERRIDE { return 0; }
static void InstallDescriptors(Isolate* isolate);
int argc_;
CallFunctionFlags flags_;
- virtual void PrintName(StringStream* stream);
+ virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT
// Minor key encoding in 32 bits with Bitfield <Type, shift, size>.
class FlagBits: public BitField<CallFunctionFlags, 0, 2> {};
class ArgcBits: public BitField<unsigned, 2, 32 - 2> {};
- Major MajorKey() { return CallFunction; }
- int MinorKey() {
+ Major MajorKey() const { return CallFunction; }
+ int MinorKey() const {
// Encode the parameters in a unique 32 bit value.
return FlagBits::encode(flags_) | ArgcBits::encode(argc_);
}
private:
CallConstructorFlags flags_;
- virtual void PrintName(StringStream* stream);
+ virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT
- Major MajorKey() { return CallConstruct; }
- int MinorKey() { return flags_; }
+ Major MajorKey() const { return CallConstruct; }
+ int MinorKey() const { return flags_; }
- bool RecordCallTarget() {
+ bool RecordCallTarget() const {
return (flags_ & RECORD_CONSTRUCTOR_TARGET) != 0;
}
};
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
private:
- Major MajorKey() { return KeyedLoadElement; }
- int NotMissMinorKey() { return DICTIONARY_ELEMENTS; }
+ Major MajorKey() const { return KeyedLoadElement; }
+ int NotMissMinorKey() const { return DICTIONARY_ELEMENTS; }
DISALLOW_COPY_AND_ASSIGN(KeyedLoadDictionaryElementStub);
};
void Generate(MacroAssembler* masm);
private:
- Major MajorKey() { return KeyedLoadElement; }
- int MinorKey() { return DICTIONARY_ELEMENTS; }
+ Major MajorKey() const { return KeyedLoadElement; }
+ int MinorKey() const { return DICTIONARY_ELEMENTS; }
DISALLOW_COPY_AND_ASSIGN(KeyedLoadDictionaryElementPlatformStub);
};
virtual InlineCacheState GetICState() { return GENERIC; }
private:
- Major MajorKey() { return KeyedLoadGeneric; }
- int NotMissMinorKey() { return 0; }
+ Major MajorKey() const { return KeyedLoadGeneric; }
+ int NotMissMinorKey() const { return 0; }
DISALLOW_COPY_AND_ASSIGN(KeyedLoadGenericElementStub);
};
class SSE3Bits:
public BitField<int, 2 * kBitsPerRegisterNumber + 5, 1> {}; // NOLINT
- Major MajorKey() { return DoubleToI; }
- int MinorKey() { return bit_field_; }
+ Major MajorKey() const { return DoubleToI; }
+ int MinorKey() const { return bit_field_; }
int bit_field_;
class IsJSArrayBits: public BitField<bool, 8, 1> {};
uint32_t bit_field_;
- Major MajorKey() { return KeyedLoadElement; }
- int NotMissMinorKey() { return bit_field_; }
+ Major MajorKey() const { return KeyedLoadElement; }
+ int NotMissMinorKey() const { return bit_field_; }
DISALLOW_COPY_AND_ASSIGN(KeyedLoadFastElementStub);
};
class IsJSArrayBits: public BitField<bool, 12, 1> {};
uint32_t bit_field_;
- Major MajorKey() { return KeyedStoreElement; }
- int NotMissMinorKey() { return bit_field_; }
+ Major MajorKey() const { return KeyedStoreElement; }
+ int NotMissMinorKey() const { return bit_field_; }
DISALLOW_COPY_AND_ASSIGN(KeyedStoreFastElementStub);
};
class IsJSArrayBits: public BitField<bool, 16, 1> {};
uint32_t bit_field_;
- Major MajorKey() { return TransitionElementsKind; }
- int NotMissMinorKey() { return bit_field_; }
+ Major MajorKey() const { return TransitionElementsKind; }
+ int NotMissMinorKey() const { return bit_field_; }
DISALLOW_COPY_AND_ASSIGN(TransitionElementsKindStub);
};
static const int kAllocationSite = 1;
protected:
- void BasePrintName(const char* name, StringStream* stream);
+ OStream& BasePrintName(OStream& os, const char* name) const; // NOLINT
private:
- int NotMissMinorKey() { return bit_field_; }
+ int NotMissMinorKey() const { return bit_field_; }
// Ensure data fits within available bits.
STATIC_ASSERT(LAST_ALLOCATION_SITE_OVERRIDE_MODE == 1);
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
private:
- Major MajorKey() { return ArrayNoArgumentConstructor; }
+ Major MajorKey() const { return ArrayNoArgumentConstructor; }
- virtual void PrintName(StringStream* stream) {
- BasePrintName("ArrayNoArgumentConstructorStub", stream);
+ virtual void PrintName(OStream& os) const V8_OVERRIDE { // NOLINT
+ BasePrintName(os, "ArrayNoArgumentConstructorStub");
}
DISALLOW_COPY_AND_ASSIGN(ArrayNoArgumentConstructorStub);
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
private:
- Major MajorKey() { return ArraySingleArgumentConstructor; }
+ Major MajorKey() const { return ArraySingleArgumentConstructor; }
- virtual void PrintName(StringStream* stream) {
- BasePrintName("ArraySingleArgumentConstructorStub", stream);
+ virtual void PrintName(OStream& os) const { // NOLINT
+ BasePrintName(os, "ArraySingleArgumentConstructorStub");
}
DISALLOW_COPY_AND_ASSIGN(ArraySingleArgumentConstructorStub);
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
private:
- Major MajorKey() { return ArrayNArgumentsConstructor; }
+ Major MajorKey() const { return ArrayNArgumentsConstructor; }
- virtual void PrintName(StringStream* stream) {
- BasePrintName("ArrayNArgumentsConstructorStub", stream);
+ virtual void PrintName(OStream& os) const { // NOLINT
+ BasePrintName(os, "ArrayNArgumentsConstructorStub");
}
DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub);
ElementsKind elements_kind() const { return kind_; }
private:
- int NotMissMinorKey() { return kind_; }
+ int NotMissMinorKey() const { return kind_; }
ElementsKind kind_;
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
private:
- Major MajorKey() { return InternalArrayNoArgumentConstructor; }
+ Major MajorKey() const { return InternalArrayNoArgumentConstructor; }
DISALLOW_COPY_AND_ASSIGN(InternalArrayNoArgumentConstructorStub);
};
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
private:
- Major MajorKey() { return InternalArraySingleArgumentConstructor; }
+ Major MajorKey() const { return InternalArraySingleArgumentConstructor; }
DISALLOW_COPY_AND_ASSIGN(InternalArraySingleArgumentConstructorStub);
};
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
private:
- Major MajorKey() { return InternalArrayNArgumentsConstructor; }
+ Major MajorKey() const { return InternalArrayNArgumentsConstructor; }
DISALLOW_COPY_AND_ASSIGN(InternalArrayNArgumentsConstructorStub);
};
elements_kind_(elements_kind),
store_mode_(store_mode) { }
- Major MajorKey() { return KeyedStoreElement; }
- int MinorKey() {
+ Major MajorKey() const { return KeyedStoreElement; }
+ int MinorKey() const {
return ElementsKindBits::encode(elements_kind_) |
IsJSArrayBits::encode(is_js_array_) |
StoreModeBits::encode(store_mode_);
explicit Types(byte bits) : EnumSet<Type, byte>(bits) {}
byte ToByte() const { return ToIntegral(); }
- void Print(StringStream* stream) const;
bool UpdateStatus(Handle<Object> object);
bool NeedsMap() const;
bool CanBeUndetectable() const;
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; }
- virtual void PrintState(StringStream* stream);
+ virtual void PrintState(OStream& os) const V8_OVERRIDE; // NOLINT
virtual bool SometimesSetsUpAFrame() { return false; }
return ToBooleanStub(isolate, UNINITIALIZED).GetCode();
}
- virtual ExtraICState GetExtraICState() {
- return types_.ToIntegral();
- }
+ virtual ExtraICState GetExtraICState() const { return types_.ToIntegral(); }
virtual InlineCacheState GetICState() {
if (types_.IsEmpty()) {
}
private:
- Major MajorKey() { return ToBoolean; }
- int NotMissMinorKey() { return GetExtraICState(); }
+ Major MajorKey() const { return ToBoolean; }
+ int NotMissMinorKey() const { return GetExtraICState(); }
ToBooleanStub(Isolate* isolate, InitializationState init_state) :
HydrogenCodeStub(isolate, init_state) {}
};
+OStream& operator<<(OStream& os, const ToBooleanStub::Types& t);
+
+
class ElementsTransitionAndStoreStub : public HydrogenCodeStub {
public:
ElementsTransitionAndStoreStub(Isolate* isolate,
class IsJSArrayBits: public BitField<bool, 16, 1> {};
class StoreModeBits: public BitField<KeyedAccessStoreMode, 17, 4> {};
- Major MajorKey() { return ElementsTransitionAndStore; }
- int NotMissMinorKey() {
+ Major MajorKey() const { return ElementsTransitionAndStore; }
+ int NotMissMinorKey() const {
return FromBits::encode(from_kind_) |
ToBits::encode(to_kind_) |
IsJSArrayBits::encode(is_jsarray_) |
: PlatformCodeStub(isolate) { }
private:
- Major MajorKey() { return StoreArrayLiteralElement; }
- int MinorKey() { return 0; }
+ Major MajorKey() const { return StoreArrayLiteralElement; }
+ int MinorKey() const { return 0; }
void Generate(MacroAssembler* masm);
private:
class FunctionModeField: public BitField<StubFunctionMode, 0, 1> {};
- Major MajorKey() { return StubFailureTrampoline; }
- int MinorKey() {
- return FunctionModeField::encode(function_mode_);
- }
+ Major MajorKey() const { return StubFailureTrampoline; }
+ int MinorKey() const { return FunctionModeField::encode(function_mode_); }
void Generate(MacroAssembler* masm);
intptr_t stack_pointer,
Isolate* isolate);
- Major MajorKey() { return ProfileEntryHook; }
- int MinorKey() { return 0; }
+ Major MajorKey() const { return ProfileEntryHook; }
+ int MinorKey() const { return 0; }
void Generate(MacroAssembler* masm);
}
-int CEntryStub::MinorKey() {
+int CEntryStub::MinorKey() const {
int result = (save_doubles_ == kSaveFPRegs) ? 1 : 0;
ASSERT(result_size_ == 1 || result_size_ == 2);
#ifdef _WIN64
void HDeadCodeEliminationPhase::PrintLive(HValue* ref, HValue* instr) {
- HeapStringAllocator allocator;
- StringStream stream(&allocator);
+ OFStream os(stdout);
+ os << "[MarkLive ";
if (ref != NULL) {
- ref->PrintTo(&stream);
+ os << *ref;
} else {
- stream.Add("root ");
+ os << "root ";
}
- stream.Add(" -> ");
- instr->PrintTo(&stream);
- PrintF("[MarkLive %s]\n", stream.ToCString().get());
+ os << " -> " << *instr << "]" << endl;
}
}
if (num_global_vars_ < kNumberOfGlobalVars) {
if (FLAG_trace_gvn) {
- HeapStringAllocator allocator;
- StringStream stream(&allocator);
- stream.Add("Tracking global var [%p] (mapped to index %d)\n",
- *cell.handle(), num_global_vars_);
- stream.OutputToStdOut();
+ OFStream os(stdout);
+ os << "Tracking global var [" << *cell.handle() << "] "
+ << "(mapped to index " << num_global_vars_ << ")" << endl;
}
*index = num_global_vars_;
global_vars_[num_global_vars_++] = cell;
}
+OStream& operator<<(OStream& os, const HValue& v) {
+ // TODO(svenpanne) Temporary impedance matching, to be removed later.
+ HeapStringAllocator allocator;
+ StringStream stream(&allocator);
+ const_cast<HValue*>(&v)->PrintTo(&stream);
+ return os << stream.ToCString().get();
+}
+
+
void HValue::PrintTypeTo(StringStream* stream) {
if (!representation().IsTagged() || type().Equals(HType::Tagged())) return;
stream->Add(" type:%s", type().ToString());
void HBranch::PrintDataTo(StringStream* stream) {
HUnaryControlInstruction::PrintDataTo(stream);
- stream->Add(" ");
- expected_input_types().Print(stream);
+ OStringStream os;
+ os << " " << expected_input_types();
+ stream->Add(os.c_str());
}
};
+OStream& operator<<(OStream& os, const HValue& v);
+
+
#define DECLARE_INSTRUCTION_FACTORY_P0(I) \
static I* New(Zone* zone, HValue* context) { \
return new(zone) I(); \
private:
SaveFPRegsMode save_doubles_;
- Major MajorKey() { return StoreBufferOverflow; }
- int MinorKey() { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
+ Major MajorKey() const { return StoreBufferOverflow; }
+ int MinorKey() const { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
};
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
private:
- Major MajorKey() { return SubString; }
- int MinorKey() { return 0; }
+ Major MajorKey() const { return SubString; }
+ int MinorKey() const { return 0; }
void Generate(MacroAssembler* masm);
};
Register scratch2);
private:
- virtual Major MajorKey() { return StringCompare; }
- virtual int MinorKey() { return 0; }
+ virtual Major MajorKey() const { return StringCompare; }
+ virtual int MinorKey() const { return 0; }
virtual void Generate(MacroAssembler* masm);
static void GenerateAsciiCharsCompareLoop(
NameDictionary::kHeaderSize +
NameDictionary::kElementsStartIndex * kPointerSize;
- Major MajorKey() { return NameDictionaryLookup; }
+ Major MajorKey() const { return NameDictionaryLookup; }
- int MinorKey() {
+ int MinorKey() const {
return DictionaryBits::encode(dictionary_.code()) |
ResultBits::encode(result_.code()) |
IndexBits::encode(index_.code()) |
Mode mode);
void InformIncrementalMarker(MacroAssembler* masm);
- Major MajorKey() { return RecordWrite; }
+ Major MajorKey() const { return RecordWrite; }
- int MinorKey() {
+ int MinorKey() const {
return ObjectBits::encode(object_.code()) |
ValueBits::encode(value_.code()) |
AddressBits::encode(address_.code()) |
}
-void CallIC::State::Print(StringStream* stream) const {
- stream->Add("(args(%d), ",
- argc_);
- stream->Add("%s, ",
- call_type_ == CallIC::METHOD ? "METHOD" : "FUNCTION");
+OStream& operator<<(OStream& os, const CallIC::State& s) {
+ return os << "(args(" << s.arg_count() << "), "
+ << (s.call_type() == CallIC::METHOD ? "METHOD" : "FUNCTION")
+ << ", ";
}
}
-void BinaryOpIC::State::Print(StringStream* stream) const {
- stream->Add("(%s", Token::Name(op_));
- if (mode_ == OVERWRITE_LEFT) stream->Add("_ReuseLeft");
- else if (mode_ == OVERWRITE_RIGHT) stream->Add("_ReuseRight");
- if (CouldCreateAllocationMementos()) stream->Add("_CreateAllocationMementos");
- stream->Add(":%s*", KindToString(left_kind_));
- if (fixed_right_arg_.has_value) {
- stream->Add("%d", fixed_right_arg_.value);
+OStream& operator<<(OStream& os, const BinaryOpIC::State& s) {
+ os << "(" << Token::Name(s.op_);
+ if (s.mode_ == OVERWRITE_LEFT)
+ os << "_ReuseLeft";
+ else if (s.mode_ == OVERWRITE_RIGHT)
+ os << "_ReuseRight";
+ if (s.CouldCreateAllocationMementos()) os << "_CreateAllocationMementos";
+ os << ":" << BinaryOpIC::State::KindToString(s.left_kind_) << "*";
+ if (s.fixed_right_arg_.has_value) {
+ os << s.fixed_right_arg_.value;
} else {
- stream->Add("%s", KindToString(right_kind_));
+ os << BinaryOpIC::State::KindToString(s.right_kind_);
}
- stream->Add("->%s)", KindToString(result_kind_));
+ return os << "->" << BinaryOpIC::State::KindToString(s.result_kind_) << ")";
}
set_target(*target);
if (FLAG_trace_ic) {
- char buffer[150];
- NoAllocationStringAllocator allocator(
- buffer, static_cast<unsigned>(sizeof(buffer)));
- StringStream stream(&allocator);
- stream.Add("[BinaryOpIC");
- old_state.Print(&stream);
- stream.Add(" => ");
- state.Print(&stream);
- stream.Add(" @ %p <- ", static_cast<void*>(*target));
- stream.OutputToStdOut();
+ OFStream os(stdout);
+ os << "[BinaryOpIC" << old_state << " => " << state << " @ "
+ << static_cast<void*>(*target) << " <- ";
JavaScriptFrame::PrintTop(isolate(), stdout, false, true);
if (!allocation_site.is_null()) {
- PrintF(" using allocation site %p", static_cast<void*>(*allocation_site));
+ os << " using allocation site " << static_cast<void*>(*allocation_site);
}
- PrintF("]\n");
+ os << "]" << endl;
}
// Patch the inlined smi code as necessary.
bool CallAsMethod() const { return call_type_ == METHOD; }
- void Print(StringStream* stream) const;
-
private:
class ArgcBits: public BitField<int, 0, Code::kArgumentsBits> {};
class CallTypeBits: public BitField<CallType, Code::kArgumentsBits, 1> {};
};
+OStream& operator<<(OStream& os, const CallIC::State& s);
+
+
class LoadIC: public IC {
public:
// ExtraICState bits
}
Type* GetResultType(Zone* zone) const;
- void Print(StringStream* stream) const;
-
void Update(Handle<Object> left,
Handle<Object> right,
Handle<Object> result);
Isolate* isolate() const { return isolate_; }
private:
+ friend OStream& operator<<(OStream& os, const BinaryOpIC::State& s);
+
enum Kind { NONE, SMI, INT32, NUMBER, STRING, GENERIC };
Kind UpdateKind(Handle<Object> object, Kind kind) const;
};
+OStream& operator<<(OStream& os, const BinaryOpIC::State& s);
+
+
class CompareIC: public IC {
public:
// The type/state lattice is defined by the following inequations:
class InlineRuntimeFunctionsTable;
class InnerPointerToCodeCache;
class MaterializedObjectStore;
-class NoAllocationStringAllocator;
class CodeAgingHelper;
class RegExpStack;
class SaveContext;
}
-static void AddIsolateIdIfNeeded(Isolate* isolate, StringStream* stream) {
- if (FLAG_logfile_per_isolate) stream->Add("isolate-%p-", isolate);
+static void AddIsolateIdIfNeeded(OStream& os, // NOLINT
+ Isolate* isolate) {
+ if (FLAG_logfile_per_isolate) os << "isolate-" << isolate << "-";
}
-static SmartArrayPointer<const char> PrepareLogFileName(
- Isolate* isolate, const char* file_name) {
- HeapStringAllocator allocator;
- StringStream stream(&allocator);
- AddIsolateIdIfNeeded(isolate, &stream);
+static void PrepareLogFileName(OStream& os, // NOLINT
+ Isolate* isolate, const char* file_name) {
+ AddIsolateIdIfNeeded(os, isolate);
for (const char* p = file_name; *p; p++) {
if (*p == '%') {
p++;
p--;
break;
case 'p':
- stream.Add("%d", base::OS::GetCurrentProcessId());
+ os << base::OS::GetCurrentProcessId();
break;
- case 't': {
+ case 't':
// %t expands to the current time in milliseconds.
- double time = base::OS::TimeCurrentMillis();
- stream.Add("%.0f", FmtElm(time));
+ os << static_cast<int64_t>(base::OS::TimeCurrentMillis());
break;
- }
case '%':
// %% expands (contracts really) to %.
- stream.Put('%');
+ os << '%';
break;
default:
// All other %'s expand to themselves.
- stream.Put('%');
- stream.Put(*p);
+ os << '%' << *p;
break;
}
} else {
- stream.Put(*p);
+ os << *p;
}
}
- return SmartArrayPointer<const char>(stream.ToCString());
}
FLAG_log_snapshot_positions = true;
}
- SmartArrayPointer<const char> log_file_name =
- PrepareLogFileName(isolate, FLAG_logfile);
- log_->Initialize(log_file_name.get());
+ OStringStream log_file_name;
+ PrepareLogFileName(log_file_name, isolate, FLAG_logfile);
+ log_->Initialize(log_file_name.c_str());
if (FLAG_perf_basic_prof) {
}
if (FLAG_ll_prof) {
- ll_logger_ = new LowLevelLogger(log_file_name.get());
+ ll_logger_ = new LowLevelLogger(log_file_name.c_str());
addCodeEventListener(ll_logger_);
}
Representation new_representation,
HeapType* old_field_type,
HeapType* new_field_type) {
- PrintF(file, "[generalizing ");
+ OFStream os(file);
+ os << "[generalizing ";
constructor_name()->PrintOn(file);
- PrintF(file, "] ");
+ os << "] ";
Name* name = instance_descriptors()->GetKey(modify_index);
if (name->IsString()) {
String::cast(name)->PrintOn(file);
} else {
- PrintF(file, "{symbol %p}", static_cast<void*>(name));
+ os << "{symbol " << static_cast<void*>(name) << "}";
}
- PrintF(file, ":");
+ os << ":";
if (constant_to_field) {
- PrintF(file, "c");
+ os << "c";
} else {
- PrintF(file, "%s", old_representation.Mnemonic());
- PrintF(file, "{");
- old_field_type->TypePrint(file, HeapType::SEMANTIC_DIM);
- PrintF(file, "}");
- }
- PrintF(file, "->%s", new_representation.Mnemonic());
- PrintF(file, "{");
- new_field_type->TypePrint(file, HeapType::SEMANTIC_DIM);
- PrintF(file, "}");
- PrintF(file, " (");
+ os << old_representation.Mnemonic() << "{";
+ old_field_type->PrintTo(os, HeapType::SEMANTIC_DIM);
+ os << "}";
+ }
+ os << "->" << new_representation.Mnemonic() << "{";
+ new_field_type->PrintTo(os, HeapType::SEMANTIC_DIM);
+ os << "} (";
if (strlen(reason) > 0) {
- PrintF(file, "%s", reason);
+ os << reason;
} else {
- PrintF(file, "+%i maps", descriptors - split);
+ os << "+" << (descriptors - split) << " maps";
}
- PrintF(file, ") [");
+ os << ") [";
JavaScriptFrame::PrintTop(GetIsolate(), file, false, true);
- PrintF(file, "]\n");
+ os << "]\n";
}
#ifdef OBJECT_PRINT
void LookupResult::Print(FILE* out) {
+ OFStream os(out);
if (!IsFound()) {
- PrintF(out, "Not Found\n");
+ os << "Not Found\n";
return;
}
- PrintF(out, "LookupResult:\n");
- PrintF(out, " -cacheable = %s\n", IsCacheable() ? "true" : "false");
- PrintF(out, " -attributes = %x\n", GetAttributes());
+ os << "LookupResult:\n";
+ os << " -cacheable = " << (IsCacheable() ? "true" : "false") << "\n";
+ os << " -attributes = " << hex << GetAttributes() << dec << "\n";
if (IsTransition()) {
- PrintF(out, " -transition target:\n");
+ os << " -transition target:\n";
GetTransitionTarget()->Print(out);
- PrintF(out, "\n");
+ os << "\n";
}
switch (type()) {
case NORMAL:
- PrintF(out, " -type = normal\n");
- PrintF(out, " -entry = %d", GetDictionaryEntry());
+ os << " -type = normal\n"
+ << " -entry = " << GetDictionaryEntry() << "\n";
break;
case CONSTANT:
- PrintF(out, " -type = constant\n");
- PrintF(out, " -value:\n");
+ os << " -type = constant\n"
+ << " -value:\n";
GetConstant()->Print(out);
- PrintF(out, "\n");
+ os << "\n";
break;
case FIELD:
- PrintF(out, " -type = field\n");
- PrintF(out, " -index = %d\n",
- GetFieldIndex().property_index());
- PrintF(out, " -field type:\n");
- GetFieldType()->TypePrint(out);
+ os << " -type = field\n"
+ << " -index = " << GetFieldIndex().property_index() << "\n"
+ << " -field type:";
+ GetFieldType()->PrintTo(os);
+ os << "\n";
break;
case CALLBACKS:
- PrintF(out, " -type = call backs\n");
- PrintF(out, " -callback object:\n");
+ os << " -type = call backs\n"
+ << " -callback object:\n";
GetCallbackObject()->Print(out);
break;
case HANDLER:
- PrintF(out, " -type = lookup proxy\n");
+ os << " -type = lookup proxy\n";
break;
case INTERCEPTOR:
- PrintF(out, " -type = lookup interceptor\n");
+ os << " -type = lookup interceptor\n";
break;
case NONEXISTENT:
UNREACHABLE();
}
-NoAllocationStringAllocator::NoAllocationStringAllocator(char* memory,
- unsigned size) {
- size_ = size;
- space_ = memory;
-}
-
-
bool StringStream::Put(char c) {
if (full()) return false;
ASSERT(length_ < capacity_);
}
-// Only grow once to the maximum allowable size.
-char* NoAllocationStringAllocator::grow(unsigned* bytes) {
- ASSERT(size_ >= *bytes);
- *bytes = size_;
- return space_;
-}
-
-
} } // namespace v8::internal
};
-// Allocator for use when no new c++ heap allocation is allowed.
-// Given a preallocated buffer up front and does no allocation while
-// building message.
-class NoAllocationStringAllocator V8_FINAL : public StringAllocator {
- public:
- NoAllocationStringAllocator(char* memory, unsigned size);
- virtual char* allocate(unsigned bytes) V8_OVERRIDE { return space_; }
- virtual char* grow(unsigned* bytes) V8_OVERRIDE;
-
- private:
- unsigned size_;
- char* space_;
-};
-
-
class FmtElm V8_FINAL {
public:
FmtElm(int value) : type_(INT) { // NOLINT
DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream);
};
-
-// Utility class to print a list of items to a stream, divided by a separator.
-class SimpleListPrinter V8_FINAL {
- public:
- explicit SimpleListPrinter(StringStream* stream, char separator = ',') {
- separator_ = separator;
- stream_ = stream;
- first_ = true;
- }
-
- void Add(const char* str) {
- if (first_) {
- first_ = false;
- } else {
- stream_->Put(separator_);
- }
- stream_->Add(str);
- }
-
- private:
- bool first_;
- char separator_;
- StringStream* stream_;
-};
-
} } // namespace v8::internal
#endif // V8_STRING_STREAM_H_
}
-template<class Config>
-void TypeImpl<Config>::BitsetType::PrintTo(StringStream* stream, int bitset) {
+template <class Config>
+void TypeImpl<Config>::BitsetType::Print(OStream& os, // NOLINT
+ int bitset) {
DisallowHeapAllocation no_allocation;
const char* name = Name(bitset);
if (name != NULL) {
- stream->Add("%s", name);
- } else {
- static const int named_bitsets[] = {
- #define BITSET_CONSTANT(type, value) REPRESENTATION(k##type),
+ os << name;
+ return;
+ }
+
+ static const int named_bitsets[] = {
+#define BITSET_CONSTANT(type, value) REPRESENTATION(k##type),
REPRESENTATION_BITSET_TYPE_LIST(BITSET_CONSTANT)
- #undef BITSET_CONSTANT
+#undef BITSET_CONSTANT
- #define BITSET_CONSTANT(type, value) SEMANTIC(k##type),
+#define BITSET_CONSTANT(type, value) SEMANTIC(k##type),
SEMANTIC_BITSET_TYPE_LIST(BITSET_CONSTANT)
- #undef BITSET_CONSTANT
- };
-
- bool is_first = true;
- stream->Add("(");
- for (int i(ARRAY_SIZE(named_bitsets) - 1); bitset != 0 && i >= 0; --i) {
- int subset = named_bitsets[i];
- if ((bitset & subset) == subset) {
- if (!is_first) stream->Add(" | ");
- is_first = false;
- stream->Add("%s", Name(subset));
- bitset -= subset;
- }
+#undef BITSET_CONSTANT
+ };
+
+ bool is_first = true;
+ os << "(";
+ for (int i(ARRAY_SIZE(named_bitsets) - 1); bitset != 0 && i >= 0; --i) {
+ int subset = named_bitsets[i];
+ if ((bitset & subset) == subset) {
+ if (!is_first) os << " | ";
+ is_first = false;
+ os << Name(subset);
+ bitset -= subset;
}
- ASSERT(bitset == 0);
- stream->Add(")");
}
+ ASSERT(bitset == 0);
+ os << ")";
}
-template<class Config>
-void TypeImpl<Config>::PrintTo(StringStream* stream, PrintDimension dim) {
+template <class Config>
+void TypeImpl<Config>::PrintTo(OStream& os, PrintDimension dim) { // NOLINT
DisallowHeapAllocation no_allocation;
if (dim != REPRESENTATION_DIM) {
if (this->IsBitset()) {
- BitsetType::PrintTo(stream, SEMANTIC(this->AsBitset()));
+ BitsetType::Print(os, SEMANTIC(this->AsBitset()));
} else if (this->IsClass()) {
- stream->Add("Class(%p < ", static_cast<void*>(*this->AsClass()->Map()));
- BitsetType::New(BitsetType::Lub(this))->PrintTo(stream, dim);
- stream->Add(")");
- return;
+ os << "Class(" << static_cast<void*>(*this->AsClass()->Map()) << " < ";
+ return BitsetType::New(BitsetType::Lub(this))->PrintTo(os, dim);
+ os << ")";
} else if (this->IsConstant()) {
- stream->Add("Constant(%p : ",
- static_cast<void*>(*this->AsConstant()->Value()));
- BitsetType::New(BitsetType::Lub(this))->PrintTo(stream, dim);
- stream->Add(")");
- return;
+ os << "Constant(" << static_cast<void*>(*this->AsConstant()->Value())
+ << " : ";
+ BitsetType::New(BitsetType::Lub(this))->PrintTo(os, dim);
+ os << ")";
} else if (this->IsContext()) {
- stream->Add("Context(");
- this->AsContext()->Outer()->PrintTo(stream, dim);
- stream->Add(")");
+ os << "Context(";
+ this->AsContext()->Outer()->PrintTo(os, dim);
+ os << ")";
} else if (this->IsUnion()) {
- stream->Add("(");
+ os << "(";
UnionHandle unioned = handle(this->AsUnion());
for (int i = 0; i < unioned->Length(); ++i) {
TypeHandle type_i = unioned->Get(i);
- if (i > 0) stream->Add(" | ");
- type_i->PrintTo(stream, dim);
+ if (i > 0) os << " | ";
+ type_i->PrintTo(os, dim);
}
- stream->Add(")");
- return;
+ os << ")";
} else if (this->IsArray()) {
- stream->Add("Array(");
- AsArray()->Element()->PrintTo(stream, dim);
- stream->Add(")");
+ os << "Array(";
+ AsArray()->Element()->PrintTo(os, dim);
+ os << ")";
} else if (this->IsFunction()) {
if (!this->AsFunction()->Receiver()->IsAny()) {
- this->AsFunction()->Receiver()->PrintTo(stream, dim);
- stream->Add(".");
+ this->AsFunction()->Receiver()->PrintTo(os, dim);
+ os << ".";
}
- stream->Add("(");
+ os << "(";
for (int i = 0; i < this->AsFunction()->Arity(); ++i) {
- if (i > 0) stream->Add(", ");
- this->AsFunction()->Parameter(i)->PrintTo(stream, dim);
+ if (i > 0) os << ", ";
+ this->AsFunction()->Parameter(i)->PrintTo(os, dim);
}
- stream->Add(")->");
- this->AsFunction()->Result()->PrintTo(stream, dim);
+ os << ")->";
+ this->AsFunction()->Result()->PrintTo(os, dim);
} else {
UNREACHABLE();
}
}
- if (dim == BOTH_DIMS) {
- stream->Add("/");
- }
+ if (dim == BOTH_DIMS) os << "/";
if (dim != SEMANTIC_DIM) {
- BitsetType::PrintTo(stream, REPRESENTATION(this->BitsetLub()));
+ BitsetType::Print(os, REPRESENTATION(this->BitsetLub()));
}
}
-template<class Config>
-void TypeImpl<Config>::TypePrint(FILE* out, PrintDimension dim) {
- HeapStringAllocator allocator;
- StringStream stream(&allocator);
- PrintTo(&stream, dim);
- stream.OutputToFile(out);
-}
-
-
-template<class Config>
-void TypeImpl<Config>::TypePrint(PrintDimension dim) {
- TypePrint(stdout, dim);
- PrintF(stdout, "\n");
- Flush(stdout);
-}
-
-
// -----------------------------------------------------------------------------
// Instantiations.
#define V8_TYPES_H_
#include "src/handles.h"
+#include "src/ostreams.h"
namespace v8 {
namespace internal {
enum PrintDimension { BOTH_DIMS, SEMANTIC_DIM, REPRESENTATION_DIM };
- void PrintTo(StringStream* stream, PrintDimension = BOTH_DIMS);
- void TypePrint(PrintDimension = BOTH_DIMS);
- void TypePrint(FILE* out, PrintDimension = BOTH_DIMS);
+ void PrintTo(OStream& os, PrintDimension dim = BOTH_DIMS); // NOLINT
protected:
// Friends.
static int InherentLub(TypeImpl* type);
static const char* Name(int bitset);
- static void PrintTo(StringStream* stream, int bitset);
+ static void Print(OStream& os, int bitset); // NOLINT
using TypeImpl::PrintTo;
};
#ifdef OBJECT_PRINT
static void PrintObserved(Variable* var, Object* value, Type* type) {
- PrintF(" observed %s ", var->IsParameter() ? "param" : "local");
+ OFStream os(stdout);
+ os << " observed " << (var->IsParameter() ? "param" : "local") << " ";
var->name()->Print();
- PrintF(" : ");
+ os << " : ";
value->ShortPrint();
- PrintF(" -> ");
- type->TypePrint();
+ os << " -> ";
+ type->PrintTo(os);
+ os << endl;
}
#endif // OBJECT_PRINT
private:
SaveFPRegsMode save_doubles_;
- Major MajorKey() { return StoreBufferOverflow; }
- int MinorKey() { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
+ Major MajorKey() const { return StoreBufferOverflow; }
+ int MinorKey() const { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
};
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
private:
- Major MajorKey() { return SubString; }
- int MinorKey() { return 0; }
+ Major MajorKey() const { return SubString; }
+ int MinorKey() const { return 0; }
void Generate(MacroAssembler* masm);
};
Register scratch2);
private:
- virtual Major MajorKey() { return StringCompare; }
- virtual int MinorKey() { return 0; }
+ virtual Major MajorKey() const { return StringCompare; }
+ virtual int MinorKey() const { return 0; }
virtual void Generate(MacroAssembler* masm);
static void GenerateAsciiCharsCompareLoop(
NameDictionary::kHeaderSize +
NameDictionary::kElementsStartIndex * kPointerSize;
- Major MajorKey() { return NameDictionaryLookup; }
+ Major MajorKey() const { return NameDictionaryLookup; }
- int MinorKey() {
+ int MinorKey() const {
return DictionaryBits::encode(dictionary_.code()) |
ResultBits::encode(result_.code()) |
IndexBits::encode(index_.code()) |
Mode mode);
void InformIncrementalMarker(MacroAssembler* masm);
- Major MajorKey() { return RecordWrite; }
+ Major MajorKey() const { return RecordWrite; }
- int MinorKey() {
+ int MinorKey() const {
return ObjectBits::encode(object_.code()) |
ValueBits::encode(value_.code()) |
AddressBits::encode(address_.code()) |