// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <sstream>
+
#include "src/v8.h"
#include "src/arm/lithium-codegen-arm.h"
void LStoreNamedField::PrintDataTo(StringStream* stream) {
object()->PrintTo(stream);
- OStringStream os;
+ std::ostringstream os;
os << hydrogen()->access() << " <- ";
- stream->Add(os.c_str());
+ stream->Add(os.str().c_str());
value()->PrintTo(stream);
}
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <sstream>
+
#include "src/v8.h"
#include "src/arm64/lithium-codegen-arm64.h"
void LStoreNamedField::PrintDataTo(StringStream* stream) {
object()->PrintTo(stream);
- OStringStream os;
+ std::ostringstream os;
os << hydrogen()->access();
- stream->Add(os.c_str());
+ stream->Add(os.str().c_str());
stream->Add(" <- ");
value()->PrintTo(stream);
}
}
-void RelocInfo::Print(Isolate* isolate, OStream& os) { // NOLINT
- os << pc_ << " " << RelocModeName(rmode_);
+void RelocInfo::Print(Isolate* isolate, std::ostream& os) { // NOLINT
+ os << static_cast<const void*>(pc_) << " " << RelocModeName(rmode_);
if (IsComment(rmode_)) {
os << " (" << reinterpret_cast<char*>(data_) << ")";
} else if (rmode_ == EMBEDDED_OBJECT) {
#ifdef ENABLE_DISASSEMBLER
// Printing
static const char* RelocModeName(Mode rmode);
- void Print(Isolate* isolate, OStream& os); // NOLINT
+ void Print(Isolate* isolate, std::ostream& os); // NOLINT
#endif // ENABLE_DISASSEMBLER
#ifdef VERIFY_HEAP
void Verify(Isolate* isolate);
// output formats are alike.
class RegExpUnparser FINAL : public RegExpVisitor {
public:
- RegExpUnparser(OStream& os, Zone* zone) : os_(os), zone_(zone) {}
+ RegExpUnparser(std::ostream& os, Zone* zone) : os_(os), zone_(zone) {}
void VisitCharacterRange(CharacterRange that);
#define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, \
void* data) OVERRIDE;
FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE)
#undef MAKE_CASE
private:
- OStream& os_;
+ std::ostream& os_;
Zone* zone_;
};
}
-OStream& RegExpTree::Print(OStream& os, Zone* zone) { // NOLINT
+std::ostream& RegExpTree::Print(std::ostream& os, Zone* zone) { // NOLINT
RegExpUnparser unparser(os, zone);
Accept(&unparser, NULL);
return os;
class Expression;
class IterationStatement;
class MaterializedLiteral;
-class OStream;
class Statement;
class TargetCollector;
class TypeFeedbackOracle;
// expression.
virtual Interval CaptureRegisters() { return Interval::Empty(); }
virtual void AppendToText(RegExpText* text, Zone* zone);
- OStream& Print(OStream& os, Zone* zone); // NOLINT
+ std::ostream& Print(std::ostream& os, Zone* zone); // NOLINT
#define MAKE_ASTYPE(Name) \
virtual RegExp##Name* As##Name(); \
virtual bool Is##Name();
#include "src/basic-block-profiler.h"
+#include <sstream>
+
namespace v8 {
namespace internal {
BasicBlockProfiler::Data::~Data() {}
-static void InsertIntoString(OStringStream* os, std::string* string) {
- string->insert(string->begin(), os->c_str(), &os->c_str()[os->size()]);
+static void InsertIntoString(std::ostringstream* os, std::string* string) {
+ string->insert(0, os->str());
}
-void BasicBlockProfiler::Data::SetCode(OStringStream* os) {
+void BasicBlockProfiler::Data::SetCode(std::ostringstream* os) {
InsertIntoString(os, &code_);
}
-void BasicBlockProfiler::Data::SetFunctionName(OStringStream* os) {
+void BasicBlockProfiler::Data::SetFunctionName(std::ostringstream* os) {
InsertIntoString(os, &function_name_);
}
-void BasicBlockProfiler::Data::SetSchedule(OStringStream* os) {
+void BasicBlockProfiler::Data::SetSchedule(std::ostringstream* os) {
InsertIntoString(os, &schedule_);
}
}
-OStream& operator<<(OStream& os, const BasicBlockProfiler& p) {
- os << "---- Start Profiling Data ----" << endl;
+std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler& p) {
+ os << "---- Start Profiling Data ----" << std::endl;
typedef BasicBlockProfiler::DataList::const_iterator iterator;
for (iterator i = p.data_list_.begin(); i != p.data_list_.end(); ++i) {
os << **i;
}
- os << "---- End Profiling Data ----" << endl;
+ os << "---- End Profiling Data ----" << std::endl;
return os;
}
-OStream& operator<<(OStream& os, const BasicBlockProfiler::Data& d) {
+std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler::Data& d) {
const char* name = "unknown function";
if (!d.function_name_.empty()) {
name = d.function_name_.c_str();
}
if (!d.schedule_.empty()) {
- os << "schedule for " << name << endl;
- os << d.schedule_.c_str() << endl;
+ os << "schedule for " << name << std::endl;
+ os << d.schedule_.c_str() << std::endl;
}
- os << "block counts for " << name << ":" << endl;
+ os << "block counts for " << name << ":" << std::endl;
for (size_t i = 0; i < d.n_blocks_; ++i) {
- os << "block " << d.block_ids_[i] << " : " << d.counts_[i] << endl;
+ os << "block " << d.block_ids_[i] << " : " << d.counts_[i] << std::endl;
}
- os << endl;
+ os << std::endl;
if (!d.code_.empty()) {
- os << d.code_.c_str() << endl;
+ os << d.code_.c_str() << std::endl;
}
return os;
}
#ifndef V8_BASIC_BLOCK_PROFILER_H_
#define V8_BASIC_BLOCK_PROFILER_H_
+#include <iosfwd>
#include <list>
+#include <string>
#include "src/v8.h"
size_t n_blocks() const { return n_blocks_; }
const uint32_t* counts() const { return &counts_[0]; }
- void SetCode(OStringStream* os);
- void SetFunctionName(OStringStream* os);
- void SetSchedule(OStringStream* os);
+ void SetCode(std::ostringstream* os);
+ void SetFunctionName(std::ostringstream* os);
+ void SetSchedule(std::ostringstream* os);
void SetBlockId(size_t offset, size_t block_id);
uint32_t* GetCounterAddress(size_t offset);
private:
friend class BasicBlockProfiler;
- friend OStream& operator<<(OStream& os, const BasicBlockProfiler::Data& s);
+ friend std::ostream& operator<<(std::ostream& os,
+ const BasicBlockProfiler::Data& s);
explicit Data(size_t n_blocks);
~Data();
const DataList* data_list() { return &data_list_; }
private:
- friend OStream& operator<<(OStream& os, const BasicBlockProfiler& s);
+ friend std::ostream& operator<<(std::ostream& os,
+ const BasicBlockProfiler& s);
DataList data_list_;
DISALLOW_COPY_AND_ASSIGN(BasicBlockProfiler);
};
-OStream& operator<<(OStream& os, const BasicBlockProfiler& s);
-OStream& operator<<(OStream& os, const BasicBlockProfiler::Data& s);
+std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler& s);
+std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler::Data& s);
} // namespace internal
} // namespace v8
if (FLAG_profile_hydrogen_code_stub_compilation) {
OFStream os(stdout);
os << "[Lazy compilation of " << stub << " took "
- << timer.Elapsed().InMillisecondsF() << " ms]" << endl;
+ << timer.Elapsed().InMillisecondsF() << " ms]" << std::endl;
}
return code;
}
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "src/v8.h"
+#include "src/code-stubs.h"
+
+#include <sstream>
#include "src/bootstrapper.h"
-#include "src/code-stubs.h"
#include "src/cpu-profiler.h"
#include "src/factory.h"
#include "src/gdb-jit.h"
void CodeStub::RecordCodeGeneration(Handle<Code> code) {
IC::RegisterWeakMapDependency(code);
- OStringStream os;
+ std::ostringstream os;
os << *this;
- PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, *code, os.c_str()));
+ PROFILE(isolate(),
+ CodeCreateEvent(Logger::STUB_TAG, *code, os.str().c_str()));
Counters* counters = isolate()->counters();
counters->total_stubs_code_size()->Increment(code->instruction_size());
}
if (FLAG_print_code_stubs) {
CodeTracer::Scope trace_scope(isolate()->GetCodeTracer());
OFStream os(trace_scope.file());
- OStringStream name;
+ std::ostringstream name;
name << *this;
- new_object->Disassemble(name.c_str(), os);
+ new_object->Disassemble(name.str().c_str(), os);
os << "\n";
}
#endif
}
-void CodeStub::PrintBaseName(OStream& os) const { // NOLINT
+void CodeStub::PrintBaseName(std::ostream& os) const { // NOLINT
os << MajorName(MajorKey(), false);
}
-void CodeStub::PrintName(OStream& os) const { // NOLINT
+void CodeStub::PrintName(std::ostream& os) const { // NOLINT
PrintBaseName(os);
PrintState(os);
}
}
-void BinaryOpICStub::PrintState(OStream& os) const { // NOLINT
+void BinaryOpICStub::PrintState(std::ostream& os) const { // NOLINT
os << state();
}
void BinaryOpICWithAllocationSiteStub::PrintState(
- OStream& os) const { // NOLINT
+ std::ostream& os) const { // NOLINT
os << state();
}
}
-void StringAddStub::PrintBaseName(OStream& os) const { // NOLINT
+void StringAddStub::PrintBaseName(std::ostream& os) const { // NOLINT
os << "StringAddStub";
if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) {
os << "_CheckBoth";
OFStream os(stdout);
os << "[";
PrintBaseName(os);
- os << ": " << from << "=>" << to << "]" << endl;
+ os << ": " << from << "=>" << to << "]" << std::endl;
}
-void CompareNilICStub::PrintBaseName(OStream& os) const { // NOLINT
+void CompareNilICStub::PrintBaseName(std::ostream& os) const { // NOLINT
CodeStub::PrintBaseName(os);
os << ((nil_value() == kNullValue) ? "(NullValue)" : "(UndefinedValue)");
}
-void CompareNilICStub::PrintState(OStream& os) const { // NOLINT
+void CompareNilICStub::PrintState(std::ostream& os) const { // NOLINT
os << state();
}
// TODO(svenpanne) Make this a real infix_ostream_iterator.
class SimpleListPrinter {
public:
- explicit SimpleListPrinter(OStream& os) : os_(os), first_(true) {}
+ explicit SimpleListPrinter(std::ostream& os) : os_(os), first_(true) {}
void Add(const char* s) {
if (first_) {
}
private:
- OStream& os_;
+ std::ostream& os_;
bool first_;
};
-OStream& operator<<(OStream& os, const CompareNilICStub::State& s) {
+std::ostream& operator<<(std::ostream& os, const CompareNilICStub::State& s) {
os << "(";
SimpleListPrinter p(os);
if (s.IsEmpty()) p.Add("None");
}
-void CallIC_ArrayStub::PrintState(OStream& os) const { // NOLINT
+void CallIC_ArrayStub::PrintState(std::ostream& os) const { // NOLINT
os << state() << " (Array)";
}
-void CallICStub::PrintState(OStream& os) const { // NOLINT
+void CallICStub::PrintState(std::ostream& os) const { // NOLINT
os << state();
}
-void InstanceofStub::PrintName(OStream& os) const { // NOLINT
+void InstanceofStub::PrintName(std::ostream& os) const { // NOLINT
os << "InstanceofStub";
if (HasArgsInRegisters()) os << "_REGS";
if (HasCallSiteInlineCheck()) os << "_INLINE";
}
-void ArgumentsAccessStub::PrintName(OStream& os) const { // NOLINT
+void ArgumentsAccessStub::PrintName(std::ostream& os) const { // NOLINT
os << "ArgumentsAccessStub_";
switch (type()) {
case READ_ELEMENT:
}
-void CallFunctionStub::PrintName(OStream& os) const { // NOLINT
+void CallFunctionStub::PrintName(std::ostream& os) const { // NOLINT
os << "CallFunctionStub_Args" << argc();
}
-void CallConstructStub::PrintName(OStream& os) const { // NOLINT
+void CallConstructStub::PrintName(std::ostream& os) const { // NOLINT
os << "CallConstructStub";
if (RecordCallTarget()) os << "_Recording";
}
-void ArrayConstructorStub::PrintName(OStream& os) const { // NOLINT
+void ArrayConstructorStub::PrintName(std::ostream& os) const { // NOLINT
os << "ArrayConstructorStub";
switch (argument_count()) {
case ANY:
}
-OStream& ArrayConstructorStubBase::BasePrintName(OStream& os, // NOLINT
- const char* name) const {
+std::ostream& ArrayConstructorStubBase::BasePrintName(
+ std::ostream& os, // NOLINT
+ const char* name) const {
os << name << "_" << ElementsKindToString(elements_kind());
if (override_mode() == DISABLE_ALLOCATION_SITES) {
os << "_DISABLE_ALLOCATION_SITES";
}
-void ToBooleanStub::PrintState(OStream& os) const { // NOLINT
+void ToBooleanStub::PrintState(std::ostream& os) const { // NOLINT
os << types();
}
-OStream& operator<<(OStream& os, const ToBooleanStub::Types& s) {
+std::ostream& operator<<(std::ostream& os, const ToBooleanStub::Types& s) {
os << "(";
SimpleListPrinter p(os);
if (s.IsEmpty()) p.Add("None");
return Code::NORMAL;
}
- friend OStream& operator<<(OStream& os, const CodeStub& s) {
+ friend std::ostream& operator<<(std::ostream& os, const CodeStub& s) {
s.PrintName(os);
return os;
}
// a fixed (non-moveable) code object.
virtual bool NeedsImmovableCode() { return false; }
- virtual void PrintName(OStream& os) const; // NOLINT
- virtual void PrintBaseName(OStream& os) const; // NOLINT
- virtual void PrintState(OStream& os) const { ; } // NOLINT
+ virtual void PrintName(std::ostream& os) const; // NOLINT
+ virtual void PrintBaseName(std::ostream& os) const; // NOLINT
+ virtual void PrintState(std::ostream& os) const { ; } // NOLINT
// Computes the key based on major and minor.
uint32_t GetKey() {
return (flags() & kReturnTrueFalseObject) != 0;
}
- virtual void PrintName(OStream& os) const OVERRIDE; // NOLINT
+ virtual void PrintName(std::ostream& os) const OVERRIDE; // NOLINT
class FlagBits : public BitField<Flags, 0, 3> {};
void GenerateDispatchToArrayStub(MacroAssembler* masm,
AllocationSiteOverrideMode mode);
- virtual void PrintName(OStream& os) const OVERRIDE; // NOLINT
+ virtual void PrintName(std::ostream& os) const OVERRIDE; // NOLINT
class ArgumentCountBits : public BitField<ArgumentCountKey, 0, 2> {};
void GenerateMiss(MacroAssembler* masm);
private:
- virtual void PrintState(OStream& os) const OVERRIDE; // NOLINT
+ virtual void PrintState(std::ostream& os) const OVERRIDE; // NOLINT
DEFINE_CALL_INTERFACE_DESCRIPTOR(CallFunctionWithFeedback);
DEFINE_PLATFORM_CODE_STUB(CallIC, PlatformCodeStub);
}
private:
- virtual void PrintState(OStream& os) const OVERRIDE; // NOLINT
+ virtual void PrintState(std::ostream& os) const OVERRIDE; // NOLINT
DEFINE_PLATFORM_CODE_STUB(CallIC_Array, CallICStub);
};
return BinaryOpICState(isolate(), GetExtraICState());
}
- virtual void PrintState(OStream& os) const FINAL OVERRIDE; // NOLINT
+ virtual void PrintState(std::ostream& os) const FINAL OVERRIDE; // NOLINT
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kLeft = 0;
return static_cast<ExtraICState>(minor_key_);
}
- virtual void PrintState(OStream& os) const OVERRIDE; // NOLINT
+ virtual void PrintState(std::ostream& os) const OVERRIDE; // NOLINT
private:
BinaryOpICState state() const {
class StringAddFlagsBits: public BitField<StringAddFlags, 0, 2> {};
class PretenureFlagBits: public BitField<PretenureFlag, 2, 1> {};
- virtual void PrintBaseName(OStream& os) const OVERRIDE; // NOLINT
+ virtual void PrintBaseName(std::ostream& os) const OVERRIDE; // NOLINT
DEFINE_CALL_INTERFACE_DESCRIPTOR(StringAdd);
DEFINE_HYDROGEN_CODE_STUB(StringAdd, HydrogenCodeStub);
set_sub_minor_key(TypesBits::update(sub_minor_key(), 0));
}
- virtual void PrintState(OStream& os) const OVERRIDE; // NOLINT
- virtual void PrintBaseName(OStream& os) const OVERRIDE; // NOLINT
+ virtual void PrintState(std::ostream& os) const OVERRIDE; // NOLINT
+ virtual void PrintBaseName(std::ostream& os) const OVERRIDE; // NOLINT
private:
CompareNilICStub(Isolate* isolate, NilValue nil,
State() : EnumSet<CompareNilType, byte>(0) { }
explicit State(byte bits) : EnumSet<CompareNilType, byte>(bits) { }
};
- friend OStream& operator<<(OStream& os, const State& s);
+ friend std::ostream& operator<<(std::ostream& os, const State& s);
State state() const { return State(TypesBits::decode(sub_minor_key())); }
};
-OStream& operator<<(OStream& os, const CompareNilICStub::State& s);
+std::ostream& operator<<(std::ostream& os, const CompareNilICStub::State& s);
class CEntryStub : public PlatformCodeStub {
private:
virtual void FinishCode(Handle<Code> code);
- virtual void PrintName(OStream& os) const OVERRIDE { // NOLINT
+ virtual void PrintName(std::ostream& os) const OVERRIDE { // NOLINT
os << (type() == StackFrame::ENTRY ? "JSEntryStub"
: "JSConstructEntryStub");
}
void GenerateNewSloppyFast(MacroAssembler* masm);
void GenerateNewSloppySlow(MacroAssembler* masm);
- virtual void PrintName(OStream& os) const OVERRIDE; // NOLINT
+ virtual void PrintName(std::ostream& os) const OVERRIDE; // NOLINT
class TypeBits : public BitField<Type, 0, 2> {};
bool NeedsChecks() const { return flags() != WRAP_AND_CALL; }
- virtual void PrintName(OStream& os) const OVERRIDE; // NOLINT
+ virtual void PrintName(std::ostream& os) const OVERRIDE; // NOLINT
// Minor key encoding in 32 bits with Bitfield <Type, shift, size>.
class FlagBits : public BitField<CallFunctionFlags, 0, 2> {};
return (flags() & RECORD_CONSTRUCTOR_TARGET) != 0;
}
- virtual void PrintName(OStream& os) const OVERRIDE; // NOLINT
+ virtual void PrintName(std::ostream& os) const OVERRIDE; // NOLINT
class FlagBits : public BitField<CallConstructorFlags, 0, 1> {};
static const int kAllocationSite = 1;
protected:
- OStream& BasePrintName(OStream& os, const char* name) const; // NOLINT
+ std::ostream& BasePrintName(std::ostream& os,
+ const char* name) const; // NOLINT
private:
// Ensure data fits within available bits.
}
private:
- virtual void PrintName(OStream& os) const OVERRIDE { // NOLINT
+ virtual void PrintName(std::ostream& os) const OVERRIDE { // NOLINT
BasePrintName(os, "ArrayNoArgumentConstructorStub");
}
}
private:
- virtual void PrintName(OStream& os) const { // NOLINT
+ virtual void PrintName(std::ostream& os) const { // NOLINT
BasePrintName(os, "ArraySingleArgumentConstructorStub");
}
}
private:
- virtual void PrintName(OStream& os) const { // NOLINT
+ virtual void PrintName(std::ostream& os) const { // NOLINT
BasePrintName(os, "ArrayNArgumentsConstructorStub");
}
ResultMode mode() const { return ResultModeBits::decode(sub_minor_key()); }
virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; }
- virtual void PrintState(OStream& os) const OVERRIDE; // NOLINT
+ virtual void PrintState(std::ostream& os) const OVERRIDE; // NOLINT
virtual bool SometimesSetsUpAFrame() { return false; }
};
-OStream& operator<<(OStream& os, const ToBooleanStub::Types& t);
+std::ostream& operator<<(std::ostream& os, const ToBooleanStub::Types& t);
class ElementsTransitionAndStoreStub : public HydrogenCodeStub {
std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) {
- OStringStream ost;
- ost << memacc.type;
- return os << ost.c_str();
+ return os << memacc.type;
}
std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) {
- OStringStream ost;
- ost << memacc.type;
- return os << ost.c_str();
+ return os << memacc.type;
}
} // namespace
// found in the LICENSE file.
#include "src/compiler/basic-block-instrumentor.h"
+
+#include <sstream>
+
#include "src/compiler/common-operator.h"
#include "src/compiler/graph.h"
#include "src/compiler/machine-operator.h"
// Set the function name.
if (!info->shared_info().is_null() &&
info->shared_info()->name()->IsString()) {
- OStringStream os;
+ std::ostringstream os;
String::cast(info->shared_info()->name())->PrintUC16(os);
data->SetFunctionName(&os);
}
// Capture the schedule string before instrumentation.
{
- OStringStream os;
+ std::ostringstream os;
os << *schedule;
data->SetSchedule(&os);
}
namespace internal {
namespace compiler {
-// TODO(bmeurer): Find a new home for these functions.
-inline std::ostream& operator<<(std::ostream& os, const MachineType& type) {
- OStringStream ost;
- ost << type;
- return os << ost.c_str();
-}
-
-
class ChangeLoweringTest : public GraphTest {
public:
ChangeLoweringTest() : simplified_(zone()) {}
: Operator1<int>(opcode, properties, inputs, outputs, mnemonic,
controls) {}
- virtual OStream& PrintParameter(OStream& os) const FINAL { return os; }
+ virtual std::ostream& PrintParameter(std::ostream& os) const FINAL {
+ return os;
+ }
};
} // namespace
// Specialization for static parameters of type {ExternalReference}.
template <>
struct StaticParameterTraits<ExternalReference> {
- static OStream& PrintTo(OStream& os, ExternalReference reference) {
+ static std::ostream& PrintTo(std::ostream& os, ExternalReference reference) {
os << reference.address();
// TODO(bmeurer): Move to operator<<(os, ExternalReference)
const Runtime::Function* function =
static_cast<int>(descriptor->ReturnCount()), mnemonic,
descriptor) {}
- virtual OStream& PrintParameter(OStream& os) const OVERRIDE {
+ virtual std::ostream& PrintParameter(std::ostream& os) const OVERRIDE {
return os << "[" << *parameter() << "]";
}
};
// Forward declarations.
class ExternalReference;
-class OStream;
namespace compiler {
}
inline std::ostream& operator<<(std::ostream& os,
const ExternalReference& value) {
- OStringStream ost;
- compiler::StaticParameterTraits<ExternalReference>::PrintTo(ost, value);
- return os << ost.c_str();
+ compiler::StaticParameterTraits<ExternalReference>::PrintTo(os, value);
+ return os;
}
namespace compiler {
#include "src/compiler/graph-visualizer.h"
+#include <sstream>
+#include <string>
+
#include "src/compiler/generic-algorithm.h"
#include "src/compiler/generic-node.h"
#include "src/compiler/generic-node-inl.h"
class Escaped {
public:
- explicit Escaped(const OStringStream& os, const char* escaped_chars = "<>|{}")
- : str_(os.c_str()), escaped_chars_(escaped_chars) {}
-
- friend OStream& operator<<(OStream& os, const Escaped& e) {
- for (const char* s = e.str_; *s != '\0'; ++s) {
- if (e.needs_escape(*s)) os << "\\";
- os << *s;
+ explicit Escaped(const std::ostringstream& os,
+ const char* escaped_chars = "<>|{}")
+ : str_(os.str()), escaped_chars_(escaped_chars) {}
+
+ friend std::ostream& operator<<(std::ostream& os, const Escaped& e) {
+ for (std::string::const_iterator i = e.str_.begin(); i != e.str_.end();
+ ++i) {
+ if (e.needs_escape(*i)) os << "\\";
+ os << *i;
}
return os;
}
return false;
}
- const char* const str_;
+ const std::string str_;
const char* const escaped_chars_;
};
class JSONGraphNodeWriter : public NullNodeVisitor {
public:
- JSONGraphNodeWriter(OStream& os, Zone* zone, const Graph* graph) // NOLINT
+ JSONGraphNodeWriter(std::ostream& os, Zone* zone,
+ const Graph* graph) // NOLINT
: os_(os),
graph_(graph),
first_node_(true) {}
GenericGraphVisit::Control Pre(Node* node);
private:
- OStream& os_;
+ std::ostream& os_;
const Graph* const graph_;
bool first_node_;
} else {
os_ << ",";
}
- OStringStream label;
+ std::ostringstream label;
label << *node->op();
os_ << "{\"id\":" << node->id() << ",\"label\":\"" << Escaped(label, "\"")
<< "\"";
class JSONGraphEdgeWriter : public NullNodeVisitor {
public:
- JSONGraphEdgeWriter(OStream& os, Zone* zone, const Graph* graph) // NOLINT
+ JSONGraphEdgeWriter(std::ostream& os, Zone* zone,
+ const Graph* graph) // NOLINT
: os_(os),
graph_(graph),
first_edge_(true) {}
GenericGraphVisit::Control PreEdge(Node* from, int index, Node* to);
private:
- OStream& os_;
+ std::ostream& os_;
const Graph* const graph_;
bool first_edge_;
}
-OStream& operator<<(OStream& os, const AsJSON& ad) {
+std::ostream& operator<<(std::ostream& os, const AsJSON& ad) {
Zone tmp_zone(ad.graph.zone()->isolate());
os << "{\"nodes\":[";
JSONGraphNodeWriter(os, &tmp_zone, &ad.graph).Print();
class GraphVisualizer : public NullNodeVisitor {
public:
- GraphVisualizer(OStream& os, Zone* zone, const Graph* graph); // NOLINT
+ GraphVisualizer(std::ostream& os, Zone* zone, const Graph* graph); // NOLINT
void Print();
NodeSet all_nodes_;
NodeSet white_nodes_;
bool use_to_def_;
- OStream& os_;
+ std::ostream& os_;
const Graph* const graph_;
DISALLOW_COPY_AND_ASSIGN(GraphVisualizer);
break;
}
- OStringStream label;
+ std::ostringstream label;
label << *node->op();
os_ << " label=\"{{#" << node->id() << ":" << Escaped(label);
if (FLAG_trace_turbo_types && !NodeProperties::IsControl(node)) {
Bounds bounds = NodeProperties::GetBounds(node);
- OStringStream upper;
+ std::ostringstream upper;
bounds.upper->PrintTo(upper);
- OStringStream lower;
+ std::ostringstream lower;
bounds.lower->PrintTo(lower);
os_ << "|" << Escaped(upper) << "|" << Escaped(lower);
}
}
-GraphVisualizer::GraphVisualizer(OStream& os, Zone* zone,
+GraphVisualizer::GraphVisualizer(std::ostream& os, Zone* zone,
const Graph* graph) // NOLINT
: zone_(zone),
all_nodes_(NodeSet::key_compare(), NodeSet::allocator_type(zone)),
graph_(graph) {}
-OStream& operator<<(OStream& os, const AsDOT& ad) {
+std::ostream& operator<<(std::ostream& os, const AsDOT& ad) {
Zone tmp_zone(ad.graph.zone()->isolate());
GraphVisualizer(os, &tmp_zone, &ad.graph).Print();
return os;
#ifndef V8_COMPILER_GRAPH_VISUALIZER_H_
#define V8_COMPILER_GRAPH_VISUALIZER_H_
-#include "src/v8.h"
+#include <iosfwd>
namespace v8 {
namespace internal {
-
-class OStream;
-
namespace compiler {
class Graph;
const Graph& graph;
};
-OStream& operator<<(OStream& os, const AsDOT& ad);
+std::ostream& operator<<(std::ostream& os, const AsDOT& ad);
+
struct AsJSON {
explicit AsJSON(const Graph& g) : graph(g) {}
const Graph& graph;
};
-OStream& operator<<(OStream& os, const AsJSON& ad);
-}
-}
-} // namespace v8::internal::compiler
+std::ostream& operator<<(std::ostream& os, const AsJSON& ad);
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
#endif // V8_COMPILER_GRAPH_VISUALIZER_H_
std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) {
- OStringStream ost;
- ost << memacc.type;
- return os << ost.c_str();
+ return os << memacc.type;
}
#ifndef V8_COMPILER_INSTRUCTION_CODES_H_
#define V8_COMPILER_INSTRUCTION_CODES_H_
+#include <iosfwd>
+
#if V8_TARGET_ARCH_ARM
#include "src/compiler/arm/instruction-codes-arm.h"
#elif V8_TARGET_ARCH_ARM64
namespace v8 {
namespace internal {
-
-class OStream;
-
namespace compiler {
// Target-specific opcodes that specify which assembly sequence to emit.
#undef COUNT_ARCH_OPCODE
};
-OStream& operator<<(OStream& os, const ArchOpcode& ao);
+std::ostream& operator<<(std::ostream& os, const ArchOpcode& ao);
// Addressing modes represent the "shape" of inputs to an instruction.
// Many instructions support multiple addressing modes. Addressing modes
#undef COUNT_ADDRESSING_MODE
};
-OStream& operator<<(OStream& os, const AddressingMode& am);
+std::ostream& operator<<(std::ostream& os, const AddressingMode& am);
// The mode of the flags continuation (see below).
enum FlagsMode { kFlags_none = 0, kFlags_branch = 1, kFlags_set = 2 };
-OStream& operator<<(OStream& os, const FlagsMode& fm);
+std::ostream& operator<<(std::ostream& os, const FlagsMode& fm);
// The condition of flags continuation (see below).
enum FlagsCondition {
kNotOverflow
};
-OStream& operator<<(OStream& os, const FlagsCondition& fc);
+std::ostream& operator<<(std::ostream& os, const FlagsCondition& fc);
// The InstructionCode is an opaque, target-specific integer that encodes
// what code to emit for an instruction in the code generator. It is not
Schedule* schedule = Export();
if (FLAG_trace_turbo) {
OFStream out(stdout);
- out << "=== Schedule before instruction selection ===" << endl << *schedule;
+ out << "=== Schedule before instruction selection ===" << std::endl
+ << *schedule;
}
EXPECT_NE(0, graph()->NodeCount());
CompilationInfo info(test_->isolate(), test_->zone());
selector.SelectInstructions();
if (FLAG_trace_turbo) {
OFStream out(stdout);
- out << "=== Code sequence after instruction selection ===" << endl
+ out << "=== Code sequence after instruction selection ===" << std::endl
<< sequence;
}
Stream s;
namespace internal {
namespace compiler {
-OStream& operator<<(OStream& os, const InstructionOperand& op) {
+std::ostream& operator<<(std::ostream& os, const InstructionOperand& op) {
switch (op.kind()) {
case InstructionOperand::INVALID:
return os << "(0)";
}
-OStream& operator<<(OStream& os, const MoveOperands& mo) {
+std::ostream& operator<<(std::ostream& os, const MoveOperands& mo) {
os << *mo.destination();
if (!mo.source()->Equals(mo.destination())) os << " = " << *mo.source();
return os << ";";
}
-OStream& operator<<(OStream& os, const ParallelMove& pm) {
+std::ostream& operator<<(std::ostream& os, const ParallelMove& pm) {
bool first = true;
for (ZoneList<MoveOperands>::iterator move = pm.move_operands()->begin();
move != pm.move_operands()->end(); ++move) {
}
-OStream& operator<<(OStream& os, const PointerMap& pm) {
+std::ostream& operator<<(std::ostream& os, const PointerMap& pm) {
os << "{";
for (ZoneList<InstructionOperand*>::iterator op =
pm.pointer_operands_.begin();
}
-OStream& operator<<(OStream& os, const ArchOpcode& ao) {
+std::ostream& operator<<(std::ostream& os, const ArchOpcode& ao) {
switch (ao) {
#define CASE(Name) \
case k##Name: \
}
-OStream& operator<<(OStream& os, const AddressingMode& am) {
+std::ostream& operator<<(std::ostream& os, const AddressingMode& am) {
switch (am) {
case kMode_None:
return os;
}
-OStream& operator<<(OStream& os, const FlagsMode& fm) {
+std::ostream& operator<<(std::ostream& os, const FlagsMode& fm) {
switch (fm) {
case kFlags_none:
return os;
}
-OStream& operator<<(OStream& os, const FlagsCondition& fc) {
+std::ostream& operator<<(std::ostream& os, const FlagsCondition& fc) {
switch (fc) {
case kEqual:
return os << "equal";
}
-OStream& operator<<(OStream& os, const Instruction& instr) {
+std::ostream& operator<<(std::ostream& os, const Instruction& instr) {
if (instr.OutputCount() > 1) os << "(";
for (size_t i = 0; i < instr.OutputCount(); i++) {
if (i > 0) os << ", ";
}
-OStream& operator<<(OStream& os, const Constant& constant) {
+std::ostream& operator<<(std::ostream& os, const Constant& constant) {
switch (constant.type()) {
case Constant::kInt32:
return os << constant.ToInt32();
}
-OStream& operator<<(OStream& os, const InstructionSequence& code) {
+std::ostream& operator<<(std::ostream& os, const InstructionSequence& code) {
for (size_t i = 0; i < code.immediates_.size(); ++i) {
Constant constant = code.immediates_[i];
os << "IMM#" << i << ": " << constant << "\n";
#define V8_COMPILER_INSTRUCTION_H_
#include <deque>
+#include <iosfwd>
#include <map>
#include <set>
namespace v8 {
namespace internal {
-
-// Forward declarations.
-class OStream;
-
namespace compiler {
// Forward declarations.
typedef ZoneVector<InstructionOperand*> InstructionOperandVector;
-OStream& operator<<(OStream& os, const InstructionOperand& op);
+std::ostream& operator<<(std::ostream& os, const InstructionOperand& op);
class UnallocatedOperand : public InstructionOperand {
public:
InstructionOperand* destination_;
};
-OStream& operator<<(OStream& os, const MoveOperands& mo);
+std::ostream& operator<<(std::ostream& os, const MoveOperands& mo);
template <InstructionOperand::Kind kOperandKind, int kNumCachedOperands>
class SubKindOperand FINAL : public InstructionOperand {
ZoneList<MoveOperands> move_operands_;
};
-OStream& operator<<(OStream& os, const ParallelMove& pm);
+std::ostream& operator<<(std::ostream& os, const ParallelMove& pm);
class PointerMap FINAL : public ZoneObject {
public:
void RecordUntagged(InstructionOperand* op, Zone* zone);
private:
- friend OStream& operator<<(OStream& os, const PointerMap& pm);
+ friend std::ostream& operator<<(std::ostream& os, const PointerMap& pm);
ZoneList<InstructionOperand*> pointer_operands_;
ZoneList<InstructionOperand*> untagged_operands_;
int instruction_position_;
};
-OStream& operator<<(OStream& os, const PointerMap& pm);
+std::ostream& operator<<(std::ostream& os, const PointerMap& pm);
// TODO(titzer): s/PointerMap/ReferenceMap/
class Instruction : public ZoneObject {
InstructionOperand* operands_[1];
};
-OStream& operator<<(OStream& os, const Instruction& instr);
+std::ostream& operator<<(std::ostream& os, const Instruction& instr);
// Represents moves inserted before an instruction due to register allocation.
// TODO(titzer): squash GapInstruction back into Instruction, since essentially
}
private:
- friend OStream& operator<<(OStream& os, const Instruction& instr);
+ friend std::ostream& operator<<(std::ostream& os, const Instruction& instr);
ParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
};
MaybeHandle<JSFunction> jsfunction_;
};
-OStream& operator<<(OStream& os, const Constant& constant);
+std::ostream& operator<<(std::ostream& os, const Constant& constant);
typedef ZoneDeque<Constant> ConstantDeque;
typedef std::map<int, Constant, std::less<int>,
int GetFrameStateDescriptorCount();
private:
- friend OStream& operator<<(OStream& os, const InstructionSequence& code);
+ friend std::ostream& operator<<(std::ostream& os,
+ const InstructionSequence& code);
typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet;
DeoptimizationVector deoptimization_entries_;
};
-OStream& operator<<(OStream& os, const InstructionSequence& code);
+std::ostream& operator<<(std::ostream& os, const InstructionSequence& code);
} // namespace compiler
} // namespace internal
// Specialization for static parameters of type {ContextAccess}.
template <>
struct StaticParameterTraits<ContextAccess> {
- static OStream& PrintTo(OStream& os, ContextAccess val) { // NOLINT
+ static std::ostream& PrintTo(std::ostream& os, ContextAccess val) { // NOLINT
return os << val.depth() << "," << val.index()
<< (val.immutable() ? ",imm" : "");
}
// Specialization for static parameters of type {Runtime::FunctionId}.
template <>
struct StaticParameterTraits<Runtime::FunctionId> {
- static OStream& PrintTo(OStream& os, Runtime::FunctionId val) { // NOLINT
+ static std::ostream& PrintTo(std::ostream& os,
+ Runtime::FunctionId val) { // NOLINT
const Runtime::Function* f = Runtime::FunctionForId(val);
return os << (f->name ? f->name : "?Runtime?");
}
namespace compiler {
-OStream& operator<<(OStream& os, const CallDescriptor::Kind& k) {
+std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k) {
switch (k) {
case CallDescriptor::kCallCodeObject:
os << "Code";
}
-OStream& operator<<(OStream& os, const CallDescriptor& d) {
+std::ostream& operator<<(std::ostream& os, const CallDescriptor& d) {
// TODO(svenpanne) Output properties etc. and be less cryptic.
return os << d.kind() << ":" << d.debug_name() << ":r" << d.ReturnCount()
<< "j" << d.JSParameterCount() << "i" << d.InputCount() << "f"
DEFINE_OPERATORS_FOR_FLAGS(CallDescriptor::Flags)
-OStream& operator<<(OStream& os, const CallDescriptor& d);
-OStream& operator<<(OStream& os, const CallDescriptor::Kind& k);
+std::ostream& operator<<(std::ostream& os, const CallDescriptor& d);
+std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k);
// Defines the linkage for a compilation, including the calling conventions
// for incoming parameters and return value(s) as well as the outgoing calling
#if GTEST_HAS_COMBINE
-// TODO(bmeurer): Find a new home for these.
-inline std::ostream& operator<<(std::ostream& os, const MachineType& type) {
- OStringStream ost;
- ost << type;
- return os << ost.c_str();
-}
-inline std::ostream& operator<<(std::ostream& os,
- const WriteBarrierKind& write_barrier_kind) {
- OStringStream ost;
- ost << write_barrier_kind;
- return os << ost.c_str();
-}
-
-
template <typename T>
class MachineOperatorTestWithParam
: public ::testing::TestWithParam< ::testing::tuple<MachineType, T> > {
namespace internal {
namespace compiler {
-OStream& operator<<(OStream& os, const WriteBarrierKind& write_barrier_kind) {
+std::ostream& operator<<(std::ostream& os,
+ const WriteBarrierKind& write_barrier_kind) {
switch (write_barrier_kind) {
case kNoWriteBarrier:
return os << "NoWriteBarrier";
}
-OStream& operator<<(OStream& os, const StoreRepresentation& rep) {
+std::ostream& operator<<(std::ostream& os, const StoreRepresentation& rep) {
return os << "(" << rep.machine_type() << " : " << rep.write_barrier_kind()
<< ")";
}
template <>
struct StaticParameterTraits<StoreRepresentation> {
- static OStream& PrintTo(OStream& os, const StoreRepresentation& rep) {
+ static std::ostream& PrintTo(std::ostream& os,
+ const StoreRepresentation& rep) {
return os << rep;
}
static int HashCode(const StoreRepresentation& rep) {
template <>
struct StaticParameterTraits<LoadRepresentation> {
- static OStream& PrintTo(OStream& os, LoadRepresentation type) { // NOLINT
+ static std::ostream& PrintTo(std::ostream& os,
+ LoadRepresentation type) { // NOLINT
return os << type;
}
static int HashCode(LoadRepresentation type) { return type; }
// Supported write barrier modes.
enum WriteBarrierKind { kNoWriteBarrier, kFullWriteBarrier };
-OStream& operator<<(OStream& os, const WriteBarrierKind& write_barrier_kind);
+std::ostream& operator<<(std::ostream& os,
+ const WriteBarrierKind& write_barrier_kind);
typedef MachineType LoadRepresentation;
return !(rep1 == rep2);
}
-OStream& operator<<(OStream& os, const StoreRepresentation& rep);
+std::ostream& operator<<(std::ostream& os, const StoreRepresentation& rep);
// Interface for building machine-level operators. These operators are
}
-OStream& operator<<(OStream& os, const MachineType& type) {
+std::ostream& operator<<(std::ostream& os, const MachineType& type) {
bool before = false;
PRINT(kRepBit);
PRINT(kRepWord8);
#ifndef V8_COMPILER_MACHINE_TYPE_H_
#define V8_COMPILER_MACHINE_TYPE_H_
+#include <iosfwd>
+
#include "src/base/bits.h"
#include "src/globals.h"
#include "src/zone.h"
namespace v8 {
namespace internal {
-
-class OStream;
-
namespace compiler {
// Machine-level types and representations.
kMachAnyTagged = kRepTagged | kTypeAny
};
-OStream& operator<<(OStream& os, const MachineType& type);
+std::ostream& operator<<(std::ostream& os, const MachineType& type);
typedef uint16_t MachineTypeUnion;
}
-OStream& operator<<(OStream& os, const Operator& op) { return op.PrintTo(os); }
+std::ostream& operator<<(std::ostream& os, const Operator& op) {
+ return op.PrintTo(os);
+}
-OStream& operator<<(OStream& os, const Node& n) {
+std::ostream& operator<<(std::ostream& os, const Node& n) {
os << n.id() << ": " << *n.op();
if (n.op()->InputCount() != 0) {
os << "(";
Node* FindProjection(size_t projection_index);
};
-OStream& operator<<(OStream& os, const Node& n);
+std::ostream& operator<<(std::ostream& os, const Node& n);
typedef GenericGraphVisit::NullNodeVisitor<NodeData, Node> NullNodeVisitor;
protected:
// Print the full operator into the given stream, including any
// static parameters. Useful for debugging and visualizing the IR.
- virtual OStream& PrintTo(OStream& os) const = 0; // NOLINT
- friend OStream& operator<<(OStream& os, const Operator& op);
+ virtual std::ostream& PrintTo(std::ostream& os) const = 0; // NOLINT
+ friend std::ostream& operator<<(std::ostream& os, const Operator& op);
private:
Opcode opcode_;
DEFINE_OPERATORS_FOR_FLAGS(Operator::Properties)
-OStream& operator<<(OStream& os, const Operator& op);
+std::ostream& operator<<(std::ostream& os, const Operator& op);
// An implementation of Operator that has no static parameters. Such operators
// have just a name, an opcode, and a fixed number of inputs and outputs.
virtual int OutputCount() const FINAL { return output_count_; }
private:
- virtual OStream& PrintTo(OStream& os) const FINAL { // NOLINT
+ virtual std::ostream& PrintTo(std::ostream& os) const FINAL { // NOLINT
return os << mnemonic();
}
// static parameters of Operator1 automatically.
template <typename T>
struct StaticParameterTraits {
- static OStream& PrintTo(OStream& os, T val) { // NOLINT
+ static std::ostream& PrintTo(std::ostream& os, T val) { // NOLINT
return os << "??";
}
static int HashCode(T a) { return 0; }
// Specialization for static parameters of type {int}.
template <>
struct StaticParameterTraits<int> {
- static OStream& PrintTo(OStream& os, int val) { // NOLINT
+ static std::ostream& PrintTo(std::ostream& os, int val) { // NOLINT
return os << val;
}
static int HashCode(int a) { return a; }
// Specialization for static parameters of type {double}.
template <>
struct StaticParameterTraits<double> {
- static OStream& PrintTo(OStream& os, double val) { // NOLINT
+ static std::ostream& PrintTo(std::ostream& os, double val) { // NOLINT
return os << val;
}
static int HashCode(double a) {
// Specialization for static parameters of type {Unique<Object>}.
template <>
struct StaticParameterTraits<Unique<Object> > {
- static OStream& PrintTo(OStream& os, Unique<Object> val) { // NOLINT
+ static std::ostream& PrintTo(std::ostream& os,
+ Unique<Object> val) { // NOLINT
return os << Brief(*val.handle());
}
static int HashCode(Unique<Object> a) {
// Specialization for static parameters of type {Unique<Name>}.
template <>
struct StaticParameterTraits<Unique<Name> > {
- static OStream& PrintTo(OStream& os, Unique<Name> val) { // NOLINT
+ static std::ostream& PrintTo(std::ostream& os, Unique<Name> val) { // NOLINT
return os << Brief(*val.handle());
}
static int HashCode(Unique<Name> a) { return static_cast<int>(a.Hashcode()); }
// direct usage of Handles in constants.
template <>
struct StaticParameterTraits<Handle<Object> > {
- static OStream& PrintTo(OStream& os, Handle<Object> val) { // NOLINT
+ static std::ostream& PrintTo(std::ostream& os,
+ Handle<Object> val) { // NOLINT
UNREACHABLE(); // Should use Unique<Object> instead
return os;
}
}
virtual int InputCount() const OVERRIDE { return input_count_; }
virtual int OutputCount() const OVERRIDE { return output_count_; }
- virtual OStream& PrintParameter(OStream& os) const { // NOLINT
+ virtual std::ostream& PrintParameter(std::ostream& os) const { // NOLINT
return StaticParameterTraits<T>::PrintTo(os << "[", parameter_) << "]";
}
protected:
- virtual OStream& PrintTo(OStream& os) const FINAL { // NOLINT
+ virtual std::ostream& PrintTo(std::ostream& os) const FINAL { // NOLINT
return PrintParameter(os << mnemonic());
}
#include "src/compiler/pipeline.h"
+#include <sstream>
+
#include "src/base/platform/elapsed-timer.h"
#include "src/compiler/ast-graph-builder.h"
#include "src/compiler/basic-block-instrumentor.h"
os << "---------------------------------------------------\n"
<< "Begin compiling method "
<< info()->function()->debug_name()->ToCString().get()
- << " using Turbofan" << endl;
+ << " using Turbofan" << std::endl;
}
// Build the graph.
os << "--------------------------------------------------\n"
<< "Finished compiling method "
<< info()->function()->debug_name()->ToCString().get()
- << " using Turbofan" << endl;
+ << " using Turbofan" << std::endl;
}
return code;
Handle<Code> code = generator.GenerateCode();
if (profiler_data != NULL) {
#if ENABLE_DISASSEMBLER
- OStringStream os;
+ std::ostringstream os;
code->Disassemble(NULL, os);
profiler_data->SetCode(&os);
#endif
#ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_
#define V8_COMPILER_REPRESENTATION_CHANGE_H_
+#include <sstream>
+
#include "src/base/bits.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/machine-operator.h"
MachineTypeUnion use) {
type_error_ = true;
if (!testing_type_errors_) {
- OStringStream out_str;
+ std::ostringstream out_str;
out_str << static_cast<MachineType>(output_type);
- OStringStream use_str;
+ std::ostringstream use_str;
use_str << static_cast<MachineType>(use);
V8_Fatal(__FILE__, __LINE__,
"RepresentationChangerError: node #%d:%s of "
"%s cannot be changed to %s",
- node->id(), node->op()->mnemonic(), out_str.c_str(),
- use_str.c_str());
+ node->id(), node->op()->mnemonic(), out_str.str().c_str(),
+ use_str.str().c_str());
}
return node;
}
namespace internal {
namespace compiler {
-
BasicBlock::BasicBlock(Zone* zone, Id id)
: rpo_number_(-1),
dominator_(NULL),
}
-OStream& operator<<(OStream& os, const BasicBlock::Control& c) {
+std::ostream& operator<<(std::ostream& os, const BasicBlock::Control& c) {
switch (c) {
case BasicBlock::kNone:
return os << "none";
}
-OStream& operator<<(OStream& os, const BasicBlock::Id& id) {
+std::ostream& operator<<(std::ostream& os, const BasicBlock::Id& id) {
return os << id.ToSize();
}
}
-OStream& operator<<(OStream& os, const Schedule& s) {
+std::ostream& operator<<(std::ostream& os, const Schedule& s) {
// TODO(svenpanne) Const-correct the RPO stuff/iterators.
BasicBlockVector* rpo = const_cast<Schedule*>(&s)->rpo_order();
for (BasicBlockVectorIter i = rpo->begin(); i != rpo->end(); ++i) {
}
return os;
}
+
} // namespace compiler
} // namespace internal
} // namespace v8
#ifndef V8_COMPILER_SCHEDULE_H_
#define V8_COMPILER_SCHEDULE_H_
+#include <iosfwd>
#include <vector>
#include "src/v8.h"
DISALLOW_COPY_AND_ASSIGN(BasicBlock);
};
-OStream& operator<<(OStream& os, const BasicBlock::Control& c);
-OStream& operator<<(OStream& os, const BasicBlock::Id& id);
+std::ostream& operator<<(std::ostream& os, const BasicBlock::Control& c);
+std::ostream& operator<<(std::ostream& os, const BasicBlock::Id& id);
typedef ZoneVector<BasicBlock*> BasicBlockVector;
typedef BasicBlockVector::iterator BasicBlockVectorIter;
BasicBlock* end_;
};
-OStream& operator<<(OStream& os, const Schedule& s);
-}
-}
-} // namespace v8::internal::compiler
+std::ostream& operator<<(std::ostream& os, const Schedule& s);
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
#endif // V8_COMPILER_SCHEDULE_H_
namespace internal {
namespace compiler {
-// TODO(bmeurer): Drop once we use std::ostream instead of our OStream.
-inline std::ostream& operator<<(std::ostream& os, const ElementAccess& access) {
- OStringStream ost;
- ost << access;
- return os << ost.c_str();
-}
-
-
// -----------------------------------------------------------------------------
// Pure operators.
namespace internal {
namespace compiler {
-OStream& operator<<(OStream& os, BaseTaggedness base_taggedness) {
+std::ostream& operator<<(std::ostream& os, BaseTaggedness base_taggedness) {
switch (base_taggedness) {
case kUntaggedBase:
return os << "untagged base";
}
-OStream& operator<<(OStream& os, ElementAccess const& access) {
+std::ostream& operator<<(std::ostream& os, ElementAccess const& access) {
os << "[" << access.base_is_tagged << ", " << access.header_size << ", ";
access.type->PrintTo(os);
os << ", " << access.machine_type << "]";
// Specialization for static parameters of type {FieldAccess}.
template <>
struct StaticParameterTraits<FieldAccess> {
- static OStream& PrintTo(OStream& os, const FieldAccess& val) {
+ static std::ostream& PrintTo(std::ostream& os, const FieldAccess& val) {
return os << val.offset;
}
static int HashCode(const FieldAccess& val) {
// Specialization for static parameters of type {ElementAccess}.
template <>
struct StaticParameterTraits<ElementAccess> {
- static OStream& PrintTo(OStream& os, const ElementAccess& access) {
+ static std::ostream& PrintTo(std::ostream& os, const ElementAccess& access) {
return os << access;
}
static int HashCode(const ElementAccess& access) {
enum BaseTaggedness { kUntaggedBase, kTaggedBase };
-OStream& operator<<(OStream&, BaseTaggedness);
+std::ostream& operator<<(std::ostream&, BaseTaggedness);
// An access descriptor for loads/stores of fixed structures like field
// accesses of heap objects. Accesses from either tagged or untagged base
bool operator==(ElementAccess const& lhs, ElementAccess const& rhs);
bool operator!=(ElementAccess const& lhs, ElementAccess const& rhs);
-OStream& operator<<(OStream&, ElementAccess const&);
+std::ostream& operator<<(std::ostream&, ElementAccess const&);
// If the accessed object is not a heap object, add this to the header_size.
std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) {
- OStringStream ost;
- ost << memacc.type;
- return os << ost.c_str();
+ return os << memacc.type;
}
std::ostream& operator<<(std::ostream& os, const MultParam& m) {
- OStringStream ost;
- ost << m.value << "." << m.lea_expected << "." << m.addressing_mode;
- return os << ost.c_str();
+ return os << m.value << "." << m.lea_expected << "." << m.addressing_mode;
}
OFStream os(stderr);
os << "[couldn't find pc offset for node=" << id.ToInt() << "]\n"
<< "[method: " << shared->DebugName()->ToCString().get() << "]\n"
- << "[source:\n" << SourceCodeOf(shared) << "\n]" << endl;
+ << "[source:\n" << SourceCodeOf(shared) << "\n]" << std::endl;
FATAL("unable to find pc offset during deoptimization");
return -1;
}
-static void DumpBuffer(OStream* os, StringBuilder* out) {
- (*os) << out->Finalize() << endl;
+static void DumpBuffer(std::ostream* os, StringBuilder* out) {
+ (*os) << out->Finalize() << std::endl;
out->Reset();
}
static const int kOutBufferSize = 2048 + String::kMaxShortPrintLength;
static const int kRelocInfoPosition = 57;
-static int DecodeIt(Isolate* isolate, OStream* os,
+static int DecodeIt(Isolate* isolate, std::ostream* os,
const V8NameConverter& converter, byte* begin, byte* end) {
SealHandleScope shs(isolate);
DisallowHeapAllocation no_alloc;
}
-int Disassembler::Decode(Isolate* isolate, OStream* os, byte* begin, byte* end,
- Code* code) {
+int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin,
+ byte* end, Code* code) {
V8NameConverter v8NameConverter(code);
return DecodeIt(isolate, os, v8NameConverter, begin, end);
}
#else // ENABLE_DISASSEMBLER
-int Disassembler::Decode(Isolate* isolate, OStream* os, byte* begin, byte* end,
- Code* code) {
+int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin,
+ byte* end, Code* code) {
return 0;
}
// code into os. Returns the number of bytes disassembled or 1 if no
// instruction could be decoded.
// the code object is used for name resolution and may be null.
- static int Decode(Isolate* isolate, OStream* os, byte* begin, byte* end,
+ static int Decode(Isolate* isolate, std::ostream* os, byte* begin, byte* end,
Code* code = NULL);
};
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <ctype.h>
-#include <stdlib.h>
+#include <cctype>
+#include <cstdlib>
+#include <sstream>
#include "src/v8.h"
}
-OStream& operator<<(OStream& os, const Flag& flag) { // NOLINT
+std::ostream& operator<<(std::ostream& os, const Flag& flag) { // NOLINT
switch (flag.type()) {
case Flag::TYPE_BOOL:
os << (*flag.bool_variable() ? "true" : "false");
}
{
bool disabled = f->type() == Flag::TYPE_BOOL && !*f->bool_variable();
- OStringStream os;
+ std::ostringstream os;
os << (disabled ? "--no" : "--") << f->name();
- args->Add(StrDup(os.c_str()));
+ args->Add(StrDup(os.str().c_str()));
}
if (f->type() != Flag::TYPE_BOOL) {
- OStringStream os;
+ std::ostringstream os;
os << *f;
- args->Add(StrDup(os.c_str()));
+ args->Add(StrDup(os.str().c_str()));
}
}
}
if (args_flag != NULL) {
- OStringStream os;
+ std::ostringstream os;
os << "--" << args_flag->name();
- args->Add(StrDup(os.c_str()));
+ args->Add(StrDup(os.str().c_str()));
JSArguments jsargs = *args_flag->args_variable();
for (int j = 0; j < jsargs.argc; j++) {
args->Add(StrDup(jsargs[j]));
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "src/frames.h"
+
+#include <sstream>
+
#include "src/v8.h"
#include "src/ast.h"
// Print details about the function.
if (FLAG_max_stack_trace_source_length != 0 && code != NULL) {
- OStringStream os;
+ std::ostringstream os;
SharedFunctionInfo* shared = function->shared();
os << "--------- s o u r c e c o d e ---------\n"
<< SourceCodeOf(shared, FLAG_max_stack_trace_source_length)
<< "\n-----------------------------------------\n";
- accumulator->Add(os.c_str());
+ accumulator->Add(os.str().c_str());
}
accumulator->Add("}\n\n");
void __gdb_print_v8_object(Object* object) {
OFStream os(stdout);
object->Print(os);
- os << flush;
+ os << std::flush;
}
#endif
}
} else {
os << "root ";
}
- os << " -> " << *instr << "]" << endl;
+ os << " -> " << *instr << "]" << std::endl;
}
}
-OStream& operator<<(OStream& os, const TrackedEffects& te) {
+std::ostream& operator<<(std::ostream& os, const TrackedEffects& te) {
SideEffectsTracker* t = te.tracker;
const char* separator = "";
os << "[";
if (FLAG_trace_gvn) {
OFStream os(stdout);
os << "Tracking global var [" << *cell.handle() << "] "
- << "(mapped to index " << num_global_vars_ << ")" << endl;
+ << "(mapped to index " << num_global_vars_ << ")" << std::endl;
}
*index = num_global_vars_;
global_vars_[num_global_vars_++] = cell;
if (FLAG_trace_gvn) {
OFStream os(stdout);
os << "Tracking inobject field access " << access << " (mapped to index "
- << num_inobject_fields_ << ")" << endl;
+ << num_inobject_fields_ << ")" << std::endl;
}
*index = num_inobject_fields_;
inobject_fields_[num_inobject_fields_++] = access;
if (FLAG_trace_gvn) {
OFStream os(stdout);
os << "Try loop invariant motion for " << *block << " changes "
- << Print(side_effects) << endl;
+ << Print(side_effects) << std::endl;
}
HBasicBlock* last = block->loop_information()->GetLastBackEdge();
for (int j = block->block_id(); j <= last->block_id(); ++j) {
if (FLAG_trace_gvn) {
OFStream os(stdout);
os << "Loop invariant code motion for " << *block << " depends on "
- << Print(loop_kills) << endl;
+ << Print(loop_kills) << std::endl;
}
HInstruction* instr = block->first();
while (instr != NULL) {
os << "Checking instruction i" << instr->id() << " ("
<< instr->Mnemonic() << ") changes " << Print(changes)
<< ", depends on " << Print(depends_on) << ". Loop changes "
- << Print(loop_kills) << endl;
+ << Print(loop_kills) << std::endl;
}
bool can_hoist = !depends_on.ContainsAnyOf(loop_kills);
if (can_hoist && !graph()->use_optimistic_licm()) {
if (FLAG_trace_gvn) {
OFStream os(stdout);
os << "Instruction i" << instr->id() << " changes " << Print(changes)
- << endl;
+ << std::endl;
}
}
if (instr->CheckFlag(HValue::kUseGVN) &&
#ifndef V8_HYDROGEN_GVN_H_
#define V8_HYDROGEN_GVN_H_
+#include <iosfwd>
+
#include "src/compiler.h"
#include "src/hydrogen.h"
#include "src/hydrogen-instructions.h"
namespace v8 {
namespace internal {
-class OStream;
-
// This class extends GVNFlagSet with additional "special" dynamic side effects,
// which can be used to represent side effects that cannot be expressed using
// the GVNFlags of an HInstruction. These special side effects are tracked by a
SideEffects ComputeDependsOn(HInstruction* instr);
private:
- friend OStream& operator<<(OStream& os, const TrackedEffects& f);
+ friend std::ostream& operator<<(std::ostream& os, const TrackedEffects& f);
bool ComputeGlobalVar(Unique<Cell> cell, int* index);
bool ComputeInobjectField(HObjectAccess access, int* index);
};
-OStream& operator<<(OStream& os, const TrackedEffects& f);
+std::ostream& operator<<(std::ostream& os, const TrackedEffects& f);
// Perform common subexpression elimination and loop-invariant code motion.
}
-OStream& operator<<(OStream& os, const HValue& v) { return v.PrintTo(os); }
+std::ostream& operator<<(std::ostream& os, const HValue& v) {
+ return v.PrintTo(os);
+}
-OStream& operator<<(OStream& os, const TypeOf& t) {
+std::ostream& operator<<(std::ostream& os, const TypeOf& t) {
if (t.value->representation().IsTagged() &&
!t.value->type().Equals(HType::Tagged()))
return os;
}
-OStream& operator<<(OStream& os, const ChangesOf& c) {
+std::ostream& operator<<(std::ostream& os, const ChangesOf& c) {
GVNFlagSet changes_flags = c.value->ChangesFlags();
if (changes_flags.IsEmpty()) return os;
os << " changes[";
}
-OStream& operator<<(OStream& os, const HSourcePosition& p) {
+std::ostream& operator<<(std::ostream& os, const HSourcePosition& p) {
if (p.IsUnknown()) {
return os << "<?>";
} else if (FLAG_hydrogen_track_positions) {
}
-OStream& HInstruction::PrintTo(OStream& os) const { // NOLINT
+std::ostream& HInstruction::PrintTo(std::ostream& os) const { // NOLINT
os << Mnemonic() << " ";
PrintDataTo(os) << ChangesOf(this) << TypeOf(this);
if (CheckFlag(HValue::kHasNoObservableSideEffects)) os << " [noOSE]";
}
-OStream& HInstruction::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HInstruction::PrintDataTo(std::ostream& os) const { // NOLINT
for (int i = 0; i < OperandCount(); ++i) {
if (i > 0) os << " ";
os << NameOf(OperandAt(i));
}
-OStream& operator<<(OStream& os, const NameOf& v) {
+std::ostream& operator<<(std::ostream& os, const NameOf& v) {
return os << v.value->representation().Mnemonic() << v.value->id();
}
-OStream& HDummyUse::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HDummyUse::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(value());
}
-OStream& HEnvironmentMarker::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HEnvironmentMarker::PrintDataTo(
+ std::ostream& os) const { // NOLINT
return os << (kind() == BIND ? "bind" : "lookup") << " var[" << index()
<< "]";
}
-OStream& HUnaryCall::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HUnaryCall::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(value()) << " #" << argument_count();
}
-OStream& HCallJSFunction::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCallJSFunction::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(function()) << " #" << argument_count();
}
}
-OStream& HBinaryCall::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HBinaryCall::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(first()) << " " << NameOf(second()) << " #"
<< argument_count();
}
}
-OStream& HBoundsCheck::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HBoundsCheck::PrintDataTo(std::ostream& os) const { // NOLINT
os << NameOf(index()) << " " << NameOf(length());
if (base() != NULL && (offset() != 0 || scale() != 0)) {
os << " base: ((";
}
-OStream& HBoundsCheckBaseIndexInformation::PrintDataTo(
- OStream& os) const { // NOLINT
+std::ostream& HBoundsCheckBaseIndexInformation::PrintDataTo(
+ std::ostream& os) const { // NOLINT
// TODO(svenpanne) This 2nd base_index() looks wrong...
return os << "base: " << NameOf(base_index())
<< ", check: " << NameOf(base_index());
}
-OStream& HCallWithDescriptor::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCallWithDescriptor::PrintDataTo(
+ std::ostream& os) const { // NOLINT
for (int i = 0; i < OperandCount(); i++) {
os << NameOf(OperandAt(i)) << " ";
}
}
-OStream& HCallNewArray::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCallNewArray::PrintDataTo(std::ostream& os) const { // NOLINT
os << ElementsKindToString(elements_kind()) << " ";
return HBinaryCall::PrintDataTo(os);
}
-OStream& HCallRuntime::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCallRuntime::PrintDataTo(std::ostream& os) const { // NOLINT
os << name()->ToCString().get() << " ";
if (save_doubles() == kSaveFPRegs) os << "[save doubles] ";
return os << "#" << argument_count();
}
-OStream& HClassOfTestAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HClassOfTestAndBranch::PrintDataTo(
+ std::ostream& os) const { // NOLINT
return os << "class_of_test(" << NameOf(value()) << ", \""
<< class_name()->ToCString().get() << "\")";
}
-OStream& HWrapReceiver::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HWrapReceiver::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(receiver()) << " " << NameOf(function());
}
-OStream& HAccessArgumentsAt::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HAccessArgumentsAt::PrintDataTo(
+ std::ostream& os) const { // NOLINT
return os << NameOf(arguments()) << "[" << NameOf(index()) << "], length "
<< NameOf(length());
}
-OStream& HAllocateBlockContext::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HAllocateBlockContext::PrintDataTo(
+ std::ostream& os) const { // NOLINT
return os << NameOf(context()) << " " << NameOf(function());
}
-OStream& HControlInstruction::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HControlInstruction::PrintDataTo(
+ std::ostream& os) const { // NOLINT
os << " goto (";
bool first_block = true;
for (HSuccessorIterator it(this); !it.Done(); it.Advance()) {
}
-OStream& HUnaryControlInstruction::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HUnaryControlInstruction::PrintDataTo(
+ std::ostream& os) const { // NOLINT
os << NameOf(value());
return HControlInstruction::PrintDataTo(os);
}
-OStream& HReturn::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HReturn::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(value()) << " (pop " << NameOf(parameter_count())
<< " values)";
}
}
-OStream& HBranch::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HBranch::PrintDataTo(std::ostream& os) const { // NOLINT
return HUnaryControlInstruction::PrintDataTo(os) << " "
<< expected_input_types();
}
-OStream& HCompareMap::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCompareMap::PrintDataTo(std::ostream& os) const { // NOLINT
os << NameOf(value()) << " (" << *map().handle() << ")";
HControlInstruction::PrintDataTo(os);
if (known_successor_index() == 0) {
}
-OStream& HUnaryMathOperation::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HUnaryMathOperation::PrintDataTo(
+ std::ostream& os) const { // NOLINT
return os << OpName() << " " << NameOf(value());
}
-OStream& HUnaryOperation::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HUnaryOperation::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(value());
}
-OStream& HHasInstanceTypeAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HHasInstanceTypeAndBranch::PrintDataTo(
+ std::ostream& os) const { // NOLINT
os << NameOf(value());
switch (from_) {
case FIRST_JS_RECEIVER_TYPE:
}
-OStream& HTypeofIsAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HTypeofIsAndBranch::PrintDataTo(
+ std::ostream& os) const { // NOLINT
os << NameOf(value()) << " == " << type_literal()->ToCString().get();
return HControlInstruction::PrintDataTo(os);
}
}
-OStream& HCheckMapValue::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCheckMapValue::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(value()) << " " << NameOf(map());
}
}
-OStream& HForInPrepareMap::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HForInPrepareMap::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(enumerable());
}
-OStream& HForInCacheArray::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HForInCacheArray::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(enumerable()) << " " << NameOf(map()) << "[" << idx_
<< "]";
}
-OStream& HLoadFieldByIndex::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HLoadFieldByIndex::PrintDataTo(
+ std::ostream& os) const { // NOLINT
return os << NameOf(object()) << " " << NameOf(index());
}
}
-OStream& HTypeof::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HTypeof::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(value());
}
}
-OStream& HForceRepresentation::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HForceRepresentation::PrintDataTo(
+ std::ostream& os) const { // NOLINT
return os << representation().Mnemonic() << " " << NameOf(value());
}
-OStream& HChange::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HChange::PrintDataTo(std::ostream& os) const { // NOLINT
HUnaryOperation::PrintDataTo(os);
os << " " << from().Mnemonic() << " to " << to().Mnemonic();
}
-OStream& HCheckMaps::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCheckMaps::PrintDataTo(std::ostream& os) const { // NOLINT
os << NameOf(value()) << " [" << *maps()->at(0).handle();
for (int i = 1; i < maps()->size(); ++i) {
os << "," << *maps()->at(i).handle();
}
-OStream& HCheckValue::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCheckValue::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(value()) << " " << Brief(*object().handle());
}
}
-OStream& HCheckInstanceType::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCheckInstanceType::PrintDataTo(
+ std::ostream& os) const { // NOLINT
os << GetCheckName() << " ";
return HUnaryOperation::PrintDataTo(os);
}
-OStream& HCallStub::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCallStub::PrintDataTo(std::ostream& os) const { // NOLINT
os << CodeStub::MajorName(major_key_, false) << " ";
return HUnaryCall::PrintDataTo(os);
}
-OStream& HTailCallThroughMegamorphicCache::PrintDataTo(
- OStream& os) const { // NOLINT
+std::ostream& HTailCallThroughMegamorphicCache::PrintDataTo(
+ std::ostream& os) const { // NOLINT
for (int i = 0; i < OperandCount(); i++) {
os << NameOf(OperandAt(i)) << " ";
}
}
-OStream& HUnknownOSRValue::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HUnknownOSRValue::PrintDataTo(std::ostream& os) const { // NOLINT
const char* type = "expression";
if (environment_->is_local_index(index_)) type = "local";
if (environment_->is_special_index(index_)) type = "special";
}
-OStream& HInstanceOf::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HInstanceOf::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(left()) << " " << NameOf(right()) << " "
<< NameOf(context());
}
}
-OStream& HPhi::PrintTo(OStream& os) const { // NOLINT
+std::ostream& HPhi::PrintTo(std::ostream& os) const { // NOLINT
os << "[";
for (int i = 0; i < OperandCount(); ++i) {
os << " " << NameOf(OperandAt(i)) << " ";
}
-OStream& HSimulate::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HSimulate::PrintDataTo(std::ostream& os) const { // NOLINT
os << "id=" << ast_id().ToInt();
if (pop_count_ > 0) os << " pop " << pop_count_;
if (values_.length() > 0) {
}
-OStream& HCapturedObject::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCapturedObject::PrintDataTo(std::ostream& os) const { // NOLINT
os << "#" << capture_id() << " ";
return HDematerializedObject::PrintDataTo(os);
}
}
-OStream& HEnterInlined::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HEnterInlined::PrintDataTo(std::ostream& os) const { // NOLINT
return os << function()->debug_name()->ToCString().get()
<< ", id=" << function()->id().ToInt();
}
}
-OStream& HConstant::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HConstant::PrintDataTo(std::ostream& os) const { // NOLINT
if (has_int32_value_) {
os << int32_value_ << " ";
} else if (has_double_value_) {
}
-OStream& HBinaryOperation::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HBinaryOperation::PrintDataTo(std::ostream& os) const { // NOLINT
os << NameOf(left()) << " " << NameOf(right());
if (CheckFlag(kCanOverflow)) os << " !";
if (CheckFlag(kBailoutOnMinusZero)) os << " -0?";
}
-OStream& HCompareGeneric::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCompareGeneric::PrintDataTo(std::ostream& os) const { // NOLINT
os << Token::Name(token()) << " ";
return HBinaryOperation::PrintDataTo(os);
}
-OStream& HStringCompareAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HStringCompareAndBranch::PrintDataTo(
+ std::ostream& os) const { // NOLINT
os << Token::Name(token()) << " ";
return HControlInstruction::PrintDataTo(os);
}
-OStream& HCompareNumericAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCompareNumericAndBranch::PrintDataTo(
+ std::ostream& os) const { // NOLINT
os << Token::Name(token()) << " " << NameOf(left()) << " " << NameOf(right());
return HControlInstruction::PrintDataTo(os);
}
-OStream& HCompareObjectEqAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HCompareObjectEqAndBranch::PrintDataTo(
+ std::ostream& os) const { // NOLINT
os << NameOf(left()) << " " << NameOf(right());
return HControlInstruction::PrintDataTo(os);
}
}
-OStream& HGoto::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HGoto::PrintDataTo(std::ostream& os) const { // NOLINT
return os << *SuccessorAt(0);
}
}
-OStream& HParameter::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HParameter::PrintDataTo(std::ostream& os) const { // NOLINT
return os << index();
}
-OStream& HLoadNamedField::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HLoadNamedField::PrintDataTo(std::ostream& os) const { // NOLINT
os << NameOf(object()) << access_;
if (maps() != NULL) {
}
-OStream& HLoadNamedGeneric::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HLoadNamedGeneric::PrintDataTo(
+ std::ostream& os) const { // NOLINT
Handle<String> n = Handle<String>::cast(name());
return os << NameOf(object()) << "." << n->ToCString().get();
}
-OStream& HLoadKeyed::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HLoadKeyed::PrintDataTo(std::ostream& os) const { // NOLINT
if (!is_external()) {
os << NameOf(elements());
} else {
}
-OStream& HLoadKeyedGeneric::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HLoadKeyedGeneric::PrintDataTo(
+ std::ostream& os) const { // NOLINT
return os << NameOf(object()) << "[" << NameOf(key()) << "]";
}
}
-OStream& HStoreNamedGeneric::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HStoreNamedGeneric::PrintDataTo(
+ std::ostream& os) const { // NOLINT
Handle<String> n = Handle<String>::cast(name());
return os << NameOf(object()) << "." << n->ToCString().get() << " = "
<< NameOf(value());
}
-OStream& HStoreNamedField::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HStoreNamedField::PrintDataTo(std::ostream& os) const { // NOLINT
os << NameOf(object()) << access_ << " = " << NameOf(value());
if (NeedsWriteBarrier()) os << " (write-barrier)";
if (has_transition()) os << " (transition map " << *transition_map() << ")";
}
-OStream& HStoreKeyed::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HStoreKeyed::PrintDataTo(std::ostream& os) const { // NOLINT
if (!is_external()) {
os << NameOf(elements());
} else {
}
-OStream& HStoreKeyedGeneric::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HStoreKeyedGeneric::PrintDataTo(
+ std::ostream& os) const { // NOLINT
return os << NameOf(object()) << "[" << NameOf(key())
<< "] = " << NameOf(value());
}
-OStream& HTransitionElementsKind::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HTransitionElementsKind::PrintDataTo(
+ std::ostream& os) const { // NOLINT
os << NameOf(object());
ElementsKind from_kind = original_map().handle()->elements_kind();
ElementsKind to_kind = transitioned_map().handle()->elements_kind();
}
-OStream& HLoadGlobalCell::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HLoadGlobalCell::PrintDataTo(std::ostream& os) const { // NOLINT
os << "[" << *cell().handle() << "]";
if (details_.IsConfigurable()) os << " (configurable)";
if (details_.IsReadOnly()) os << " (read-only)";
}
-OStream& HLoadGlobalGeneric::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HLoadGlobalGeneric::PrintDataTo(
+ std::ostream& os) const { // NOLINT
return os << name()->ToCString().get() << " ";
}
-OStream& HInnerAllocatedObject::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HInnerAllocatedObject::PrintDataTo(
+ std::ostream& os) const { // NOLINT
os << NameOf(base_object()) << " offset ";
return offset()->PrintTo(os);
}
-OStream& HStoreGlobalCell::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HStoreGlobalCell::PrintDataTo(std::ostream& os) const { // NOLINT
os << "[" << *cell().handle() << "] = " << NameOf(value());
if (details_.IsConfigurable()) os << " (configurable)";
if (details_.IsReadOnly()) os << " (read-only)";
}
-OStream& HLoadContextSlot::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HLoadContextSlot::PrintDataTo(std::ostream& os) const { // NOLINT
return os << NameOf(value()) << "[" << slot_index() << "]";
}
-OStream& HStoreContextSlot::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HStoreContextSlot::PrintDataTo(
+ std::ostream& os) const { // NOLINT
return os << NameOf(context()) << "[" << slot_index()
<< "] = " << NameOf(value());
}
}
-OStream& HAllocate::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HAllocate::PrintDataTo(std::ostream& os) const { // NOLINT
os << NameOf(size()) << " (";
if (IsNewSpaceAllocation()) os << "N";
if (IsOldPointerSpaceAllocation()) os << "P";
}
-OStream& HStringAdd::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HStringAdd::PrintDataTo(std::ostream& os) const { // NOLINT
if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) {
os << "_CheckBoth";
} else if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_LEFT) {
#undef H_CONSTANT_DOUBLE
-OStream& HBitwise::PrintDataTo(OStream& os) const { // NOLINT
+std::ostream& HBitwise::PrintDataTo(std::ostream& os) const { // NOLINT
os << Token::Name(op_) << " ";
return HBitwiseBinaryOperation::PrintDataTo(os);
}
}
-OStream& operator<<(OStream& os, const HObjectAccess& access) {
+std::ostream& operator<<(std::ostream& os, const HObjectAccess& access) {
os << ".";
switch (access.portion()) {
#ifndef V8_HYDROGEN_INSTRUCTIONS_H_
#define V8_HYDROGEN_INSTRUCTIONS_H_
+#include <iosfwd>
+
#include "src/v8.h"
#include "src/allocation.h"
class HValue;
class LInstruction;
class LChunkBuilder;
-class OStream;
#define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \
V(ArithmeticBinaryOperation) \
};
-OStream& operator<<(OStream& os, const HSourcePosition& p);
+std::ostream& operator<<(std::ostream& os, const HSourcePosition& p);
class HValue : public ZoneObject {
virtual void FinalizeUniqueness() { }
// Printing support.
- virtual OStream& PrintTo(OStream& os) const = 0; // NOLINT
+ virtual std::ostream& PrintTo(std::ostream& os) const = 0; // NOLINT
const char* Mnemonic() const;
result.Remove(kOsrEntries);
return result;
}
- friend OStream& operator<<(OStream& os, const ChangesOf& v);
+ friend std::ostream& operator<<(std::ostream& os, const ChangesOf& v);
// A flag mask of all side effects that can make observable changes in
// an executing program (i.e. are not safe to repeat, move or remove);
};
-OStream& operator<<(OStream& os, const HValue& v);
-OStream& operator<<(OStream& os, const NameOf& v);
-OStream& operator<<(OStream& os, const TypeOf& v);
-OStream& operator<<(OStream& os, const ChangesOf& v);
+std::ostream& operator<<(std::ostream& os, const HValue& v);
+std::ostream& operator<<(std::ostream& os, const NameOf& v);
+std::ostream& operator<<(std::ostream& os, const TypeOf& v);
+std::ostream& operator<<(std::ostream& os, const ChangesOf& v);
#define DECLARE_INSTRUCTION_FACTORY_P0(I) \
HInstruction* next() const { return next_; }
HInstruction* previous() const { return previous_; }
- virtual OStream& PrintTo(OStream& os) const OVERRIDE; // NOLINT
- virtual OStream& PrintDataTo(OStream& os) const; // NOLINT
+ virtual std::ostream& PrintTo(std::ostream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const; // NOLINT
bool IsLinked() const { return block() != NULL; }
void Unlink();
virtual int SuccessorCount() const = 0;
virtual void SetSuccessorAt(int i, HBasicBlock* block) = 0;
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual bool KnownSuccessorBlock(HBasicBlock** block) {
*block = NULL;
return Representation::None();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(DummyUse);
};
return Representation::None();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(Goto)
};
SetSuccessorAt(1, false_target);
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
HValue* value() const { return OperandAt(0); }
};
virtual bool KnownSuccessorBlock(HBasicBlock** block) OVERRIDE;
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
ToBooleanStub::Types expected_input_types() const {
return expected_input_types_;
return false;
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
static const int kNoKnownSuccessorIndex = -1;
int known_successor_index() const { return known_successor_index_; }
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
HValue* value() const { return OperandAt(0); }
HValue* context() const { return OperandAt(1); }
}
HValue* value() const { return OperandAt(0); }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
};
return representation(); // Same as the output representation.
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation)
virtual Range* InferRange(Zone* zone) OVERRIDE;
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(Change)
done_with_replay_(false) {}
~HSimulate() {}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
bool HasAstId() const { return !ast_id_.IsNone(); }
BailoutId ast_id() const { return ast_id_; }
return Representation::None();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
#ifdef DEBUG
void set_closure(Handle<JSFunction> closure) {
void RegisterReturnTarget(HBasicBlock* return_target, Zone* zone);
ZoneList<HBasicBlock*>* return_targets() { return &return_targets_; }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
Handle<JSFunction> closure() const { return closure_; }
HConstant* closure_context() const { return closure_context_; }
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
HValue* value() const { return OperandAt(0); }
};
SetOperandAt(1, second);
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(
int index) FINAL OVERRIDE {
HValue* function() const { return OperandAt(0); }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(
int index) FINAL OVERRIDE {
return OperandAt(0);
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
private:
// The argument count includes the receiver.
HValue* context() { return first(); }
HValue* constructor() { return second(); }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
ElementsKind elements_kind() const { return elements_kind_; }
const Runtime::Function*,
int);
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
HValue* context() { return OperandAt(0); }
const Runtime::Function* function() const { return c_function_; }
HValue* context() const { return OperandAt(0); }
HValue* value() const { return OperandAt(1); }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
if (index == 0) {
return HType::HeapObject();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
HValue* value() const { return OperandAt(0); }
HValue* typecheck() const { return OperandAt(1); }
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual HValue* Canonicalize() OVERRIDE;
DECLARE_INSTRUCTION_FACTORY_P2(HCheckInstanceType, HValue*, Check);
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::Tagged();
induction_variable_data_ = InductionVariableData::ExaminePhi(this);
}
- virtual OStream& PrintTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintTo(std::ostream& os) const OVERRIDE; // NOLINT
#ifdef DEBUG
virtual void Verify() OVERRIDE;
// Replay effects of this instruction on the given environment.
void ReplayEnvironment(HEnvironment* env);
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(CapturedObject)
}
virtual bool EmitAtUses() OVERRIDE;
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
HConstant* CopyToRepresentation(Representation r, Zone* zone) const;
Maybe<HConstant*> CopyToTruncatedInt32(Zone* zone);
Maybe<HConstant*> CopyToTruncatedNumber(Zone* zone);
virtual bool IsCommutative() const { return false; }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
if (index == 0) return Representation::Tagged();
virtual HValue* Canonicalize() OVERRIDE;
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
bool known_function() const { return known_function_; }
DECLARE_CONCRETE_INSTRUCTION(WrapReceiver)
public:
DECLARE_INSTRUCTION_FACTORY_P3(HAccessArgumentsAt, HValue*, HValue*, HValue*);
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
// The arguments elements is considered tagged.
return representation();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual void InferRepresentation(
HInferRepresentationPhase* h_infer) OVERRIDE;
return representation();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual int RedefinedOperandIndex() OVERRIDE { return 0; }
virtual bool IsPurelyInformativeDefinition() OVERRIDE { return true; }
}
Token::Value token() const { return token_; }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(CompareGeneric)
virtual bool KnownSuccessorBlock(HBasicBlock** block) OVERRIDE;
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
void SetOperandPositions(Zone* zone,
HSourcePosition left_pos,
HValue* left() const { return OperandAt(0); }
HValue* right() const { return OperandAt(1); }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::Tagged();
HValue* right() { return OperandAt(2); }
Token::Value token() const { return token_; }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::Tagged();
InstanceType from() { return from_; }
InstanceType to() { return to_; }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::Tagged();
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
Handle<String> class_name() const { return class_name_; }
DECLARE_INSTRUCTION_FACTORY_P2(HTypeofIsAndBranch, HValue*, Handle<String>);
Handle<String> type_literal() const { return type_literal_.handle(); }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch)
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(InstanceOf)
virtual HValue* Canonicalize() OVERRIDE;
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(Bitwise)
unsigned index() const { return index_; }
ParameterKind kind() const { return kind_; }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::None();
HValue* context() { return value(); }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(CallStub)
HValue* name() const { return OperandAt(2); }
Code::Flags flags() const { return flags_; }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache)
public:
DECLARE_INSTRUCTION_FACTORY_P2(HUnknownOSRValue, HEnvironment*, int);
- virtual OStream& PrintDataTo(OStream& os) const; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::None();
Unique<Cell> cell() const { return cell_; }
bool RequiresHoleCheck() const;
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual intptr_t Hashcode() OVERRIDE {
return cell_.Hashcode();
slot_ = slot;
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::Tagged();
virtual bool HandleSideEffectDominator(GVNFlag side_effect,
HValue* dominator) OVERRIDE;
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(Allocate)
return index == 0 ? Representation::Tagged() : Representation::Integer32();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject)
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell)
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot)
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot)
friend class HLoadNamedField;
friend class HStoreNamedField;
friend class SideEffectsTracker;
- friend OStream& operator<<(OStream& os, const HObjectAccess& access);
+ friend std::ostream& operator<<(std::ostream& os,
+ const HObjectAccess& access);
inline Portion portion() const {
return PortionField::decode(value_);
};
-OStream& operator<<(OStream& os, const HObjectAccess& access);
+std::ostream& operator<<(std::ostream& os, const HObjectAccess& access);
class HLoadNamedField FINAL : public HTemplateInstruction<2> {
return Representation::Tagged();
}
virtual Range* InferRange(Zone* zone) OVERRIDE;
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
bool CanBeReplacedWith(HValue* other) const {
if (!CheckFlag(HValue::kCantBeReplaced)) return false;
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric)
return RequiredInputRepresentation(index);
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
bool UsesMustHandleHole() const;
bool AllUsesCanTreatHoleAsNaN() const;
slot_ = slot;
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
// tagged[tagged]
dominator_ = dominator;
return false;
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
HValue* object() const { return OperandAt(0); }
HValue* value() const { return OperandAt(1); }
Handle<String> name() const { return name_; }
StrictMode strict_mode() const { return strict_mode_; }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::Tagged();
bool NeedsCanonicalization();
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(StoreKeyed)
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric)
ElementsKind from_kind() const { return from_kind_; }
ElementsKind to_kind() const { return to_kind_; }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind)
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(StringAdd)
HValue* context() const { return OperandAt(0); }
HValue* value() const { return OperandAt(1); }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::Tagged();
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual HType CalculateInferredType() OVERRIDE {
if (value()->type().IsHeapObject()) return value()->type();
HValue* context() const { return OperandAt(0); }
HValue* enumerable() const { return OperandAt(1); }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual HType CalculateInferredType() OVERRIDE {
return HType::Tagged();
index_cache_ = index_cache;
}
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual HType CalculateInferredType() OVERRIDE {
return HType::Tagged();
HValue* object() const { return OperandAt(0); }
HValue* index() const { return OperandAt(1); }
- virtual OStream& PrintDataTo(OStream& os) const OVERRIDE; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
virtual HType CalculateInferredType() OVERRIDE {
return HType::Tagged();
return Representation::Tagged();
}
- virtual OStream& PrintDataTo(OStream& os) const; // NOLINT
+ virtual std::ostream& PrintDataTo(std::ostream& os) const; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext)
}
-OStream& operator<<(OStream& os, const HType& t) {
+std::ostream& operator<<(std::ostream& os, const HType& t) {
// Note: The c1visualizer syntax for locals allows only a sequence of the
// following characters: A-Za-z0-9_-|:
switch (t.kind_) {
#define HYDROGEN_TYPES_H_
#include <climits>
+#include <iosfwd>
#include "src/base/macros.h"
// Forward declarations.
template <typename T> class Handle;
class Object;
-class OStream;
#define HTYPE_LIST(V) \
V(Any, 0x0) /* 0000 0000 0000 0000 */ \
static HType FromType(typename T::TypeHandle type) WARN_UNUSED_RESULT;
static HType FromValue(Handle<Object> value) WARN_UNUSED_RESULT;
- friend OStream& operator<<(OStream& os, const HType& t);
+ friend std::ostream& operator<<(std::ostream& os, const HType& t);
private:
enum Kind {
};
-OStream& operator<<(OStream& os, const HType& t);
+std::ostream& operator<<(std::ostream& os, const HType& t);
} } // namespace v8::internal
#endif // HYDROGEN_TYPES_H_
#include "src/hydrogen.h"
#include <algorithm>
+#include <sstream>
#include "src/v8.h"
}
-OStream& operator<<(OStream& os, const HBasicBlock& b) {
+std::ostream& operator<<(std::ostream& os, const HBasicBlock& b) {
return os << "B" << b.block_id();
}
OFStream os(tracing_scope.file());
os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{"
<< info()->optimization_id() << "," << id << "} AS " << inline_id
- << " AT " << position << endl;
+ << " AT " << position << std::endl;
}
return inline_id;
}
-OStream& operator<<(OStream& os, const HEnvironment& env) {
+std::ostream& operator<<(std::ostream& os, const HEnvironment& env) {
for (int i = 0; i < env.length(); i++) {
if (i == 0) os << "parameters\n";
if (i == env.parameter_count()) os << "specials\n";
for (int j = 0; j < total; ++j) {
HPhi* phi = current->phis()->at(j);
PrintIndent();
- OStringStream os;
+ std::ostringstream os;
os << phi->merged_index() << " " << NameOf(phi) << " " << *phi << "\n";
- trace_.Add(os.c_str());
+ trace_.Add(os.str().c_str());
}
}
HInstruction* instruction = it.Current();
int uses = instruction->UseCount();
PrintIndent();
- OStringStream os;
+ std::ostringstream os;
os << "0 " << uses << " " << NameOf(instruction) << " " << *instruction;
if (FLAG_hydrogen_track_positions &&
instruction->has_position() &&
os << pos.position();
}
os << " <|@\n";
- trace_.Add(os.c_str());
+ trace_.Add(os.str().c_str());
}
}
trace_.Add("%d ",
LifetimePosition::FromInstructionIndex(i).Value());
linstr->PrintTo(&trace_);
- OStringStream os;
+ std::ostringstream os;
os << " [hir:" << NameOf(linstr->hydrogen_value()) << "] <|@\n";
- trace_.Add(os.c_str());
+ trace_.Add(os.str().c_str());
}
}
}
};
-OStream& operator<<(OStream& os, const HBasicBlock& b);
+std::ostream& operator<<(std::ostream& os, const HBasicBlock& b);
class HPredecessorIterator FINAL BASE_EMBEDDED {
};
-OStream& operator<<(OStream& os, const HEnvironment& env);
+std::ostream& operator<<(std::ostream& os, const HEnvironment& env);
class HOptimizedGraphBuilder;
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <sstream>
+
#include "src/v8.h"
#if V8_TARGET_ARCH_IA32
void LStoreNamedField::PrintDataTo(StringStream* stream) {
object()->PrintTo(stream);
- OStringStream os;
+ std::ostringstream os;
os << hydrogen()->access() << " <- ";
- stream->Add(os.c_str());
+ stream->Add(os.str().c_str());
value()->PrintTo(stream);
}
}
-OStream& operator<<(OStream& os, const CallICState& s) {
+std::ostream& operator<<(std::ostream& os, const CallICState& s) {
return os << "(args(" << s.arg_count() << "), "
<< (s.call_type() == CallICState::METHOD ? "METHOD" : "FUNCTION")
<< ", ";
}
-OStream& operator<<(OStream& os, const BinaryOpICState& s) {
+std::ostream& operator<<(std::ostream& os, const BinaryOpICState& s) {
os << "(" << Token::Name(s.op_);
if (s.mode_ == OVERWRITE_LEFT)
os << "_ReuseLeft";
};
-OStream& operator<<(OStream& os, const CallICState& s);
+std::ostream& operator<<(std::ostream& os, const CallICState& s);
// Mode to overwrite BinaryExpression values.
Isolate* isolate() const { return isolate_; }
private:
- friend OStream& operator<<(OStream& os, const BinaryOpICState& s);
+ friend std::ostream& operator<<(std::ostream& os, const BinaryOpICState& s);
enum Kind { NONE, SMI, INT32, NUMBER, STRING, GENERIC };
};
-OStream& operator<<(OStream& os, const BinaryOpICState& s);
+std::ostream& operator<<(std::ostream& os, const BinaryOpICState& s);
class CompareICState {
if (!allocation_site.is_null()) {
os << " using allocation site " << static_cast<void*>(*allocation_site);
}
- os << "]" << endl;
+ os << "]" << std::endl;
}
// Patch the inlined smi code as necessary.
class DotPrinter: public NodeVisitor {
public:
- DotPrinter(OStream& os, bool ignore_case) // NOLINT
+ DotPrinter(std::ostream& os, bool ignore_case) // NOLINT
: os_(os),
ignore_case_(ignore_case) {}
void PrintNode(const char* label, RegExpNode* node);
FOR_EACH_NODE_TYPE(DECLARE_VISIT)
#undef DECLARE_VISIT
private:
- OStream& os_;
+ std::ostream& os_;
bool ignore_case_;
};
}
os_ << "\"];\n";
Visit(node);
- os_ << "}" << endl;
+ os_ << "}" << std::endl;
}
class TableEntryBodyPrinter {
public:
- TableEntryBodyPrinter(OStream& os, ChoiceNode* choice) // NOLINT
+ TableEntryBodyPrinter(std::ostream& os, ChoiceNode* choice) // NOLINT
: os_(os),
choice_(choice) {}
void Call(uc16 from, DispatchTable::Entry entry) {
}
private:
ChoiceNode* choice() { return choice_; }
- OStream& os_;
+ std::ostream& os_;
ChoiceNode* choice_;
};
class TableEntryHeaderPrinter {
public:
- explicit TableEntryHeaderPrinter(OStream& os) // NOLINT
+ explicit TableEntryHeaderPrinter(std::ostream& os) // NOLINT
: first_(true),
os_(os) {}
void Call(uc16 from, DispatchTable::Entry entry) {
private:
bool first_;
- OStream& os_;
+ std::ostream& os_;
};
class AttributePrinter {
public:
- explicit AttributePrinter(OStream& os) // NOLINT
+ explicit AttributePrinter(std::ostream& os) // NOLINT
: os_(os),
first_(true) {}
void PrintSeparator() {
}
private:
- OStream& os_;
+ std::ostream& os_;
bool first_;
};
class DispatchTableDumper {
public:
- explicit DispatchTableDumper(OStream& os) : os_(os) {}
+ explicit DispatchTableDumper(std::ostream& os) : os_(os) {}
void Call(uc16 key, DispatchTable::Entry entry);
private:
- OStream& os_;
+ std::ostream& os_;
};
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "src/v8.h"
-
#include "src/lithium-codegen.h"
+#include <sstream>
+
+#include "src/v8.h"
+
#if V8_TARGET_ARCH_IA32
#include "src/ia32/lithium-ia32.h" // NOLINT
#include "src/ia32/lithium-codegen-ia32.h" // NOLINT
void LCodeGenBase::DeoptComment(const Deoptimizer::Reason& reason) {
- OStringStream os;
+ std::ostringstream os;
os << ";;; deoptimize at " << HSourcePosition(reason.raw_position) << " "
<< reason.mnemonic;
if (reason.detail != NULL) os << ": " << reason.detail;
- Comment("%s", os.c_str());
+ Comment("%s", os.str().c_str());
}
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <stdarg.h>
+#include "src/log.h"
+
+#include <cstdarg>
+#include <sstream>
#include "src/v8.h"
#include "src/cpu-profiler.h"
#include "src/deoptimizer.h"
#include "src/global-handles.h"
-#include "src/log.h"
#include "src/log-utils.h"
#include "src/macro-assembler.h"
#include "src/perf-jit.h"
}
-static void AddIsolateIdIfNeeded(OStream& os, // NOLINT
+static void AddIsolateIdIfNeeded(std::ostream& os, // NOLINT
Isolate* isolate) {
if (FLAG_logfile_per_isolate) os << "isolate-" << isolate << "-";
}
-static void PrepareLogFileName(OStream& os, // NOLINT
+static void PrepareLogFileName(std::ostream& os, // NOLINT
Isolate* isolate, const char* file_name) {
AddIsolateIdIfNeeded(os, isolate);
for (const char* p = file_name; *p; p++) {
FLAG_log_snapshot_positions = true;
}
- OStringStream log_file_name;
+ std::ostringstream log_file_name;
PrepareLogFileName(log_file_name, isolate, FLAG_logfile);
- log_->Initialize(log_file_name.c_str());
+ log_->Initialize(log_file_name.str().c_str());
if (FLAG_perf_basic_prof) {
}
if (FLAG_ll_prof) {
- ll_logger_ = new LowLevelLogger(log_file_name.c_str());
+ ll_logger_ = new LowLevelLogger(log_file_name.str().c_str());
addCodeEventListener(ll_logger_);
}
void LStoreNamedField::PrintDataTo(StringStream* stream) {
object()->PrintTo(stream);
- OStringStream os;
+ std::ostringstream os;
os << hydrogen()->access() << " <- ";
stream->Add(os.c_str());
value()->PrintTo(stream);
void LStoreNamedField::PrintDataTo(StringStream* stream) {
object()->PrintTo(stream);
- OStringStream os;
+ std::ostringstream os;
os << hydrogen()->access() << " <- ";
stream->Add(os.c_str());
value()->PrintTo(stream);
void Object::Print() {
OFStream os(stdout);
this->Print(os);
- os << flush;
+ os << std::flush;
}
-void Object::Print(OStream& os) { // NOLINT
+void Object::Print(std::ostream& os) { // NOLINT
if (IsSmi()) {
Smi::cast(this)->SmiPrint(os);
} else {
}
-void HeapObject::PrintHeader(OStream& os, const char* id) { // NOLINT
+void HeapObject::PrintHeader(std::ostream& os, const char* id) { // NOLINT
os << "" << reinterpret_cast<void*>(this) << ": [" << id << "]\n";
}
-void HeapObject::HeapObjectPrint(OStream& os) { // NOLINT
+void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
InstanceType instance_type = map()->instance_type();
HandleScope scope(GetIsolate());
}
-void ByteArray::ByteArrayPrint(OStream& os) { // NOLINT
+void ByteArray::ByteArrayPrint(std::ostream& os) { // NOLINT
os << "byte array, data starts at " << GetDataStartAddress();
}
-void FreeSpace::FreeSpacePrint(OStream& os) { // NOLINT
+void FreeSpace::FreeSpacePrint(std::ostream& os) { // NOLINT
os << "free space, size " << Size();
}
-#define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size) \
- void External##Type##Array::External##Type##ArrayPrint(OStream& os) { \
- os << "external " #type " array"; \
+#define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size) \
+ void External##Type##Array::External##Type##ArrayPrint(std::ostream& os) { \
+ os << "external " #type " array"; \
}
TYPED_ARRAYS(EXTERNAL_ARRAY_PRINTER)
template <class Traits>
-void FixedTypedArray<Traits>::FixedTypedArrayPrint(OStream& os) { // NOLINT
+void FixedTypedArray<Traits>::FixedTypedArrayPrint(
+ std::ostream& os) { // NOLINT
os << "fixed " << Traits::Designator();
}
-void JSObject::PrintProperties(OStream& os) { // NOLINT
+void JSObject::PrintProperties(std::ostream& os) { // NOLINT
if (HasFastProperties()) {
DescriptorArray* descs = map()->instance_descriptors();
for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) {
template <class T>
-static void DoPrintElements(OStream& os, Object* object) { // NOLINT
+static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT
T* p = T::cast(object);
for (int i = 0; i < p->length(); i++) {
os << " " << i << ": " << p->get_scalar(i) << "\n";
}
-void JSObject::PrintElements(OStream& os) { // NOLINT
+void JSObject::PrintElements(std::ostream& os) { // NOLINT
// Don't call GetElementsKind, its validation code can cause the printer to
// fail when debugging.
switch (map()->elements_kind()) {
}
-void JSObject::PrintTransitions(OStream& os) { // NOLINT
+void JSObject::PrintTransitions(std::ostream& os) { // NOLINT
if (!map()->HasTransitionArray()) return;
TransitionArray* transitions = map()->transitions();
for (int i = 0; i < transitions->number_of_transitions(); i++) {
}
-void JSObject::JSObjectPrint(OStream& os) { // NOLINT
+void JSObject::JSObjectPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSObject");
// Don't call GetElementsKind, its validation code can cause the printer to
// fail when debugging.
}
-void JSModule::JSModulePrint(OStream& os) { // NOLINT
+void JSModule::JSModulePrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSModule");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n"
<< " - context = ";
}
-void Symbol::SymbolPrint(OStream& os) { // NOLINT
+void Symbol::SymbolPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "Symbol");
os << " - hash: " << Hash();
os << "\n - name: " << Brief(name());
}
-void Map::MapPrint(OStream& os) { // NOLINT
+void Map::MapPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "Map");
os << " - type: " << TypeToString(instance_type()) << "\n";
os << " - instance size: " << instance_size() << "\n";
}
-void CodeCache::CodeCachePrint(OStream& os) { // NOLINT
+void CodeCache::CodeCachePrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "CodeCache");
os << "\n - default_cache: " << Brief(default_cache());
os << "\n - normal_type_cache: " << Brief(normal_type_cache());
}
-void PolymorphicCodeCache::PolymorphicCodeCachePrint(OStream& os) { // NOLINT
+void PolymorphicCodeCache::PolymorphicCodeCachePrint(
+ std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "PolymorphicCodeCache");
os << "\n - cache: " << Brief(cache());
}
-void TypeFeedbackInfo::TypeFeedbackInfoPrint(OStream& os) { // NOLINT
+void TypeFeedbackInfo::TypeFeedbackInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "TypeFeedbackInfo");
os << " - ic_total_count: " << ic_total_count()
<< ", ic_with_type_info_count: " << ic_with_type_info_count()
}
-void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(OStream& os) { // NOLINT
+void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(
+ std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "AliasedArgumentsEntry");
os << "\n - aliased_context_slot: " << aliased_context_slot();
}
-void FixedArray::FixedArrayPrint(OStream& os) { // NOLINT
+void FixedArray::FixedArrayPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "FixedArray");
os << " - length: " << length();
for (int i = 0; i < length(); i++) {
}
-void FixedDoubleArray::FixedDoubleArrayPrint(OStream& os) { // NOLINT
+void FixedDoubleArray::FixedDoubleArrayPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "FixedDoubleArray");
os << " - length: " << length();
for (int i = 0; i < length(); i++) {
}
-void ConstantPoolArray::ConstantPoolArrayPrint(OStream& os) { // NOLINT
+void ConstantPoolArray::ConstantPoolArrayPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "ConstantPoolArray");
os << " - length: " << length();
for (int i = 0; i <= last_index(INT32, SMALL_SECTION); i++) {
}
-void JSValue::JSValuePrint(OStream& os) { // NOLINT
+void JSValue::JSValuePrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "ValueObject");
value()->Print(os);
}
-void JSMessageObject::JSMessageObjectPrint(OStream& os) { // NOLINT
+void JSMessageObject::JSMessageObjectPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSMessageObject");
os << " - type: " << Brief(type());
os << "\n - arguments: " << Brief(arguments());
}
-void String::StringPrint(OStream& os) { // NOLINT
+void String::StringPrint(std::ostream& os) { // NOLINT
if (StringShape(this).IsInternalized()) {
os << "#";
} else if (StringShape(this).IsCons()) {
}
-void Name::NamePrint(OStream& os) { // NOLINT
+void Name::NamePrint(std::ostream& os) { // NOLINT
if (IsString())
String::cast(this)->StringPrint(os);
else
};
-void JSDate::JSDatePrint(OStream& os) { // NOLINT
+void JSDate::JSDatePrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSDate");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - value = ";
}
-void JSProxy::JSProxyPrint(OStream& os) { // NOLINT
+void JSProxy::JSProxyPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSProxy");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - handler = ";
}
-void JSFunctionProxy::JSFunctionProxyPrint(OStream& os) { // NOLINT
+void JSFunctionProxy::JSFunctionProxyPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSFunctionProxy");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - handler = ";
}
-void JSSet::JSSetPrint(OStream& os) { // NOLINT
+void JSSet::JSSetPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSSet");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - table = " << Brief(table());
}
-void JSMap::JSMapPrint(OStream& os) { // NOLINT
+void JSMap::JSMapPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSMap");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - table = " << Brief(table());
template <class Derived, class TableType>
-void OrderedHashTableIterator<
- Derived, TableType>::OrderedHashTableIteratorPrint(OStream& os) { // NOLINT
+void
+OrderedHashTableIterator<Derived, TableType>::OrderedHashTableIteratorPrint(
+ std::ostream& os) { // NOLINT
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - table = " << Brief(table());
os << "\n - index = " << Brief(index());
template void OrderedHashTableIterator<
JSSetIterator,
- OrderedHashSet>::OrderedHashTableIteratorPrint(OStream& os); // NOLINT
+ OrderedHashSet>::OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT
template void OrderedHashTableIterator<
JSMapIterator,
- OrderedHashMap>::OrderedHashTableIteratorPrint(OStream& os); // NOLINT
+ OrderedHashMap>::OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT
-void JSSetIterator::JSSetIteratorPrint(OStream& os) { // NOLINT
+void JSSetIterator::JSSetIteratorPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSSetIterator");
OrderedHashTableIteratorPrint(os);
}
-void JSMapIterator::JSMapIteratorPrint(OStream& os) { // NOLINT
+void JSMapIterator::JSMapIteratorPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSMapIterator");
OrderedHashTableIteratorPrint(os);
}
-void JSWeakMap::JSWeakMapPrint(OStream& os) { // NOLINT
+void JSWeakMap::JSWeakMapPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSWeakMap");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - table = " << Brief(table());
}
-void JSWeakSet::JSWeakSetPrint(OStream& os) { // NOLINT
+void JSWeakSet::JSWeakSetPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSWeakSet");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - table = " << Brief(table());
}
-void JSArrayBuffer::JSArrayBufferPrint(OStream& os) { // NOLINT
+void JSArrayBuffer::JSArrayBufferPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSArrayBuffer");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - backing_store = " << backing_store() << "\n";
}
-void JSTypedArray::JSTypedArrayPrint(OStream& os) { // NOLINT
+void JSTypedArray::JSTypedArrayPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSTypedArray");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - buffer = " << Brief(buffer());
}
-void JSDataView::JSDataViewPrint(OStream& os) { // NOLINT
+void JSDataView::JSDataViewPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSDataView");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - buffer =" << Brief(buffer());
}
-void JSFunction::JSFunctionPrint(OStream& os) { // NOLINT
+void JSFunction::JSFunctionPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "Function");
os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
os << " - initial_map = ";
}
-void SharedFunctionInfo::SharedFunctionInfoPrint(OStream& os) { // NOLINT
+void SharedFunctionInfo::SharedFunctionInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "SharedFunctionInfo");
os << " - name: " << Brief(name());
os << "\n - expected_nof_properties: " << expected_nof_properties();
}
-void JSGlobalProxy::JSGlobalProxyPrint(OStream& os) { // NOLINT
+void JSGlobalProxy::JSGlobalProxyPrint(std::ostream& os) { // NOLINT
os << "global_proxy ";
JSObjectPrint(os);
os << "native context : " << Brief(native_context());
}
-void JSGlobalObject::JSGlobalObjectPrint(OStream& os) { // NOLINT
+void JSGlobalObject::JSGlobalObjectPrint(std::ostream& os) { // NOLINT
os << "global ";
JSObjectPrint(os);
os << "native context : " << Brief(native_context());
}
-void JSBuiltinsObject::JSBuiltinsObjectPrint(OStream& os) { // NOLINT
+void JSBuiltinsObject::JSBuiltinsObjectPrint(std::ostream& os) { // NOLINT
os << "builtins ";
JSObjectPrint(os);
}
-void Cell::CellPrint(OStream& os) { // NOLINT
+void Cell::CellPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "Cell");
}
-void PropertyCell::PropertyCellPrint(OStream& os) { // NOLINT
+void PropertyCell::PropertyCellPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "PropertyCell");
}
-void Code::CodePrint(OStream& os) { // NOLINT
+void Code::CodePrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "Code");
#ifdef ENABLE_DISASSEMBLER
if (FLAG_use_verbose_printer) {
}
-void Foreign::ForeignPrint(OStream& os) { // NOLINT
+void Foreign::ForeignPrint(std::ostream& os) { // NOLINT
os << "foreign address : " << foreign_address();
}
void ExecutableAccessorInfo::ExecutableAccessorInfoPrint(
- OStream& os) { // NOLINT
+ std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "ExecutableAccessorInfo");
os << "\n - name: " << Brief(name());
os << "\n - flag: " << Brief(flag());
}
-void DeclaredAccessorInfo::DeclaredAccessorInfoPrint(OStream& os) { // NOLINT
+void DeclaredAccessorInfo::DeclaredAccessorInfoPrint(
+ std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "DeclaredAccessorInfo");
os << "\n - name: " << Brief(name());
os << "\n - flag: " << Brief(flag());
void DeclaredAccessorDescriptor::DeclaredAccessorDescriptorPrint(
- OStream& os) { // NOLINT
+ std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "DeclaredAccessorDescriptor");
os << "\n - internal field: " << Brief(serialized_data());
os << "\n";
}
-void Box::BoxPrint(OStream& os) { // NOLINT
+void Box::BoxPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "Box");
os << "\n - value: " << Brief(value());
os << "\n";
}
-void AccessorPair::AccessorPairPrint(OStream& os) { // NOLINT
+void AccessorPair::AccessorPairPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "AccessorPair");
os << "\n - getter: " << Brief(getter());
os << "\n - setter: " << Brief(setter());
}
-void AccessCheckInfo::AccessCheckInfoPrint(OStream& os) { // NOLINT
+void AccessCheckInfo::AccessCheckInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "AccessCheckInfo");
os << "\n - named_callback: " << Brief(named_callback());
os << "\n - indexed_callback: " << Brief(indexed_callback());
}
-void InterceptorInfo::InterceptorInfoPrint(OStream& os) { // NOLINT
+void InterceptorInfo::InterceptorInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "InterceptorInfo");
os << "\n - getter: " << Brief(getter());
os << "\n - setter: " << Brief(setter());
}
-void CallHandlerInfo::CallHandlerInfoPrint(OStream& os) { // NOLINT
+void CallHandlerInfo::CallHandlerInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "CallHandlerInfo");
os << "\n - callback: " << Brief(callback());
os << "\n - data: " << Brief(data());
}
-void FunctionTemplateInfo::FunctionTemplateInfoPrint(OStream& os) { // NOLINT
+void FunctionTemplateInfo::FunctionTemplateInfoPrint(
+ std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "FunctionTemplateInfo");
os << "\n - class name: " << Brief(class_name());
os << "\n - tag: " << Brief(tag());
}
-void ObjectTemplateInfo::ObjectTemplateInfoPrint(OStream& os) { // NOLINT
+void ObjectTemplateInfo::ObjectTemplateInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "ObjectTemplateInfo");
os << " - tag: " << Brief(tag());
os << "\n - property_list: " << Brief(property_list());
}
-void SignatureInfo::SignatureInfoPrint(OStream& os) { // NOLINT
+void SignatureInfo::SignatureInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "SignatureInfo");
os << "\n - receiver: " << Brief(receiver());
os << "\n - args: " << Brief(args());
}
-void TypeSwitchInfo::TypeSwitchInfoPrint(OStream& os) { // NOLINT
+void TypeSwitchInfo::TypeSwitchInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "TypeSwitchInfo");
os << "\n - types: " << Brief(types());
os << "\n";
}
-void AllocationSite::AllocationSitePrint(OStream& os) { // NOLINT
+void AllocationSite::AllocationSitePrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "AllocationSite");
os << " - weak_next: " << Brief(weak_next());
os << "\n - dependent code: " << Brief(dependent_code());
}
-void AllocationMemento::AllocationMementoPrint(OStream& os) { // NOLINT
+void AllocationMemento::AllocationMementoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "AllocationMemento");
os << " - allocation site: ";
if (IsValid()) {
}
-void Script::ScriptPrint(OStream& os) { // NOLINT
+void Script::ScriptPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "Script");
os << "\n - source: " << Brief(source());
os << "\n - name: " << Brief(name());
}
-void DebugInfo::DebugInfoPrint(OStream& os) { // NOLINT
+void DebugInfo::DebugInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "DebugInfo");
os << "\n - shared: " << Brief(shared());
os << "\n - original_code: " << Brief(original_code());
}
-void BreakPointInfo::BreakPointInfoPrint(OStream& os) { // NOLINT
+void BreakPointInfo::BreakPointInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "BreakPointInfo");
os << "\n - code_position: " << code_position()->value();
os << "\n - source_position: " << source_position()->value();
}
-void DescriptorArray::PrintDescriptors(OStream& os) { // NOLINT
+void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT
os << "Descriptor array " << number_of_descriptors() << "\n";
for (int i = 0; i < number_of_descriptors(); i++) {
Descriptor desc;
}
-void TransitionArray::PrintTransitions(OStream& os) { // NOLINT
+void TransitionArray::PrintTransitions(std::ostream& os) { // NOLINT
os << "Transition array %d\n", number_of_transitions();
for (int i = 0; i < number_of_transitions(); i++) {
os << " " << i << ": ";
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <sstream>
+
#include "src/v8.h"
#include "src/accessors.h"
void Object::ShortPrint(StringStream* accumulator) {
- OStringStream os;
+ std::ostringstream os;
os << Brief(this);
- accumulator->Add(os.c_str());
+ accumulator->Add(os.str().c_str());
}
-OStream& operator<<(OStream& os, const Brief& v) {
+std::ostream& operator<<(std::ostream& os, const Brief& v) {
if (v.value->IsSmi()) {
Smi::cast(v.value)->SmiPrint(os);
} else {
}
-void Smi::SmiPrint(OStream& os) const { // NOLINT
+void Smi::SmiPrint(std::ostream& os) const { // NOLINT
os << value();
}
}
-void String::PrintUC16(OStream& os, int start, int end) { // NOLINT
+void String::PrintUC16(std::ostream& os, int start, int end) { // NOLINT
if (end < 0) end = length();
ConsStringIteratorOp op;
StringCharacterStream stream(this, &op, start);
}
-void HeapObject::HeapObjectShortPrint(OStream& os) { // NOLINT
+void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
Heap* heap = GetHeap();
if (!heap->Contains(this)) {
os << "!!!INVALID POINTER!!!";
}
-void HeapNumber::HeapNumberPrint(OStream& os) { // NOLINT
+void HeapNumber::HeapNumberPrint(std::ostream& os) { // NOLINT
os << value();
}
// Output the source code without any allocation in the heap.
-OStream& operator<<(OStream& os, const SourceCodeOf& v) {
+std::ostream& operator<<(std::ostream& os, const SourceCodeOf& v) {
const SharedFunctionInfo* s = v.value;
// For some native functions there is no source.
if (!s->HasSourceCode()) return os << "<No Source>";
#ifdef ENABLE_DISASSEMBLER
void DeoptimizationInputData::DeoptimizationInputDataPrint(
- OStream& os) { // NOLINT
+ std::ostream& os) { // NOLINT
disasm::NameConverter converter;
int deopt_count = DeoptCount();
os << "Deoptimization Input Data (deopt points = " << deopt_count << ")\n";
void DeoptimizationOutputData::DeoptimizationOutputDataPrint(
- OStream& os) { // NOLINT
+ std::ostream& os) { // NOLINT
os << "Deoptimization Output Data (deopt points = " << this->DeoptPoints()
<< ")\n";
if (this->DeoptPoints() == 0) return;
}
-void Code::PrintExtraICState(OStream& os, // NOLINT
+void Code::PrintExtraICState(std::ostream& os, // NOLINT
Kind kind, ExtraICState extra) {
os << "extra_ic_state = ";
if ((kind == STORE_IC || kind == KEYED_STORE_IC) && (extra == STRICT)) {
}
-void Code::Disassemble(const char* name, OStream& os) { // NOLINT
+void Code::Disassemble(const char* name, std::ostream& os) { // NOLINT
os << "kind = " << Kind2String(kind()) << "\n";
if (IsCodeStubOrIC()) {
const char* n = CodeStub::MajorName(CodeStub::GetMajorKey(this), true);
// we keep it here instead to satisfy certain compilers.
#ifdef OBJECT_PRINT
template <typename Derived, typename Shape, typename Key>
-void Dictionary<Derived, Shape, Key>::Print(OStream& os) { // NOLINT
+void Dictionary<Derived, Shape, Key>::Print(std::ostream& os) { // NOLINT
int capacity = DerivedHashTable::Capacity();
for (int i = 0; i < capacity; i++) {
Object* k = DerivedHashTable::KeyAt(i);
#ifndef V8_OBJECTS_H_
#define V8_OBJECTS_H_
+#include <iosfwd>
+
#include "src/allocation.h"
#include "src/assert-scope.h"
#include "src/bailout-reason.h"
namespace v8 {
namespace internal {
-class OStream;
-
enum KeyedAccessStoreMode {
STANDARD_STORE,
STORE_TRANSITION_SMI_TO_OBJECT,
#endif
#ifdef OBJECT_PRINT
-#define DECLARE_PRINTER(Name) void Name##Print(OStream& os); // NOLINT
+#define DECLARE_PRINTER(Name) void Name##Print(std::ostream& os); // NOLINT
#else
#define DECLARE_PRINTER(Name)
#endif
void Print();
// Prints this object with details.
- void Print(OStream& os); // NOLINT
+ void Print(std::ostream& os); // NOLINT
#endif
private:
};
-OStream& operator<<(OStream& os, const Brief& v);
+std::ostream& operator<<(std::ostream& os, const Brief& v);
// Smi represents integer Numbers that can be stored in 31 bits.
DECLARE_CAST(Smi)
// Dispatched behavior.
- void SmiPrint(OStream& os) const; // NOLINT
+ void SmiPrint(std::ostream& os) const; // NOLINT
DECLARE_VERIFIER(Smi)
static const int kMinValue =
const DisallowHeapAllocation& promise);
// Dispatched behavior.
- void HeapObjectShortPrint(OStream& os); // NOLINT
+ void HeapObjectShortPrint(std::ostream& os); // NOLINT
#ifdef OBJECT_PRINT
- void PrintHeader(OStream& os, const char* id); // NOLINT
+ void PrintHeader(std::ostream& os, const char* id); // NOLINT
#endif
DECLARE_PRINTER(HeapObject)
DECLARE_VERIFIER(HeapObject)
// Dispatched behavior.
bool HeapNumberBooleanValue();
- void HeapNumberPrint(OStream& os); // NOLINT
+ void HeapNumberPrint(std::ostream& os); // NOLINT
DECLARE_VERIFIER(HeapNumber)
inline int get_exponent();
DECLARE_PRINTER(JSObject)
DECLARE_VERIFIER(JSObject)
#ifdef OBJECT_PRINT
- void PrintProperties(OStream& os); // NOLINT
- void PrintElements(OStream& os); // NOLINT
- void PrintTransitions(OStream& os); // NOLINT
+ void PrintProperties(std::ostream& os); // NOLINT
+ void PrintElements(std::ostream& os); // NOLINT
+ void PrintTransitions(std::ostream& os); // NOLINT
#endif
static void PrintElementsTransition(
#ifdef OBJECT_PRINT
// Print all the descriptors.
- void PrintDescriptors(OStream& os); // NOLINT
+ void PrintDescriptors(std::ostream& os); // NOLINT
#endif
#ifdef DEBUG
static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key);
#ifdef OBJECT_PRINT
- void Print(OStream& os); // NOLINT
+ void Print(std::ostream& os); // NOLINT
#endif
// Returns the key (slow).
Object* SlowReverseLookup(Object* value);
DECLARE_CAST(DeoptimizationInputData)
#ifdef ENABLE_DISASSEMBLER
- void DeoptimizationInputDataPrint(OStream& os); // NOLINT
+ void DeoptimizationInputDataPrint(std::ostream& os); // NOLINT
#endif
private:
DECLARE_CAST(DeoptimizationOutputData)
#if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER)
- void DeoptimizationOutputDataPrint(OStream& os); // NOLINT
+ void DeoptimizationOutputDataPrint(std::ostream& os); // NOLINT
#endif
};
// Printing
static const char* ICState2String(InlineCacheState state);
static const char* StubType2String(StubType type);
- static void PrintExtraICState(OStream& os, // NOLINT
+ static void PrintExtraICState(std::ostream& os, // NOLINT
Kind kind, ExtraICState extra);
- void Disassemble(const char* name, OStream& os); // NOLINT
+ void Disassemble(const char* name, std::ostream& os); // NOLINT
#endif // ENABLE_DISASSEMBLER
// [instruction_size]: Size of the native instructions
};
-OStream& operator<<(OStream& os, const SourceCodeOf& v);
+std::ostream& operator<<(std::ostream& os, const SourceCodeOf& v);
class JSGeneratorObject: public JSObject {
// Dispatched behavior.
void StringShortPrint(StringStream* accumulator);
- void PrintUC16(OStream& os, int start = 0, int end = -1); // NOLINT
+ void PrintUC16(std::ostream& os, int start = 0, int end = -1); // NOLINT
#ifdef OBJECT_PRINT
char* ToAsciiArray();
#endif
DECL_ACCESSORS(kind, Object)
#ifdef OBJECT_PRINT
- void OrderedHashTableIteratorPrint(OStream& os); // NOLINT
+ void OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT
#endif
static const int kTableOffset = JSObject::kHeaderSize;
#include "src/ostreams.h"
-#include <algorithm>
-#include <cmath>
-
-#include "src/base/platform/platform.h" // For isinf/isnan with MSVC
-
#if V8_OS_WIN
#define snprintf sprintf_s
#endif
namespace v8 {
namespace internal {
-// Be lazy and delegate the value=>char conversion to snprintf.
-template<class T>
-OStream& OStream::print(const char* format, T x) {
- char buf[32];
- int n = snprintf(buf, sizeof(buf), format, x);
- return (n < 0) ? *this : write(buf, n);
-}
+OFStreamBase::OFStreamBase(FILE* f) : f_(f) {}
-OStream& OStream::operator<<(short x) { // NOLINT(runtime/int)
- return print(hex_ ? "%hx" : "%hd", x);
-}
+OFStreamBase::~OFStreamBase() {}
-OStream& OStream::operator<<(unsigned short x) { // NOLINT(runtime/int)
- return print(hex_ ? "%hx" : "%hu", x);
-}
+OFStreamBase::int_type OFStreamBase::sync() { return 0; }
-OStream& OStream::operator<<(int x) {
- return print(hex_ ? "%x" : "%d", x);
+OFStreamBase::int_type OFStreamBase::overflow(int_type c) {
+ return (c != EOF) ? std::fputc(c, f_) : c;
}
-OStream& OStream::operator<<(unsigned int x) {
- return print(hex_ ? "%x" : "%u", x);
-}
-
-
-OStream& OStream::operator<<(long x) { // NOLINT(runtime/int)
- return print(hex_ ? "%lx" : "%ld", x);
-}
+OFStream::OFStream(FILE* f) : OFStreamBase(f), std::ostream(this) {}
-OStream& OStream::operator<<(unsigned long x) { // NOLINT(runtime/int)
- return print(hex_ ? "%lx" : "%lu", x);
-}
-
-
-OStream& OStream::operator<<(long long x) { // NOLINT(runtime/int)
- return print(hex_ ? "%llx" : "%lld", x);
-}
-
-
-OStream& OStream::operator<<(unsigned long long x) { // NOLINT(runtime/int)
- return print(hex_ ? "%llx" : "%llu", x);
-}
-
+OFStream::~OFStream() {}
-OStream& OStream::operator<<(double x) {
- if (std::isinf(x)) return *this << (x < 0 ? "-inf" : "inf");
- if (std::isnan(x)) return *this << "nan";
- return print("%g", x);
-}
-
-
-OStream& OStream::operator<<(void* x) {
- return print("%p", x);
-}
-
-
-OStream& OStream::operator<<(char x) {
- return put(x);
-}
-
-
-OStream& OStream::operator<<(signed char x) {
- return put(x);
-}
-
-
-OStream& OStream::operator<<(unsigned char x) {
- return put(x);
-}
-
-
-OStream& OStream::dec() {
- hex_ = false;
- return *this;
-}
-
-
-OStream& OStream::hex() {
- hex_ = true;
- return *this;
-}
-
-
-OStream& flush(OStream& os) { // NOLINT(runtime/references)
- return os.flush();
-}
-
-
-OStream& endl(OStream& os) { // NOLINT(runtime/references)
- return flush(os.put('\n'));
-}
-
-
-OStream& hex(OStream& os) { // NOLINT(runtime/references)
- return os.hex();
-}
-
-
-OStream& dec(OStream& os) { // NOLINT(runtime/references)
- return os.dec();
-}
-
-
-OStringStream& OStringStream::write(const char* s, size_t n) {
- size_t new_size = size_ + n;
- if (new_size < size_) return *this; // Overflow => no-op.
- reserve(new_size + 1);
- memcpy(data_ + size_, s, n);
- size_ = new_size;
- data_[size_] = '\0';
- return *this;
-}
-
-
-OStringStream& OStringStream::flush() {
- return *this;
-}
-
-
-void OStringStream::reserve(size_t requested_capacity) {
- if (requested_capacity <= capacity_) return;
- size_t new_capacity = // Handle possible overflow by not doubling.
- std::max(std::max(capacity_ * 2, capacity_), requested_capacity);
- char * new_data = allocate(new_capacity);
- memcpy(new_data, data_, size_);
- deallocate(data_, capacity_);
- capacity_ = new_capacity;
- data_ = new_data;
-}
-
-
-OFStream& OFStream::write(const char* s, size_t n) {
- if (f_) fwrite(s, n, 1, f_);
- return *this;
-}
-
-
-OFStream& OFStream::flush() {
- if (f_) fflush(f_);
- return *this;
-}
+namespace {
// Locale-independent predicates.
-static bool IsPrint(uint16_t c) { return 0x20 <= c && c <= 0x7e; }
-static bool IsSpace(uint16_t c) { return (0x9 <= c && c <= 0xd) || c == 0x20; }
-static bool IsOK(uint16_t c) { return (IsPrint(c) || IsSpace(c)) && c != '\\'; }
+bool IsPrint(uint16_t c) { return 0x20 <= c && c <= 0x7e; }
+bool IsSpace(uint16_t c) { return (0x9 <= c && c <= 0xd) || c == 0x20; }
+bool IsOK(uint16_t c) { return (IsPrint(c) || IsSpace(c)) && c != '\\'; }
-static OStream& PrintUC16(OStream& os, uint16_t c, bool (*pred)(uint16_t)) {
+std::ostream& PrintUC16(std::ostream& os, uint16_t c, bool (*pred)(uint16_t)) {
char buf[10];
const char* format = pred(c) ? "%c" : (c <= 0xff) ? "\\x%02x" : "\\u%04x";
snprintf(buf, sizeof(buf), format, c);
return os << buf;
}
+} // namespace
-OStream& operator<<(OStream& os, const AsReversiblyEscapedUC16& c) {
+
+std::ostream& operator<<(std::ostream& os, const AsReversiblyEscapedUC16& c) {
return PrintUC16(os, c.value, IsOK);
}
-OStream& operator<<(OStream& os, const AsUC16& c) {
+std::ostream& operator<<(std::ostream& os, const AsUC16& c) {
return PrintUC16(os, c.value, IsPrint);
}
-} } // namespace v8::internal
+
+} // namespace internal
+} // namespace v8
#ifndef V8_OSTREAMS_H_
#define V8_OSTREAMS_H_
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
+#include <cstddef>
+#include <cstdio>
+#include <cstring>
+#include <ostream> // NOLINT
+#include <streambuf>
#include "include/v8config.h"
#include "src/base/macros.h"
namespace v8 {
namespace internal {
-// An abstract base class for output streams with a cut-down standard interface.
-class OStream {
- public:
- OStream() : hex_(false) { }
- virtual ~OStream() { }
-
- // For manipulators like 'os << endl' or 'os << flush', etc.
- OStream& operator<<(OStream& (*manipulator)(OStream& os)) {
- return manipulator(*this);
- }
-
- // Numeric conversions.
- OStream& operator<<(short x); // NOLINT(runtime/int)
- OStream& operator<<(unsigned short x); // NOLINT(runtime/int)
- OStream& operator<<(int x);
- OStream& operator<<(unsigned int x);
- OStream& operator<<(long x); // NOLINT(runtime/int)
- OStream& operator<<(unsigned long x); // NOLINT(runtime/int)
- OStream& operator<<(long long x); // NOLINT(runtime/int)
- OStream& operator<<(unsigned long long x); // NOLINT(runtime/int)
- OStream& operator<<(double x);
- OStream& operator<<(void* x);
-
- // Character output.
- OStream& operator<<(char x);
- OStream& operator<<(signed char x);
- OStream& operator<<(unsigned char x);
- OStream& operator<<(const char* s) { return write(s, strlen(s)); }
- OStream& put(char c) { return write(&c, 1); }
-
- // Primitive format flag handling, can be extended if needed.
- OStream& dec();
- OStream& hex();
-
- virtual OStream& write(const char* s, size_t n) = 0;
- virtual OStream& flush() = 0;
-
- private:
- template<class T> OStream& print(const char* format, T x);
-
- bool hex_;
-
- DISALLOW_COPY_AND_ASSIGN(OStream);
-};
-
-
-// Some manipulators.
-OStream& flush(OStream& os); // NOLINT(runtime/references)
-OStream& endl(OStream& os); // NOLINT(runtime/references)
-OStream& dec(OStream& os); // NOLINT(runtime/references)
-OStream& hex(OStream& os); // NOLINT(runtime/references)
-
-
-// An output stream writing to a character buffer.
-class OStringStream: public OStream {
- public:
- OStringStream() : size_(0), capacity_(32), data_(allocate(capacity_)) {
- data_[0] = '\0';
- }
- ~OStringStream() { deallocate(data_, capacity_); }
-
- size_t size() const { return size_; }
- size_t capacity() const { return capacity_; }
- const char* data() const { return data_; }
-
- // Internally, our character data is always 0-terminated.
- const char* c_str() const { return data(); }
+class OFStreamBase : public std::streambuf {
+ protected:
+ explicit OFStreamBase(FILE* f);
+ virtual ~OFStreamBase();
- virtual OStringStream& write(const char* s, size_t n) OVERRIDE;
- virtual OStringStream& flush() OVERRIDE;
+ virtual int_type sync() FINAL;
+ virtual int_type overflow(int_type c) FINAL;
private:
- // Primitive allocator interface, can be extracted if needed.
- static char* allocate (size_t n) { return new char[n]; }
- static void deallocate (char* s, size_t n) { delete[] s; }
-
- void reserve(size_t requested_capacity);
-
- size_t size_;
- size_t capacity_;
- char* data_;
+ FILE* const f_;
- DISALLOW_COPY_AND_ASSIGN(OStringStream);
+ DISALLOW_COPY_AND_ASSIGN(OFStreamBase);
};
// An output stream writing to a file.
-class OFStream: public OStream {
+class OFStream FINAL : private virtual OFStreamBase, public std::ostream {
public:
- explicit OFStream(FILE* f) : f_(f) { }
- virtual ~OFStream() { }
-
- virtual OFStream& write(const char* s, size_t n) OVERRIDE;
- virtual OFStream& flush() OVERRIDE;
+ explicit OFStream(FILE* f);
+ ~OFStream();
private:
- FILE* const f_;
-
DISALLOW_COPY_AND_ASSIGN(OFStream);
};
// Writes the given character to the output escaping everything outside of
// printable/space ASCII range. Additionally escapes '\' making escaping
// reversible.
-OStream& operator<<(OStream& os, const AsReversiblyEscapedUC16& c);
+std::ostream& operator<<(std::ostream& os, const AsReversiblyEscapedUC16& c);
// Writes the given character to the output escaping everything outside
// of printable ASCII range.
-OStream& operator<<(OStream& os, const AsUC16& c);
-} } // namespace v8::internal
+std::ostream& operator<<(std::ostream& os, const AsUC16& c);
+
+} // namespace internal
+} // namespace v8
#endif // V8_OSTREAMS_H_
}
-OStream& operator<<(OStream& os, const LookupResult& r) {
+std::ostream& operator<<(std::ostream& os, const LookupResult& r) {
if (!r.IsFound()) return os << "Not Found\n";
os << "LookupResult:\n";
}
-OStream& operator<<(OStream& os, const Descriptor& d) {
+std::ostream& operator<<(std::ostream& os, const Descriptor& d) {
return os << "Descriptor " << Brief(*d.GetKey()) << " @ "
<< Brief(*d.GetValue());
}
#ifndef V8_PROPERTY_H_
#define V8_PROPERTY_H_
+#include <iosfwd>
+
#include "src/factory.h"
#include "src/field-index.h"
#include "src/field-index-inl.h"
namespace v8 {
namespace internal {
-class OStream;
-
// Abstraction for elements in instance-descriptor arrays.
//
// Each descriptor has a key, property attributes, property type,
};
-OStream& operator<<(OStream& os, const Descriptor& d);
+std::ostream& operator<<(std::ostream& os, const Descriptor& d);
class FieldDescriptor FINAL : public Descriptor {
};
-OStream& operator<<(OStream& os, const LookupResult& r);
+std::ostream& operator<<(std::ostream& os, const LookupResult& r);
} } // namespace v8::internal
#endif // V8_PROPERTY_H_
}
OFStream os(stdout);
func->code()->Print(os);
- os << endl;
+ os << std::endl;
#endif // DEBUG
return isolate->heap()->undefined_value();
}
}
OFStream os(stdout);
func->shared()->construct_stub()->Print(os);
- os << endl;
+ os << std::endl;
#endif // DEBUG
return isolate->heap()->undefined_value();
}
// ShortPrint is available in release mode. Print is not.
os << Brief(args[0]);
#endif
- os << endl;
+ os << std::endl;
return args[0]; // return TOS
}
}
-void SafepointTable::PrintEntry(unsigned index, OStream& os) const { // NOLINT
+void SafepointTable::PrintEntry(unsigned index,
+ std::ostream& os) const { // NOLINT
disasm::NameConverter converter;
SafepointEntry entry = GetEntry(index);
uint8_t* bits = entry.bits();
}
-void SafepointTable::PrintBits(OStream& os, // NOLINT
+void SafepointTable::PrintBits(std::ostream& os, // NOLINT
uint8_t byte, int digits) {
DCHECK(digits >= 0 && digits <= kBitsPerByte);
for (int i = 0; i < digits; i++) {
// Returns the entry for the given pc.
SafepointEntry FindEntry(Address pc) const;
- void PrintEntry(unsigned index, OStream& os) const; // NOLINT
+ void PrintEntry(unsigned index, std::ostream& os) const; // NOLINT
private:
static const uint8_t kNoRegisters = 0xFF;
return GetPcOffsetLocation(index) + kPcSize;
}
- static void PrintBits(OStream& os, // NOLINT
+ static void PrintBits(std::ostream& os, // NOLINT
uint8_t byte, int digits);
DisallowHeapAllocation no_allocation_;
#ifdef OBJECT_PRINT
// Print all the transitions.
- void PrintTransitions(OStream& os); // NOLINT
+ void PrintTransitions(std::ostream& os); // NOLINT
#endif
#ifdef DEBUG
template <class Config>
-void TypeImpl<Config>::BitsetType::Print(OStream& os, // NOLINT
+void TypeImpl<Config>::BitsetType::Print(std::ostream& os, // NOLINT
bitset bits) {
DisallowHeapAllocation no_allocation;
const char* name = Name(bits);
template <class Config>
-void TypeImpl<Config>::PrintTo(OStream& os, PrintDimension dim) { // NOLINT
+void TypeImpl<Config>::PrintTo(std::ostream& os, PrintDimension dim) {
DisallowHeapAllocation no_allocation;
if (dim != REPRESENTATION_DIM) {
if (this->IsBitset()) {
void TypeImpl<Config>::Print() {
OFStream os(stdout);
PrintTo(os);
- os << endl;
+ os << std::endl;
}
template <class Config>
void TypeImpl<Config>::BitsetType::Print(bitset bits) {
OFStream os(stdout);
Print(os, bits);
- os << endl;
+ os << std::endl;
}
#endif
enum PrintDimension { BOTH_DIMS, SEMANTIC_DIM, REPRESENTATION_DIM };
- void PrintTo(OStream& os, PrintDimension dim = BOTH_DIMS); // NOLINT
+ void PrintTo(std::ostream& os, PrintDimension dim = BOTH_DIMS); // NOLINT
#ifdef DEBUG
void Print();
static bitset Lub(Limits lim);
static const char* Name(bitset);
- static void Print(OStream& os, bitset); // NOLINT
+ static void Print(std::ostream& os, bitset); // NOLINT
#ifdef DEBUG
static void Print(bitset);
#endif
var->name()->Print(os);
os << " : " << Brief(value) << " -> ";
type->PrintTo(os);
- os << endl;
+ os << std::endl;
}
#endif // OBJECT_PRINT
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <sstream>
+
#include "src/v8.h"
#if V8_TARGET_ARCH_X64
void LStoreNamedField::PrintDataTo(StringStream* stream) {
object()->PrintTo(stream);
- OStringStream os;
+ std::ostringstream os;
os << hydrogen()->access() << " <- ";
- stream->Add(os.c_str());
+ stream->Add(os.str().c_str());
value()->PrintTo(stream);
}
void LStoreNamedField::PrintDataTo(StringStream* stream) {
object()->PrintTo(stream);
- OStringStream os;
+ std::ostringstream os;
os << hydrogen()->access() << " <- ";
stream->Add(os.c_str());
value()->PrintTo(stream);
'test-mementos.cc',
'test-object-observe.cc',
'test-ordered-hash-table.cc',
- 'test-ostreams.cc',
'test-parsing.cc',
'test-platform.cc',
'test-profile-generator.cc',
return Value(op->kind(), op->index());
}
- friend OStream& operator<<(OStream& os, const InterpreterState& is) {
+ friend std::ostream& operator<<(std::ostream& os,
+ const InterpreterState& is) {
for (OperandMap::const_iterator it = is.values_.begin();
it != is.values_.end(); ++it) {
if (it != is.values_.begin()) os << " ";
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <sstream>
+
#include "src/v8.h"
#include "src/compiler/operator.h"
using namespace v8::internal::compiler;
#define NaN (v8::base::OS::nan_value())
-#define Infinity (std::numeric_limits<double>::infinity())
TEST(TestOperatorMnemonic) {
SimpleOperator op1(10, Operator::kNoProperties, 0, 0, "ThisOne");
static SmartArrayPointer<const char> OperatorToString(Operator* op) {
- OStringStream os;
+ std::ostringstream os;
os << *op;
- return SmartArrayPointer<const char>(StrDup(os.c_str()));
+ return SmartArrayPointer<const char>(StrDup(os.str().c_str()));
}
Operator1<double> op3(12, Operator::kNoProperties, 0, 1, "FooBar", 2e+123);
CHECK_EQ("FooBar[2e+123]", OperatorToString(&op3).get());
- Operator1<double> op4(12, Operator::kNoProperties, 0, 1, "BarFoo", Infinity);
- CHECK_EQ("BarFoo[inf]", OperatorToString(&op4).get());
-
Operator1<double> op5(12, Operator::kNoProperties, 0, 1, "BarFoo", NaN);
CHECK_EQ("BarFoo[nan]", OperatorToString(&op5).get());
}
if (FLAG_trace_turbo_scheduler) {
OFStream os(stdout);
- os << *schedule << endl;
+ os << *schedule << std::endl;
}
ScheduleVerifier::Run(schedule);
CHECK_EQ(expected, GetScheduledNodeCount(schedule));
OFStream os(stdout);
g->shared()->Print(os);
- os << endl;
+ os << std::endl;
}
#endif // OBJECT_PRINT
+++ /dev/null
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <string.h>
-#include <limits>
-
-#include "include/v8stdint.h"
-#include "src/ostreams.h"
-#include "test/cctest/cctest.h"
-
-using namespace v8::internal;
-
-
-TEST(OStringStreamConstructor) {
- OStringStream oss;
- const size_t expected_size = 0;
- CHECK(expected_size == oss.size());
- CHECK_GT(oss.capacity(), 0);
- CHECK_NE(NULL, oss.data());
- CHECK_EQ("", oss.c_str());
-}
-
-
-#define TEST_STRING \
- "Ash nazg durbatuluk, " \
- "ash nazg gimbatul, " \
- "ash nazg thrakatuluk, " \
- "agh burzum-ishi krimpatul."
-
-TEST(OStringStreamGrow) {
- OStringStream oss;
- const int repeat = 30;
- size_t len = strlen(TEST_STRING);
- for (int i = 0; i < repeat; ++i) {
- oss.write(TEST_STRING, len);
- }
- const char* expected =
- TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING
- TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING
- TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING
- TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING
- TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING
- TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING;
- const size_t expected_len = len * repeat;
- CHECK(expected_len == oss.size());
- CHECK_GT(oss.capacity(), 0);
- CHECK_EQ(0, strncmp(expected, oss.data(), expected_len));
- CHECK_EQ(expected, oss.c_str());
-}
-
-
-template <class T>
-static void check(const char* expected, T value) {
- OStringStream oss;
- oss << value << " " << hex << value;
- CHECK_EQ(expected, oss.c_str());
-}
-
-
-TEST(NumericFormatting) {
- check<bool>("0 0", false);
- check<bool>("1 1", true);
-
- check<int16_t>("-12345 cfc7", -12345);
- check<int16_t>("-32768 8000", std::numeric_limits<int16_t>::min());
- check<int16_t>("32767 7fff", std::numeric_limits<int16_t>::max());
-
- check<uint16_t>("34567 8707", 34567);
- check<uint16_t>("0 0", std::numeric_limits<uint16_t>::min());
- check<uint16_t>("65535 ffff", std::numeric_limits<uint16_t>::max());
-
- check<int32_t>("-1234567 ffed2979", -1234567);
- check<int32_t>("-2147483648 80000000", std::numeric_limits<int32_t>::min());
- check<int32_t>("2147483647 7fffffff", std::numeric_limits<int32_t>::max());
-
- check<uint32_t>("3456789 34bf15", 3456789);
- check<uint32_t>("0 0", std::numeric_limits<uint32_t>::min());
- check<uint32_t>("4294967295 ffffffff", std::numeric_limits<uint32_t>::max());
-
- check<int64_t>("-1234567 ffffffffffed2979", -1234567);
- check<int64_t>("-9223372036854775808 8000000000000000",
- std::numeric_limits<int64_t>::min());
- check<int64_t>("9223372036854775807 7fffffffffffffff",
- std::numeric_limits<int64_t>::max());
-
- check<uint64_t>("3456789 34bf15", 3456789);
- check<uint64_t>("0 0", std::numeric_limits<uint64_t>::min());
- check<uint64_t>("18446744073709551615 ffffffffffffffff",
- std::numeric_limits<uint64_t>::max());
-
- check<float>("0 0", 0.0f);
- check<float>("123 123", 123.0f);
- check<float>("-0.5 -0.5", -0.5f);
- check<float>("1.25 1.25", 1.25f);
- check<float>("0.0625 0.0625", 6.25e-2f);
-
- check<double>("0 0", 0.0);
- check<double>("123 123", 123.0);
- check<double>("-0.5 -0.5", -0.5);
- check<double>("1.25 1.25", 1.25);
- check<double>("0.0625 0.0625", 6.25e-2);
-}
-
-
-TEST(CharacterOutput) {
- check<char>("a a", 'a');
- check<signed char>("B B", 'B');
- check<unsigned char>("9 9", '9');
- check<const char*>("bye bye", "bye");
-
- OStringStream os;
- os.put('H').write("ello", 4);
- CHECK_EQ("Hello", os.c_str());
-}
-
-
-TEST(Manipulators) {
- OStringStream os;
- os << 123 << hex << 123 << endl << 123 << dec << 123 << 123;
- CHECK_EQ("1237b\n7b123123", os.c_str());
-}
-
-
-class MiscStuff {
- public:
- MiscStuff(int i, double d, const char* s) : i_(i), d_(d), s_(s) { }
-
- private:
- friend OStream& operator<<(OStream& os, const MiscStuff& m);
-
- int i_;
- double d_;
- const char* s_;
-};
-
-
-OStream& operator<<(OStream& os, const MiscStuff& m) {
- return os << "{i:" << m.i_ << ", d:" << m.d_ << ", s:'" << m.s_ << "'}";
-}
-
-
-TEST(CustomOutput) {
- OStringStream os;
- MiscStuff m(123, 4.5, "Hurz!");
- os << m;
- CHECK_EQ("{i:123, d:4.5, s:'Hurz!'}", os.c_str());
-}
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include <stdlib.h>
+#include <cstdlib>
+#include <sstream>
#include "src/v8.h"
&reader, false, &result, &zone));
CHECK(result.tree != NULL);
CHECK(result.error.is_null());
- OStringStream os;
+ std::ostringstream os;
result.tree->Print(os, &zone);
- CHECK_EQ(expected, os.c_str());
+ CHECK_EQ(expected, os.str().c_str());
}
// Check that we don't allow more than kMaxCapture captures
const int kMaxCaptures = 1 << 16; // Must match RegExpParser::kMaxCaptures.
const char* kTooManyCaptures = "Too many captures";
- OStringStream os;
+ std::ostringstream os;
for (int i = 0; i <= kMaxCaptures; i++) {
os << "()";
}
- ExpectError(os.c_str(), kTooManyCaptures);
+ ExpectError(os.str().c_str(), kTooManyCaptures);
}