void LStoreNamedField::PrintDataTo(StringStream* stream) {
object()->PrintTo(stream);
- hydrogen()->access().PrintTo(stream);
- stream->Add(" <- ");
+ OStringStream os;
+ os << hydrogen()->access() << " <- ";
+ stream->Add(os.c_str());
value()->PrintTo(stream);
}
|| (strcmp(cmd, "printobject") == 0)) {
if (argc == 2) {
int32_t value;
+ OFStream os(stdout);
if (GetValue(arg1, &value)) {
Object* obj = reinterpret_cast<Object*>(value);
- PrintF("%s: \n", arg1);
+ os << arg1 << ": \n";
#ifdef DEBUG
- obj->PrintLn();
+ obj->Print(os);
+ os << "\n";
#else
- obj->ShortPrint();
- PrintF("\n");
+ os << Brief(obj) << "\n";
#endif
} else {
- PrintF("%s unrecognized\n", arg1);
+ os << arg1 << " unrecognized\n";
}
} else {
PrintF("printobject <value>\n");
void LStoreNamedField::PrintDataTo(StringStream* stream) {
object()->PrintTo(stream);
- hydrogen()->access().PrintTo(stream);
+ OStringStream os;
+ os << hydrogen()->access();
+ stream->Add(os.c_str());
stream->Add(" <- ");
value()->PrintTo(stream);
}
(strcmp(cmd, "po") == 0)) {
if (argc == 2) {
int64_t value;
+ OFStream os(stdout);
if (GetValue(arg1, &value)) {
Object* obj = reinterpret_cast<Object*>(value);
- PrintF("%s: \n", arg1);
+ os << arg1 << ": \n";
#ifdef DEBUG
- obj->PrintLn();
+ obj->Print(os);
+ os << "\n";
#else
- obj->ShortPrint();
- PrintF("\n");
+ os << Brief(obj) << "\n";
#endif
} else {
- PrintF("%s unrecognized\n", arg1);
+ os << arg1 << " unrecognized\n";
}
} else {
PrintF("printobject <value>\n"
}
-void RelocInfo::Print(Isolate* isolate, FILE* out) {
- PrintF(out, "%p %s", pc_, RelocModeName(rmode_));
+void RelocInfo::Print(Isolate* isolate, OStream& os) { // NOLINT
+ os << pc_ << " " << RelocModeName(rmode_);
if (IsComment(rmode_)) {
- PrintF(out, " (%s)", reinterpret_cast<char*>(data_));
+ os << " (" << reinterpret_cast<char*>(data_) << ")";
} else if (rmode_ == EMBEDDED_OBJECT) {
- PrintF(out, " (");
- target_object()->ShortPrint(out);
- PrintF(out, ")");
+ os << " (" << Brief(target_object()) << ")";
} else if (rmode_ == EXTERNAL_REFERENCE) {
ExternalReferenceEncoder ref_encoder(isolate);
- PrintF(out, " (%s) (%p)",
- ref_encoder.NameOfAddress(target_reference()),
- target_reference());
+ os << " (" << ref_encoder.NameOfAddress(target_reference()) << ") ("
+ << target_reference() << ")";
} else if (IsCodeTarget(rmode_)) {
Code* code = Code::GetCodeFromTargetAddress(target_address());
- PrintF(out, " (%s) (%p)", Code::Kind2String(code->kind()),
- target_address());
+ os << " (" << Code::Kind2String(code->kind()) << ") (" << target_address()
+ << ")";
if (rmode_ == CODE_TARGET_WITH_ID) {
- PrintF(out, " (id=%d)", static_cast<int>(data_));
+ os << " (id=" << static_cast<int>(data_) << ")";
}
} else if (IsPosition(rmode_)) {
- PrintF(out, " (%" V8_PTR_PREFIX "d)", data());
+ os << " (" << data() << ")";
} else if (IsRuntimeEntry(rmode_) &&
isolate->deoptimizer_data() != NULL) {
// Depotimization bailouts are stored as runtime entries.
int id = Deoptimizer::GetDeoptimizationId(
isolate, target_address(), Deoptimizer::EAGER);
if (id != Deoptimizer::kNotDeoptimizationEntry) {
- PrintF(out, " (deoptimization bailout %d)", id);
+ os << " (deoptimization bailout " << id << ")";
}
}
- PrintF(out, "\n");
+ os << "\n";
}
#endif // ENABLE_DISASSEMBLER
#ifdef ENABLE_DISASSEMBLER
// Printing
static const char* RelocModeName(Mode rmode);
- void Print(Isolate* isolate, FILE* out);
+ void Print(Isolate* isolate, OStream& os); // NOLINT
#endif // ENABLE_DISASSEMBLER
#ifdef VERIFY_HEAP
void Verify(Isolate* isolate);
// output formats are alike.
class RegExpUnparser V8_FINAL : public RegExpVisitor {
public:
- explicit RegExpUnparser(Zone* zone);
+ RegExpUnparser(OStream& os, Zone* zone) : os_(os), zone_(zone) {}
void VisitCharacterRange(CharacterRange that);
- SmartArrayPointer<const char> ToString() { return stream_.ToCString(); }
#define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, \
void* data) V8_OVERRIDE;
FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE)
#undef MAKE_CASE
private:
- StringStream* stream() { return &stream_; }
- HeapStringAllocator alloc_;
- StringStream stream_;
+ OStream& os_;
Zone* zone_;
};
-RegExpUnparser::RegExpUnparser(Zone* zone) : stream_(&alloc_), zone_(zone) {
-}
-
-
void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) {
- stream()->Add("(|");
+ os_ << "(|";
for (int i = 0; i < that->alternatives()->length(); i++) {
- stream()->Add(" ");
+ os_ << " ";
that->alternatives()->at(i)->Accept(this, data);
}
- stream()->Add(")");
+ os_ << ")";
return NULL;
}
void* RegExpUnparser::VisitAlternative(RegExpAlternative* that, void* data) {
- stream()->Add("(:");
+ os_ << "(:";
for (int i = 0; i < that->nodes()->length(); i++) {
- stream()->Add(" ");
+ os_ << " ";
that->nodes()->at(i)->Accept(this, data);
}
- stream()->Add(")");
+ os_ << ")";
return NULL;
}
void RegExpUnparser::VisitCharacterRange(CharacterRange that) {
- stream()->Add("%k", that.from());
+ os_ << AsUC16(that.from());
if (!that.IsSingleton()) {
- stream()->Add("-%k", that.to());
+ os_ << "-" << AsUC16(that.to());
}
}
void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that,
void* data) {
- if (that->is_negated())
- stream()->Add("^");
- stream()->Add("[");
+ if (that->is_negated()) os_ << "^";
+ os_ << "[";
for (int i = 0; i < that->ranges(zone_)->length(); i++) {
- if (i > 0) stream()->Add(" ");
+ if (i > 0) os_ << " ";
VisitCharacterRange(that->ranges(zone_)->at(i));
}
- stream()->Add("]");
+ os_ << "]";
return NULL;
}
void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) {
switch (that->assertion_type()) {
case RegExpAssertion::START_OF_INPUT:
- stream()->Add("@^i");
+ os_ << "@^i";
break;
case RegExpAssertion::END_OF_INPUT:
- stream()->Add("@$i");
+ os_ << "@$i";
break;
case RegExpAssertion::START_OF_LINE:
- stream()->Add("@^l");
+ os_ << "@^l";
break;
case RegExpAssertion::END_OF_LINE:
- stream()->Add("@$l");
+ os_ << "@$l";
break;
case RegExpAssertion::BOUNDARY:
- stream()->Add("@b");
+ os_ << "@b";
break;
case RegExpAssertion::NON_BOUNDARY:
- stream()->Add("@B");
+ os_ << "@B";
break;
}
return NULL;
void* RegExpUnparser::VisitAtom(RegExpAtom* that, void* data) {
- stream()->Add("'");
+ os_ << "'";
Vector<const uc16> chardata = that->data();
for (int i = 0; i < chardata.length(); i++) {
- stream()->Add("%k", chardata[i]);
+ os_ << AsUC16(chardata[i]);
}
- stream()->Add("'");
+ os_ << "'";
return NULL;
}
if (that->elements()->length() == 1) {
that->elements()->at(0).tree()->Accept(this, data);
} else {
- stream()->Add("(!");
+ os_ << "(!";
for (int i = 0; i < that->elements()->length(); i++) {
- stream()->Add(" ");
+ os_ << " ";
that->elements()->at(i).tree()->Accept(this, data);
}
- stream()->Add(")");
+ os_ << ")";
}
return NULL;
}
void* RegExpUnparser::VisitQuantifier(RegExpQuantifier* that, void* data) {
- stream()->Add("(# %i ", that->min());
+ os_ << "(# " << that->min() << " ";
if (that->max() == RegExpTree::kInfinity) {
- stream()->Add("- ");
+ os_ << "- ";
} else {
- stream()->Add("%i ", that->max());
+ os_ << that->max() << " ";
}
- stream()->Add(that->is_greedy() ? "g " : that->is_possessive() ? "p " : "n ");
+ os_ << (that->is_greedy() ? "g " : that->is_possessive() ? "p " : "n ");
that->body()->Accept(this, data);
- stream()->Add(")");
+ os_ << ")";
return NULL;
}
void* RegExpUnparser::VisitCapture(RegExpCapture* that, void* data) {
- stream()->Add("(^ ");
+ os_ << "(^ ";
that->body()->Accept(this, data);
- stream()->Add(")");
+ os_ << ")";
return NULL;
}
void* RegExpUnparser::VisitLookahead(RegExpLookahead* that, void* data) {
- stream()->Add("(-> ");
- stream()->Add(that->is_positive() ? "+ " : "- ");
+ os_ << "(-> " << (that->is_positive() ? "+ " : "- ");
that->body()->Accept(this, data);
- stream()->Add(")");
+ os_ << ")";
return NULL;
}
void* RegExpUnparser::VisitBackReference(RegExpBackReference* that,
void* data) {
- stream()->Add("(<- %i)", that->index());
+ os_ << "(<- " << that->index() << ")";
return NULL;
}
void* RegExpUnparser::VisitEmpty(RegExpEmpty* that, void* data) {
- stream()->Put('%');
+ os_ << '%';
return NULL;
}
-SmartArrayPointer<const char> RegExpTree::ToString(Zone* zone) {
- RegExpUnparser unparser(zone);
+OStream& RegExpTree::Print(OStream& os, Zone* zone) { // NOLINT
+ RegExpUnparser unparser(os, zone);
Accept(&unparser, NULL);
- return unparser.ToString();
+ return os;
}
#include "src/isolate.h"
#include "src/jsregexp.h"
#include "src/list-inl.h"
+#include "src/ostreams.h"
#include "src/runtime.h"
#include "src/small-pointer-list.h"
#include "src/smart-pointers.h"
// expression.
virtual Interval CaptureRegisters() { return Interval::Empty(); }
virtual void AppendToText(RegExpText* text, Zone* zone);
- SmartArrayPointer<const char> ToString(Zone* zone);
+ OStream& Print(OStream& os, Zone* zone); // NOLINT
#define MAKE_ASTYPE(Name) \
virtual RegExp##Name* As##Name(); \
virtual bool Is##Name();
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_builtin_code) {
CodeTracer::Scope trace_scope(isolate->GetCodeTracer());
- PrintF(trace_scope.file(), "Builtin: %s\n", functions[i].s_name);
- code->Disassemble(functions[i].s_name, trace_scope.file());
- PrintF(trace_scope.file(), "\n");
+ OFStream os(trace_scope.file());
+ os << "Builtin: " << functions[i].s_name << "\n";
+ code->Disassemble(functions[i].s_name, os);
+ os << "\n";
}
#endif
} else {
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_code_stubs) {
CodeTracer::Scope trace_scope(isolate()->GetCodeTracer());
- OStringStream os;
- os << *this;
- new_object->Disassemble(os.c_str(), trace_scope.file());
- PrintF(trace_scope.file(), "\n");
+ OFStream os(trace_scope.file());
+ OStringStream name;
+ name << *this;
+ new_object->Disassemble(name.c_str(), os);
+ os << "\n";
}
#endif
code->kind() == Code::FUNCTION;
CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer());
+ OFStream os(tracing_scope.file());
if (print_source) {
Handle<Script> script = info->script();
if (!script->IsUndefined() && !script->source()->IsUndefined()) {
- PrintF(tracing_scope.file(), "--- Raw source ---\n");
+ os << "--- Raw source ---\n";
ConsStringIteratorOp op;
StringCharacterStream stream(String::cast(script->source()),
&op,
function->end_position() - function->start_position() + 1;
for (int i = 0; i < source_len; i++) {
if (stream.HasMore()) {
- PrintF(tracing_scope.file(), "%c", stream.GetNext());
+ os.put(stream.GetNext());
}
}
- PrintF(tracing_scope.file(), "\n\n");
+ os << "\n\n";
}
}
if (info->IsOptimizing()) {
if (FLAG_print_unopt_code) {
- PrintF(tracing_scope.file(), "--- Unoptimized code ---\n");
+ os << "--- Unoptimized code ---\n";
info->closure()->shared()->code()->Disassemble(
- function->debug_name()->ToCString().get(), tracing_scope.file());
+ function->debug_name()->ToCString().get(), os);
}
- PrintF(tracing_scope.file(), "--- Optimized code ---\n");
- PrintF(tracing_scope.file(),
- "optimization_id = %d\n", info->optimization_id());
+ os << "--- Optimized code ---\n"
+ << "optimization_id = " << info->optimization_id() << "\n";
} else {
- PrintF(tracing_scope.file(), "--- Code ---\n");
+ os << "--- Code ---\n";
}
if (print_source) {
- PrintF(tracing_scope.file(),
- "source_position = %d\n", function->start_position());
+ os << "source_position = " << function->start_position() << "\n";
}
if (info->IsStub()) {
CodeStub::Major major_key = info->code_stub()->MajorKey();
- code->Disassemble(CodeStub::MajorName(major_key, false),
- tracing_scope.file());
+ code->Disassemble(CodeStub::MajorName(major_key, false), os);
} else {
- code->Disassemble(function->debug_name()->ToCString().get(),
- tracing_scope.file());
+ code->Disassemble(function->debug_name()->ToCString().get(), os);
}
- PrintF(tracing_scope.file(), "--- End code ---\n");
+ os << "--- End code ---\n";
}
#endif // ENABLE_DISASSEMBLER
}
return data->PcAndState(i)->value();
}
}
- PrintF(stderr, "[couldn't find pc offset for node=%d]\n", id.ToInt());
- PrintF(stderr, "[method: %s]\n", shared->DebugName()->ToCString().get());
- // Print the source code if available.
- HeapStringAllocator string_allocator;
- StringStream stream(&string_allocator);
- shared->SourceCodePrint(&stream, -1);
- PrintF(stderr, "[source:\n%s\n]", stream.ToCString().get());
+ 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;
FATAL("unable to find pc offset during deoptimization");
return -1;
}
-void PrintElementsKind(FILE* out, ElementsKind kind) {
- PrintF(out, "%s", ElementsKindToString(kind));
-}
-
-
ElementsKind GetInitialFastElementsKind() {
if (FLAG_packed_arrays) {
return FAST_SMI_ELEMENTS;
#define V8_ELEMENTS_KIND_H_
#include "src/checks.h"
+#include "src/ostreams.h"
namespace v8 {
namespace internal {
int ElementsKindToShiftSize(ElementsKind elements_kind);
int GetDefaultHeaderSizeForElementsKind(ElementsKind elements_kind);
const char* ElementsKindToString(ElementsKind kind);
-void PrintElementsKind(FILE* out, ElementsKind kind);
ElementsKind GetInitialFastElementsKind();
#include "src/assembler.h"
#include "src/base/platform/platform.h"
-#include "src/smart-pointers.h"
-#include "src/string-stream.h"
+#include "src/ostreams.h"
namespace v8 {
namespace internal {
}
-static SmartArrayPointer<const char> ToString(Flag* flag) {
- HeapStringAllocator string_allocator;
- StringStream buffer(&string_allocator);
- switch (flag->type()) {
+OStream& operator<<(OStream& os, const Flag& flag) { // NOLINT
+ switch (flag.type()) {
case Flag::TYPE_BOOL:
- buffer.Add("%s", (*flag->bool_variable() ? "true" : "false"));
+ os << (*flag.bool_variable() ? "true" : "false");
break;
case Flag::TYPE_MAYBE_BOOL:
- buffer.Add("%s", flag->maybe_bool_variable()->has_value
- ? (flag->maybe_bool_variable()->value ? "true" : "false")
- : "unset");
+ os << (flag.maybe_bool_variable()->has_value
+ ? (flag.maybe_bool_variable()->value ? "true" : "false")
+ : "unset");
break;
case Flag::TYPE_INT:
- buffer.Add("%d", *flag->int_variable());
+ os << *flag.int_variable();
break;
case Flag::TYPE_FLOAT:
- buffer.Add("%f", FmtElm(*flag->float_variable()));
+ os << *flag.float_variable();
break;
case Flag::TYPE_STRING: {
- const char* str = flag->string_value();
- buffer.Add("%s", str ? str : "NULL");
+ const char* str = flag.string_value();
+ os << (str ? str : "NULL");
break;
}
case Flag::TYPE_ARGS: {
- JSArguments args = *flag->args_variable();
+ JSArguments args = *flag.args_variable();
if (args.argc > 0) {
- buffer.Add("%s", args[0]);
+ os << args[0];
for (int i = 1; i < args.argc; i++) {
- buffer.Add(" %s", args[i]);
+ os << args[i];
}
}
break;
}
}
- return buffer.ToCString();
+ return os;
}
args_flag = f; // Must be last in arguments.
continue;
}
- HeapStringAllocator string_allocator;
- StringStream buffer(&string_allocator);
- if (f->type() != Flag::TYPE_BOOL || *(f->bool_variable())) {
- buffer.Add("--%s", f->name());
- } else {
- buffer.Add("--no%s", f->name());
+ {
+ bool disabled = f->type() == Flag::TYPE_BOOL && !*f->bool_variable();
+ OStringStream os;
+ os << (disabled ? "--no" : "--") << f->name();
+ args->Add(StrDup(os.c_str()));
}
- args->Add(buffer.ToCString().Detach());
if (f->type() != Flag::TYPE_BOOL) {
- args->Add(ToString(f).Detach());
+ OStringStream os;
+ os << *f;
+ args->Add(StrDup(os.c_str()));
}
}
}
if (args_flag != NULL) {
- HeapStringAllocator string_allocator;
- StringStream buffer(&string_allocator);
- buffer.Add("--%s", args_flag->name());
- args->Add(buffer.ToCString().Detach());
+ OStringStream os;
+ os << "--" << args_flag->name();
+ args->Add(StrDup(os.c_str()));
JSArguments jsargs = *args_flag->args_variable();
for (int j = 0; j < jsargs.argc; j++) {
args->Add(StrDup(jsargs[j]));
CpuFeatures::PrintTarget();
CpuFeatures::PrintFeatures();
- printf("Usage:\n");
- printf(" shell [options] -e string\n");
- printf(" execute string in V8\n");
- printf(" shell [options] file1 file2 ... filek\n");
- printf(" run JavaScript scripts in file1, file2, ..., filek\n");
- printf(" shell [options]\n");
- printf(" shell [options] --shell [file1 file2 ... filek]\n");
- printf(" run an interactive JavaScript shell\n");
- printf(" d8 [options] file1 file2 ... filek\n");
- printf(" d8 [options]\n");
- printf(" d8 [options] --shell [file1 file2 ... filek]\n");
- printf(" run the new debugging shell\n\n");
- printf("Options:\n");
+ OFStream os(stdout);
+ os << "Usage:\n"
+ << " shell [options] -e string\n"
+ << " execute string in V8\n"
+ << " shell [options] file1 file2 ... filek\n"
+ << " run JavaScript scripts in file1, file2, ..., filek\n"
+ << " shell [options]\n"
+ << " shell [options] --shell [file1 file2 ... filek]\n"
+ << " run an interactive JavaScript shell\n"
+ << " d8 [options] file1 file2 ... filek\n"
+ << " d8 [options]\n"
+ << " d8 [options] --shell [file1 file2 ... filek]\n"
+ << " run the new debugging shell\n\n"
+ << "Options:\n";
for (size_t i = 0; i < num_flags; ++i) {
Flag* f = &flags[i];
- SmartArrayPointer<const char> value = ToString(f);
- printf(" --%s (%s)\n type: %s default: %s\n",
- f->name(), f->comment(), Type2String(f->type()), value.get());
+ os << " --" << f->name() << " (" << f->comment() << ")\n"
+ << " type: " << Type2String(f->type()) << " default: " << *f
+ << "\n";
}
}
// Print details about the function.
if (FLAG_max_stack_trace_source_length != 0 && code != NULL) {
+ OStringStream os;
SharedFunctionInfo* shared = function->shared();
- accumulator->Add("--------- s o u r c e c o d e ---------\n");
- shared->SourceCodePrint(accumulator, FLAG_max_stack_trace_source_length);
- accumulator->Add("\n-----------------------------------------\n");
+ 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("}\n\n");
#ifdef OBJECT_PRINT
void __gdb_print_v8_object(Object* object) {
- object->Print();
- PrintF(stdout, "\n");
+ OFStream os(stdout);
+ object->Print(os);
+ os << flush;
}
#endif
}
void PathTracer::ProcessResults() {
if (found_target_) {
- PrintF("=====================================\n");
- PrintF("==== Path to object ====\n");
- PrintF("=====================================\n\n");
+ OFStream os(stdout);
+ os << "=====================================\n"
+ << "==== Path to object ====\n"
+ << "=====================================\n\n";
ASSERT(!object_stack_.is_empty());
for (int i = 0; i < object_stack_.length(); i++) {
- if (i > 0) PrintF("\n |\n |\n V\n\n");
- Object* obj = object_stack_[i];
- obj->Print();
+ if (i > 0) os << "\n |\n |\n V\n\n";
+ object_stack_[i]->Print(os);
}
- PrintF("=====================================\n");
+ os << "=====================================\n";
}
}
}
-void SideEffectsTracker::PrintSideEffectsTo(StringStream* stream,
- SideEffects side_effects) const {
+OStream& operator<<(OStream& os, const TrackedEffects& te) {
+ SideEffectsTracker* t = te.tracker;
const char* separator = "";
- stream->Add("[");
+ os << "[";
for (int bit = 0; bit < kNumberOfFlags; ++bit) {
GVNFlag flag = GVNFlagFromInt(bit);
- if (side_effects.ContainsFlag(flag)) {
- stream->Add(separator);
+ if (te.effects.ContainsFlag(flag)) {
+ os << separator;
separator = ", ";
switch (flag) {
-#define DECLARE_FLAG(Type) \
- case k##Type: \
- stream->Add(#Type); \
- break;
+#define DECLARE_FLAG(Type) \
+ case k##Type: \
+ os << #Type; \
+ break;
GVN_TRACKED_FLAG_LIST(DECLARE_FLAG)
GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG)
#undef DECLARE_FLAG
}
}
}
- for (int index = 0; index < num_global_vars_; ++index) {
- if (side_effects.ContainsSpecial(GlobalVar(index))) {
- stream->Add(separator);
+ for (int index = 0; index < t->num_global_vars_; ++index) {
+ if (te.effects.ContainsSpecial(t->GlobalVar(index))) {
+ os << separator << "[" << *t->global_vars_[index].handle() << "]";
separator = ", ";
- stream->Add("[%p]", *global_vars_[index].handle());
}
}
- for (int index = 0; index < num_inobject_fields_; ++index) {
- if (side_effects.ContainsSpecial(InobjectField(index))) {
- stream->Add(separator);
+ for (int index = 0; index < t->num_inobject_fields_; ++index) {
+ if (te.effects.ContainsSpecial(t->InobjectField(index))) {
+ os << separator << t->inobject_fields_[index];
separator = ", ";
- inobject_fields_[index].PrintTo(stream);
}
}
- stream->Add("]");
+ os << "]";
+ return os;
}
}
if (num_inobject_fields_ < kNumberOfInobjectFields) {
if (FLAG_trace_gvn) {
- HeapStringAllocator allocator;
- StringStream stream(&allocator);
- stream.Add("Tracking inobject field access ");
- access.PrintTo(&stream);
- stream.Add(" (mapped to index %d)\n", num_inobject_fields_);
- stream.OutputToStdOut();
+ OFStream os(stdout);
+ os << "Tracking inobject field access " << access << " (mapped to index "
+ << num_inobject_fields_ << ")" << endl;
}
*index = num_inobject_fields_;
inobject_fields_[num_inobject_fields_++] = access;
if (block->IsLoopHeader()) {
SideEffects side_effects = loop_side_effects_[block->block_id()];
if (FLAG_trace_gvn) {
- HeapStringAllocator allocator;
- StringStream stream(&allocator);
- stream.Add("Try loop invariant motion for block B%d changes ",
- block->block_id());
- side_effects_tracker_.PrintSideEffectsTo(&stream, side_effects);
- stream.Add("\n");
- stream.OutputToStdOut();
+ OFStream os(stdout);
+ os << "Try loop invariant motion for " << *block << " changes "
+ << Print(side_effects) << endl;
}
HBasicBlock* last = block->loop_information()->GetLastBackEdge();
for (int j = block->block_id(); j <= last->block_id(); ++j) {
SideEffects loop_kills) {
HBasicBlock* pre_header = loop_header->predecessors()->at(0);
if (FLAG_trace_gvn) {
- HeapStringAllocator allocator;
- StringStream stream(&allocator);
- stream.Add("Loop invariant code motion for B%d depends on ",
- block->block_id());
- side_effects_tracker_.PrintSideEffectsTo(&stream, loop_kills);
- stream.Add("\n");
- stream.OutputToStdOut();
+ OFStream os(stdout);
+ os << "Loop invariant code motion for " << *block << " depends on "
+ << Print(loop_kills) << endl;
}
HInstruction* instr = block->first();
while (instr != NULL) {
SideEffects changes = side_effects_tracker_.ComputeChanges(instr);
SideEffects depends_on = side_effects_tracker_.ComputeDependsOn(instr);
if (FLAG_trace_gvn) {
- HeapStringAllocator allocator;
- StringStream stream(&allocator);
- stream.Add("Checking instruction i%d (%s) changes ",
- instr->id(), instr->Mnemonic());
- side_effects_tracker_.PrintSideEffectsTo(&stream, changes);
- stream.Add(", depends on ");
- side_effects_tracker_.PrintSideEffectsTo(&stream, depends_on);
- stream.Add(". Loop changes ");
- side_effects_tracker_.PrintSideEffectsTo(&stream, loop_kills);
- stream.Add("\n");
- stream.OutputToStdOut();
+ OFStream os(stdout);
+ os << "Checking instruction i" << instr->id() << " ("
+ << instr->Mnemonic() << ") changes " << Print(changes)
+ << ", depends on " << Print(depends_on) << ". Loop changes "
+ << Print(loop_kills) << endl;
}
bool can_hoist = !depends_on.ContainsAnyOf(loop_kills);
if (can_hoist && !graph()->use_optimistic_licm()) {
map->Kill(changes);
dominators->Store(changes, instr);
if (FLAG_trace_gvn) {
- HeapStringAllocator allocator;
- StringStream stream(&allocator);
- stream.Add("Instruction i%d changes ", instr->id());
- side_effects_tracker_.PrintSideEffectsTo(&stream, changes);
- stream.Add("\n");
- stream.OutputToStdOut();
+ OFStream os(stdout);
+ os << "Instruction i" << instr->id() << " changes " << Print(changes)
+ << endl;
}
}
if (instr->CheckFlag(HValue::kUseGVN) &&
#ifndef V8_HYDROGEN_GVN_H_
#define V8_HYDROGEN_GVN_H_
+#include "src/compiler.h"
#include "src/hydrogen.h"
#include "src/hydrogen-instructions.h"
-#include "src/compiler.h"
+#include "src/ostreams.h"
#include "src/zone.h"
namespace v8 {
void RemoveFlag(GVNFlag flag) { bits_ &= ~MaskFlag(flag); }
void RemoveAll() { bits_ = 0; }
uint64_t ToIntegral() const { return bits_; }
- void PrintTo(StringStream* stream) const;
private:
uint64_t MaskFlag(GVNFlag flag) const {
};
+class TrackedEffects;
+
// Tracks global variable and inobject field loads/stores in a fine grained
// fashion, and represents them using the "special" dynamic side effects of the
// SideEffects class (see above). This way unrelated global variable/inobject
SideEffectsTracker() : num_global_vars_(0), num_inobject_fields_(0) {}
SideEffects ComputeChanges(HInstruction* instr);
SideEffects ComputeDependsOn(HInstruction* instr);
- void PrintSideEffectsTo(StringStream* stream, SideEffects side_effects) const;
private:
+ friend OStream& operator<<(OStream& os, const TrackedEffects& f);
bool ComputeGlobalVar(Unique<Cell> cell, int* index);
bool ComputeInobjectField(HObjectAccess access, int* index);
};
+// Helper class for printing, because the effects don't know their tracker.
+struct TrackedEffects {
+ TrackedEffects(SideEffectsTracker* t, SideEffects e)
+ : tracker(t), effects(e) {}
+ SideEffectsTracker* tracker;
+ SideEffects effects;
+};
+
+
+OStream& operator<<(OStream& os, const TrackedEffects& f);
+
+
// Perform common subexpression elimination and loop-invariant code motion.
class HGlobalValueNumberingPhase V8_FINAL : public HPhase {
public:
SideEffects loop_kills);
bool AllowCodeMotion();
bool ShouldMove(HInstruction* instr, HBasicBlock* loop_header);
+ TrackedEffects Print(SideEffects side_effects) {
+ return TrackedEffects(&side_effects_tracker_, side_effects);
+ }
SideEffectsTracker side_effects_tracker_;
bool removed_side_effects_;
}
-OStream& operator<<(OStream& os, const HValue& v) {
- // TODO(svenpanne) Temporary impedance matching, to be removed later.
- HeapStringAllocator allocator;
- StringStream stream(&allocator);
- const_cast<HValue*>(&v)->PrintTo(&stream);
- return os << stream.ToCString().get();
-}
+OStream& operator<<(OStream& os, const HValue& v) { return v.PrintTo(os); }
-void HValue::PrintTypeTo(StringStream* stream) {
- if (!representation().IsTagged() || type().Equals(HType::Tagged())) return;
- stream->Add(" type:%s", type().ToString());
+OStream& operator<<(OStream& os, const TypeOf& t) {
+ if (t.value->representation().IsTagged() &&
+ !t.value->type().Equals(HType::Tagged()))
+ return os;
+ return os << " type:" << t.value->type();
}
-void HValue::PrintChangesTo(StringStream* stream) {
- GVNFlagSet changes_flags = ChangesFlags();
- if (changes_flags.IsEmpty()) return;
- stream->Add(" changes[");
- if (changes_flags == AllSideEffectsFlagSet()) {
- stream->Add("*");
+OStream& operator<<(OStream& os, const ChangesOf& c) {
+ GVNFlagSet changes_flags = c.value->ChangesFlags();
+ if (changes_flags.IsEmpty()) return os;
+ os << " changes[";
+ if (changes_flags == c.value->AllSideEffectsFlagSet()) {
+ os << "*";
} else {
bool add_comma = false;
-#define PRINT_DO(Type) \
- if (changes_flags.Contains(k##Type)) { \
- if (add_comma) stream->Add(","); \
- add_comma = true; \
- stream->Add(#Type); \
- }
+#define PRINT_DO(Type) \
+ if (changes_flags.Contains(k##Type)) { \
+ if (add_comma) os << ","; \
+ add_comma = true; \
+ os << #Type; \
+ }
GVN_TRACKED_FLAG_LIST(PRINT_DO);
GVN_UNTRACKED_FLAG_LIST(PRINT_DO);
#undef PRINT_DO
}
- stream->Add("]");
-}
-
-
-void HValue::PrintNameTo(StringStream* stream) {
- stream->Add("%s%d", representation_.Mnemonic(), id());
+ return os << "]";
}
}
-void HSourcePosition::PrintTo(FILE* out) {
- if (IsUnknown()) {
- PrintF(out, "<?>");
+OStream& operator<<(OStream& os, const HSourcePosition& p) {
+ if (p.IsUnknown()) {
+ return os << "<?>";
+ } else if (FLAG_hydrogen_track_positions) {
+ return os << "<" << p.inlining_id() << ":" << p.position() << ">";
} else {
- if (FLAG_hydrogen_track_positions) {
- PrintF(out, "<%d:%d>", inlining_id(), position());
- } else {
- PrintF(out, "<0:%d>", raw());
- }
+ return os << "<0:" << p.raw() << ">";
}
}
-void HInstruction::PrintTo(StringStream* stream) {
- PrintMnemonicTo(stream);
- PrintDataTo(stream);
- PrintChangesTo(stream);
- PrintTypeTo(stream);
- if (CheckFlag(HValue::kHasNoObservableSideEffects)) {
- stream->Add(" [noOSE]");
- }
- if (CheckFlag(HValue::kIsDead)) {
- stream->Add(" [dead]");
- }
+OStream& HInstruction::PrintTo(OStream& os) const { // NOLINT
+ os << Mnemonic() << " ";
+ PrintDataTo(os) << ChangesOf(this) << TypeOf(this);
+ if (CheckFlag(HValue::kHasNoObservableSideEffects)) os << " [noOSE]";
+ if (CheckFlag(HValue::kIsDead)) os << " [dead]";
+ return os;
}
-void HInstruction::PrintDataTo(StringStream *stream) {
+OStream& HInstruction::PrintDataTo(OStream& os) const { // NOLINT
for (int i = 0; i < OperandCount(); ++i) {
- if (i > 0) stream->Add(" ");
- OperandAt(i)->PrintNameTo(stream);
+ if (i > 0) os << " ";
+ os << NameOf(OperandAt(i));
}
-}
-
-
-void HInstruction::PrintMnemonicTo(StringStream* stream) {
- stream->Add("%s ", Mnemonic());
+ return os;
}
}
-void HDummyUse::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
+OStream& operator<<(OStream& os, const NameOf& v) {
+ return os << v.value->representation().Mnemonic() << v.value->id();
+}
+
+OStream& HDummyUse::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(value());
}
-void HEnvironmentMarker::PrintDataTo(StringStream* stream) {
- stream->Add("%s var[%d]", kind() == BIND ? "bind" : "lookup", index());
+OStream& HEnvironmentMarker::PrintDataTo(OStream& os) const { // NOLINT
+ return os << (kind() == BIND ? "bind" : "lookup") << " var[" << index()
+ << "]";
}
-void HUnaryCall::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
- stream->Add(" ");
- stream->Add("#%d", argument_count());
+OStream& HUnaryCall::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(value()) << " #" << argument_count();
}
-void HCallJSFunction::PrintDataTo(StringStream* stream) {
- function()->PrintNameTo(stream);
- stream->Add(" ");
- stream->Add("#%d", argument_count());
+OStream& HCallJSFunction::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(function()) << " #" << argument_count();
}
}
-
-
-void HBinaryCall::PrintDataTo(StringStream* stream) {
- first()->PrintNameTo(stream);
- stream->Add(" ");
- second()->PrintNameTo(stream);
- stream->Add(" ");
- stream->Add("#%d", argument_count());
+OStream& HBinaryCall::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(first()) << " " << NameOf(second()) << " #"
+ << argument_count();
}
}
-void HBoundsCheck::PrintDataTo(StringStream* stream) {
- index()->PrintNameTo(stream);
- stream->Add(" ");
- length()->PrintNameTo(stream);
+OStream& HBoundsCheck::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(index()) << " " << NameOf(length());
if (base() != NULL && (offset() != 0 || scale() != 0)) {
- stream->Add(" base: ((");
+ os << " base: ((";
if (base() != index()) {
- index()->PrintNameTo(stream);
+ os << NameOf(index());
} else {
- stream->Add("index");
+ os << "index";
}
- stream->Add(" + %d) >> %d)", offset(), scale());
- }
- if (skip_check()) {
- stream->Add(" [DISABLED]");
+ os << " + " << offset() << ") >> " << scale() << ")";
}
+ if (skip_check()) os << " [DISABLED]";
+ return os;
}
}
-void HBoundsCheckBaseIndexInformation::PrintDataTo(StringStream* stream) {
- stream->Add("base: ");
- base_index()->PrintNameTo(stream);
- stream->Add(", check: ");
- base_index()->PrintNameTo(stream);
+OStream& HBoundsCheckBaseIndexInformation::PrintDataTo(
+ OStream& os) const { // NOLINT
+ // TODO(svenpanne) This 2nd base_index() looks wrong...
+ return os << "base: " << NameOf(base_index())
+ << ", check: " << NameOf(base_index());
}
-void HCallWithDescriptor::PrintDataTo(StringStream* stream) {
+OStream& HCallWithDescriptor::PrintDataTo(OStream& os) const { // NOLINT
for (int i = 0; i < OperandCount(); i++) {
- OperandAt(i)->PrintNameTo(stream);
- stream->Add(" ");
+ os << NameOf(OperandAt(i)) << " ";
}
- stream->Add("#%d", argument_count());
+ return os << "#" << argument_count();
}
-void HCallNewArray::PrintDataTo(StringStream* stream) {
- stream->Add(ElementsKindToString(elements_kind()));
- stream->Add(" ");
- HBinaryCall::PrintDataTo(stream);
+OStream& HCallNewArray::PrintDataTo(OStream& os) const { // NOLINT
+ os << ElementsKindToString(elements_kind()) << " ";
+ return HBinaryCall::PrintDataTo(os);
}
-void HCallRuntime::PrintDataTo(StringStream* stream) {
- stream->Add("%o ", *name());
- if (save_doubles() == kSaveFPRegs) {
- stream->Add("[save doubles] ");
- }
- stream->Add("#%d", argument_count());
+OStream& HCallRuntime::PrintDataTo(OStream& os) const { // NOLINT
+ os << name()->ToCString().get() << " ";
+ if (save_doubles() == kSaveFPRegs) os << "[save doubles] ";
+ return os << "#" << argument_count();
}
-void HClassOfTestAndBranch::PrintDataTo(StringStream* stream) {
- stream->Add("class_of_test(");
- value()->PrintNameTo(stream);
- stream->Add(", \"%o\")", *class_name());
+OStream& HClassOfTestAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+ return os << "class_of_test(" << NameOf(value()) << ", \""
+ << class_name()->ToCString().get() << "\")";
}
-void HWrapReceiver::PrintDataTo(StringStream* stream) {
- receiver()->PrintNameTo(stream);
- stream->Add(" ");
- function()->PrintNameTo(stream);
+OStream& HWrapReceiver::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(receiver()) << " " << NameOf(function());
}
-void HAccessArgumentsAt::PrintDataTo(StringStream* stream) {
- arguments()->PrintNameTo(stream);
- stream->Add("[");
- index()->PrintNameTo(stream);
- stream->Add("], length ");
- length()->PrintNameTo(stream);
+OStream& HAccessArgumentsAt::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(arguments()) << "[" << NameOf(index()) << "], length "
+ << NameOf(length());
}
-void HAllocateBlockContext::PrintDataTo(StringStream* stream) {
- context()->PrintNameTo(stream);
- stream->Add(" ");
- function()->PrintNameTo(stream);
+OStream& HAllocateBlockContext::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(context()) << " " << NameOf(function());
}
-void HControlInstruction::PrintDataTo(StringStream* stream) {
- stream->Add(" goto (");
+OStream& HControlInstruction::PrintDataTo(OStream& os) const { // NOLINT
+ os << " goto (";
bool first_block = true;
for (HSuccessorIterator it(this); !it.Done(); it.Advance()) {
- stream->Add(first_block ? "B%d" : ", B%d", it.Current()->block_id());
+ if (!first_block) os << ", ";
+ os << *it.Current();
first_block = false;
}
- stream->Add(")");
+ return os << ")";
}
-void HUnaryControlInstruction::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
- HControlInstruction::PrintDataTo(stream);
+OStream& HUnaryControlInstruction::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(value());
+ return HControlInstruction::PrintDataTo(os);
}
-void HReturn::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
- stream->Add(" (pop ");
- parameter_count()->PrintNameTo(stream);
- stream->Add(" values)");
+OStream& HReturn::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(value()) << " (pop " << NameOf(parameter_count())
+ << " values)";
}
}
-void HBranch::PrintDataTo(StringStream* stream) {
- HUnaryControlInstruction::PrintDataTo(stream);
- OStringStream os;
- os << " " << expected_input_types();
- stream->Add(os.c_str());
+OStream& HBranch::PrintDataTo(OStream& os) const { // NOLINT
+ return HUnaryControlInstruction::PrintDataTo(os) << " "
+ << expected_input_types();
}
-void HCompareMap::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
- stream->Add(" (%p)", *map().handle());
- HControlInstruction::PrintDataTo(stream);
+OStream& HCompareMap::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(value()) << " (" << *map().handle() << ")";
+ HControlInstruction::PrintDataTo(os);
if (known_successor_index() == 0) {
- stream->Add(" [true]");
+ os << " [true]";
} else if (known_successor_index() == 1) {
- stream->Add(" [false]");
+ os << " [false]";
}
+ return os;
}
}
-void HUnaryMathOperation::PrintDataTo(StringStream* stream) {
- const char* name = OpName();
- stream->Add("%s ", name);
- value()->PrintNameTo(stream);
+OStream& HUnaryMathOperation::PrintDataTo(OStream& os) const { // NOLINT
+ return os << OpName() << " " << NameOf(value());
}
-void HUnaryOperation::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
+OStream& HUnaryOperation::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(value());
}
-void HHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
+OStream& HHasInstanceTypeAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(value());
switch (from_) {
case FIRST_JS_RECEIVER_TYPE:
- if (to_ == LAST_TYPE) stream->Add(" spec_object");
+ if (to_ == LAST_TYPE) os << " spec_object";
break;
case JS_REGEXP_TYPE:
- if (to_ == JS_REGEXP_TYPE) stream->Add(" reg_exp");
+ if (to_ == JS_REGEXP_TYPE) os << " reg_exp";
break;
case JS_ARRAY_TYPE:
- if (to_ == JS_ARRAY_TYPE) stream->Add(" array");
+ if (to_ == JS_ARRAY_TYPE) os << " array";
break;
case JS_FUNCTION_TYPE:
- if (to_ == JS_FUNCTION_TYPE) stream->Add(" function");
+ if (to_ == JS_FUNCTION_TYPE) os << " function";
break;
default:
break;
}
+ return os;
}
-void HTypeofIsAndBranch::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
- stream->Add(" == %o", *type_literal_.handle());
- HControlInstruction::PrintDataTo(stream);
+OStream& HTypeofIsAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(value()) << " == " << type_literal()->ToCString().get();
+ return HControlInstruction::PrintDataTo(os);
}
}
-void HCheckMapValue::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
- stream->Add(" ");
- map()->PrintNameTo(stream);
+OStream& HCheckMapValue::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(value()) << " " << NameOf(map());
}
}
-void HForInPrepareMap::PrintDataTo(StringStream* stream) {
- enumerable()->PrintNameTo(stream);
+OStream& HForInPrepareMap::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(enumerable());
}
-void HForInCacheArray::PrintDataTo(StringStream* stream) {
- enumerable()->PrintNameTo(stream);
- stream->Add(" ");
- map()->PrintNameTo(stream);
- stream->Add("[%d]", idx_);
+OStream& HForInCacheArray::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(enumerable()) << " " << NameOf(map()) << "[" << idx_
+ << "]";
}
-void HLoadFieldByIndex::PrintDataTo(StringStream* stream) {
- object()->PrintNameTo(stream);
- stream->Add(" ");
- index()->PrintNameTo(stream);
+OStream& HLoadFieldByIndex::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(object()) << " " << NameOf(index());
}
}
-void HTypeof::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
+OStream& HTypeof::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(value());
}
}
-void HForceRepresentation::PrintDataTo(StringStream* stream) {
- stream->Add("%s ", representation().Mnemonic());
- value()->PrintNameTo(stream);
+OStream& HForceRepresentation::PrintDataTo(OStream& os) const { // NOLINT
+ return os << representation().Mnemonic() << " " << NameOf(value());
}
-void HChange::PrintDataTo(StringStream* stream) {
- HUnaryOperation::PrintDataTo(stream);
- stream->Add(" %s to %s", from().Mnemonic(), to().Mnemonic());
+OStream& HChange::PrintDataTo(OStream& os) const { // NOLINT
+ HUnaryOperation::PrintDataTo(os);
+ os << " " << from().Mnemonic() << " to " << to().Mnemonic();
- if (CanTruncateToSmi()) stream->Add(" truncating-smi");
- if (CanTruncateToInt32()) stream->Add(" truncating-int32");
- if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?");
- if (CheckFlag(kAllowUndefinedAsNaN)) stream->Add(" allow-undefined-as-nan");
+ if (CanTruncateToSmi()) os << " truncating-smi";
+ if (CanTruncateToInt32()) os << " truncating-int32";
+ if (CheckFlag(kBailoutOnMinusZero)) os << " -0?";
+ if (CheckFlag(kAllowUndefinedAsNaN)) os << " allow-undefined-as-nan";
+ return os;
}
}
-void HCheckMaps::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
- stream->Add(" [%p", *maps()->at(0).handle());
+OStream& HCheckMaps::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(value()) << " [" << *maps()->at(0).handle();
for (int i = 1; i < maps()->size(); ++i) {
- stream->Add(",%p", *maps()->at(i).handle());
+ os << "," << *maps()->at(i).handle();
}
- stream->Add("]%s", IsStabilityCheck() ? "(stability-check)" : "");
+ os << "]";
+ if (IsStabilityCheck()) os << "(stability-check)";
+ return os;
}
}
-void HCheckValue::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
- stream->Add(" ");
- object().handle()->ShortPrint(stream);
+OStream& HCheckValue::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(value()) << " " << Brief(*object().handle());
}
}
-const char* HCheckInstanceType::GetCheckName() {
+const char* HCheckInstanceType::GetCheckName() const {
switch (check_) {
case IS_SPEC_OBJECT: return "object";
case IS_JS_ARRAY: return "array";
}
-void HCheckInstanceType::PrintDataTo(StringStream* stream) {
- stream->Add("%s ", GetCheckName());
- HUnaryOperation::PrintDataTo(stream);
+OStream& HCheckInstanceType::PrintDataTo(OStream& os) const { // NOLINT
+ os << GetCheckName() << " ";
+ return HUnaryOperation::PrintDataTo(os);
}
-void HCallStub::PrintDataTo(StringStream* stream) {
- stream->Add("%s ",
- CodeStub::MajorName(major_key_, false));
- HUnaryCall::PrintDataTo(stream);
+OStream& HCallStub::PrintDataTo(OStream& os) const { // NOLINT
+ os << CodeStub::MajorName(major_key_, false) << " ";
+ return HUnaryCall::PrintDataTo(os);
}
-void HUnknownOSRValue::PrintDataTo(StringStream *stream) {
+OStream& HUnknownOSRValue::PrintDataTo(OStream& os) const { // NOLINT
const char* type = "expression";
if (environment_->is_local_index(index_)) type = "local";
if (environment_->is_special_index(index_)) type = "special";
if (environment_->is_parameter_index(index_)) type = "parameter";
- stream->Add("%s @ %d", type, index_);
+ return os << type << " @ " << index_;
}
-void HInstanceOf::PrintDataTo(StringStream* stream) {
- left()->PrintNameTo(stream);
- stream->Add(" ");
- right()->PrintNameTo(stream);
- stream->Add(" ");
- context()->PrintNameTo(stream);
+OStream& HInstanceOf::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(left()) << " " << NameOf(right()) << " "
+ << NameOf(context());
}
}
-void HPhi::PrintTo(StringStream* stream) {
- stream->Add("[");
+OStream& HPhi::PrintTo(OStream& os) const { // NOLINT
+ os << "[";
for (int i = 0; i < OperandCount(); ++i) {
- HValue* value = OperandAt(i);
- stream->Add(" ");
- value->PrintNameTo(stream);
- stream->Add(" ");
+ os << " " << NameOf(OperandAt(i)) << " ";
}
- stream->Add(" uses:%d_%ds_%di_%dd_%dt",
- UseCount(),
- smi_non_phi_uses() + smi_indirect_uses(),
- int32_non_phi_uses() + int32_indirect_uses(),
- double_non_phi_uses() + double_indirect_uses(),
- tagged_non_phi_uses() + tagged_indirect_uses());
- PrintTypeTo(stream);
- stream->Add("]");
+ return os << " uses:" << UseCount() << "_"
+ << smi_non_phi_uses() + smi_indirect_uses() << "s_"
+ << int32_non_phi_uses() + int32_indirect_uses() << "i_"
+ << double_non_phi_uses() + double_indirect_uses() << "d_"
+ << tagged_non_phi_uses() + tagged_indirect_uses() << "t"
+ << TypeOf(this) << "]";
}
}
-void HSimulate::PrintDataTo(StringStream* stream) {
- stream->Add("id=%d", ast_id().ToInt());
- if (pop_count_ > 0) stream->Add(" pop %d", pop_count_);
+OStream& HSimulate::PrintDataTo(OStream& os) const { // NOLINT
+ os << "id=" << ast_id().ToInt();
+ if (pop_count_ > 0) os << " pop " << pop_count_;
if (values_.length() > 0) {
- if (pop_count_ > 0) stream->Add(" /");
+ if (pop_count_ > 0) os << " /";
for (int i = values_.length() - 1; i >= 0; --i) {
if (HasAssignedIndexAt(i)) {
- stream->Add(" var[%d] = ", GetAssignedIndexAt(i));
+ os << " var[" << GetAssignedIndexAt(i) << "] = ";
} else {
- stream->Add(" push ");
+ os << " push ";
}
- values_[i]->PrintNameTo(stream);
- if (i > 0) stream->Add(",");
+ os << NameOf(values_[i]);
+ if (i > 0) os << ",";
}
}
+ return os;
}
}
-void HCapturedObject::PrintDataTo(StringStream* stream) {
- stream->Add("#%d ", capture_id());
- HDematerializedObject::PrintDataTo(stream);
+OStream& HCapturedObject::PrintDataTo(OStream& os) const { // NOLINT
+ os << "#" << capture_id() << " ";
+ return HDematerializedObject::PrintDataTo(os);
}
}
-void HEnterInlined::PrintDataTo(StringStream* stream) {
- SmartArrayPointer<char> name = function()->debug_name()->ToCString();
- stream->Add("%s, id=%d", name.get(), function()->id().ToInt());
+OStream& HEnterInlined::PrintDataTo(OStream& os) const { // NOLINT
+ return os << function()->debug_name()->ToCString().get()
+ << ", id=" << function()->id().ToInt();
}
}
-void HConstant::PrintDataTo(StringStream* stream) {
+OStream& HConstant::PrintDataTo(OStream& os) const { // NOLINT
if (has_int32_value_) {
- stream->Add("%d ", int32_value_);
+ os << int32_value_ << " ";
} else if (has_double_value_) {
- stream->Add("%f ", FmtElm(double_value_));
+ os << double_value_ << " ";
} else if (has_external_reference_value_) {
- stream->Add("%p ", reinterpret_cast<void*>(
- external_reference_value_.address()));
+ os << reinterpret_cast<void*>(external_reference_value_.address()) << " ";
} else {
- handle(Isolate::Current())->ShortPrint(stream);
- stream->Add(" ");
- if (HasStableMapValue()) {
- stream->Add("[stable-map] ");
- }
- if (HasObjectMap()) {
- stream->Add("[map %p] ", *ObjectMap().handle());
- }
- }
- if (!is_not_in_new_space_) {
- stream->Add("[new space] ");
+ // The handle() method is silently and lazily mutating the object.
+ Handle<Object> h = const_cast<HConstant*>(this)->handle(Isolate::Current());
+ os << Brief(*h) << " ";
+ if (HasStableMapValue()) os << "[stable-map] ";
+ if (HasObjectMap()) os << "[map " << *ObjectMap().handle() << "] ";
}
+ if (!is_not_in_new_space_) os << "[new space] ";
+ return os;
}
-void HBinaryOperation::PrintDataTo(StringStream* stream) {
- left()->PrintNameTo(stream);
- stream->Add(" ");
- right()->PrintNameTo(stream);
- if (CheckFlag(kCanOverflow)) stream->Add(" !");
- if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?");
+OStream& HBinaryOperation::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(left()) << " " << NameOf(right());
+ if (CheckFlag(kCanOverflow)) os << " !";
+ if (CheckFlag(kBailoutOnMinusZero)) os << " -0?";
+ return os;
}
}
-void HCompareGeneric::PrintDataTo(StringStream* stream) {
- stream->Add(Token::Name(token()));
- stream->Add(" ");
- HBinaryOperation::PrintDataTo(stream);
+OStream& HCompareGeneric::PrintDataTo(OStream& os) const { // NOLINT
+ os << Token::Name(token()) << " ";
+ return HBinaryOperation::PrintDataTo(os);
}
-void HStringCompareAndBranch::PrintDataTo(StringStream* stream) {
- stream->Add(Token::Name(token()));
- stream->Add(" ");
- HControlInstruction::PrintDataTo(stream);
+OStream& HStringCompareAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+ os << Token::Name(token()) << " ";
+ return HControlInstruction::PrintDataTo(os);
}
-void HCompareNumericAndBranch::PrintDataTo(StringStream* stream) {
- stream->Add(Token::Name(token()));
- stream->Add(" ");
- left()->PrintNameTo(stream);
- stream->Add(" ");
- right()->PrintNameTo(stream);
- HControlInstruction::PrintDataTo(stream);
+OStream& HCompareNumericAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+ os << Token::Name(token()) << " " << NameOf(left()) << " " << NameOf(right());
+ return HControlInstruction::PrintDataTo(os);
}
-void HCompareObjectEqAndBranch::PrintDataTo(StringStream* stream) {
- left()->PrintNameTo(stream);
- stream->Add(" ");
- right()->PrintNameTo(stream);
- HControlInstruction::PrintDataTo(stream);
+OStream& HCompareObjectEqAndBranch::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(left()) << " " << NameOf(right());
+ return HControlInstruction::PrintDataTo(os);
}
}
-
-void HGoto::PrintDataTo(StringStream* stream) {
- stream->Add("B%d", SuccessorAt(0)->block_id());
+OStream& HGoto::PrintDataTo(OStream& os) const { // NOLINT
+ return os << *SuccessorAt(0);
}
}
-void HParameter::PrintDataTo(StringStream* stream) {
- stream->Add("%u", index());
+OStream& HParameter::PrintDataTo(OStream& os) const { // NOLINT
+ return os << index();
}
-void HLoadNamedField::PrintDataTo(StringStream* stream) {
- object()->PrintNameTo(stream);
- access_.PrintTo(stream);
+OStream& HLoadNamedField::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(object()) << access_;
if (maps() != NULL) {
- stream->Add(" [%p", *maps()->at(0).handle());
+ os << " [" << *maps()->at(0).handle();
for (int i = 1; i < maps()->size(); ++i) {
- stream->Add(",%p", *maps()->at(i).handle());
+ os << "," << *maps()->at(i).handle();
}
- stream->Add("]");
+ os << "]";
}
- if (HasDependency()) {
- stream->Add(" ");
- dependency()->PrintNameTo(stream);
- }
+ if (HasDependency()) os << " " << NameOf(dependency());
+ return os;
}
-void HLoadNamedGeneric::PrintDataTo(StringStream* stream) {
- object()->PrintNameTo(stream);
- stream->Add(".");
- stream->Add(String::cast(*name())->ToCString().get());
+OStream& HLoadNamedGeneric::PrintDataTo(OStream& os) const { // NOLINT
+ Handle<String> n = Handle<String>::cast(name());
+ return os << NameOf(object()) << "." << n->ToCString().get();
}
-void HLoadKeyed::PrintDataTo(StringStream* stream) {
+OStream& HLoadKeyed::PrintDataTo(OStream& os) const { // NOLINT
if (!is_external()) {
- elements()->PrintNameTo(stream);
+ os << NameOf(elements());
} else {
ASSERT(elements_kind() >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND &&
elements_kind() <= LAST_EXTERNAL_ARRAY_ELEMENTS_KIND);
- elements()->PrintNameTo(stream);
- stream->Add(".");
- stream->Add(ElementsKindToString(elements_kind()));
+ os << NameOf(elements()) << "." << ElementsKindToString(elements_kind());
}
- stream->Add("[");
- key()->PrintNameTo(stream);
- if (IsDehoisted()) {
- stream->Add(" + %d]", base_offset());
- } else {
- stream->Add("]");
- }
+ os << "[" << NameOf(key());
+ if (IsDehoisted()) os << " + " << base_offset();
+ os << "]";
- if (HasDependency()) {
- stream->Add(" ");
- dependency()->PrintNameTo(stream);
- }
-
- if (RequiresHoleCheck()) {
- stream->Add(" check_hole");
- }
+ if (HasDependency()) os << " " << NameOf(dependency());
+ if (RequiresHoleCheck()) os << " check_hole";
+ return os;
}
}
-void HLoadKeyedGeneric::PrintDataTo(StringStream* stream) {
- object()->PrintNameTo(stream);
- stream->Add("[");
- key()->PrintNameTo(stream);
- stream->Add("]");
+OStream& HLoadKeyedGeneric::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(object()) << "[" << NameOf(key()) << "]";
}
}
-void HStoreNamedGeneric::PrintDataTo(StringStream* stream) {
- object()->PrintNameTo(stream);
- stream->Add(".");
- ASSERT(name()->IsString());
- stream->Add(String::cast(*name())->ToCString().get());
- stream->Add(" = ");
- value()->PrintNameTo(stream);
+OStream& HStoreNamedGeneric::PrintDataTo(OStream& os) const { // NOLINT
+ Handle<String> n = Handle<String>::cast(name());
+ return os << NameOf(object()) << "." << n->ToCString().get() << " = "
+ << NameOf(value());
}
-void HStoreNamedField::PrintDataTo(StringStream* stream) {
- object()->PrintNameTo(stream);
- access_.PrintTo(stream);
- stream->Add(" = ");
- value()->PrintNameTo(stream);
- if (NeedsWriteBarrier()) {
- stream->Add(" (write-barrier)");
- }
- if (has_transition()) {
- stream->Add(" (transition map %p)", *transition_map());
- }
+OStream& HStoreNamedField::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(object()) << access_ << " = " << NameOf(value());
+ if (NeedsWriteBarrier()) os << " (write-barrier)";
+ if (has_transition()) os << " (transition map " << *transition_map() << ")";
+ return os;
}
-void HStoreKeyed::PrintDataTo(StringStream* stream) {
+OStream& HStoreKeyed::PrintDataTo(OStream& os) const { // NOLINT
if (!is_external()) {
- elements()->PrintNameTo(stream);
+ os << NameOf(elements());
} else {
- elements()->PrintNameTo(stream);
- stream->Add(".");
- stream->Add(ElementsKindToString(elements_kind()));
ASSERT(elements_kind() >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND &&
elements_kind() <= LAST_EXTERNAL_ARRAY_ELEMENTS_KIND);
+ os << NameOf(elements()) << "." << ElementsKindToString(elements_kind());
}
- stream->Add("[");
- key()->PrintNameTo(stream);
- if (IsDehoisted()) {
- stream->Add(" + %d] = ", base_offset());
- } else {
- stream->Add("] = ");
- }
-
- value()->PrintNameTo(stream);
+ os << "[" << NameOf(key());
+ if (IsDehoisted()) os << " + " << base_offset();
+ return os << "] = " << NameOf(value());
}
-void HStoreKeyedGeneric::PrintDataTo(StringStream* stream) {
- object()->PrintNameTo(stream);
- stream->Add("[");
- key()->PrintNameTo(stream);
- stream->Add("] = ");
- value()->PrintNameTo(stream);
+OStream& HStoreKeyedGeneric::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(object()) << "[" << NameOf(key())
+ << "] = " << NameOf(value());
}
-void HTransitionElementsKind::PrintDataTo(StringStream* stream) {
- object()->PrintNameTo(stream);
+OStream& HTransitionElementsKind::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(object());
ElementsKind from_kind = original_map().handle()->elements_kind();
ElementsKind to_kind = transitioned_map().handle()->elements_kind();
- stream->Add(" %p [%s] -> %p [%s]",
- *original_map().handle(),
- ElementsAccessor::ForKind(from_kind)->name(),
- *transitioned_map().handle(),
- ElementsAccessor::ForKind(to_kind)->name());
- if (IsSimpleMapChangeTransition(from_kind, to_kind)) stream->Add(" (simple)");
+ os << " " << *original_map().handle() << " ["
+ << ElementsAccessor::ForKind(from_kind)->name() << "] -> "
+ << *transitioned_map().handle() << " ["
+ << ElementsAccessor::ForKind(to_kind)->name() << "]";
+ if (IsSimpleMapChangeTransition(from_kind, to_kind)) os << " (simple)";
+ return os;
}
-void HLoadGlobalCell::PrintDataTo(StringStream* stream) {
- stream->Add("[%p]", *cell().handle());
- if (!details_.IsDontDelete()) stream->Add(" (deleteable)");
- if (details_.IsReadOnly()) stream->Add(" (read-only)");
+OStream& HLoadGlobalCell::PrintDataTo(OStream& os) const { // NOLINT
+ os << "[" << *cell().handle() << "]";
+ if (!details_.IsDontDelete()) os << " (deleteable)";
+ if (details_.IsReadOnly()) os << " (read-only)";
+ return os;
}
}
-void HLoadGlobalGeneric::PrintDataTo(StringStream* stream) {
- stream->Add("%o ", *name());
+OStream& HLoadGlobalGeneric::PrintDataTo(OStream& os) const { // NOLINT
+ return os << name()->ToCString().get() << " ";
}
-void HInnerAllocatedObject::PrintDataTo(StringStream* stream) {
- base_object()->PrintNameTo(stream);
- stream->Add(" offset ");
- offset()->PrintTo(stream);
+OStream& HInnerAllocatedObject::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(base_object()) << " offset ";
+ return offset()->PrintTo(os);
}
-void HStoreGlobalCell::PrintDataTo(StringStream* stream) {
- stream->Add("[%p] = ", *cell().handle());
- value()->PrintNameTo(stream);
- if (!details_.IsDontDelete()) stream->Add(" (deleteable)");
- if (details_.IsReadOnly()) stream->Add(" (read-only)");
+OStream& HStoreGlobalCell::PrintDataTo(OStream& os) const { // NOLINT
+ os << "[" << *cell().handle() << "] = " << NameOf(value());
+ if (!details_.IsDontDelete()) os << " (deleteable)";
+ if (details_.IsReadOnly()) os << " (read-only)";
+ return os;
}
-void HLoadContextSlot::PrintDataTo(StringStream* stream) {
- value()->PrintNameTo(stream);
- stream->Add("[%d]", slot_index());
+OStream& HLoadContextSlot::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(value()) << "[" << slot_index() << "]";
}
-void HStoreContextSlot::PrintDataTo(StringStream* stream) {
- context()->PrintNameTo(stream);
- stream->Add("[%d] = ", slot_index());
- value()->PrintNameTo(stream);
+OStream& HStoreContextSlot::PrintDataTo(OStream& os) const { // NOLINT
+ return os << NameOf(context()) << "[" << slot_index()
+ << "] = " << NameOf(value());
}
}
-void HAllocate::PrintDataTo(StringStream* stream) {
- size()->PrintNameTo(stream);
- stream->Add(" (");
- if (IsNewSpaceAllocation()) stream->Add("N");
- if (IsOldPointerSpaceAllocation()) stream->Add("P");
- if (IsOldDataSpaceAllocation()) stream->Add("D");
- if (MustAllocateDoubleAligned()) stream->Add("A");
- if (MustPrefillWithFiller()) stream->Add("F");
- stream->Add(")");
+OStream& HAllocate::PrintDataTo(OStream& os) const { // NOLINT
+ os << NameOf(size()) << " (";
+ if (IsNewSpaceAllocation()) os << "N";
+ if (IsOldPointerSpaceAllocation()) os << "P";
+ if (IsOldDataSpaceAllocation()) os << "D";
+ if (MustAllocateDoubleAligned()) os << "A";
+ if (MustPrefillWithFiller()) os << "F";
+ return os << ")";
}
}
-void HStringAdd::PrintDataTo(StringStream* stream) {
+OStream& HStringAdd::PrintDataTo(OStream& os) const { // NOLINT
if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) {
- stream->Add("_CheckBoth");
+ os << "_CheckBoth";
} else if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_LEFT) {
- stream->Add("_CheckLeft");
+ os << "_CheckLeft";
} else if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_RIGHT) {
- stream->Add("_CheckRight");
+ os << "_CheckRight";
}
- HBinaryOperation::PrintDataTo(stream);
- stream->Add(" (");
- if (pretenure_flag() == NOT_TENURED) stream->Add("N");
- else if (pretenure_flag() == TENURED) stream->Add("D");
- stream->Add(")");
+ HBinaryOperation::PrintDataTo(os);
+ os << " (";
+ if (pretenure_flag() == NOT_TENURED)
+ os << "N";
+ else if (pretenure_flag() == TENURED)
+ os << "D";
+ return os << ")";
}
#undef H_CONSTANT_DOUBLE
-void HBitwise::PrintDataTo(StringStream* stream) {
- stream->Add(Token::Name(op_));
- stream->Add(" ");
- HBitwiseBinaryOperation::PrintDataTo(stream);
+OStream& HBitwise::PrintDataTo(OStream& os) const { // NOLINT
+ os << Token::Name(op_) << " ";
+ return HBitwiseBinaryOperation::PrintDataTo(os);
}
}
-void HObjectAccess::PrintTo(StringStream* stream) const {
- stream->Add(".");
+OStream& operator<<(OStream& os, const HObjectAccess& access) {
+ os << ".";
- switch (portion()) {
- case kArrayLengths:
- case kStringLengths:
- stream->Add("%length");
+ switch (access.portion()) {
+ case HObjectAccess::kArrayLengths:
+ case HObjectAccess::kStringLengths:
+ os << "%length";
break;
- case kElementsPointer:
- stream->Add("%elements");
+ case HObjectAccess::kElementsPointer:
+ os << "%elements";
break;
- case kMaps:
- stream->Add("%map");
+ case HObjectAccess::kMaps:
+ os << "%map";
break;
- case kDouble: // fall through
- case kInobject:
- if (!name_.is_null()) {
- stream->Add(String::cast(*name_)->ToCString().get());
+ case HObjectAccess::kDouble: // fall through
+ case HObjectAccess::kInobject:
+ if (!access.name().is_null()) {
+ os << Handle<String>::cast(access.name())->ToCString().get();
}
- stream->Add("[in-object]");
+ os << "[in-object]";
break;
- case kBackingStore:
- if (!name_.is_null()) {
- stream->Add(String::cast(*name_)->ToCString().get());
+ case HObjectAccess::kBackingStore:
+ if (!access.name().is_null()) {
+ os << Handle<String>::cast(access.name())->ToCString().get();
}
- stream->Add("[backing-store]");
+ os << "[backing-store]";
break;
- case kExternalMemory:
- stream->Add("[external-memory]");
+ case HObjectAccess::kExternalMemory:
+ os << "[external-memory]";
break;
}
- stream->Add("@%d", offset());
+ return os << "@" << access.offset();
}
} } // namespace v8::internal
#include "src/data-flow.h"
#include "src/deoptimizer.h"
#include "src/hydrogen-types.h"
+#include "src/ostreams.h"
#include "src/small-pointer-list.h"
-#include "src/string-stream.h"
#include "src/unique.h"
#include "src/utils.h"
#include "src/zone.h"
namespace internal {
// Forward declarations.
+class ChangesOf;
class HBasicBlock;
class HDiv;
class HEnvironment;
int raw() const { return value_; }
- void PrintTo(FILE* f);
-
private:
typedef BitField<int, 0, 9> InliningIdField;
};
+OStream& operator<<(OStream& os, const HSourcePosition& p);
+
+
class HValue : public ZoneObject {
public:
static const int kNoNumber = -1;
bool IsDefinedAfter(HBasicBlock* other) const;
// Operands.
- virtual int OperandCount() = 0;
+ virtual int OperandCount() const = 0;
virtual HValue* OperandAt(int index) const = 0;
void SetOperandAt(int index, HValue* value);
virtual void FinalizeUniqueness() { }
// Printing support.
- virtual void PrintTo(StringStream* stream) = 0;
- void PrintNameTo(StringStream* stream);
- void PrintTypeTo(StringStream* stream);
- void PrintChangesTo(StringStream* stream);
+ virtual OStream& PrintTo(OStream& os) const = 0; // NOLINT
const char* Mnemonic() const;
result.Remove(kOsrEntries);
return result;
}
+ friend OStream& operator<<(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);
DISALLOW_COPY_AND_ASSIGN(HValue);
};
+// Support for printing various aspects of an HValue.
+struct NameOf {
+ explicit NameOf(const HValue* const v) : value(v) {}
+ const HValue* value;
+};
+
+
+struct TypeOf {
+ explicit TypeOf(const HValue* const v) : value(v) {}
+ const HValue* value;
+};
+
+
+struct ChangesOf {
+ explicit ChangesOf(const HValue* const v) : value(v) {}
+ const HValue* value;
+};
+
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);
#define DECLARE_INSTRUCTION_FACTORY_P0(I) \
HInstruction* next() const { return next_; }
HInstruction* previous() const { return previous_; }
- virtual void PrintTo(StringStream* stream) V8_OVERRIDE;
- virtual void PrintDataTo(StringStream* stream);
+ virtual OStream& PrintTo(OStream& os) const V8_OVERRIDE; // NOLINT
+ virtual OStream& PrintDataTo(OStream& os) const; // NOLINT
bool IsLinked() const { return block() != NULL; }
void Unlink();
SetBlock(block);
}
- void PrintMnemonicTo(StringStream* stream);
-
HInstruction* next_;
HInstruction* previous_;
HPositionInfo position_;
template<int V>
class HTemplateInstruction : public HInstruction {
public:
- virtual int OperandCount() V8_FINAL V8_OVERRIDE { return V; }
+ virtual int OperandCount() const V8_FINAL V8_OVERRIDE { return V; }
virtual HValue* OperandAt(int i) const V8_FINAL V8_OVERRIDE {
return inputs_[i];
}
class HControlInstruction : public HInstruction {
public:
- virtual HBasicBlock* SuccessorAt(int i) = 0;
- virtual int SuccessorCount() = 0;
+ virtual HBasicBlock* SuccessorAt(int i) const = 0;
+ virtual int SuccessorCount() const = 0;
virtual void SetSuccessorAt(int i, HBasicBlock* block) = 0;
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual bool KnownSuccessorBlock(HBasicBlock** block) {
*block = NULL;
class HSuccessorIterator V8_FINAL BASE_EMBEDDED {
public:
- explicit HSuccessorIterator(HControlInstruction* instr)
- : instr_(instr), current_(0) { }
+ explicit HSuccessorIterator(const HControlInstruction* instr)
+ : instr_(instr), current_(0) {}
bool Done() { return current_ >= instr_->SuccessorCount(); }
HBasicBlock* Current() { return instr_->SuccessorAt(current_); }
void Advance() { current_++; }
private:
- HControlInstruction* instr_;
+ const HControlInstruction* instr_;
int current_;
};
template<int S, int V>
class HTemplateControlInstruction : public HControlInstruction {
public:
- int SuccessorCount() V8_OVERRIDE { return S; }
- HBasicBlock* SuccessorAt(int i) V8_OVERRIDE { return successors_[i]; }
+ int SuccessorCount() const V8_OVERRIDE { return S; }
+ HBasicBlock* SuccessorAt(int i) const V8_OVERRIDE { return successors_[i]; }
void SetSuccessorAt(int i, HBasicBlock* block) V8_OVERRIDE {
successors_[i] = block;
}
- int OperandCount() V8_OVERRIDE { return V; }
+ int OperandCount() const V8_OVERRIDE { return V; }
HValue* OperandAt(int i) const V8_OVERRIDE { return inputs_[i]; }
set_representation(Representation::Tagged());
}
- HValue* value() { return OperandAt(0); }
+ HValue* value() const { return OperandAt(0); }
virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { return false; }
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::None();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(DummyUse);
};
return Representation::None();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(Goto)
};
SetSuccessorAt(1, false_target);
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
- HValue* value() { return OperandAt(0); }
+ HValue* value() const { return OperandAt(0); }
};
virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE;
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
ToBooleanStub::Types expected_input_types() const {
return expected_input_types_;
return false;
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
static const int kNoKnownSuccessorIndex = -1;
int known_successor_index() const { return known_successor_index_; }
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
- HValue* value() { return OperandAt(0); }
- HValue* context() { return OperandAt(1); }
- HValue* parameter_count() { return OperandAt(2); }
+ HValue* value() const { return OperandAt(0); }
+ HValue* context() const { return OperandAt(1); }
+ HValue* parameter_count() const { return OperandAt(2); }
DECLARE_CONCRETE_INSTRUCTION(Return)
}
HValue* value() const { return OperandAt(0); }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
};
static HInstruction* New(Zone* zone, HValue* context, HValue* value,
Representation required_representation);
- HValue* value() { return OperandAt(0); }
+ HValue* value() const { return OperandAt(0); }
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return representation(); // Same as the output representation.
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation)
virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(Change)
done_with_replay_(false) {}
~HSimulate() {}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
bool HasAstId() const { return !ast_id_.IsNone(); }
BailoutId ast_id() const { return ast_id_; }
}
return -1;
}
- virtual int OperandCount() V8_OVERRIDE { return values_.length(); }
+ virtual int OperandCount() const V8_OVERRIDE { return values_.length(); }
virtual HValue* OperandAt(int index) const V8_OVERRIDE {
return values_[index];
}
DECLARE_INSTRUCTION_FACTORY_P2(HEnvironmentMarker, Kind, int);
- Kind kind() { return kind_; }
- int index() { return index_; }
+ Kind kind() const { return kind_; }
+ int index() const { return index_; }
HSimulate* next_simulate() { return next_simulate_; }
void set_next_simulate(HSimulate* simulate) {
next_simulate_ = simulate;
return Representation::None();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_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 void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
Handle<JSFunction> closure() const { return closure_; }
int arguments_count() const { return arguments_count_; }
virtual int argument_delta() const V8_OVERRIDE { return inputs_.length(); }
HValue* argument(int i) { return OperandAt(i); }
- virtual int OperandCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
+ virtual int OperandCount() const V8_FINAL V8_OVERRIDE {
+ return inputs_.length();
+ }
virtual HValue* OperandAt(int i) const V8_FINAL V8_OVERRIDE {
return inputs_[i];
}
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
- HValue* value() { return OperandAt(0); }
+ HValue* value() const { return OperandAt(0); }
};
SetOperandAt(1, second);
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(
int index) V8_FINAL V8_OVERRIDE {
return Representation::Tagged();
}
- HValue* first() { return OperandAt(0); }
- HValue* second() { return OperandAt(1); }
+ HValue* first() const { return OperandAt(0); }
+ HValue* second() const { return OperandAt(1); }
};
int argument_count,
bool pass_argument_count);
- HValue* function() { return OperandAt(0); }
+ HValue* function() const { return OperandAt(0); }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(
int index) V8_FINAL V8_OVERRIDE {
return res;
}
- virtual int OperandCount() V8_FINAL V8_OVERRIDE { return values_.length(); }
+ virtual int OperandCount() const V8_FINAL V8_OVERRIDE {
+ return values_.length();
+ }
virtual HValue* OperandAt(int index) const V8_FINAL V8_OVERRIDE {
return values_[index];
}
return OperandAt(0);
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
private:
// The argument count includes the receiver.
HValue* context() { return first(); }
HValue* constructor() { return second(); }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
ElementsKind elements_kind() const { return elements_kind_; }
const Runtime::Function*,
int);
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
HValue* context() { return OperandAt(0); }
const Runtime::Function* function() const { return c_function_; }
HValue* value,
BuiltinFunctionId op);
- HValue* context() { return OperandAt(0); }
- HValue* value() { return OperandAt(1); }
+ HValue* context() const { return OperandAt(0); }
+ HValue* value() const { return OperandAt(1); }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
if (index == 0) {
return HType::HeapObject();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
HValue* value() const { return OperandAt(0); }
HValue* typecheck() const { return OperandAt(1); }
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual HValue* Canonicalize() V8_OVERRIDE;
DECLARE_INSTRUCTION_FACTORY_P2(HCheckInstanceType, HValue*, Check);
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
virtual int RedefinedOperandIndex() { return 0; }
private:
- const char* GetCheckName();
+ const char* GetCheckName() const;
HCheckInstanceType(HValue* value, Check check)
: HUnaryOperation(value, HType::HeapObject()), check_(check) {
return representation();
}
virtual HType CalculateInferredType() V8_OVERRIDE;
- virtual int OperandCount() V8_OVERRIDE { return inputs_.length(); }
+ virtual int OperandCount() const V8_OVERRIDE { return inputs_.length(); }
virtual HValue* OperandAt(int index) const V8_OVERRIDE {
return inputs_[index];
}
induction_variable_data_ = InductionVariableData::ExaminePhi(this);
}
- virtual void PrintTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintTo(OStream& os) const V8_OVERRIDE; // NOLINT
#ifdef DEBUG
virtual void Verify() V8_OVERRIDE;
public:
HDematerializedObject(int count, Zone* zone) : values_(count, zone) {}
- virtual int OperandCount() V8_FINAL V8_OVERRIDE { return values_.length(); }
+ virtual int OperandCount() const V8_FINAL V8_OVERRIDE {
+ return values_.length();
+ }
virtual HValue* OperandAt(int index) const V8_FINAL V8_OVERRIDE {
return values_[index];
}
// Replay effects of this instruction on the given environment.
void ReplayEnvironment(HEnvironment* env);
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(CapturedObject)
}
virtual bool EmitAtUses() V8_OVERRIDE;
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_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 void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
if (index == 0) return Representation::Tagged();
return Representation::Tagged();
}
- HValue* receiver() { return OperandAt(0); }
- HValue* function() { return OperandAt(1); }
+ HValue* receiver() const { return OperandAt(0); }
+ HValue* function() const { return OperandAt(1); }
virtual HValue* Canonicalize() V8_OVERRIDE;
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
bool known_function() const { return known_function_; }
DECLARE_CONCRETE_INSTRUCTION(WrapReceiver)
public:
DECLARE_INSTRUCTION_FACTORY_P3(HAccessArgumentsAt, HValue*, HValue*, HValue*);
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
// The arguments elements is considered tagged.
: Representation::Integer32();
}
- HValue* arguments() { return OperandAt(0); }
- HValue* length() { return OperandAt(1); }
- HValue* index() { return OperandAt(2); }
+ HValue* arguments() const { return OperandAt(0); }
+ HValue* length() const { return OperandAt(1); }
+ HValue* index() const { return OperandAt(2); }
DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt)
bool skip_check() const { return skip_check_; }
void set_skip_check() { skip_check_ = true; }
- HValue* base() { return base_; }
- int offset() { return offset_; }
- int scale() { return scale_; }
+ HValue* base() const { return base_; }
+ int offset() const { return offset_; }
+ int scale() const { return scale_; }
void ApplyIndexChange();
bool DetectCompoundIndex() {
return representation();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual void InferRepresentation(
HInferRepresentationPhase* h_infer) V8_OVERRIDE;
- HValue* index() { return OperandAt(0); }
- HValue* length() { return OperandAt(1); }
- bool allow_equality() { return allow_equality_; }
+ HValue* index() const { return OperandAt(0); }
+ HValue* length() const { return OperandAt(1); }
+ bool allow_equality() const { return allow_equality_; }
void set_allow_equality(bool v) { allow_equality_ = v; }
virtual int RedefinedOperandIndex() V8_OVERRIDE { return 0; }
}
}
- HValue* base_index() { return OperandAt(0); }
+ HValue* base_index() const { return OperandAt(0); }
HBoundsCheck* bounds_check() { return HBoundsCheck::cast(OperandAt(1)); }
DECLARE_CONCRETE_INSTRUCTION(BoundsCheckBaseIndexInformation)
return representation();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual int RedefinedOperandIndex() V8_OVERRIDE { return 0; }
virtual bool IsPurelyInformativeDefinition() V8_OVERRIDE { return true; }
}
Token::Value token() const { return token_; }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(CompareGeneric)
HValue*, HValue*, Token::Value,
HBasicBlock*, HBasicBlock*);
- HValue* left() { return OperandAt(0); }
- HValue* right() { return OperandAt(1); }
+ HValue* left() const { return OperandAt(0); }
+ HValue* right() const { return OperandAt(1); }
Token::Value token() const { return token_; }
void set_observed_input_representation(Representation left,
virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE;
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
void SetOperandPositions(Zone* zone,
HSourcePosition left_pos,
known_successor_index_ = known_successor_index;
}
- HValue* left() { return OperandAt(0); }
- HValue* right() { return OperandAt(1); }
+ HValue* left() const { return OperandAt(0); }
+ HValue* right() const { return OperandAt(1); }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
HValue* right() { return OperandAt(2); }
Token::Value token() const { return token_; }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
InstanceType from() { return from_; }
InstanceType to() { return to_; }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
Handle<String> class_name() const { return class_name_; }
public:
DECLARE_INSTRUCTION_FACTORY_P2(HTypeofIsAndBranch, HValue*, Handle<String>);
- Handle<String> type_literal() { return type_literal_.handle(); }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ Handle<String> type_literal() const { return type_literal_.handle(); }
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch)
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(InstanceOf)
virtual HValue* Canonicalize() V8_OVERRIDE;
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(Bitwise)
unsigned index() const { return index_; }
ParameterKind kind() const { return kind_; }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::None();
HValue* context() { return value(); }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(CallStub)
public:
DECLARE_INSTRUCTION_FACTORY_P2(HUnknownOSRValue, HEnvironment*, int);
- virtual void PrintDataTo(StringStream* stream);
+ virtual OStream& PrintDataTo(OStream& os) const; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::None();
Unique<Cell> cell() const { return cell_; }
bool RequiresHoleCheck() const;
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual intptr_t Hashcode() V8_OVERRIDE {
return cell_.Hashcode();
class HLoadGlobalGeneric V8_FINAL : public HTemplateInstruction<2> {
public:
DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HLoadGlobalGeneric, HValue*,
- Handle<Object>, bool);
+ Handle<String>, bool);
HValue* context() { return OperandAt(0); }
HValue* global_object() { return OperandAt(1); }
- Handle<Object> name() const { return name_; }
+ Handle<String> name() const { return name_; }
bool for_typeof() const { return for_typeof_; }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric)
private:
- HLoadGlobalGeneric(HValue* context,
- HValue* global_object,
- Handle<Object> name,
- bool for_typeof)
- : name_(name),
- for_typeof_(for_typeof) {
+ HLoadGlobalGeneric(HValue* context, HValue* global_object,
+ Handle<String> name, bool for_typeof)
+ : name_(name), for_typeof_(for_typeof) {
SetOperandAt(0, context);
SetOperandAt(1, global_object);
set_representation(Representation::Tagged());
SetAllSideEffects();
}
- Handle<Object> name_;
+ Handle<String> name_;
bool for_typeof_;
};
// Maximum instance size for which allocations will be inlined.
static const int kMaxInlineSize = 64 * kPointerSize;
- HValue* context() { return OperandAt(0); }
- HValue* size() { return OperandAt(1); }
+ HValue* context() const { return OperandAt(0); }
+ HValue* size() const { return OperandAt(1); }
bool has_size_upper_bound() { return size_upper_bound_ != NULL; }
HConstant* size_upper_bound() { return size_upper_bound_; }
virtual bool HandleSideEffectDominator(GVNFlag side_effect,
HValue* dominator) V8_OVERRIDE;
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(Allocate)
return new(zone) HInnerAllocatedObject(value, offset, type);
}
- HValue* base_object() { return OperandAt(0); }
- HValue* offset() { return OperandAt(1); }
+ HValue* base_object() const { return OperandAt(0); }
+ HValue* offset() const { return OperandAt(1); }
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return index == 0 ? Representation::Tagged() : Representation::Integer32();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject)
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell)
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot)
DECLARE_INSTRUCTION_FACTORY_P4(HStoreContextSlot, HValue*, int,
Mode, HValue*);
- HValue* context() { return OperandAt(0); }
- HValue* value() { return OperandAt(1); }
+ HValue* context() const { return OperandAt(0); }
+ HValue* value() const { return OperandAt(1); }
int slot_index() const { return slot_index_; }
Mode mode() const { return mode_; }
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot)
return HObjectAccess(kInobject, GlobalObject::kNativeContextOffset);
}
- void PrintTo(StringStream* stream) const;
-
inline bool Equals(HObjectAccess that) const {
return value_ == that.value_; // portion and offset must match
}
friend class HLoadNamedField;
friend class HStoreNamedField;
friend class SideEffectsTracker;
+ friend OStream& operator<<(OStream& os, const HObjectAccess& access);
inline Portion portion() const {
return PortionField::decode(value_);
};
+OStream& operator<<(OStream& os, const HObjectAccess& access);
+
+
class HLoadNamedField V8_FINAL : public HTemplateInstruction<2> {
public:
DECLARE_INSTRUCTION_FACTORY_P3(HLoadNamedField, HValue*,
DECLARE_INSTRUCTION_FACTORY_P5(HLoadNamedField, HValue*, HValue*,
HObjectAccess, const UniqueSet<Map>*, HType);
- HValue* object() { return OperandAt(0); }
- HValue* dependency() {
+ HValue* object() const { return OperandAt(0); }
+ HValue* dependency() const {
ASSERT(HasDependency());
return OperandAt(1);
}
return Representation::Tagged();
}
virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
bool CanBeReplacedWith(HValue* other) const {
if (!CheckFlag(HValue::kCantBeReplaced)) return false;
DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HLoadNamedGeneric, HValue*,
Handle<Object>);
- HValue* context() { return OperandAt(0); }
- HValue* object() { return OperandAt(1); }
+ HValue* context() const { return OperandAt(0); }
+ HValue* object() const { return OperandAt(1); }
Handle<Object> name() const { return name_; }
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric)
virtual ElementsKind elements_kind() const = 0;
// TryIncreaseBaseOffset returns false if overflow would result.
virtual bool TryIncreaseBaseOffset(uint32_t increase_by_value) = 0;
- virtual bool IsDehoisted() = 0;
+ virtual bool IsDehoisted() const = 0;
virtual void SetDehoisted(bool is_dehoisted) = 0;
virtual ~ArrayInstructionInterface() { }
bool is_typed_elements() const {
return is_external() || is_fixed_typed_array();
}
- HValue* elements() { return OperandAt(0); }
- HValue* key() { return OperandAt(1); }
- HValue* dependency() {
+ HValue* elements() const { return OperandAt(0); }
+ HValue* key() const { return OperandAt(1); }
+ HValue* dependency() const {
ASSERT(HasDependency());
return OperandAt(2);
}
bool HasDependency() const { return OperandAt(0) != OperandAt(2); }
- uint32_t base_offset() { return BaseOffsetField::decode(bit_field_); }
+ uint32_t base_offset() const { return BaseOffsetField::decode(bit_field_); }
bool TryIncreaseBaseOffset(uint32_t increase_by_value);
HValue* GetKey() { return key(); }
void SetKey(HValue* key) { SetOperandAt(1, key); }
- bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); }
+ bool IsDehoisted() const { return IsDehoistedField::decode(bit_field_); }
void SetDehoisted(bool is_dehoisted) {
bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted);
}
return RequiredInputRepresentation(index);
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
bool UsesMustHandleHole() const;
bool AllUsesCanTreatHoleAsNaN() const;
public:
DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HLoadKeyedGeneric, HValue*,
HValue*);
- HValue* object() { return OperandAt(0); }
- HValue* key() { return OperandAt(1); }
- HValue* context() { return OperandAt(2); }
+ HValue* object() const { return OperandAt(0); }
+ HValue* key() const { return OperandAt(1); }
+ HValue* context() const { return OperandAt(2); }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
// tagged[tagged]
dominator_ = dominator;
return false;
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
HValue* object() const { return OperandAt(0); }
HValue* value() const { return OperandAt(1); }
SetChangesFlag(kMaps);
}
- bool NeedsWriteBarrier() {
+ bool NeedsWriteBarrier() const {
ASSERT(!field_representation().IsDouble() || !has_transition());
if (field_representation().IsDouble()) return false;
if (field_representation().IsSmi()) return false;
DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreNamedGeneric, HValue*,
Handle<String>, HValue*,
StrictMode);
- HValue* object() { return OperandAt(0); }
- HValue* value() { return OperandAt(1); }
- HValue* context() { return OperandAt(2); }
- Handle<String> name() { return name_; }
- StrictMode strict_mode() { return strict_mode_; }
+ HValue* object() const { return OperandAt(0); }
+ HValue* value() const { return OperandAt(1); }
+ HValue* context() const { return OperandAt(2); }
+ Handle<String> name() const { return name_; }
+ StrictMode strict_mode() const { return strict_mode_; }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
}
StoreFieldOrKeyedMode store_mode() const { return store_mode_; }
ElementsKind elements_kind() const { return elements_kind_; }
- uint32_t base_offset() { return base_offset_; }
+ uint32_t base_offset() const { return base_offset_; }
bool TryIncreaseBaseOffset(uint32_t increase_by_value);
HValue* GetKey() { return key(); }
void SetKey(HValue* key) { SetOperandAt(1, key); }
- bool IsDehoisted() { return is_dehoisted_; }
+ bool IsDehoisted() const { return is_dehoisted_; }
void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; }
bool IsUninitialized() { return is_uninitialized_; }
void SetUninitialized(bool is_uninitialized) {
bool NeedsCanonicalization();
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(StoreKeyed)
DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreKeyedGeneric, HValue*,
HValue*, HValue*, StrictMode);
- HValue* object() { return OperandAt(0); }
- HValue* key() { return OperandAt(1); }
- HValue* value() { return OperandAt(2); }
- HValue* context() { return OperandAt(3); }
- StrictMode strict_mode() { return strict_mode_; }
+ HValue* object() const { return OperandAt(0); }
+ HValue* key() const { return OperandAt(1); }
+ HValue* value() const { return OperandAt(2); }
+ HValue* context() const { return OperandAt(3); }
+ StrictMode strict_mode() const { return strict_mode_; }
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
// tagged[tagged] = tagged
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric)
return Representation::Tagged();
}
- HValue* object() { return OperandAt(0); }
- HValue* context() { return OperandAt(1); }
- Unique<Map> original_map() { return original_map_; }
- Unique<Map> transitioned_map() { return transitioned_map_; }
- ElementsKind from_kind() { return from_kind_; }
- ElementsKind to_kind() { return to_kind_; }
+ HValue* object() const { return OperandAt(0); }
+ HValue* context() const { return OperandAt(1); }
+ Unique<Map> original_map() const { return original_map_; }
+ Unique<Map> transitioned_map() const { return transitioned_map_; }
+ ElementsKind from_kind() const { return from_kind_; }
+ ElementsKind to_kind() const { return to_kind_; }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind)
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(StringAdd)
public:
DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P1(HTypeof, HValue*);
- HValue* context() { return OperandAt(0); }
- HValue* value() { return OperandAt(1); }
+ HValue* context() const { return OperandAt(0); }
+ HValue* value() const { return OperandAt(1); }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual HType CalculateInferredType() V8_OVERRIDE {
if (value()->type().IsHeapObject()) return value()->type();
return Representation::Tagged();
}
- HValue* context() { return OperandAt(0); }
- HValue* enumerable() { return OperandAt(1); }
+ HValue* context() const { return OperandAt(0); }
+ HValue* enumerable() const { return OperandAt(1); }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual HType CalculateInferredType() V8_OVERRIDE {
return HType::Tagged();
return Representation::Tagged();
}
- HValue* enumerable() { return OperandAt(0); }
- HValue* map() { return OperandAt(1); }
- int idx() { return idx_; }
+ HValue* enumerable() const { return OperandAt(0); }
+ HValue* map() const { return OperandAt(1); }
+ int idx() const { return idx_; }
HForInCacheArray* index_cache() {
return index_cache_;
index_cache_ = index_cache;
}
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual HType CalculateInferredType() V8_OVERRIDE {
return HType::Tagged();
}
}
- HValue* object() { return OperandAt(0); }
- HValue* index() { return OperandAt(1); }
+ HValue* object() const { return OperandAt(0); }
+ HValue* index() const { return OperandAt(1); }
- virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+ virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT
virtual HType CalculateInferredType() V8_OVERRIDE {
return HType::Tagged();
public:
DECLARE_INSTRUCTION_FACTORY_P3(HAllocateBlockContext, HValue*,
HValue*, Handle<ScopeInfo>);
- HValue* context() { return OperandAt(0); }
- HValue* function() { return OperandAt(1); }
- Handle<ScopeInfo> scope_info() { return scope_info_; }
+ HValue* context() const { return OperandAt(0); }
+ HValue* function() const { return OperandAt(1); }
+ Handle<ScopeInfo> scope_info() const { return scope_info_; }
virtual Representation RequiredInputRepresentation(int index) {
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream);
+ virtual OStream& PrintDataTo(OStream& os) const; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext)
}
-const char* HType::ToString() const {
+OStream& operator<<(OStream& os, const HType& t) {
// Note: The c1visualizer syntax for locals allows only a sequence of the
// following characters: A-Za-z0-9_-|:
- switch (kind_) {
- #define DEFINE_CASE(Name, mask) case k##Name: return #Name;
+ switch (t.kind_) {
+#define DEFINE_CASE(Name, mask) \
+ case HType::k##Name: \
+ return os << #Name;
HTYPE_LIST(DEFINE_CASE)
- #undef DEFINE_CASE
+#undef DEFINE_CASE
}
UNREACHABLE();
- return NULL;
+ return os;
}
} } // namespace v8::internal
#include <climits>
#include "src/base/macros.h"
+#include "src/ostreams.h"
namespace v8 {
namespace internal {
static HType FromType(typename T::TypeHandle type) V8_WARN_UNUSED_RESULT;
static HType FromValue(Handle<Object> value) V8_WARN_UNUSED_RESULT;
- const char* ToString() const V8_WARN_UNUSED_RESULT;
+ friend OStream& operator<<(OStream& os, const HType& t);
private:
enum Kind {
int16_t kind_;
};
+
+OStream& operator<<(OStream& os, const HType& t);
} } // namespace v8::internal
#endif // HYDROGEN_TYPES_H_
}
+OStream& operator<<(OStream& os, const HBasicBlock& b) {
+ return os << "B" << b.block_id();
+}
+
+
HGraph::HGraph(CompilationInfo* info)
: isolate_(info->isolate()),
next_block_id_(0),
if (!shared->script()->IsUndefined()) {
Handle<Script> script(Script::cast(shared->script()));
if (!script->source()->IsUndefined()) {
- CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
- PrintF(tracing_scope.file(),
- "--- FUNCTION SOURCE (%s) id{%d,%d} ---\n",
- shared->DebugName()->ToCString().get(),
- info()->optimization_id(),
- id);
-
+ CodeTracer::Scope tracing_scopex(isolate()->GetCodeTracer());
+ OFStream os(tracing_scopex.file());
+ os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get()
+ << ") id{" << info()->optimization_id() << "," << id << "} ---\n";
{
ConsStringIteratorOp op;
StringCharacterStream stream(String::cast(script->source()),
shared->end_position() - shared->start_position() + 1;
for (int i = 0; i < source_len; i++) {
if (stream.HasMore()) {
- PrintF(tracing_scope.file(), "%c", stream.GetNext());
+ os.put(stream.GetNext());
}
}
}
- PrintF(tracing_scope.file(), "\n--- END ---\n");
+ os << "\n--- END ---\n";
}
}
}
if (inline_id != 0) {
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
- PrintF(tracing_scope.file(), "INLINE (%s) id{%d,%d} AS %d AT ",
- shared->DebugName()->ToCString().get(),
- info()->optimization_id(),
- id,
- inline_id);
- position.PrintTo(tracing_scope.file());
- PrintF(tracing_scope.file(), "\n");
+ OFStream os(tracing_scope.file());
+ os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{"
+ << info()->optimization_id() << "," << id << "} AS " << inline_id
+ << " AT " << position << endl;
}
return inline_id;
}
-void HEnvironment::PrintTo(StringStream* stream) {
- for (int i = 0; i < length(); i++) {
- if (i == 0) stream->Add("parameters\n");
- if (i == parameter_count()) stream->Add("specials\n");
- if (i == parameter_count() + specials_count()) stream->Add("locals\n");
- if (i == parameter_count() + specials_count() + local_count()) {
- stream->Add("expressions\n");
+OStream& operator<<(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";
+ if (i == env.parameter_count() + env.specials_count()) os << "locals\n";
+ if (i == env.parameter_count() + env.specials_count() + env.local_count()) {
+ os << "expressions\n";
}
- HValue* val = values_.at(i);
- stream->Add("%d: ", i);
+ HValue* val = env.values()->at(i);
+ os << i << ": ";
if (val != NULL) {
- val->PrintNameTo(stream);
+ os << val;
} else {
- stream->Add("NULL");
+ os << "NULL";
}
- stream->Add("\n");
+ os << "\n";
}
- PrintF("\n");
-}
-
-
-void HEnvironment::PrintToStd() {
- HeapStringAllocator string_allocator;
- StringStream trace(&string_allocator);
- PrintTo(&trace);
- PrintF("%s", trace.ToCString().get());
+ return os << "\n";
}
for (int j = 0; j < total; ++j) {
HPhi* phi = current->phis()->at(j);
PrintIndent();
- trace_.Add("%d ", phi->merged_index());
- phi->PrintNameTo(&trace_);
- trace_.Add(" ");
- phi->PrintTo(&trace_);
- trace_.Add("\n");
+ OStringStream os;
+ os << phi->merged_index() << " " << NameOf(phi) << " " << *phi << "\n";
+ trace_.Add(os.c_str());
}
}
HInstruction* instruction = it.Current();
int uses = instruction->UseCount();
PrintIndent();
- trace_.Add("0 %d ", uses);
- instruction->PrintNameTo(&trace_);
- trace_.Add(" ");
- instruction->PrintTo(&trace_);
+ OStringStream os;
+ os << "0 " << uses << " " << NameOf(instruction) << " " << *instruction;
if (FLAG_hydrogen_track_positions &&
instruction->has_position() &&
instruction->position().raw() != 0) {
const HSourcePosition pos = instruction->position();
- trace_.Add(" pos:");
- if (pos.inlining_id() != 0) {
- trace_.Add("%d_", pos.inlining_id());
- }
- trace_.Add("%d", pos.position());
+ os << " pos:";
+ if (pos.inlining_id() != 0) os << pos.inlining_id() << "_";
+ os << pos.position();
}
- trace_.Add(" <|@\n");
+ os << " <|@\n";
+ trace_.Add(os.c_str());
}
}
trace_.Add("%d ",
LifetimePosition::FromInstructionIndex(i).Value());
linstr->PrintTo(&trace_);
- trace_.Add(" [hir:");
- linstr->hydrogen_value()->PrintNameTo(&trace_);
- trace_.Add("]");
- trace_.Add(" <|@\n");
+ OStringStream os;
+ os << " [hir:" << NameOf(linstr->hydrogen_value()) << "] <|@\n";
+ trace_.Add(os.c_str());
}
}
}
};
+OStream& operator<<(OStream& os, const HBasicBlock& b);
+
+
class HPredecessorIterator V8_FINAL BASE_EMBEDDED {
public:
explicit HPredecessorIterator(HBasicBlock* block)
return i >= parameter_count() && i < parameter_count() + specials_count();
}
- void PrintTo(StringStream* stream);
- void PrintToStd();
-
Zone* zone() const { return zone_; }
private:
};
+OStream& operator<<(OStream& os, const HEnvironment& env);
+
+
class HOptimizedGraphBuilder;
enum ArgumentsAllowedFlag {
void LStoreNamedField::PrintDataTo(StringStream* stream) {
object()->PrintTo(stream);
- hydrogen()->access().PrintTo(stream);
- stream->Add(" <- ");
+ OStringStream os;
+ os << hydrogen()->access() << " <- ";
+ stream->Add(os.c_str());
value()->PrintTo(stream);
}
TransitionMarkFromState(state()),
TransitionMarkFromState(new_state),
modifier);
- name->Print();
+ OFStream os(stdout);
+ name->Print(os);
PrintF("]\n");
}
}
#include "src/factory.h"
#include "src/jsregexp-inl.h"
#include "src/jsregexp.h"
+#include "src/ostreams.h"
#include "src/parser.h"
#include "src/regexp-macro-assembler.h"
#include "src/regexp-macro-assembler-irregexp.h"
#include "src/regexp-stack.h"
#include "src/runtime.h"
#include "src/string-search.h"
-#include "src/string-stream.h"
#ifndef V8_INTERPRETED_REGEXP
#if V8_TARGET_ARCH_IA32
#ifdef DEBUG
if (FLAG_print_code) {
CodeTracer::Scope trace_scope(heap->isolate()->GetCodeTracer());
- Handle<Code>::cast(code)->Disassemble(pattern->ToCString().get(),
- trace_scope.file());
+ OFStream os(trace_scope.file());
+ Handle<Code>::cast(code)->Disassemble(pattern->ToCString().get(), os);
}
if (FLAG_trace_regexp_assembler) {
delete macro_assembler_;
class DotPrinter: public NodeVisitor {
public:
- explicit DotPrinter(bool ignore_case)
- : ignore_case_(ignore_case),
- stream_(&alloc_) { }
+ DotPrinter(OStream& os, bool ignore_case) // NOLINT
+ : os_(os),
+ ignore_case_(ignore_case) {}
void PrintNode(const char* label, RegExpNode* node);
void Visit(RegExpNode* node);
void PrintAttributes(RegExpNode* from);
- StringStream* stream() { return &stream_; }
void PrintOnFailure(RegExpNode* from, RegExpNode* to);
#define DECLARE_VISIT(Type) \
virtual void Visit##Type(Type##Node* that);
FOR_EACH_NODE_TYPE(DECLARE_VISIT)
#undef DECLARE_VISIT
private:
+ OStream& os_;
bool ignore_case_;
- HeapStringAllocator alloc_;
- StringStream stream_;
};
void DotPrinter::PrintNode(const char* label, RegExpNode* node) {
- stream()->Add("digraph G {\n graph [label=\"");
+ os_ << "digraph G {\n graph [label=\"";
for (int i = 0; label[i]; i++) {
switch (label[i]) {
case '\\':
- stream()->Add("\\\\");
+ os_ << "\\\\";
break;
case '"':
- stream()->Add("\"");
+ os_ << "\"";
break;
default:
- stream()->Put(label[i]);
+ os_ << label[i];
break;
}
}
- stream()->Add("\"];\n");
+ os_ << "\"];\n";
Visit(node);
- stream()->Add("}\n");
- printf("%s", stream()->ToCString().get());
+ os_ << "}" << endl;
}
void DotPrinter::PrintOnFailure(RegExpNode* from, RegExpNode* on_failure) {
- stream()->Add(" n%p -> n%p [style=dotted];\n", from, on_failure);
+ os_ << " n" << from << " -> n" << on_failure << " [style=dotted];\n";
Visit(on_failure);
}
class TableEntryBodyPrinter {
public:
- TableEntryBodyPrinter(StringStream* stream, ChoiceNode* choice)
- : stream_(stream), choice_(choice) { }
+ TableEntryBodyPrinter(OStream& os, ChoiceNode* choice) // NOLINT
+ : os_(os),
+ choice_(choice) {}
void Call(uc16 from, DispatchTable::Entry entry) {
OutSet* out_set = entry.out_set();
for (unsigned i = 0; i < OutSet::kFirstLimit; i++) {
if (out_set->Get(i)) {
- stream()->Add(" n%p:s%io%i -> n%p;\n",
- choice(),
- from,
- i,
- choice()->alternatives()->at(i).node());
+ os_ << " n" << choice() << ":s" << from << "o" << i << " -> n"
+ << choice()->alternatives()->at(i).node() << ";\n";
}
}
}
private:
- StringStream* stream() { return stream_; }
ChoiceNode* choice() { return choice_; }
- StringStream* stream_;
+ OStream& os_;
ChoiceNode* choice_;
};
class TableEntryHeaderPrinter {
public:
- explicit TableEntryHeaderPrinter(StringStream* stream)
- : first_(true), stream_(stream) { }
+ explicit TableEntryHeaderPrinter(OStream& os) // NOLINT
+ : first_(true),
+ os_(os) {}
void Call(uc16 from, DispatchTable::Entry entry) {
if (first_) {
first_ = false;
} else {
- stream()->Add("|");
+ os_ << "|";
}
- stream()->Add("{\\%k-\\%k|{", from, entry.to());
+ os_ << "{\\" << AsUC16(from) << "-\\" << AsUC16(entry.to()) << "|{";
OutSet* out_set = entry.out_set();
int priority = 0;
for (unsigned i = 0; i < OutSet::kFirstLimit; i++) {
if (out_set->Get(i)) {
- if (priority > 0) stream()->Add("|");
- stream()->Add("<s%io%i> %i", from, i, priority);
+ if (priority > 0) os_ << "|";
+ os_ << "<s" << from << "o" << i << "> " << priority;
priority++;
}
}
- stream()->Add("}}");
+ os_ << "}}";
}
private:
bool first_;
- StringStream* stream() { return stream_; }
- StringStream* stream_;
+ OStream& os_;
};
class AttributePrinter {
public:
- explicit AttributePrinter(DotPrinter* out)
- : out_(out), first_(true) { }
+ explicit AttributePrinter(OStream& os) // NOLINT
+ : os_(os),
+ first_(true) {}
void PrintSeparator() {
if (first_) {
first_ = false;
} else {
- out_->stream()->Add("|");
+ os_ << "|";
}
}
void PrintBit(const char* name, bool value) {
if (!value) return;
PrintSeparator();
- out_->stream()->Add("{%s}", name);
+ os_ << "{" << name << "}";
}
void PrintPositive(const char* name, int value) {
if (value < 0) return;
PrintSeparator();
- out_->stream()->Add("{%s|%x}", name, value);
+ os_ << "{" << name << "|" << value << "}";
}
+
private:
- DotPrinter* out_;
+ OStream& os_;
bool first_;
};
void DotPrinter::PrintAttributes(RegExpNode* that) {
- stream()->Add(" a%p [shape=Mrecord, color=grey, fontcolor=grey, "
- "margin=0.1, fontsize=10, label=\"{",
- that);
- AttributePrinter printer(this);
+ os_ << " a" << that << " [shape=Mrecord, color=grey, fontcolor=grey, "
+ << "margin=0.1, fontsize=10, label=\"{";
+ AttributePrinter printer(os_);
NodeInfo* info = that->info();
printer.PrintBit("NI", info->follows_newline_interest);
printer.PrintBit("WI", info->follows_word_interest);
Label* label = that->label();
if (label->is_bound())
printer.PrintPositive("@", label->pos());
- stream()->Add("}\"];\n");
- stream()->Add(" a%p -> n%p [style=dashed, color=grey, "
- "arrowhead=none];\n", that, that);
+ os_ << "}\"];\n"
+ << " a" << that << " -> n" << that
+ << " [style=dashed, color=grey, arrowhead=none];\n";
}
static const bool kPrintDispatchTable = false;
void DotPrinter::VisitChoice(ChoiceNode* that) {
if (kPrintDispatchTable) {
- stream()->Add(" n%p [shape=Mrecord, label=\"", that);
- TableEntryHeaderPrinter header_printer(stream());
+ os_ << " n" << that << " [shape=Mrecord, label=\"";
+ TableEntryHeaderPrinter header_printer(os_);
that->GetTable(ignore_case_)->ForEach(&header_printer);
- stream()->Add("\"]\n", that);
+ os_ << "\"]\n";
PrintAttributes(that);
- TableEntryBodyPrinter body_printer(stream(), that);
+ TableEntryBodyPrinter body_printer(os_, that);
that->GetTable(ignore_case_)->ForEach(&body_printer);
} else {
- stream()->Add(" n%p [shape=Mrecord, label=\"?\"];\n", that);
+ os_ << " n" << that << " [shape=Mrecord, label=\"?\"];\n";
for (int i = 0; i < that->alternatives()->length(); i++) {
GuardedAlternative alt = that->alternatives()->at(i);
- stream()->Add(" n%p -> n%p;\n", that, alt.node());
+ os_ << " n" << that << " -> n" << alt.node();
}
}
for (int i = 0; i < that->alternatives()->length(); i++) {
void DotPrinter::VisitText(TextNode* that) {
Zone* zone = that->zone();
- stream()->Add(" n%p [label=\"", that);
+ os_ << " n" << that << " [label=\"";
for (int i = 0; i < that->elements()->length(); i++) {
- if (i > 0) stream()->Add(" ");
+ if (i > 0) os_ << " ";
TextElement elm = that->elements()->at(i);
switch (elm.text_type()) {
case TextElement::ATOM: {
- stream()->Add("'%w'", elm.atom()->data());
+ Vector<const uc16> data = elm.atom()->data();
+ for (int i = 0; i < data.length(); i++) {
+ os_ << static_cast<char>(data[i]);
+ }
break;
}
case TextElement::CHAR_CLASS: {
RegExpCharacterClass* node = elm.char_class();
- stream()->Add("[");
- if (node->is_negated())
- stream()->Add("^");
+ os_ << "[";
+ if (node->is_negated()) os_ << "^";
for (int j = 0; j < node->ranges(zone)->length(); j++) {
CharacterRange range = node->ranges(zone)->at(j);
- stream()->Add("%k-%k", range.from(), range.to());
+ os_ << AsUC16(range.from()) << "-" << AsUC16(range.to());
}
- stream()->Add("]");
+ os_ << "]";
break;
}
default:
UNREACHABLE();
}
}
- stream()->Add("\", shape=box, peripheries=2];\n");
+ os_ << "\", shape=box, peripheries=2];\n";
PrintAttributes(that);
- stream()->Add(" n%p -> n%p;\n", that, that->on_success());
+ os_ << " n" << that << " -> n" << that->on_success() << ";\n";
Visit(that->on_success());
}
void DotPrinter::VisitBackReference(BackReferenceNode* that) {
- stream()->Add(" n%p [label=\"$%i..$%i\", shape=doubleoctagon];\n",
- that,
- that->start_register(),
- that->end_register());
+ os_ << " n" << that << " [label=\"$" << that->start_register() << "..$"
+ << that->end_register() << "\", shape=doubleoctagon];\n";
PrintAttributes(that);
- stream()->Add(" n%p -> n%p;\n", that, that->on_success());
+ os_ << " n" << that << " -> n" << that->on_success() << ";\n";
Visit(that->on_success());
}
void DotPrinter::VisitEnd(EndNode* that) {
- stream()->Add(" n%p [style=bold, shape=point];\n", that);
+ os_ << " n" << that << " [style=bold, shape=point];\n";
PrintAttributes(that);
}
void DotPrinter::VisitAssertion(AssertionNode* that) {
- stream()->Add(" n%p [", that);
+ os_ << " n" << that << " [";
switch (that->assertion_type()) {
case AssertionNode::AT_END:
- stream()->Add("label=\"$\", shape=septagon");
+ os_ << "label=\"$\", shape=septagon";
break;
case AssertionNode::AT_START:
- stream()->Add("label=\"^\", shape=septagon");
+ os_ << "label=\"^\", shape=septagon";
break;
case AssertionNode::AT_BOUNDARY:
- stream()->Add("label=\"\\b\", shape=septagon");
+ os_ << "label=\"\\b\", shape=septagon";
break;
case AssertionNode::AT_NON_BOUNDARY:
- stream()->Add("label=\"\\B\", shape=septagon");
+ os_ << "label=\"\\B\", shape=septagon";
break;
case AssertionNode::AFTER_NEWLINE:
- stream()->Add("label=\"(?<=\\n)\", shape=septagon");
+ os_ << "label=\"(?<=\\n)\", shape=septagon";
break;
}
- stream()->Add("];\n");
+ os_ << "];\n";
PrintAttributes(that);
RegExpNode* successor = that->on_success();
- stream()->Add(" n%p -> n%p;\n", that, successor);
+ os_ << " n" << that << " -> n" << successor << ";\n";
Visit(successor);
}
void DotPrinter::VisitAction(ActionNode* that) {
- stream()->Add(" n%p [", that);
+ os_ << " n" << that << " [";
switch (that->action_type_) {
case ActionNode::SET_REGISTER:
- stream()->Add("label=\"$%i:=%i\", shape=octagon",
- that->data_.u_store_register.reg,
- that->data_.u_store_register.value);
+ os_ << "label=\"$" << that->data_.u_store_register.reg
+ << ":=" << that->data_.u_store_register.value << "\", shape=octagon";
break;
case ActionNode::INCREMENT_REGISTER:
- stream()->Add("label=\"$%i++\", shape=octagon",
- that->data_.u_increment_register.reg);
+ os_ << "label=\"$" << that->data_.u_increment_register.reg
+ << "++\", shape=octagon";
break;
case ActionNode::STORE_POSITION:
- stream()->Add("label=\"$%i:=$pos\", shape=octagon",
- that->data_.u_position_register.reg);
+ os_ << "label=\"$" << that->data_.u_position_register.reg
+ << ":=$pos\", shape=octagon";
break;
case ActionNode::BEGIN_SUBMATCH:
- stream()->Add("label=\"$%i:=$pos,begin\", shape=septagon",
- that->data_.u_submatch.current_position_register);
+ os_ << "label=\"$" << that->data_.u_submatch.current_position_register
+ << ":=$pos,begin\", shape=septagon";
break;
case ActionNode::POSITIVE_SUBMATCH_SUCCESS:
- stream()->Add("label=\"escape\", shape=septagon");
+ os_ << "label=\"escape\", shape=septagon";
break;
case ActionNode::EMPTY_MATCH_CHECK:
- stream()->Add("label=\"$%i=$pos?,$%i<%i?\", shape=septagon",
- that->data_.u_empty_match_check.start_register,
- that->data_.u_empty_match_check.repetition_register,
- that->data_.u_empty_match_check.repetition_limit);
+ os_ << "label=\"$" << that->data_.u_empty_match_check.start_register
+ << "=$pos?,$" << that->data_.u_empty_match_check.repetition_register
+ << "<" << that->data_.u_empty_match_check.repetition_limit
+ << "?\", shape=septagon";
break;
case ActionNode::CLEAR_CAPTURES: {
- stream()->Add("label=\"clear $%i to $%i\", shape=septagon",
- that->data_.u_clear_captures.range_from,
- that->data_.u_clear_captures.range_to);
+ os_ << "label=\"clear $" << that->data_.u_clear_captures.range_from
+ << " to $" << that->data_.u_clear_captures.range_to
+ << "\", shape=septagon";
break;
}
}
- stream()->Add("];\n");
+ os_ << "];\n";
PrintAttributes(that);
RegExpNode* successor = that->on_success();
- stream()->Add(" n%p -> n%p;\n", that, successor);
+ os_ << " n" << that << " -> n" << successor << ";\n";
Visit(successor);
}
class DispatchTableDumper {
public:
- explicit DispatchTableDumper(StringStream* stream) : stream_(stream) { }
+ explicit DispatchTableDumper(OStream& os) : os_(os) {}
void Call(uc16 key, DispatchTable::Entry entry);
- StringStream* stream() { return stream_; }
private:
- StringStream* stream_;
+ OStream& os_;
};
void DispatchTableDumper::Call(uc16 key, DispatchTable::Entry entry) {
- stream()->Add("[%k-%k]: {", key, entry.to());
+ os_ << "[" << AsUC16(key) << "-" << AsUC16(entry.to()) << "]: {";
OutSet* set = entry.out_set();
bool first = true;
for (unsigned i = 0; i < OutSet::kFirstLimit; i++) {
if (first) {
first = false;
} else {
- stream()->Add(", ");
+ os_ << ", ";
}
- stream()->Add("%i", i);
+ os_ << i;
}
}
- stream()->Add("}\n");
+ os_ << "}\n";
}
void DispatchTable::Dump() {
- HeapStringAllocator alloc;
- StringStream stream(&alloc);
- DispatchTableDumper dumper(&stream);
+ OFStream os(stderr);
+ DispatchTableDumper dumper(os);
tree()->ForEach(&dumper);
- base::OS::PrintError("%s", stream.ToCString().get());
}
void RegExpEngine::DotPrint(const char* label,
RegExpNode* node,
bool ignore_case) {
- DotPrinter printer(ignore_case);
+ OFStream os(stdout);
+ DotPrinter printer(os, ignore_case);
printer.PrintNode(label, node);
}
for (int i = 0; i < number_of_descriptors(); i++) {
Name* key = GetSortedKey(i);
if (key == current_key) {
- PrintDescriptors();
+ OFStream os(stdout);
+ PrintDescriptors(os);
return false;
}
current_key = key;
uint32_t hash = GetSortedKey(i)->Hash();
if (hash < current) {
- PrintDescriptors();
+ OFStream os(stdout);
+ PrintDescriptors(os);
return false;
}
current = hash;
for (int i = 0; i < number_of_transitions(); i++) {
Name* key = GetSortedKey(i);
if (key == current_key) {
- PrintTransitions();
+ OFStream os(stdout);
+ PrintTransitions(os);
return false;
}
current_key = key;
uint32_t hash = GetSortedKey(i)->Hash();
if (hash < current) {
- PrintTransitions();
+ OFStream os(stdout);
+ PrintTransitions(os);
return false;
}
current = hash;
}
-int SharedFunctionInfo::start_position() {
+int SharedFunctionInfo::start_position() const {
return start_position_and_type() >> kStartPositionShift;
}
#ifdef OBJECT_PRINT
void Object::Print() {
- Print(stdout);
+ OFStream os(stdout);
+ this->Print(os);
+ os << flush;
}
-void Object::Print(FILE* out) {
+void Object::Print(OStream& os) { // NOLINT
if (IsSmi()) {
- Smi::cast(this)->SmiPrint(out);
+ Smi::cast(this)->SmiPrint(os);
} else {
- HeapObject::cast(this)->HeapObjectPrint(out);
+ HeapObject::cast(this)->HeapObjectPrint(os);
}
- Flush(out);
}
-void Object::PrintLn() {
- PrintLn(stdout);
+void HeapObject::PrintHeader(OStream& os, const char* id) { // NOLINT
+ os << "" << reinterpret_cast<void*>(this) << ": [" << id << "]\n";
}
-void Object::PrintLn(FILE* out) {
- Print(out);
- PrintF(out, "\n");
-}
-
-
-void HeapObject::PrintHeader(FILE* out, const char* id) {
- PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id);
-}
-
-
-void HeapObject::HeapObjectPrint(FILE* out) {
+void HeapObject::HeapObjectPrint(OStream& os) { // NOLINT
InstanceType instance_type = map()->instance_type();
HandleScope scope(GetIsolate());
if (instance_type < FIRST_NONSTRING_TYPE) {
- String::cast(this)->StringPrint(out);
+ String::cast(this)->StringPrint(os);
return;
}
switch (instance_type) {
case SYMBOL_TYPE:
- Symbol::cast(this)->SymbolPrint(out);
+ Symbol::cast(this)->SymbolPrint(os);
break;
case MAP_TYPE:
- Map::cast(this)->MapPrint(out);
+ Map::cast(this)->MapPrint(os);
break;
case HEAP_NUMBER_TYPE:
- HeapNumber::cast(this)->HeapNumberPrint(out);
+ HeapNumber::cast(this)->HeapNumberPrint(os);
break;
case MUTABLE_HEAP_NUMBER_TYPE:
- PrintF(out, "<mutable ");
- HeapNumber::cast(this)->HeapNumberPrint(out);
- PrintF(out, ">");
+ os << "<mutable ";
+ HeapNumber::cast(this)->HeapNumberPrint(os);
+ os << ">";
break;
case FIXED_DOUBLE_ARRAY_TYPE:
- FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(out);
+ FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(os);
break;
case CONSTANT_POOL_ARRAY_TYPE:
- ConstantPoolArray::cast(this)->ConstantPoolArrayPrint(out);
+ ConstantPoolArray::cast(this)->ConstantPoolArrayPrint(os);
break;
case FIXED_ARRAY_TYPE:
- FixedArray::cast(this)->FixedArrayPrint(out);
+ FixedArray::cast(this)->FixedArrayPrint(os);
break;
case BYTE_ARRAY_TYPE:
- ByteArray::cast(this)->ByteArrayPrint(out);
+ ByteArray::cast(this)->ByteArrayPrint(os);
break;
case FREE_SPACE_TYPE:
- FreeSpace::cast(this)->FreeSpacePrint(out);
+ FreeSpace::cast(this)->FreeSpacePrint(os);
break;
-#define PRINT_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \
- case EXTERNAL_##TYPE##_ARRAY_TYPE: \
- External##Type##Array::cast(this)->External##Type##ArrayPrint(out); \
- break;
+#define PRINT_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \
+ case EXTERNAL_##TYPE##_ARRAY_TYPE: \
+ External##Type##Array::cast(this)->External##Type##ArrayPrint(os); \
+ break;
TYPED_ARRAYS(PRINT_EXTERNAL_ARRAY)
#undef PRINT_EXTERNAL_ARRAY
-#define PRINT_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
- case Fixed##Type##Array::kInstanceType: \
- Fixed##Type##Array::cast(this)->FixedTypedArrayPrint(out); \
- break;
+#define PRINT_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
+ case Fixed##Type##Array::kInstanceType: \
+ Fixed##Type##Array::cast(this)->FixedTypedArrayPrint(os); \
+ break;
TYPED_ARRAYS(PRINT_FIXED_TYPED_ARRAY)
#undef PRINT_FIXED_TYPED_ARRAY
case FILLER_TYPE:
- PrintF(out, "filler");
+ os << "filler";
break;
case JS_OBJECT_TYPE: // fall through
case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
case JS_ARRAY_TYPE:
case JS_GENERATOR_OBJECT_TYPE:
case JS_REGEXP_TYPE:
- JSObject::cast(this)->JSObjectPrint(out);
+ JSObject::cast(this)->JSObjectPrint(os);
break;
case ODDBALL_TYPE:
- Oddball::cast(this)->to_string()->Print(out);
+ Oddball::cast(this)->to_string()->Print(os);
break;
case JS_MODULE_TYPE:
- JSModule::cast(this)->JSModulePrint(out);
+ JSModule::cast(this)->JSModulePrint(os);
break;
case JS_FUNCTION_TYPE:
- JSFunction::cast(this)->JSFunctionPrint(out);
+ JSFunction::cast(this)->JSFunctionPrint(os);
break;
case JS_GLOBAL_PROXY_TYPE:
- JSGlobalProxy::cast(this)->JSGlobalProxyPrint(out);
+ JSGlobalProxy::cast(this)->JSGlobalProxyPrint(os);
break;
case JS_GLOBAL_OBJECT_TYPE:
- JSGlobalObject::cast(this)->JSGlobalObjectPrint(out);
+ JSGlobalObject::cast(this)->JSGlobalObjectPrint(os);
break;
case JS_BUILTINS_OBJECT_TYPE:
- JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out);
+ JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(os);
break;
case JS_VALUE_TYPE:
- PrintF(out, "Value wrapper around:");
- JSValue::cast(this)->value()->Print(out);
+ os << "Value wrapper around:";
+ JSValue::cast(this)->value()->Print(os);
break;
case JS_DATE_TYPE:
- JSDate::cast(this)->JSDatePrint(out);
+ JSDate::cast(this)->JSDatePrint(os);
break;
case CODE_TYPE:
- Code::cast(this)->CodePrint(out);
+ Code::cast(this)->CodePrint(os);
break;
case JS_PROXY_TYPE:
- JSProxy::cast(this)->JSProxyPrint(out);
+ JSProxy::cast(this)->JSProxyPrint(os);
break;
case JS_FUNCTION_PROXY_TYPE:
- JSFunctionProxy::cast(this)->JSFunctionProxyPrint(out);
+ JSFunctionProxy::cast(this)->JSFunctionProxyPrint(os);
break;
case JS_SET_TYPE:
- JSSet::cast(this)->JSSetPrint(out);
+ JSSet::cast(this)->JSSetPrint(os);
break;
case JS_MAP_TYPE:
- JSMap::cast(this)->JSMapPrint(out);
+ JSMap::cast(this)->JSMapPrint(os);
break;
case JS_SET_ITERATOR_TYPE:
- JSSetIterator::cast(this)->JSSetIteratorPrint(out);
+ JSSetIterator::cast(this)->JSSetIteratorPrint(os);
break;
case JS_MAP_ITERATOR_TYPE:
- JSMapIterator::cast(this)->JSMapIteratorPrint(out);
+ JSMapIterator::cast(this)->JSMapIteratorPrint(os);
break;
case JS_WEAK_MAP_TYPE:
- JSWeakMap::cast(this)->JSWeakMapPrint(out);
+ JSWeakMap::cast(this)->JSWeakMapPrint(os);
break;
case JS_WEAK_SET_TYPE:
- JSWeakSet::cast(this)->JSWeakSetPrint(out);
+ JSWeakSet::cast(this)->JSWeakSetPrint(os);
break;
case FOREIGN_TYPE:
- Foreign::cast(this)->ForeignPrint(out);
+ Foreign::cast(this)->ForeignPrint(os);
break;
case SHARED_FUNCTION_INFO_TYPE:
- SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out);
+ SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(os);
break;
case JS_MESSAGE_OBJECT_TYPE:
- JSMessageObject::cast(this)->JSMessageObjectPrint(out);
+ JSMessageObject::cast(this)->JSMessageObjectPrint(os);
break;
case CELL_TYPE:
- Cell::cast(this)->CellPrint(out);
+ Cell::cast(this)->CellPrint(os);
break;
case PROPERTY_CELL_TYPE:
- PropertyCell::cast(this)->PropertyCellPrint(out);
+ PropertyCell::cast(this)->PropertyCellPrint(os);
break;
case JS_ARRAY_BUFFER_TYPE:
- JSArrayBuffer::cast(this)->JSArrayBufferPrint(out);
+ JSArrayBuffer::cast(this)->JSArrayBufferPrint(os);
break;
case JS_TYPED_ARRAY_TYPE:
- JSTypedArray::cast(this)->JSTypedArrayPrint(out);
+ JSTypedArray::cast(this)->JSTypedArrayPrint(os);
break;
case JS_DATA_VIEW_TYPE:
- JSDataView::cast(this)->JSDataViewPrint(out);
+ JSDataView::cast(this)->JSDataViewPrint(os);
break;
#define MAKE_STRUCT_CASE(NAME, Name, name) \
case NAME##_TYPE: \
- Name::cast(this)->Name##Print(out); \
+ Name::cast(this)->Name##Print(os); \
break;
STRUCT_LIST(MAKE_STRUCT_CASE)
#undef MAKE_STRUCT_CASE
default:
- PrintF(out, "UNKNOWN TYPE %d", map()->instance_type());
+ os << "UNKNOWN TYPE " << map()->instance_type();
UNREACHABLE();
break;
}
}
-void ByteArray::ByteArrayPrint(FILE* out) {
- PrintF(out, "byte array, data starts at %p", GetDataStartAddress());
+void ByteArray::ByteArrayPrint(OStream& os) { // NOLINT
+ os << "byte array, data starts at " << GetDataStartAddress();
}
-void FreeSpace::FreeSpacePrint(FILE* out) {
- PrintF(out, "free space, size %d", Size());
+void FreeSpace::FreeSpacePrint(OStream& os) { // NOLINT
+ os << "free space, size " << Size();
}
-#define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size) \
- void External##Type##Array::External##Type##ArrayPrint(FILE* out) { \
- PrintF(out, "external " #type " array"); \
+#define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size) \
+ void External##Type##Array::External##Type##ArrayPrint(OStream& os) { \
+ os << "external " #type " array"; \
}
TYPED_ARRAYS(EXTERNAL_ARRAY_PRINTER)
template <class Traits>
-void FixedTypedArray<Traits>::FixedTypedArrayPrint(FILE* out) {
- PrintF(out, "fixed %s", Traits::Designator());
+void FixedTypedArray<Traits>::FixedTypedArrayPrint(OStream& os) { // NOLINT
+ os << "fixed " << Traits::Designator();
}
-void JSObject::PrintProperties(FILE* out) {
+void JSObject::PrintProperties(OStream& os) { // NOLINT
if (HasFastProperties()) {
DescriptorArray* descs = map()->instance_descriptors();
for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) {
- PrintF(out, " ");
- descs->GetKey(i)->NamePrint(out);
- PrintF(out, ": ");
+ os << " ";
+ descs->GetKey(i)->NamePrint(os);
+ os << ": ";
switch (descs->GetType(i)) {
case FIELD: {
FieldIndex index = FieldIndex::ForDescriptor(map(), i);
- RawFastPropertyAt(index)->ShortPrint(out);
- PrintF(out, " (field at offset %d)\n", index.property_index());
+ os << Brief(RawFastPropertyAt(index)) << " (field at offset "
+ << index.property_index() << ")\n";
break;
}
case CONSTANT:
- descs->GetConstant(i)->ShortPrint(out);
- PrintF(out, " (constant)\n");
+ os << Brief(descs->GetConstant(i)) << " (constant)\n";
break;
case CALLBACKS:
- descs->GetCallbacksObject(i)->ShortPrint(out);
- PrintF(out, " (callback)\n");
+ os << Brief(descs->GetCallbacksObject(i)) << " (callback)\n";
break;
case NORMAL: // only in slow mode
case HANDLER: // only in lookup results, not in descriptors
}
}
} else {
- property_dictionary()->Print(out);
+ property_dictionary()->Print(os);
}
}
-template<class T>
-static void DoPrintElements(FILE *out, Object* object) {
+template <class T>
+static void DoPrintElements(OStream& os, Object* object) { // NOLINT
T* p = T::cast(object);
for (int i = 0; i < p->length(); i++) {
- PrintF(out, " %d: %d\n", i, p->get_scalar(i));
+ os << " " << i << ": " << p->get_scalar(i) << "\n";
}
}
-template<class T>
-static void DoPrintDoubleElements(FILE* out, Object* object) {
- T* p = T::cast(object);
- for (int i = 0; i < p->length(); i++) {
- PrintF(out, " %d: %f\n", i, p->get_scalar(i));
- }
-}
-
-
-void JSObject::PrintElements(FILE* out) {
+void JSObject::PrintElements(OStream& os) { // NOLINT
// Don't call GetElementsKind, its validation code can cause the printer to
// fail when debugging.
switch (map()->elements_kind()) {
// Print in array notation for non-sparse arrays.
FixedArray* p = FixedArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
- PrintF(out, " %d: ", i);
- p->get(i)->ShortPrint(out);
- PrintF(out, "\n");
+ os << " " << i << ": " << Brief(p->get(i)) << "\n";
}
break;
}
if (elements()->length() > 0) {
FixedDoubleArray* p = FixedDoubleArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
+ os << " " << i << ": ";
if (p->is_the_hole(i)) {
- PrintF(out, " %d: <the hole>", i);
+ os << "<the hole>";
} else {
- PrintF(out, " %d: %g", i, p->get_scalar(i));
+ os << p->get_scalar(i);
}
- PrintF(out, "\n");
+ os << "\n";
}
}
break;
}
-#define PRINT_ELEMENTS(Kind, Type) \
- case Kind: { \
- DoPrintElements<Type>(out, elements()); \
- break; \
- }
-
-#define PRINT_DOUBLE_ELEMENTS(Kind, Type) \
- case Kind: { \
- DoPrintDoubleElements<Type>(out, elements()); \
- break; \
- }
+#define PRINT_ELEMENTS(Kind, Type) \
+ case Kind: { \
+ DoPrintElements<Type>(os, elements()); \
+ break; \
+ }
PRINT_ELEMENTS(EXTERNAL_UINT8_CLAMPED_ELEMENTS, ExternalUint8ClampedArray)
PRINT_ELEMENTS(EXTERNAL_INT8_ELEMENTS, ExternalInt8Array)
PRINT_ELEMENTS(EXTERNAL_INT32_ELEMENTS, ExternalInt32Array)
PRINT_ELEMENTS(EXTERNAL_UINT32_ELEMENTS,
ExternalUint32Array)
- PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT32_ELEMENTS, ExternalFloat32Array)
- PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT64_ELEMENTS, ExternalFloat64Array)
-
+ PRINT_ELEMENTS(EXTERNAL_FLOAT32_ELEMENTS, ExternalFloat32Array)
+ PRINT_ELEMENTS(EXTERNAL_FLOAT64_ELEMENTS, ExternalFloat64Array)
PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array)
PRINT_ELEMENTS(UINT8_CLAMPED_ELEMENTS, FixedUint8ClampedArray)
PRINT_ELEMENTS(INT16_ELEMENTS, FixedInt16Array)
PRINT_ELEMENTS(UINT32_ELEMENTS, FixedUint32Array)
PRINT_ELEMENTS(INT32_ELEMENTS, FixedInt32Array)
- PRINT_DOUBLE_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array)
- PRINT_DOUBLE_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array)
+ PRINT_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array)
+ PRINT_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array)
-#undef PRINT_DOUBLE_ELEMENTS
#undef PRINT_ELEMENTS
case DICTIONARY_ELEMENTS:
- elements()->Print(out);
+ elements()->Print(os);
break;
case SLOPPY_ARGUMENTS_ELEMENTS: {
FixedArray* p = FixedArray::cast(elements());
- PrintF(out, " parameter map:");
+ os << " parameter map:";
for (int i = 2; i < p->length(); i++) {
- PrintF(out, " %d:", i - 2);
- p->get(i)->ShortPrint(out);
+ os << " " << (i - 2) << ":" << Brief(p->get(i));
}
- PrintF(out, "\n context: ");
- p->get(0)->ShortPrint(out);
- PrintF(out, "\n arguments: ");
- p->get(1)->ShortPrint(out);
- PrintF(out, "\n");
+ os << "\n context: " << Brief(p->get(0))
+ << "\n arguments: " << Brief(p->get(1)) << "\n";
break;
}
}
}
-void JSObject::PrintTransitions(FILE* out) {
+void JSObject::PrintTransitions(OStream& os) { // NOLINT
if (!map()->HasTransitionArray()) return;
TransitionArray* transitions = map()->transitions();
for (int i = 0; i < transitions->number_of_transitions(); i++) {
Name* key = transitions->GetKey(i);
- PrintF(out, " ");
- key->NamePrint(out);
- PrintF(out, ": ");
+ os << " ";
+ key->NamePrint(os);
+ os << ": ";
if (key == GetHeap()->frozen_symbol()) {
- PrintF(out, " (transition to frozen)\n");
+ os << " (transition to frozen)\n";
} else if (key == GetHeap()->elements_transition_symbol()) {
- PrintF(out, " (transition to ");
- PrintElementsKind(out, transitions->GetTarget(i)->elements_kind());
- PrintF(out, ")\n");
+ os << " (transition to "
+ << ElementsKindToString(transitions->GetTarget(i)->elements_kind())
+ << ")\n";
} else if (key == GetHeap()->observed_symbol()) {
- PrintF(out, " (transition to Object.observe)\n");
+ os << " (transition to Object.observe)\n";
} else {
switch (transitions->GetTargetDetails(i).type()) {
case FIELD: {
- PrintF(out, " (transition to field)\n");
+ os << " (transition to field)\n";
break;
}
case CONSTANT:
- PrintF(out, " (transition to constant)\n");
+ os << " (transition to constant)\n";
break;
case CALLBACKS:
- PrintF(out, " (transition to callback)\n");
+ os << " (transition to callback)\n";
break;
// Values below are never in the target descriptor array.
case NORMAL:
}
-void JSObject::JSObjectPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSObject");
- PrintF(out, " - map = %p [", reinterpret_cast<void*>(map()));
+void JSObject::JSObjectPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSObject");
// Don't call GetElementsKind, its validation code can cause the printer to
// fail when debugging.
- PrintElementsKind(out, this->map()->elements_kind());
- PrintF(out,
- "]\n - prototype = %p\n",
- reinterpret_cast<void*>(GetPrototype()));
- PrintF(out, " {\n");
- PrintProperties(out);
- PrintTransitions(out);
- PrintElements(out);
- PrintF(out, " }\n");
+ os << " - map = " << reinterpret_cast<void*>(map()) << " ["
+ << ElementsKindToString(this->map()->elements_kind())
+ << "]\n - prototype = " << reinterpret_cast<void*>(GetPrototype()) << "\n"
+ << " {\n";
+ PrintProperties(os);
+ PrintTransitions(os);
+ PrintElements(os);
+ os << " }\n";
}
-void JSModule::JSModulePrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSModule");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - context = ");
- context()->Print(out);
- PrintF(out, " - scope_info = ");
- scope_info()->ShortPrint(out);
- PrintElementsKind(out, this->map()->elements_kind());
- PrintF(out, " {\n");
- PrintProperties(out);
- PrintElements(out);
- PrintF(out, " }\n");
+void JSModule::JSModulePrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSModule");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n"
+ << " - context = ";
+ context()->Print(os);
+ os << " - scope_info = " << Brief(scope_info())
+ << ElementsKindToString(this->map()->elements_kind()) << " {\n";
+ PrintProperties(os);
+ PrintElements(os);
+ os << " }\n";
}
}
-void Symbol::SymbolPrint(FILE* out) {
- HeapObject::PrintHeader(out, "Symbol");
- PrintF(out, " - hash: %d\n", Hash());
- PrintF(out, " - name: ");
- name()->ShortPrint();
- PrintF(out, " - private: %d\n", is_private());
- PrintF(out, "\n");
+void Symbol::SymbolPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "Symbol");
+ os << " - hash: " << Hash();
+ os << "\n - name: " << Brief(name());
+ os << " - private: " << is_private();
+ os << "\n";
}
-void Map::MapPrint(FILE* out) {
- HeapObject::PrintHeader(out, "Map");
- PrintF(out, " - type: %s\n", TypeToString(instance_type()));
- PrintF(out, " - instance size: %d\n", instance_size());
- PrintF(out, " - inobject properties: %d\n", inobject_properties());
- PrintF(out, " - elements kind: ");
- PrintElementsKind(out, elements_kind());
- PrintF(out, "\n - pre-allocated property fields: %d\n",
- pre_allocated_property_fields());
- PrintF(out, " - unused property fields: %d\n", unused_property_fields());
- if (is_hidden_prototype()) {
- PrintF(out, " - hidden_prototype\n");
- }
- if (has_named_interceptor()) {
- PrintF(out, " - named_interceptor\n");
- }
- if (has_indexed_interceptor()) {
- PrintF(out, " - indexed_interceptor\n");
- }
- if (is_undetectable()) {
- PrintF(out, " - undetectable\n");
- }
- if (has_instance_call_handler()) {
- PrintF(out, " - instance_call_handler\n");
- }
- if (is_access_check_needed()) {
- PrintF(out, " - access_check_needed\n");
- }
+void Map::MapPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "Map");
+ os << " - type: " << TypeToString(instance_type()) << "\n";
+ os << " - instance size: " << instance_size() << "\n";
+ os << " - inobject properties: " << inobject_properties() << "\n";
+ os << " - elements kind: " << ElementsKindToString(elements_kind());
+ os << "\n - pre-allocated property fields: "
+ << pre_allocated_property_fields() << "\n";
+ os << " - unused property fields: " << unused_property_fields() << "\n";
+ if (is_hidden_prototype()) os << " - hidden_prototype\n";
+ if (has_named_interceptor()) os << " - named_interceptor\n";
+ if (has_indexed_interceptor()) os << " - indexed_interceptor\n";
+ if (is_undetectable()) os << " - undetectable\n";
+ if (has_instance_call_handler()) os << " - instance_call_handler\n";
+ if (is_access_check_needed()) os << " - access_check_needed\n";
if (is_frozen()) {
- PrintF(out, " - frozen\n");
+ os << " - frozen\n";
} else if (!is_extensible()) {
- PrintF(out, " - sealed\n");
+ os << " - sealed\n";
}
- PrintF(out, " - back pointer: ");
- GetBackPointer()->ShortPrint(out);
- PrintF(out, "\n - instance descriptors %s#%i: ",
- owns_descriptors() ? "(own) " : "",
- NumberOfOwnDescriptors());
- instance_descriptors()->ShortPrint(out);
+ os << " - back pointer: " << Brief(GetBackPointer());
+ os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "")
+ << "#" << NumberOfOwnDescriptors() << ": "
+ << Brief(instance_descriptors());
if (HasTransitionArray()) {
- PrintF(out, "\n - transitions: ");
- transitions()->ShortPrint(out);
+ os << "\n - transitions: " << Brief(transitions());
}
- PrintF(out, "\n - prototype: ");
- prototype()->ShortPrint(out);
- PrintF(out, "\n - constructor: ");
- constructor()->ShortPrint(out);
- PrintF(out, "\n - code cache: ");
- code_cache()->ShortPrint(out);
- PrintF(out, "\n - dependent code: ");
- dependent_code()->ShortPrint(out);
- PrintF(out, "\n");
+ os << "\n - prototype: " << Brief(prototype());
+ os << "\n - constructor: " << Brief(constructor());
+ os << "\n - code cache: " << Brief(code_cache());
+ os << "\n - dependent code: " << Brief(dependent_code());
+ os << "\n";
}
-void CodeCache::CodeCachePrint(FILE* out) {
- HeapObject::PrintHeader(out, "CodeCache");
- PrintF(out, "\n - default_cache: ");
- default_cache()->ShortPrint(out);
- PrintF(out, "\n - normal_type_cache: ");
- normal_type_cache()->ShortPrint(out);
+void CodeCache::CodeCachePrint(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(FILE* out) {
- HeapObject::PrintHeader(out, "PolymorphicCodeCache");
- PrintF(out, "\n - cache: ");
- cache()->ShortPrint(out);
+void PolymorphicCodeCache::PolymorphicCodeCachePrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "PolymorphicCodeCache");
+ os << "\n - cache: " << Brief(cache());
}
-void TypeFeedbackInfo::TypeFeedbackInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "TypeFeedbackInfo");
- PrintF(out, " - ic_total_count: %d, ic_with_type_info_count: %d\n",
- ic_total_count(), ic_with_type_info_count());
+void TypeFeedbackInfo::TypeFeedbackInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "TypeFeedbackInfo");
+ os << " - ic_total_count: " << ic_total_count()
+ << ", ic_with_type_info_count: " << ic_with_type_info_count() << "\n";
}
-void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(FILE* out) {
- HeapObject::PrintHeader(out, "AliasedArgumentsEntry");
- PrintF(out, "\n - aliased_context_slot: %d", aliased_context_slot());
+void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "AliasedArgumentsEntry");
+ os << "\n - aliased_context_slot: " << aliased_context_slot();
}
-void FixedArray::FixedArrayPrint(FILE* out) {
- HeapObject::PrintHeader(out, "FixedArray");
- PrintF(out, " - length: %d", length());
+void FixedArray::FixedArrayPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "FixedArray");
+ os << " - length: " << length();
for (int i = 0; i < length(); i++) {
- PrintF(out, "\n [%d]: ", i);
- get(i)->ShortPrint(out);
+ os << "\n [" << i << "]: " << Brief(get(i));
}
- PrintF(out, "\n");
+ os << "\n";
}
-void FixedDoubleArray::FixedDoubleArrayPrint(FILE* out) {
- HeapObject::PrintHeader(out, "FixedDoubleArray");
- PrintF(out, " - length: %d", length());
+void FixedDoubleArray::FixedDoubleArrayPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "FixedDoubleArray");
+ os << " - length: " << length();
for (int i = 0; i < length(); i++) {
+ os << "\n [" << i << "]: ";
if (is_the_hole(i)) {
- PrintF(out, "\n [%d]: <the hole>", i);
+ os << "<the hole>";
} else {
- PrintF(out, "\n [%d]: %g", i, get_scalar(i));
+ os << get_scalar(i);
}
}
- PrintF(out, "\n");
+ os << "\n";
}
-void ConstantPoolArray::ConstantPoolArrayPrint(FILE* out) {
- HeapObject::PrintHeader(out, "ConstantPoolArray");
- PrintF(out, " - length: %d", length());
+void ConstantPoolArray::ConstantPoolArrayPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "ConstantPoolArray");
+ os << " - length: " << length();
for (int i = 0; i <= last_index(INT32, SMALL_SECTION); i++) {
if (i < last_index(INT64, SMALL_SECTION)) {
- PrintF(out, "\n [%d]: double: %g", i, get_int64_entry_as_double(i));
+ os << "\n [" << i << "]: double: " << get_int64_entry_as_double(i);
} else if (i <= last_index(CODE_PTR, SMALL_SECTION)) {
- PrintF(out, "\n [%d]: code target pointer: %p", i,
- reinterpret_cast<void*>(get_code_ptr_entry(i)));
+ os << "\n [" << i << "]: code target pointer: "
+ << reinterpret_cast<void*>(get_code_ptr_entry(i));
} else if (i <= last_index(HEAP_PTR, SMALL_SECTION)) {
- PrintF(out, "\n [%d]: heap pointer: %p", i,
- reinterpret_cast<void*>(get_heap_ptr_entry(i)));
+ os << "\n [" << i << "]: heap pointer: "
+ << reinterpret_cast<void*>(get_heap_ptr_entry(i));
} else if (i <= last_index(INT32, SMALL_SECTION)) {
- PrintF(out, "\n [%d]: int32: %d", i, get_int32_entry(i));
+ os << "\n [" << i << "]: int32: " << get_int32_entry(i);
}
}
if (is_extended_layout()) {
- PrintF(out, "\n Extended section:");
+ os << "\n Extended section:";
for (int i = first_extended_section_index();
i <= last_index(INT32, EXTENDED_SECTION); i++) {
- if (i < last_index(INT64, EXTENDED_SECTION)) {
- PrintF(out, "\n [%d]: double: %g", i, get_int64_entry_as_double(i));
- } else if (i <= last_index(CODE_PTR, EXTENDED_SECTION)) {
- PrintF(out, "\n [%d]: code target pointer: %p", i,
- reinterpret_cast<void*>(get_code_ptr_entry(i)));
- } else if (i <= last_index(HEAP_PTR, EXTENDED_SECTION)) {
- PrintF(out, "\n [%d]: heap pointer: %p", i,
- reinterpret_cast<void*>(get_heap_ptr_entry(i)));
- } else if (i <= last_index(INT32, EXTENDED_SECTION)) {
- PrintF(out, "\n [%d]: int32: %d", i, get_int32_entry(i));
+ if (i < last_index(INT64, EXTENDED_SECTION)) {
+ os << "\n [" << i << "]: double: " << get_int64_entry_as_double(i);
+ } else if (i <= last_index(CODE_PTR, EXTENDED_SECTION)) {
+ os << "\n [" << i << "]: code target pointer: "
+ << reinterpret_cast<void*>(get_code_ptr_entry(i));
+ } else if (i <= last_index(HEAP_PTR, EXTENDED_SECTION)) {
+ os << "\n [" << i << "]: heap pointer: "
+ << reinterpret_cast<void*>(get_heap_ptr_entry(i));
+ } else if (i <= last_index(INT32, EXTENDED_SECTION)) {
+ os << "\n [" << i << "]: int32: " << get_int32_entry(i);
+ }
}
}
- }
- PrintF(out, "\n");
+ os << "\n";
}
-void JSValue::JSValuePrint(FILE* out) {
- HeapObject::PrintHeader(out, "ValueObject");
- value()->Print(out);
+void JSValue::JSValuePrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "ValueObject");
+ value()->Print(os);
}
-void JSMessageObject::JSMessageObjectPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSMessageObject");
- PrintF(out, " - type: ");
- type()->ShortPrint(out);
- PrintF(out, "\n - arguments: ");
- arguments()->ShortPrint(out);
- PrintF(out, "\n - start_position: %d", start_position());
- PrintF(out, "\n - end_position: %d", end_position());
- PrintF(out, "\n - script: ");
- script()->ShortPrint(out);
- PrintF(out, "\n - stack_frames: ");
- stack_frames()->ShortPrint(out);
- PrintF(out, "\n");
+void JSMessageObject::JSMessageObjectPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSMessageObject");
+ os << " - type: " << Brief(type());
+ os << "\n - arguments: " << Brief(arguments());
+ os << "\n - start_position: " << start_position();
+ os << "\n - end_position: " << end_position();
+ os << "\n - script: " << Brief(script());
+ os << "\n - stack_frames: " << Brief(stack_frames());
+ os << "\n";
}
-void String::StringPrint(FILE* out) {
+void String::StringPrint(OStream& os) { // NOLINT
if (StringShape(this).IsInternalized()) {
- PrintF(out, "#");
+ os << "#";
} else if (StringShape(this).IsCons()) {
- PrintF(out, "c\"");
+ os << "c\"";
} else {
- PrintF(out, "\"");
+ os << "\"";
}
const char truncated_epilogue[] = "...<truncated>";
}
}
for (int i = 0; i < len; i++) {
- PrintF(out, "%c", Get(i));
+ os.put(Get(i));
}
if (len != length()) {
- PrintF(out, "%s", truncated_epilogue);
+ os << truncated_epilogue;
}
- if (!StringShape(this).IsInternalized()) PrintF(out, "\"");
+ if (!StringShape(this).IsInternalized()) os << "\"";
}
-void Name::NamePrint(FILE* out) {
+void Name::NamePrint(OStream& os) { // NOLINT
if (IsString())
- String::cast(this)->StringPrint(out);
+ String::cast(this)->StringPrint(os);
else
- ShortPrint();
+ os << Brief(this);
}
};
-void JSDate::JSDatePrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSDate");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - value = ");
- value()->Print(out);
+void JSDate::JSDatePrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSDate");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - value = ";
+ value()->Print(os);
if (!year()->IsSmi()) {
- PrintF(out, " - time = NaN\n");
+ os << " - time = NaN\n";
} else {
- PrintF(out, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
- weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0],
- year()->IsSmi() ? Smi::cast(year())->value() : -1,
- month()->IsSmi() ? Smi::cast(month())->value() : -1,
- day()->IsSmi() ? Smi::cast(day())->value() : -1,
- hour()->IsSmi() ? Smi::cast(hour())->value() : -1,
- min()->IsSmi() ? Smi::cast(min())->value() : -1,
- sec()->IsSmi() ? Smi::cast(sec())->value() : -1);
+ // TODO(svenpanne) Add some basic formatting to our streams.
+ Vector<char> buf = Vector<char>::New(100);
+ SNPrintF(
+ buf, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
+ weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0],
+ year()->IsSmi() ? Smi::cast(year())->value() : -1,
+ month()->IsSmi() ? Smi::cast(month())->value() : -1,
+ day()->IsSmi() ? Smi::cast(day())->value() : -1,
+ hour()->IsSmi() ? Smi::cast(hour())->value() : -1,
+ min()->IsSmi() ? Smi::cast(min())->value() : -1,
+ sec()->IsSmi() ? Smi::cast(sec())->value() : -1);
+ os << buf.start();
}
}
-void JSProxy::JSProxyPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSProxy");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - handler = ");
- handler()->Print(out);
- PrintF(out, "\n - hash = ");
- hash()->Print(out);
- PrintF(out, "\n");
+void JSProxy::JSProxyPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSProxy");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - handler = ";
+ handler()->Print(os);
+ os << "\n - hash = ";
+ hash()->Print(os);
+ os << "\n";
}
-void JSFunctionProxy::JSFunctionProxyPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSFunctionProxy");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - handler = ");
- handler()->Print(out);
- PrintF(out, "\n - call_trap = ");
- call_trap()->Print(out);
- PrintF(out, "\n - construct_trap = ");
- construct_trap()->Print(out);
- PrintF(out, "\n");
+void JSFunctionProxy::JSFunctionProxyPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSFunctionProxy");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - handler = ";
+ handler()->Print(os);
+ os << "\n - call_trap = ";
+ call_trap()->Print(os);
+ os << "\n - construct_trap = ";
+ construct_trap()->Print(os);
+ os << "\n";
}
-void JSSet::JSSetPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSSet");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - table = ");
- table()->ShortPrint(out);
- PrintF(out, "\n");
+void JSSet::JSSetPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSSet");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - table = " << Brief(table());
+ os << "\n";
}
-void JSMap::JSMapPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSMap");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - table = ");
- table()->ShortPrint(out);
- PrintF(out, "\n");
+void JSMap::JSMapPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSMap");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - table = " << Brief(table());
+ os << "\n";
}
-template<class Derived, class TableType>
-void OrderedHashTableIterator<Derived, TableType>::
- OrderedHashTableIteratorPrint(FILE* out) {
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - table = ");
- table()->ShortPrint(out);
- PrintF(out, "\n - index = ");
- index()->ShortPrint(out);
- PrintF(out, "\n - kind = ");
- kind()->ShortPrint(out);
- PrintF(out, "\n");
+template <class Derived, class TableType>
+void OrderedHashTableIterator<
+ Derived, TableType>::OrderedHashTableIteratorPrint(OStream& os) { // NOLINT
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - table = " << Brief(table());
+ os << "\n - index = " << Brief(index());
+ os << "\n - kind = " << Brief(kind());
+ os << "\n";
}
-template void
-OrderedHashTableIterator<JSSetIterator,
- OrderedHashSet>::OrderedHashTableIteratorPrint(FILE* out);
+template void OrderedHashTableIterator<
+ JSSetIterator,
+ OrderedHashSet>::OrderedHashTableIteratorPrint(OStream& os); // NOLINT
-template void
-OrderedHashTableIterator<JSMapIterator,
- OrderedHashMap>::OrderedHashTableIteratorPrint(FILE* out);
+template void OrderedHashTableIterator<
+ JSMapIterator,
+ OrderedHashMap>::OrderedHashTableIteratorPrint(OStream& os); // NOLINT
-void JSSetIterator::JSSetIteratorPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSSetIterator");
- OrderedHashTableIteratorPrint(out);
+void JSSetIterator::JSSetIteratorPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSSetIterator");
+ OrderedHashTableIteratorPrint(os);
}
-void JSMapIterator::JSMapIteratorPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSMapIterator");
- OrderedHashTableIteratorPrint(out);
+void JSMapIterator::JSMapIteratorPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSMapIterator");
+ OrderedHashTableIteratorPrint(os);
}
-void JSWeakMap::JSWeakMapPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSWeakMap");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - table = ");
- table()->ShortPrint(out);
- PrintF(out, "\n");
+void JSWeakMap::JSWeakMapPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSWeakMap");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - table = " << Brief(table());
+ os << "\n";
}
-void JSWeakSet::JSWeakSetPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSWeakSet");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - table = ");
- table()->ShortPrint(out);
- PrintF(out, "\n");
+void JSWeakSet::JSWeakSetPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSWeakSet");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - table = " << Brief(table());
+ os << "\n";
}
-void JSArrayBuffer::JSArrayBufferPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSArrayBuffer");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - backing_store = %p\n", backing_store());
- PrintF(out, " - byte_length = ");
- byte_length()->ShortPrint(out);
- PrintF(out, "\n");
+void JSArrayBuffer::JSArrayBufferPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSArrayBuffer");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - backing_store = " << backing_store() << "\n";
+ os << " - byte_length = " << Brief(byte_length());
+ os << "\n";
}
-void JSTypedArray::JSTypedArrayPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSTypedArray");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - buffer =");
- buffer()->ShortPrint(out);
- PrintF(out, "\n - byte_offset = ");
- byte_offset()->ShortPrint(out);
- PrintF(out, "\n - byte_length = ");
- byte_length()->ShortPrint(out);
- PrintF(out, "\n - length = ");
- length()->ShortPrint(out);
- PrintF(out, "\n");
- PrintElements(out);
+void JSTypedArray::JSTypedArrayPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSTypedArray");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - buffer =" << Brief(buffer());
+ os << "\n - byte_offset = " << Brief(byte_offset());
+ os << "\n - byte_length = " << Brief(byte_length());
+ os << "\n - length = " << Brief(length());
+ os << "\n";
+ PrintElements(os);
}
-void JSDataView::JSDataViewPrint(FILE* out) {
- HeapObject::PrintHeader(out, "JSDataView");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - buffer =");
- buffer()->ShortPrint(out);
- PrintF(out, "\n - byte_offset = ");
- byte_offset()->ShortPrint(out);
- PrintF(out, "\n - byte_length = ");
- byte_length()->ShortPrint(out);
- PrintF(out, "\n");
+void JSDataView::JSDataViewPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "JSDataView");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - buffer =" << Brief(buffer());
+ os << "\n - byte_offset = " << Brief(byte_offset());
+ os << "\n - byte_length = " << Brief(byte_length());
+ os << "\n";
}
-void JSFunction::JSFunctionPrint(FILE* out) {
- HeapObject::PrintHeader(out, "Function");
- PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
- PrintF(out, " - initial_map = ");
- if (has_initial_map()) {
- initial_map()->ShortPrint(out);
- }
- PrintF(out, "\n - shared_info = ");
- shared()->ShortPrint(out);
- PrintF(out, "\n - name = ");
- shared()->name()->Print(out);
- PrintF(out, "\n - context = ");
- context()->ShortPrint(out);
+void JSFunction::JSFunctionPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "Function");
+ os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
+ os << " - initial_map = ";
+ if (has_initial_map()) os << Brief(initial_map());
+ os << "\n - shared_info = " << Brief(shared());
+ os << "\n - name = " << Brief(shared()->name());
+ os << "\n - context = " << Brief(context());
if (shared()->bound()) {
- PrintF(out, "\n - bindings = ");
- function_bindings()->ShortPrint(out);
+ os << "\n - bindings = " << Brief(function_bindings());
} else {
- PrintF(out, "\n - literals = ");
- literals()->ShortPrint(out);
+ os << "\n - literals = " << Brief(literals());
}
- PrintF(out, "\n - code = ");
- code()->ShortPrint(out);
- PrintF(out, "\n");
-
- PrintProperties(out);
- PrintElements(out);
-
- PrintF(out, "\n");
-}
-
-
-void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "SharedFunctionInfo");
- PrintF(out, " - name: ");
- name()->ShortPrint(out);
- PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties());
- PrintF(out, "\n - ast_node_count: %d", ast_node_count());
- PrintF(out, "\n - instance class name = ");
- instance_class_name()->Print(out);
- PrintF(out, "\n - code = ");
- code()->ShortPrint(out);
+ os << "\n - code = " << Brief(code());
+ os << "\n";
+ PrintProperties(os);
+ PrintElements(os);
+ os << "\n";
+}
+
+
+void SharedFunctionInfo::SharedFunctionInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "SharedFunctionInfo");
+ os << " - name: " << Brief(name());
+ os << "\n - expected_nof_properties: " << expected_nof_properties();
+ os << "\n - ast_node_count: " << ast_node_count();
+ os << "\n - instance class name = ";
+ instance_class_name()->Print(os);
+ os << "\n - code = " << Brief(code());
if (HasSourceCode()) {
- PrintF(out, "\n - source code = ");
+ os << "\n - source code = ";
String* source = String::cast(Script::cast(script())->source());
int start = start_position();
int length = end_position() - start;
source->ToCString(DISALLOW_NULLS,
FAST_STRING_TRAVERSAL,
start, length, NULL);
- PrintF(out, "%s", source_string.get());
+ os << source_string.get();
}
// Script files are often large, hard to read.
- // PrintF(out, "\n - script =");
- // script()->Print(out);
- PrintF(out, "\n - function token position = %d", function_token_position());
- PrintF(out, "\n - start position = %d", start_position());
- PrintF(out, "\n - end position = %d", end_position());
- PrintF(out, "\n - is expression = %d", is_expression());
- PrintF(out, "\n - debug info = ");
- debug_info()->ShortPrint(out);
- PrintF(out, "\n - length = %d", length());
- PrintF(out, "\n - optimized_code_map = ");
- optimized_code_map()->ShortPrint(out);
- PrintF(out, "\n - feedback_vector = ");
- feedback_vector()->FixedArrayPrint(out);
- PrintF(out, "\n");
+ // os << "\n - script =";
+ // script()->Print(os);
+ os << "\n - function token position = " << function_token_position();
+ os << "\n - start position = " << start_position();
+ os << "\n - end position = " << end_position();
+ os << "\n - is expression = " << is_expression();
+ os << "\n - debug info = " << Brief(debug_info());
+ os << "\n - length = " << length();
+ os << "\n - optimized_code_map = " << Brief(optimized_code_map());
+ os << "\n - feedback_vector = ";
+ feedback_vector()->FixedArrayPrint(os);
+ os << "\n";
}
-void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) {
- PrintF(out, "global_proxy ");
- JSObjectPrint(out);
- PrintF(out, "native context : ");
- native_context()->ShortPrint(out);
- PrintF(out, "\n");
+void JSGlobalProxy::JSGlobalProxyPrint(OStream& os) { // NOLINT
+ os << "global_proxy ";
+ JSObjectPrint(os);
+ os << "native context : " << Brief(native_context());
+ os << "\n";
}
-void JSGlobalObject::JSGlobalObjectPrint(FILE* out) {
- PrintF(out, "global ");
- JSObjectPrint(out);
- PrintF(out, "native context : ");
- native_context()->ShortPrint(out);
- PrintF(out, "\n");
+void JSGlobalObject::JSGlobalObjectPrint(OStream& os) { // NOLINT
+ os << "global ";
+ JSObjectPrint(os);
+ os << "native context : " << Brief(native_context());
+ os << "\n";
}
-void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) {
- PrintF(out, "builtins ");
- JSObjectPrint(out);
+void JSBuiltinsObject::JSBuiltinsObjectPrint(OStream& os) { // NOLINT
+ os << "builtins ";
+ JSObjectPrint(os);
}
-void Cell::CellPrint(FILE* out) {
- HeapObject::PrintHeader(out, "Cell");
+void Cell::CellPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "Cell");
}
-void PropertyCell::PropertyCellPrint(FILE* out) {
- HeapObject::PrintHeader(out, "PropertyCell");
+void PropertyCell::PropertyCellPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "PropertyCell");
}
-void Code::CodePrint(FILE* out) {
- HeapObject::PrintHeader(out, "Code");
+void Code::CodePrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "Code");
#ifdef ENABLE_DISASSEMBLER
if (FLAG_use_verbose_printer) {
- Disassemble(NULL, out);
+ Disassemble(NULL, os);
}
#endif
}
-void Foreign::ForeignPrint(FILE* out) {
- PrintF(out, "foreign address : %p", foreign_address());
+void Foreign::ForeignPrint(OStream& os) { // NOLINT
+ os << "foreign address : " << foreign_address();
}
-void ExecutableAccessorInfo::ExecutableAccessorInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "ExecutableAccessorInfo");
- PrintF(out, "\n - name: ");
- name()->ShortPrint(out);
- PrintF(out, "\n - flag: ");
- flag()->ShortPrint(out);
- PrintF(out, "\n - getter: ");
- getter()->ShortPrint(out);
- PrintF(out, "\n - setter: ");
- setter()->ShortPrint(out);
- PrintF(out, "\n - data: ");
- data()->ShortPrint(out);
+void ExecutableAccessorInfo::ExecutableAccessorInfoPrint(
+ OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "ExecutableAccessorInfo");
+ os << "\n - name: " << Brief(name());
+ os << "\n - flag: " << Brief(flag());
+ os << "\n - getter: " << Brief(getter());
+ os << "\n - setter: " << Brief(setter());
+ os << "\n - data: " << Brief(data());
+ os << "\n";
}
-void DeclaredAccessorInfo::DeclaredAccessorInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "DeclaredAccessorInfo");
- PrintF(out, "\n - name: ");
- name()->ShortPrint(out);
- PrintF(out, "\n - flag: ");
- flag()->ShortPrint(out);
- PrintF(out, "\n - descriptor: ");
- descriptor()->ShortPrint(out);
+void DeclaredAccessorInfo::DeclaredAccessorInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "DeclaredAccessorInfo");
+ os << "\n - name: " << Brief(name());
+ os << "\n - flag: " << Brief(flag());
+ os << "\n - descriptor: " << Brief(descriptor());
+ os << "\n";
}
-void DeclaredAccessorDescriptor::DeclaredAccessorDescriptorPrint(FILE* out) {
- HeapObject::PrintHeader(out, "DeclaredAccessorDescriptor");
- PrintF(out, "\n - internal field: ");
- serialized_data()->ShortPrint(out);
-}
-
-
-void Box::BoxPrint(FILE* out) {
- HeapObject::PrintHeader(out, "Box");
- PrintF(out, "\n - value: ");
- value()->ShortPrint(out);
-}
+void DeclaredAccessorDescriptor::DeclaredAccessorDescriptorPrint(
+ OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "DeclaredAccessorDescriptor");
+ os << "\n - internal field: " << Brief(serialized_data());
+ os << "\n";
+}
-
-void AccessorPair::AccessorPairPrint(FILE* out) {
- HeapObject::PrintHeader(out, "AccessorPair");
- PrintF(out, "\n - getter: ");
- getter()->ShortPrint(out);
- PrintF(out, "\n - setter: ");
- setter()->ShortPrint(out);
+
+void Box::BoxPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "Box");
+ os << "\n - value: " << Brief(value());
+ os << "\n";
+}
+
+
+void AccessorPair::AccessorPairPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "AccessorPair");
+ os << "\n - getter: " << Brief(getter());
+ os << "\n - setter: " << Brief(setter());
+ os << "\n";
+}
+
+
+void AccessCheckInfo::AccessCheckInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "AccessCheckInfo");
+ os << "\n - named_callback: " << Brief(named_callback());
+ os << "\n - indexed_callback: " << Brief(indexed_callback());
+ os << "\n - data: " << Brief(data());
+ os << "\n";
+}
+
+
+void InterceptorInfo::InterceptorInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "InterceptorInfo");
+ os << "\n - getter: " << Brief(getter());
+ os << "\n - setter: " << Brief(setter());
+ os << "\n - query: " << Brief(query());
+ os << "\n - deleter: " << Brief(deleter());
+ os << "\n - enumerator: " << Brief(enumerator());
+ os << "\n - data: " << Brief(data());
+ os << "\n";
}
-void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "AccessCheckInfo");
- PrintF(out, "\n - named_callback: ");
- named_callback()->ShortPrint(out);
- PrintF(out, "\n - indexed_callback: ");
- indexed_callback()->ShortPrint(out);
- PrintF(out, "\n - data: ");
- data()->ShortPrint(out);
+void CallHandlerInfo::CallHandlerInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "CallHandlerInfo");
+ os << "\n - callback: " << Brief(callback());
+ os << "\n - data: " << Brief(data());
+ os << "\n";
}
-void InterceptorInfo::InterceptorInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "InterceptorInfo");
- PrintF(out, "\n - getter: ");
- getter()->ShortPrint(out);
- PrintF(out, "\n - setter: ");
- setter()->ShortPrint(out);
- PrintF(out, "\n - query: ");
- query()->ShortPrint(out);
- PrintF(out, "\n - deleter: ");
- deleter()->ShortPrint(out);
- PrintF(out, "\n - enumerator: ");
- enumerator()->ShortPrint(out);
- PrintF(out, "\n - data: ");
- data()->ShortPrint(out);
-}
-
-
-void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "CallHandlerInfo");
- PrintF(out, "\n - callback: ");
- callback()->ShortPrint(out);
- PrintF(out, "\n - data: ");
- data()->ShortPrint(out);
- PrintF(out, "\n - call_stub_cache: ");
-}
-
-
-void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "FunctionTemplateInfo");
- PrintF(out, "\n - class name: ");
- class_name()->ShortPrint(out);
- PrintF(out, "\n - tag: ");
- tag()->ShortPrint(out);
- PrintF(out, "\n - property_list: ");
- property_list()->ShortPrint(out);
- PrintF(out, "\n - serial_number: ");
- serial_number()->ShortPrint(out);
- PrintF(out, "\n - call_code: ");
- call_code()->ShortPrint(out);
- PrintF(out, "\n - property_accessors: ");
- property_accessors()->ShortPrint(out);
- PrintF(out, "\n - prototype_template: ");
- prototype_template()->ShortPrint(out);
- PrintF(out, "\n - parent_template: ");
- parent_template()->ShortPrint(out);
- PrintF(out, "\n - named_property_handler: ");
- named_property_handler()->ShortPrint(out);
- PrintF(out, "\n - indexed_property_handler: ");
- indexed_property_handler()->ShortPrint(out);
- PrintF(out, "\n - instance_template: ");
- instance_template()->ShortPrint(out);
- PrintF(out, "\n - signature: ");
- signature()->ShortPrint(out);
- PrintF(out, "\n - access_check_info: ");
- access_check_info()->ShortPrint(out);
- PrintF(out, "\n - hidden_prototype: %s",
- hidden_prototype() ? "true" : "false");
- PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false");
- PrintF(out, "\n - need_access_check: %s",
- needs_access_check() ? "true" : "false");
-}
-
-
-void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "ObjectTemplateInfo");
- PrintF(out, " - tag: ");
- tag()->ShortPrint(out);
- PrintF(out, "\n - property_list: ");
- property_list()->ShortPrint(out);
- PrintF(out, "\n - property_accessors: ");
- property_accessors()->ShortPrint(out);
- PrintF(out, "\n - constructor: ");
- constructor()->ShortPrint(out);
- PrintF(out, "\n - internal_field_count: ");
- internal_field_count()->ShortPrint(out);
- PrintF(out, "\n");
-}
-
-
-void SignatureInfo::SignatureInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "SignatureInfo");
- PrintF(out, "\n - receiver: ");
- receiver()->ShortPrint(out);
- PrintF(out, "\n - args: ");
- args()->ShortPrint(out);
-}
-
-
-void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "TypeSwitchInfo");
- PrintF(out, "\n - types: ");
- types()->ShortPrint(out);
-}
-
-
-void AllocationSite::AllocationSitePrint(FILE* out) {
- HeapObject::PrintHeader(out, "AllocationSite");
- PrintF(out, " - weak_next: ");
- weak_next()->ShortPrint(out);
- PrintF(out, "\n - dependent code: ");
- dependent_code()->ShortPrint(out);
- PrintF(out, "\n - nested site: ");
- nested_site()->ShortPrint(out);
- PrintF(out, "\n - memento found count: ");
- Smi::FromInt(memento_found_count())->ShortPrint(out);
- PrintF(out, "\n - memento create count: ");
- Smi::FromInt(memento_create_count())->ShortPrint(out);
- PrintF(out, "\n - pretenure decision: ");
- Smi::FromInt(pretenure_decision())->ShortPrint(out);
- PrintF(out, "\n - transition_info: ");
+void FunctionTemplateInfo::FunctionTemplateInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "FunctionTemplateInfo");
+ os << "\n - class name: " << Brief(class_name());
+ os << "\n - tag: " << Brief(tag());
+ os << "\n - property_list: " << Brief(property_list());
+ os << "\n - serial_number: " << Brief(serial_number());
+ os << "\n - call_code: " << Brief(call_code());
+ os << "\n - property_accessors: " << Brief(property_accessors());
+ os << "\n - prototype_template: " << Brief(prototype_template());
+ os << "\n - parent_template: " << Brief(parent_template());
+ os << "\n - named_property_handler: " << Brief(named_property_handler());
+ os << "\n - indexed_property_handler: " << Brief(indexed_property_handler());
+ os << "\n - instance_template: " << Brief(instance_template());
+ os << "\n - signature: " << Brief(signature());
+ os << "\n - access_check_info: " << Brief(access_check_info());
+ os << "\n - hidden_prototype: " << (hidden_prototype() ? "true" : "false");
+ os << "\n - undetectable: " << (undetectable() ? "true" : "false");
+ os << "\n - need_access_check: " << (needs_access_check() ? "true" : "false");
+ os << "\n";
+}
+
+
+void ObjectTemplateInfo::ObjectTemplateInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "ObjectTemplateInfo");
+ os << " - tag: " << Brief(tag());
+ os << "\n - property_list: " << Brief(property_list());
+ os << "\n - property_accessors: " << Brief(property_accessors());
+ os << "\n - constructor: " << Brief(constructor());
+ os << "\n - internal_field_count: " << Brief(internal_field_count());
+ os << "\n";
+}
+
+
+void SignatureInfo::SignatureInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "SignatureInfo");
+ os << "\n - receiver: " << Brief(receiver());
+ os << "\n - args: " << Brief(args());
+ os << "\n";
+}
+
+
+void TypeSwitchInfo::TypeSwitchInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "TypeSwitchInfo");
+ os << "\n - types: " << Brief(types());
+ os << "\n";
+}
+
+
+void AllocationSite::AllocationSitePrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "AllocationSite");
+ os << " - weak_next: " << Brief(weak_next());
+ os << "\n - dependent code: " << Brief(dependent_code());
+ os << "\n - nested site: " << Brief(nested_site());
+ os << "\n - memento found count: "
+ << Brief(Smi::FromInt(memento_found_count()));
+ os << "\n - memento create count: "
+ << Brief(Smi::FromInt(memento_create_count()));
+ os << "\n - pretenure decision: "
+ << Brief(Smi::FromInt(pretenure_decision()));
+ os << "\n - transition_info: ";
if (transition_info()->IsSmi()) {
ElementsKind kind = GetElementsKind();
- PrintF(out, "Array allocation with ElementsKind ");
- PrintElementsKind(out, kind);
- PrintF(out, "\n");
- return;
+ os << "Array allocation with ElementsKind " << ElementsKindToString(kind);
} else if (transition_info()->IsJSArray()) {
- PrintF(out, "Array literal ");
- transition_info()->ShortPrint(out);
- PrintF(out, "\n");
- return;
+ os << "Array literal " << Brief(transition_info());
+ } else {
+ os << "unknown transition_info" << Brief(transition_info());
}
-
- PrintF(out, "unknown transition_info");
- transition_info()->ShortPrint(out);
- PrintF(out, "\n");
+ os << "\n";
}
-void AllocationMemento::AllocationMementoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "AllocationMemento");
- PrintF(out, " - allocation site: ");
+void AllocationMemento::AllocationMementoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "AllocationMemento");
+ os << " - allocation site: ";
if (IsValid()) {
- GetAllocationSite()->Print();
+ GetAllocationSite()->Print(os);
} else {
- PrintF(out, "<invalid>\n");
+ os << "<invalid>\n";
}
}
-void Script::ScriptPrint(FILE* out) {
- HeapObject::PrintHeader(out, "Script");
- PrintF(out, "\n - source: ");
- source()->ShortPrint(out);
- PrintF(out, "\n - name: ");
- name()->ShortPrint(out);
- PrintF(out, "\n - line_offset: ");
- line_offset()->ShortPrint(out);
- PrintF(out, "\n - column_offset: ");
- column_offset()->ShortPrint(out);
- PrintF(out, "\n - type: ");
- type()->ShortPrint(out);
- PrintF(out, "\n - id: ");
- id()->ShortPrint(out);
- PrintF(out, "\n - context data: ");
- context_data()->ShortPrint(out);
- PrintF(out, "\n - wrapper: ");
- wrapper()->ShortPrint(out);
- PrintF(out, "\n - compilation type: %d", compilation_type());
- PrintF(out, "\n - line ends: ");
- line_ends()->ShortPrint(out);
- PrintF(out, "\n - eval from shared: ");
- eval_from_shared()->ShortPrint(out);
- PrintF(out, "\n - eval from instructions offset: ");
- eval_from_instructions_offset()->ShortPrint(out);
- PrintF(out, "\n");
-}
-
-
-void DebugInfo::DebugInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "DebugInfo");
- PrintF(out, "\n - shared: ");
- shared()->ShortPrint(out);
- PrintF(out, "\n - original_code: ");
- original_code()->ShortPrint(out);
- PrintF(out, "\n - code: ");
- code()->ShortPrint(out);
- PrintF(out, "\n - break_points: ");
- break_points()->Print(out);
-}
-
-
-void BreakPointInfo::BreakPointInfoPrint(FILE* out) {
- HeapObject::PrintHeader(out, "BreakPointInfo");
- PrintF(out, "\n - code_position: %d", code_position()->value());
- PrintF(out, "\n - source_position: %d", source_position()->value());
- PrintF(out, "\n - statement_position: %d", statement_position()->value());
- PrintF(out, "\n - break_point_objects: ");
- break_point_objects()->ShortPrint(out);
-}
-
-
-void DescriptorArray::PrintDescriptors(FILE* out) {
- PrintF(out, "Descriptor array %d\n", number_of_descriptors());
+void Script::ScriptPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "Script");
+ os << "\n - source: " << Brief(source());
+ os << "\n - name: " << Brief(name());
+ os << "\n - line_offset: " << Brief(line_offset());
+ os << "\n - column_offset: " << Brief(column_offset());
+ os << "\n - type: " << Brief(type());
+ os << "\n - id: " << Brief(id());
+ os << "\n - context data: " << Brief(context_data());
+ os << "\n - wrapper: " << Brief(wrapper());
+ os << "\n - compilation type: " << compilation_type();
+ os << "\n - line ends: " << Brief(line_ends());
+ os << "\n - eval from shared: " << Brief(eval_from_shared());
+ os << "\n - eval from instructions offset: "
+ << Brief(eval_from_instructions_offset());
+ os << "\n";
+}
+
+
+void DebugInfo::DebugInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "DebugInfo");
+ os << "\n - shared: " << Brief(shared());
+ os << "\n - original_code: " << Brief(original_code());
+ os << "\n - code: " << Brief(code());
+ os << "\n - break_points: ";
+ break_points()->Print(os);
+}
+
+
+void BreakPointInfo::BreakPointInfoPrint(OStream& os) { // NOLINT
+ HeapObject::PrintHeader(os, "BreakPointInfo");
+ os << "\n - code_position: " << code_position()->value();
+ os << "\n - source_position: " << source_position()->value();
+ os << "\n - statement_position: " << statement_position()->value();
+ os << "\n - break_point_objects: " << Brief(break_point_objects());
+ os << "\n";
+}
+
+
+void DescriptorArray::PrintDescriptors(OStream& os) { // NOLINT
+ os << "Descriptor array " << number_of_descriptors() << "\n";
for (int i = 0; i < number_of_descriptors(); i++) {
- PrintF(out, " %d: ", i);
Descriptor desc;
Get(i, &desc);
- desc.Print(out);
+ os << " " << i << ": " << desc;
}
- PrintF(out, "\n");
+ os << "\n";
}
-void TransitionArray::PrintTransitions(FILE* out) {
- PrintF(out, "Transition array %d\n", number_of_transitions());
+void TransitionArray::PrintTransitions(OStream& os) { // NOLINT
+ os << "Transition array %d\n", number_of_transitions();
for (int i = 0; i < number_of_transitions(); i++) {
- PrintF(out, " %d: ", i);
- GetKey(i)->NamePrint(out);
- PrintF(out, ": ");
+ os << " " << i << ": ";
+ GetKey(i)->NamePrint(os);
+ os << ": ";
switch (GetTargetDetails(i).type()) {
case FIELD: {
- PrintF(out, " (transition to field)\n");
+ os << " (transition to field)\n";
break;
}
case CONSTANT:
- PrintF(out, " (transition to constant)\n");
+ os << " (transition to constant)\n";
break;
case CALLBACKS:
- PrintF(out, " (transition to callback)\n");
+ os << " (transition to callback)\n";
break;
// Values below are never in the target descriptor array.
case NORMAL:
break;
}
}
- PrintF(out, "\n");
+ os << "\n";
}
void Object::ShortPrint(FILE* out) {
- HeapStringAllocator allocator;
- StringStream accumulator(&allocator);
- ShortPrint(&accumulator);
- accumulator.OutputToFile(out);
+ OFStream os(out);
+ os << Brief(this);
}
void Object::ShortPrint(StringStream* accumulator) {
- if (IsSmi()) {
- Smi::cast(this)->SmiPrint(accumulator);
- } else {
- HeapObject::cast(this)->HeapObjectShortPrint(accumulator);
- }
+ OStringStream os;
+ os << Brief(this);
+ accumulator->Add(os.c_str());
}
-void Smi::SmiPrint(FILE* out) {
- PrintF(out, "%d", value());
+OStream& operator<<(OStream& os, const Brief& v) {
+ if (v.value->IsSmi()) {
+ Smi::cast(v.value)->SmiPrint(os);
+ } else {
+ // TODO(svenpanne) Const-correct HeapObjectShortPrint!
+ HeapObject* obj = const_cast<HeapObject*>(HeapObject::cast(v.value));
+ obj->HeapObjectShortPrint(os);
+ }
+ return os;
}
-void Smi::SmiPrint(StringStream* accumulator) {
- accumulator->Add("%d", value());
+void Smi::SmiPrint(OStream& os) const { // NOLINT
+ os << value();
}
}
+void String::PrintUC16(OStream& os, int start, int end) { // NOLINT
+ if (end < 0) end = length();
+ ConsStringIteratorOp op;
+ StringCharacterStream stream(this, &op, start);
+ for (int i = start; i < end && stream.HasMore(); i++) {
+ os << AsUC16(stream.GetNext());
+ }
+}
+
+
void JSObject::JSObjectShortPrint(StringStream* accumulator) {
switch (map()->instance_type()) {
case JS_ARRAY_TYPE: {
ElementsKind from_kind, Handle<FixedArrayBase> from_elements,
ElementsKind to_kind, Handle<FixedArrayBase> to_elements) {
if (from_kind != to_kind) {
- PrintF(file, "elements transition [");
- PrintElementsKind(file, from_kind);
- PrintF(file, " -> ");
- PrintElementsKind(file, to_kind);
- PrintF(file, "] in ");
+ OFStream os(file);
+ os << "elements transition [" << ElementsKindToString(from_kind) << " -> "
+ << ElementsKindToString(to_kind) << "] in ";
JavaScriptFrame::PrintTop(object->GetIsolate(), file, false, true);
PrintF(file, " for ");
object->ShortPrint(file);
}
-void HeapObject::HeapObjectShortPrint(StringStream* accumulator) {
+void HeapObject::HeapObjectShortPrint(OStream& os) { // NOLINT
Heap* heap = GetHeap();
if (!heap->Contains(this)) {
- accumulator->Add("!!!INVALID POINTER!!!");
+ os << "!!!INVALID POINTER!!!";
return;
}
if (!heap->Contains(map())) {
- accumulator->Add("!!!INVALID MAP!!!");
+ os << "!!!INVALID MAP!!!";
return;
}
- accumulator->Add("%p ", this);
+ os << this << " ";
if (IsString()) {
- String::cast(this)->StringShortPrint(accumulator);
+ HeapStringAllocator allocator;
+ StringStream accumulator(&allocator);
+ String::cast(this)->StringShortPrint(&accumulator);
+ os << accumulator.ToCString().get();
return;
}
if (IsJSObject()) {
- JSObject::cast(this)->JSObjectShortPrint(accumulator);
+ HeapStringAllocator allocator;
+ StringStream accumulator(&allocator);
+ JSObject::cast(this)->JSObjectShortPrint(&accumulator);
+ os << accumulator.ToCString().get();
return;
}
switch (map()->instance_type()) {
case MAP_TYPE:
- accumulator->Add("<Map(elements=%u)>", Map::cast(this)->elements_kind());
+ os << "<Map(elements=" << Map::cast(this)->elements_kind() << ")>";
break;
case FIXED_ARRAY_TYPE:
- accumulator->Add("<FixedArray[%u]>", FixedArray::cast(this)->length());
+ os << "<FixedArray[" << FixedArray::cast(this)->length() << "]>";
break;
case FIXED_DOUBLE_ARRAY_TYPE:
- accumulator->Add("<FixedDoubleArray[%u]>",
- FixedDoubleArray::cast(this)->length());
+ os << "<FixedDoubleArray[" << FixedDoubleArray::cast(this)->length()
+ << "]>";
break;
case BYTE_ARRAY_TYPE:
- accumulator->Add("<ByteArray[%u]>", ByteArray::cast(this)->length());
+ os << "<ByteArray[" << ByteArray::cast(this)->length() << "]>";
break;
case FREE_SPACE_TYPE:
- accumulator->Add("<FreeSpace[%u]>", FreeSpace::cast(this)->Size());
- break;
-#define TYPED_ARRAY_SHORT_PRINT(Type, type, TYPE, ctype, size) \
- case EXTERNAL_##TYPE##_ARRAY_TYPE: \
- accumulator->Add("<External" #Type "Array[%u]>", \
- External##Type##Array::cast(this)->length()); \
- break; \
- case FIXED_##TYPE##_ARRAY_TYPE: \
- accumulator->Add("<Fixed" #Type "Array[%u]>", \
- Fixed##Type##Array::cast(this)->length()); \
+ os << "<FreeSpace[" << FreeSpace::cast(this)->Size() << "]>";
break;
+#define TYPED_ARRAY_SHORT_PRINT(Type, type, TYPE, ctype, size) \
+ case EXTERNAL_##TYPE##_ARRAY_TYPE: \
+ os << "<External" #Type "Array[" \
+ << External##Type##Array::cast(this)->length() << "]>"; \
+ break; \
+ case FIXED_##TYPE##_ARRAY_TYPE: \
+ os << "<Fixed" #Type "Array[" << Fixed##Type##Array::cast(this)->length() \
+ << "]>"; \
+ break;
TYPED_ARRAYS(TYPED_ARRAY_SHORT_PRINT)
#undef TYPED_ARRAY_SHORT_PRINT
SmartArrayPointer<char> debug_name =
shared->DebugName()->ToCString();
if (debug_name[0] != 0) {
- accumulator->Add("<SharedFunctionInfo %s>", debug_name.get());
+ os << "<SharedFunctionInfo " << debug_name.get() << ">";
} else {
- accumulator->Add("<SharedFunctionInfo>");
+ os << "<SharedFunctionInfo>";
}
break;
}
case JS_MESSAGE_OBJECT_TYPE:
- accumulator->Add("<JSMessageObject>");
+ os << "<JSMessageObject>";
break;
#define MAKE_STRUCT_CASE(NAME, Name, name) \
case NAME##_TYPE: \
- accumulator->Put('<'); \
- accumulator->Add(#Name); \
- accumulator->Put('>'); \
+ os << "<" #Name ">"; \
break;
STRUCT_LIST(MAKE_STRUCT_CASE)
#undef MAKE_STRUCT_CASE
case CODE_TYPE:
- accumulator->Add("<Code>");
+ os << "<Code>";
break;
case ODDBALL_TYPE: {
- if (IsUndefined())
- accumulator->Add("<undefined>");
- else if (IsTheHole())
- accumulator->Add("<the hole>");
- else if (IsNull())
- accumulator->Add("<null>");
- else if (IsTrue())
- accumulator->Add("<true>");
- else if (IsFalse())
- accumulator->Add("<false>");
- else
- accumulator->Add("<Odd Oddball>");
+ if (IsUndefined()) {
+ os << "<undefined>";
+ } else if (IsTheHole()) {
+ os << "<the hole>";
+ } else if (IsNull()) {
+ os << "<null>";
+ } else if (IsTrue()) {
+ os << "<true>";
+ } else if (IsFalse()) {
+ os << "<false>";
+ } else {
+ os << "<Odd Oddball>";
+ }
break;
}
case SYMBOL_TYPE: {
Symbol* symbol = Symbol::cast(this);
- accumulator->Add("<Symbol: %d", symbol->Hash());
+ os << "<Symbol: " << symbol->Hash();
if (!symbol->name()->IsUndefined()) {
- accumulator->Add(" ");
- String::cast(symbol->name())->StringShortPrint(accumulator);
+ os << " ";
+ HeapStringAllocator allocator;
+ StringStream accumulator(&allocator);
+ String::cast(symbol->name())->StringShortPrint(&accumulator);
+ os << accumulator.ToCString().get();
}
- accumulator->Add(">");
+ os << ">";
break;
}
- case HEAP_NUMBER_TYPE:
- accumulator->Add("<Number: ");
- HeapNumber::cast(this)->HeapNumberPrint(accumulator);
- accumulator->Put('>');
+ case HEAP_NUMBER_TYPE: {
+ os << "<Number: ";
+ HeapNumber::cast(this)->HeapNumberPrint(os);
+ os << ">";
break;
- case MUTABLE_HEAP_NUMBER_TYPE:
- accumulator->Add("<MutableNumber: ");
- HeapNumber::cast(this)->HeapNumberPrint(accumulator);
- accumulator->Put('>');
+ }
+ case MUTABLE_HEAP_NUMBER_TYPE: {
+ os << "<MutableNumber: ";
+ HeapNumber::cast(this)->HeapNumberPrint(os);
+ os << '>';
break;
+ }
case JS_PROXY_TYPE:
- accumulator->Add("<JSProxy>");
+ os << "<JSProxy>";
break;
case JS_FUNCTION_PROXY_TYPE:
- accumulator->Add("<JSFunctionProxy>");
+ os << "<JSFunctionProxy>";
break;
case FOREIGN_TYPE:
- accumulator->Add("<Foreign>");
+ os << "<Foreign>";
break;
- case CELL_TYPE:
- accumulator->Add("Cell for ");
- Cell::cast(this)->value()->ShortPrint(accumulator);
+ case CELL_TYPE: {
+ os << "Cell for ";
+ HeapStringAllocator allocator;
+ StringStream accumulator(&allocator);
+ Cell::cast(this)->value()->ShortPrint(&accumulator);
+ os << accumulator.ToCString().get();
break;
- case PROPERTY_CELL_TYPE:
- accumulator->Add("PropertyCell for ");
- PropertyCell::cast(this)->value()->ShortPrint(accumulator);
+ }
+ case PROPERTY_CELL_TYPE: {
+ os << "PropertyCell for ";
+ HeapStringAllocator allocator;
+ StringStream accumulator(&allocator);
+ PropertyCell::cast(this)->value()->ShortPrint(&accumulator);
+ os << accumulator.ToCString().get();
break;
+ }
default:
- accumulator->Add("<Other heap object (%d)>", map()->instance_type());
+ os << "<Other heap object (" << map()->instance_type() << ")>";
break;
}
}
}
-void HeapNumber::HeapNumberPrint(FILE* out) {
- PrintF(out, "%.16g", value());
-}
-
-
-void HeapNumber::HeapNumberPrint(StringStream* accumulator) {
- // The Windows version of vsnprintf can allocate when printing a %g string
- // into a buffer that may not be big enough. We don't want random memory
- // allocation when producing post-crash stack traces, so we print into a
- // buffer that is plenty big enough for any floating point number, then
- // print that using vsnprintf (which may truncate but never allocate if
- // there is no more space in the buffer).
- EmbeddedVector<char, 100> buffer;
- SNPrintF(buffer, "%.16g", value());
- accumulator->Add("%s", buffer.start());
+void HeapNumber::HeapNumberPrint(OStream& os) { // NOLINT
+ os << value();
}
#ifdef DEBUG
if (FLAG_trace_normalization) {
- PrintF("Object properties have been normalized:\n");
- object->Print();
+ OFStream os(stdout);
+ os << "Object properties have been normalized:\n";
+ object->Print(os);
}
#endif
}
#ifdef DEBUG
if (FLAG_trace_normalization) {
- PrintF("Object elements have been normalized:\n");
- object->Print();
+ OFStream os(stdout);
+ os << "Object elements have been normalized:\n";
+ object->Print(os);
}
#endif
}
-bool SharedFunctionInfo::HasSourceCode() {
+bool SharedFunctionInfo::HasSourceCode() const {
return !script()->IsUndefined() &&
!reinterpret_cast<Script*>(script())->source()->IsUndefined();
}
}
-// Support function for printing the source code to a StringStream
-// without any allocation in the heap.
-void SharedFunctionInfo::SourceCodePrint(StringStream* accumulator,
- int max_length) {
+// Output the source code without any allocation in the heap.
+OStream& operator<<(OStream& os, const SourceCodeOf& v) {
+ const SharedFunctionInfo* s = v.value;
// For some native functions there is no source.
- if (!HasSourceCode()) {
- accumulator->Add("<No Source>");
- return;
- }
+ if (!s->HasSourceCode()) return os << "<No Source>";
// Get the source for the script which this function came from.
// Don't use String::cast because we don't want more assertion errors while
// we are already creating a stack dump.
String* script_source =
- reinterpret_cast<String*>(Script::cast(script())->source());
+ reinterpret_cast<String*>(Script::cast(s->script())->source());
- if (!script_source->LooksValid()) {
- accumulator->Add("<Invalid Source>");
- return;
- }
+ if (!script_source->LooksValid()) return os << "<Invalid Source>";
- if (!is_toplevel()) {
- accumulator->Add("function ");
- Object* name = this->name();
+ if (!s->is_toplevel()) {
+ os << "function ";
+ Object* name = s->name();
if (name->IsString() && String::cast(name)->length() > 0) {
- accumulator->PrintName(name);
+ String::cast(name)->PrintUC16(os);
}
}
- int len = end_position() - start_position();
- if (len <= max_length || max_length < 0) {
- accumulator->Put(script_source, start_position(), end_position());
+ int len = s->end_position() - s->start_position();
+ if (len <= v.max_length || v.max_length < 0) {
+ script_source->PrintUC16(os, s->start_position(), s->end_position());
+ return os;
} else {
- accumulator->Put(script_source,
- start_position(),
- start_position() + max_length);
- accumulator->Add("...\n");
+ script_source->PrintUC16(os, s->start_position(),
+ s->start_position() + v.max_length);
+ return os << "...\n";
}
}
#ifdef ENABLE_DISASSEMBLER
-void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) {
+void DeoptimizationInputData::DeoptimizationInputDataPrint(
+ OStream& os) { // NOLINT
disasm::NameConverter converter;
int deopt_count = DeoptCount();
- PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count);
+ os << "Deoptimization Input Data (deopt points = " << deopt_count << ")\n";
if (0 == deopt_count) return;
- PrintF(out, "%6s %6s %6s %6s %12s\n", "index", "ast id", "argc", "pc",
- FLAG_print_code_verbose ? "commands" : "");
+ os << " index ast id argc pc";
+ if (FLAG_print_code_verbose) os << "commands";
+ os << "\n";
for (int i = 0; i < deopt_count; i++) {
- PrintF(out, "%6d %6d %6d %6d",
- i,
- AstId(i).ToInt(),
- ArgumentsStackHeight(i)->value(),
- Pc(i)->value());
+ // TODO(svenpanne) Add some basic formatting to our streams.
+ Vector<char> buf1 = Vector<char>::New(128);
+ SNPrintF(buf1, "%6d %6d %6d %6d", i, AstId(i).ToInt(),
+ ArgumentsStackHeight(i)->value(), Pc(i)->value());
+ os << buf1.start();
if (!FLAG_print_code_verbose) {
- PrintF(out, "\n");
+ os << "\n";
continue;
}
// Print details of the frame translation.
ASSERT(Translation::BEGIN == opcode);
int frame_count = iterator.Next();
int jsframe_count = iterator.Next();
- PrintF(out, " %s {frame count=%d, js frame count=%d}\n",
- Translation::StringFor(opcode),
- frame_count,
- jsframe_count);
+ os << " " << Translation::StringFor(opcode)
+ << " {frame count=" << frame_count
+ << ", js frame count=" << jsframe_count << "}\n";
while (iterator.HasNext() &&
Translation::BEGIN !=
(opcode = static_cast<Translation::Opcode>(iterator.Next()))) {
- PrintF(out, "%24s %s ", "", Translation::StringFor(opcode));
+ Vector<char> buf2 = Vector<char>::New(128);
+ SNPrintF(buf2, "%24s %s ", "", Translation::StringFor(opcode));
+ os << buf2.start();
switch (opcode) {
case Translation::BEGIN:
int ast_id = iterator.Next();
int function_id = iterator.Next();
unsigned height = iterator.Next();
- PrintF(out, "{ast_id=%d, function=", ast_id);
+ os << "{ast_id=" << ast_id << ", function=";
if (function_id != Translation::kSelfLiteralId) {
Object* function = LiteralArray()->get(function_id);
- JSFunction::cast(function)->PrintName(out);
+ os << Brief(JSFunction::cast(function)->shared()->DebugName());
} else {
- PrintF(out, "<self>");
+ os << "<self>";
}
- PrintF(out, ", height=%u}", height);
+ os << ", height=" << height << "}";
break;
}
case Translation::COMPILED_STUB_FRAME: {
Code::Kind stub_kind = static_cast<Code::Kind>(iterator.Next());
- PrintF(out, "{kind=%d}", stub_kind);
+ os << "{kind=" << stub_kind << "}";
break;
}
JSFunction* function =
JSFunction::cast(LiteralArray()->get(function_id));
unsigned height = iterator.Next();
- PrintF(out, "{function=");
- function->PrintName(out);
- PrintF(out, ", height=%u}", height);
+ os << "{function=" << Brief(function->shared()->DebugName())
+ << ", height=" << height << "}";
break;
}
int function_id = iterator.Next();
JSFunction* function =
JSFunction::cast(LiteralArray()->get(function_id));
- PrintF(out, "{function=");
- function->PrintName(out);
- PrintF(out, "}");
+ os << "{function=" << Brief(function->shared()->DebugName()) << "}";
break;
}
case Translation::REGISTER: {
int reg_code = iterator.Next();
- PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code));
+ os << "{input=" << converter.NameOfCPURegister(reg_code) << "}";
break;
}
case Translation::INT32_REGISTER: {
int reg_code = iterator.Next();
- PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code));
+ os << "{input=" << converter.NameOfCPURegister(reg_code) << "}";
break;
}
case Translation::UINT32_REGISTER: {
int reg_code = iterator.Next();
- PrintF(out, "{input=%s (unsigned)}",
- converter.NameOfCPURegister(reg_code));
+ os << "{input=" << converter.NameOfCPURegister(reg_code)
+ << " (unsigned)}";
break;
}
case Translation::DOUBLE_REGISTER: {
int reg_code = iterator.Next();
- PrintF(out, "{input=%s}",
- DoubleRegister::AllocationIndexToString(reg_code));
+ os << "{input=" << DoubleRegister::AllocationIndexToString(reg_code)
+ << "}";
break;
}
case Translation::STACK_SLOT: {
int input_slot_index = iterator.Next();
- PrintF(out, "{input=%d}", input_slot_index);
+ os << "{input=" << input_slot_index << "}";
break;
}
case Translation::INT32_STACK_SLOT: {
int input_slot_index = iterator.Next();
- PrintF(out, "{input=%d}", input_slot_index);
+ os << "{input=" << input_slot_index << "}";
break;
}
case Translation::UINT32_STACK_SLOT: {
int input_slot_index = iterator.Next();
- PrintF(out, "{input=%d (unsigned)}", input_slot_index);
+ os << "{input=" << input_slot_index << " (unsigned)}";
break;
}
case Translation::DOUBLE_STACK_SLOT: {
int input_slot_index = iterator.Next();
- PrintF(out, "{input=%d}", input_slot_index);
+ os << "{input=" << input_slot_index << "}";
break;
}
case Translation::LITERAL: {
unsigned literal_index = iterator.Next();
- PrintF(out, "{literal_id=%u}", literal_index);
+ os << "{literal_id=" << literal_index << "}";
break;
}
case Translation::DUPLICATED_OBJECT: {
int object_index = iterator.Next();
- PrintF(out, "{object_index=%d}", object_index);
+ os << "{object_index=" << object_index << "}";
break;
}
case Translation::ARGUMENTS_OBJECT:
case Translation::CAPTURED_OBJECT: {
int args_length = iterator.Next();
- PrintF(out, "{length=%d}", args_length);
+ os << "{length=" << args_length << "}";
break;
}
}
- PrintF(out, "\n");
+ os << "\n";
}
}
}
-void DeoptimizationOutputData::DeoptimizationOutputDataPrint(FILE* out) {
- PrintF(out, "Deoptimization Output Data (deopt points = %d)\n",
- this->DeoptPoints());
+void DeoptimizationOutputData::DeoptimizationOutputDataPrint(
+ OStream& os) { // NOLINT
+ os << "Deoptimization Output Data (deopt points = " << this->DeoptPoints()
+ << ")\n";
if (this->DeoptPoints() == 0) return;
- PrintF(out, "%6s %8s %s\n", "ast id", "pc", "state");
+ os << "ast id pc state\n";
for (int i = 0; i < this->DeoptPoints(); i++) {
int pc_and_state = this->PcAndState(i)->value();
- PrintF(out, "%6d %8d %s\n",
- this->AstId(i).ToInt(),
- FullCodeGenerator::PcField::decode(pc_and_state),
- FullCodeGenerator::State2String(
- FullCodeGenerator::StateField::decode(pc_and_state)));
+ // TODO(svenpanne) Add some basic formatting to our streams.
+ Vector<char> buf = Vector<char>::New(100);
+ SNPrintF(buf, "%6d %8d %s\n", this->AstId(i).ToInt(),
+ FullCodeGenerator::PcField::decode(pc_and_state),
+ FullCodeGenerator::State2String(
+ FullCodeGenerator::StateField::decode(pc_and_state)));
+ os << buf.start();
}
}
}
-void Code::PrintExtraICState(FILE* out, Kind kind, ExtraICState extra) {
- PrintF(out, "extra_ic_state = ");
- const char* name = NULL;
- switch (kind) {
- case STORE_IC:
- case KEYED_STORE_IC:
- if (extra == STRICT) name = "STRICT";
- break;
- default:
- break;
- }
- if (name != NULL) {
- PrintF(out, "%s\n", name);
+void Code::PrintExtraICState(OStream& os, // NOLINT
+ Kind kind, ExtraICState extra) {
+ os << "extra_ic_state = ";
+ if ((kind == STORE_IC || kind == KEYED_STORE_IC) && (extra == STRICT)) {
+ os << "STRICT\n";
} else {
- PrintF(out, "%d\n", extra);
+ os << extra << "\n";
}
}
-void Code::Disassemble(const char* name, FILE* out) {
- PrintF(out, "kind = %s\n", Kind2String(kind()));
+void Code::Disassemble(const char* name, OStream& os) { // NOLINT
+ os << "kind = " << Kind2String(kind()) << "\n";
if (has_major_key()) {
- PrintF(out, "major_key = %s\n",
- CodeStub::MajorName(CodeStub::GetMajorKey(this), true));
+ const char* n = CodeStub::MajorName(CodeStub::GetMajorKey(this), true);
+ os << "major_key = " << (n == NULL ? "null" : n) << "\n";
}
if (is_inline_cache_stub()) {
- PrintF(out, "ic_state = %s\n", ICState2String(ic_state()));
- PrintExtraICState(out, kind(), extra_ic_state());
+ os << "ic_state = " << ICState2String(ic_state()) << "\n";
+ PrintExtraICState(os, kind(), extra_ic_state());
if (ic_state() == MONOMORPHIC) {
- PrintF(out, "type = %s\n", StubType2String(type()));
+ os << "type = " << StubType2String(type()) << "\n";
}
if (is_compare_ic_stub()) {
ASSERT(major_key() == CodeStub::CompareIC);
Token::Value op;
ICCompareStub::DecodeMinorKey(stub_info(), &left_state, &right_state,
&handler_state, &op);
- PrintF(out, "compare_state = %s*%s -> %s\n",
- CompareIC::GetStateName(left_state),
- CompareIC::GetStateName(right_state),
- CompareIC::GetStateName(handler_state));
- PrintF(out, "compare_operation = %s\n", Token::Name(op));
+ os << "compare_state = " << CompareIC::GetStateName(left_state) << "*"
+ << CompareIC::GetStateName(right_state) << " -> "
+ << CompareIC::GetStateName(handler_state) << "\n";
+ os << "compare_operation = " << Token::Name(op) << "\n";
}
}
if ((name != NULL) && (name[0] != '\0')) {
- PrintF(out, "name = %s\n", name);
+ os << "name = " << name << "\n";
}
if (kind() == OPTIMIZED_FUNCTION) {
- PrintF(out, "stack_slots = %d\n", stack_slots());
+ os << "stack_slots = " << stack_slots() << "\n";
}
- PrintF(out, "Instructions (size = %d)\n", instruction_size());
- Disassembler::Decode(out, this);
- PrintF(out, "\n");
+ os << "Instructions (size = " << instruction_size() << ")\n";
+ // TODO(svenpanne) The Disassembler should use streams, too!
+ Disassembler::Decode(stdout, this);
+ os << "\n";
if (kind() == FUNCTION) {
DeoptimizationOutputData* data =
DeoptimizationOutputData::cast(this->deoptimization_data());
- data->DeoptimizationOutputDataPrint(out);
+ data->DeoptimizationOutputDataPrint(os);
} else if (kind() == OPTIMIZED_FUNCTION) {
DeoptimizationInputData* data =
DeoptimizationInputData::cast(this->deoptimization_data());
- data->DeoptimizationInputDataPrint(out);
+ data->DeoptimizationInputDataPrint(os);
}
- PrintF(out, "\n");
+ os << "\n";
if (is_crankshafted()) {
SafepointTable table(this);
- PrintF(out, "Safepoints (size = %u)\n", table.size());
+ os << "Safepoints (size = " << table.size() << ")\n";
for (unsigned i = 0; i < table.length(); i++) {
unsigned pc_offset = table.GetPcOffset(i);
- PrintF(out, "%p %4d ", (instruction_start() + pc_offset), pc_offset);
- table.PrintEntry(i, out);
- PrintF(out, " (sp -> fp)");
+ os << (instruction_start() + pc_offset) << " ";
+ // TODO(svenpanne) Add some basic formatting to our streams.
+ Vector<char> buf1 = Vector<char>::New(30);
+ SNPrintF(buf1, "%4d", pc_offset);
+ os << buf1.start() << " ";
+ table.PrintEntry(i, os);
+ os << " (sp -> fp) ";
SafepointEntry entry = table.GetEntry(i);
if (entry.deoptimization_index() != Safepoint::kNoDeoptimizationIndex) {
- PrintF(out, " %6d", entry.deoptimization_index());
+ Vector<char> buf2 = Vector<char>::New(30);
+ SNPrintF(buf2, "%6d", entry.deoptimization_index());
+ os << buf2.start();
} else {
- PrintF(out, " <none>");
+ os << "<none>";
}
if (entry.argument_count() > 0) {
- PrintF(out, " argc: %d", entry.argument_count());
+ os << " argc: " << entry.argument_count();
}
- PrintF(out, "\n");
+ os << "\n";
}
- PrintF(out, "\n");
+ os << "\n";
} else if (kind() == FUNCTION) {
unsigned offset = back_edge_table_offset();
// If there is no back edge table, the "table start" will be at or after
DisallowHeapAllocation no_gc;
BackEdgeTable back_edges(this, &no_gc);
- PrintF(out, "Back edges (size = %u)\n", back_edges.length());
- PrintF(out, "ast_id pc_offset loop_depth\n");
+ os << "Back edges (size = " << back_edges.length() << ")\n";
+ os << "ast_id pc_offset loop_depth\n";
for (uint32_t i = 0; i < back_edges.length(); i++) {
- PrintF(out, "%6d %9u %10u\n", back_edges.ast_id(i).ToInt(),
- back_edges.pc_offset(i),
- back_edges.loop_depth(i));
+ Vector<char> buf = Vector<char>::New(100);
+ SNPrintF(buf, "%6d %9u %10u\n", back_edges.ast_id(i).ToInt(),
+ back_edges.pc_offset(i), back_edges.loop_depth(i));
+ os << buf.start();
}
- PrintF(out, "\n");
+ os << "\n";
}
#ifdef OBJECT_PRINT
if (!type_feedback_info()->IsUndefined()) {
- TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(out);
- PrintF(out, "\n");
+ OFStream os(stdout);
+ TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(os);
+ os << "\n";
}
#endif
}
- PrintF(out, "RelocInfo (size = %d)\n", relocation_size());
+ os << "RelocInfo (size = " << relocation_size() << ")\n";
for (RelocIterator it(this); !it.done(); it.next()) {
- it.rinfo()->Print(GetIsolate(), out);
+ it.rinfo()->Print(GetIsolate(), os);
}
- PrintF(out, "\n");
+ os << "\n";
}
#endif // ENABLE_DISASSEMBLER
JSObject::ValidateElements(object);
#ifdef DEBUG
if (FLAG_trace_normalization) {
- PrintF("Object elements are fast case again:\n");
- object->Print();
+ OFStream os(stdout);
+ os << "Object elements are fast case again:\n";
+ object->Print(os);
}
#endif
}
// together, so even though this function belongs in objects-debug.cc,
// 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(FILE* out) {
+template <typename Derived, typename Shape, typename Key>
+void Dictionary<Derived, Shape, Key>::Print(OStream& os) { // NOLINT
int capacity = DerivedHashTable::Capacity();
for (int i = 0; i < capacity; i++) {
Object* k = DerivedHashTable::KeyAt(i);
if (DerivedHashTable::IsKey(k)) {
- PrintF(out, " ");
+ os << " ";
if (k->IsString()) {
- String::cast(k)->StringPrint(out);
+ String::cast(k)->StringPrint(os);
} else {
- k->ShortPrint(out);
+ os << Brief(k);
}
- PrintF(out, ": ");
- ValueAt(i)->ShortPrint(out);
- PrintF(out, "\n");
+ os << ": " << Brief(ValueAt(i)) << "\n";
}
}
}
#include "src/field-index.h"
#include "src/flags.h"
#include "src/list.h"
+#include "src/ostreams.h"
#include "src/property-details.h"
#include "src/smart-pointers.h"
#include "src/unicode-inl.h"
#endif
#ifdef OBJECT_PRINT
-#define DECLARE_PRINTER(Name) void Name##Print(FILE* out = stdout);
+#define DECLARE_PRINTER(Name) void Name##Print(OStream& os); // NOLINT
#else
#define DECLARE_PRINTER(Name)
#endif
// Prints this object without details to a message accumulator.
void ShortPrint(StringStream* accumulator);
+ // For our gdb macros, we should perhaps change these in the future.
+ void Print();
+
DECLARE_CAST(Object)
// Layout description.
#ifdef OBJECT_PRINT
// Prints this object with details.
- void Print();
- void Print(FILE* out);
- void PrintLn();
- void PrintLn(FILE* out);
+ void Print(OStream& os); // NOLINT
#endif
private:
};
+struct Brief {
+ explicit Brief(const Object* const v) : value(v) {}
+ const Object* value;
+};
+
+
+OStream& operator<<(OStream& os, const Brief& v);
+
+
// Smi represents integer Numbers that can be stored in 31 bits.
// Smis are immediate which means they are NOT allocated in the heap.
// The this pointer has the following format: [31 bit signed int] 0
DECLARE_CAST(Smi)
// Dispatched behavior.
- void SmiPrint(FILE* out = stdout);
- void SmiPrint(StringStream* accumulator);
-
+ void SmiPrint(OStream& os) const; // NOLINT
DECLARE_VERIFIER(Smi)
static const int kMinValue =
const DisallowHeapAllocation& promise);
// Dispatched behavior.
- void HeapObjectShortPrint(StringStream* accumulator);
+ void HeapObjectShortPrint(OStream& os); // NOLINT
#ifdef OBJECT_PRINT
- void PrintHeader(FILE* out, const char* id);
+ void PrintHeader(OStream& os, const char* id); // NOLINT
#endif
DECLARE_PRINTER(HeapObject)
DECLARE_VERIFIER(HeapObject)
// Dispatched behavior.
bool HeapNumberBooleanValue();
- void HeapNumberPrint(FILE* out = stdout);
- void HeapNumberPrint(StringStream* accumulator);
+ void HeapNumberPrint(OStream& os); // NOLINT
DECLARE_VERIFIER(HeapNumber)
inline int get_exponent();
DECLARE_PRINTER(JSObject)
DECLARE_VERIFIER(JSObject)
#ifdef OBJECT_PRINT
- void PrintProperties(FILE* out = stdout);
- void PrintElements(FILE* out = stdout);
- void PrintTransitions(FILE* out = stdout);
+ void PrintProperties(OStream& os); // NOLINT
+ void PrintElements(OStream& os); // NOLINT
+ void PrintTransitions(OStream& os); // NOLINT
#endif
static void PrintElementsTransition(
#ifdef OBJECT_PRINT
// Print all the descriptors.
- void PrintDescriptors(FILE* out = stdout);
+ void PrintDescriptors(OStream& os); // NOLINT
#endif
#ifdef DEBUG
static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key);
#ifdef OBJECT_PRINT
- void Print(FILE* out = stdout);
+ void Print(OStream& os); // NOLINT
#endif
// Returns the key (slow).
Object* SlowReverseLookup(Object* value);
DECLARE_CAST(DeoptimizationInputData)
#ifdef ENABLE_DISASSEMBLER
- void DeoptimizationInputDataPrint(FILE* out);
+ void DeoptimizationInputDataPrint(OStream& os); // NOLINT
#endif
private:
DECLARE_CAST(DeoptimizationOutputData)
#if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER)
- void DeoptimizationOutputDataPrint(FILE* out);
+ void DeoptimizationOutputDataPrint(OStream& os); // NOLINT
#endif
};
// Printing
static const char* ICState2String(InlineCacheState state);
static const char* StubType2String(StubType type);
- static void PrintExtraICState(FILE* out, Kind kind, ExtraICState extra);
- void Disassemble(const char* name, FILE* out = stdout);
+ static void PrintExtraICState(OStream& os, // NOLINT
+ Kind kind, ExtraICState extra);
+ void Disassemble(const char* name, OStream& os); // NOLINT
#endif // ENABLE_DISASSEMBLER
// [instruction_size]: Size of the native instructions
inline void set_function_token_position(int function_token_position);
// Position of this function in the script source.
- inline int start_position();
+ inline int start_position() const;
inline void set_start_position(int start_position);
// End position of this function in the script source.
bool VerifyBailoutId(BailoutId id);
// [source code]: Source code for the function.
- bool HasSourceCode();
+ bool HasSourceCode() const;
Handle<Object> GetSourceCode();
// Number of times the function was optimized.
int CalculateInObjectProperties();
// Dispatched behavior.
- // Set max_length to -1 for unlimited length.
- void SourceCodePrint(StringStream* accumulator, int max_length);
DECLARE_PRINTER(SharedFunctionInfo)
DECLARE_VERIFIER(SharedFunctionInfo)
};
+// Printing support.
+struct SourceCodeOf {
+ SourceCodeOf(SharedFunctionInfo* v, int max = -1)
+ : value(v), max_length(max) {}
+ const SharedFunctionInfo* value;
+ int max_length;
+};
+
+
+OStream& operator<<(OStream& os, const SourceCodeOf& v);
+
+
class JSGeneratorObject: public JSObject {
public:
// [function]: The function corresponding to this generator object.
// Dispatched behavior.
void StringShortPrint(StringStream* accumulator);
+ void PrintUC16(OStream& os, int start = 0, int end = -1); // NOLINT
#ifdef OBJECT_PRINT
char* ToAsciiArray();
#endif
DECL_ACCESSORS(kind, Smi)
#ifdef OBJECT_PRINT
- void OrderedHashTableIteratorPrint(FILE* out);
+ void OrderedHashTableIteratorPrint(OStream& os); // NOLINT
#endif
static const int kTableOffset = JSObject::kHeaderSize;
return *this;
}
+
+OStream& operator<<(OStream& os, const AsUC16& c) {
+ char buf[10];
+ const char* format = (0x20 <= c.value && c.value <= 0x7F)
+ ? "%c"
+ : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x";
+ snprintf(buf, sizeof(buf), format, c.value);
+ return os << buf;
+}
} } // namespace v8::internal
DISALLOW_COPY_AND_ASSIGN(OFStream);
};
+
+// A wrapper to disambiguate uint16_t and uc16.
+struct AsUC16 {
+ explicit AsUC16(uint16_t v) : value(v) {}
+ uint16_t value;
+};
+
+
+OStream& operator<<(OStream& os, const AsUC16& c);
} } // namespace v8::internal
#endif // V8_OSTREAMS_H_
}
-#ifdef OBJECT_PRINT
-void LookupResult::Print(FILE* out) {
- OFStream os(out);
- if (!IsFound()) {
- os << "Not Found\n";
- return;
- }
+OStream& operator<<(OStream& os, const LookupResult& r) {
+ if (!r.IsFound()) return os << "Not Found\n";
os << "LookupResult:\n";
- os << " -cacheable = " << (IsCacheable() ? "true" : "false") << "\n";
- os << " -attributes = " << hex << GetAttributes() << dec << "\n";
- if (IsTransition()) {
- os << " -transition target:\n";
- GetTransitionTarget()->Print(out);
- os << "\n";
+ os << " -cacheable = " << (r.IsCacheable() ? "true" : "false") << "\n";
+ os << " -attributes = " << hex << r.GetAttributes() << dec << "\n";
+ if (r.IsTransition()) {
+ os << " -transition target:\n" << Brief(r.GetTransitionTarget()) << "\n";
}
- switch (type()) {
+ switch (r.type()) {
case NORMAL:
- os << " -type = normal\n"
- << " -entry = " << GetDictionaryEntry() << "\n";
- break;
+ return os << " -type = normal\n"
+ << " -entry = " << r.GetDictionaryEntry() << "\n";
case CONSTANT:
- os << " -type = constant\n"
- << " -value:\n";
- GetConstant()->Print(out);
- os << "\n";
- break;
+ return os << " -type = constant\n"
+ << " -value:\n" << Brief(r.GetConstant()) << "\n";
case FIELD:
os << " -type = field\n"
- << " -index = " << GetFieldIndex().property_index() << "\n"
+ << " -index = " << r.GetFieldIndex().property_index() << "\n"
<< " -field type:";
- GetFieldType()->PrintTo(os);
- os << "\n";
- break;
+ r.GetFieldType()->PrintTo(os);
+ return os << "\n";
case CALLBACKS:
- os << " -type = call backs\n"
- << " -callback object:\n";
- GetCallbackObject()->Print(out);
- break;
+ return os << " -type = call backs\n"
+ << " -callback object:\n" << Brief(r.GetCallbackObject());
case HANDLER:
- os << " -type = lookup proxy\n";
- break;
+ return os << " -type = lookup proxy\n";
case INTERCEPTOR:
- os << " -type = lookup interceptor\n";
- break;
+ return os << " -type = lookup interceptor\n";
case NONEXISTENT:
UNREACHABLE();
break;
}
+ return os;
}
-void Descriptor::Print(FILE* out) {
- PrintF(out, "Descriptor ");
- GetKey()->ShortPrint(out);
- PrintF(out, " @ ");
- GetValue()->ShortPrint(out);
+OStream& operator<<(OStream& os, const Descriptor& d) {
+ return os << "Descriptor " << Brief(*d.GetKey()) << " @ "
+ << Brief(*d.GetValue());
}
-#endif
} } // namespace v8::internal
#include "src/field-index.h"
#include "src/field-index-inl.h"
#include "src/isolate.h"
+#include "src/ostreams.h"
#include "src/types.h"
namespace v8 {
}
}
- Handle<Name> GetKey() { return key_; }
- Handle<Object> GetValue() { return value_; }
- PropertyDetails GetDetails() { return details_; }
-
-#ifdef OBJECT_PRINT
- void Print(FILE* out);
-#endif
+ Handle<Name> GetKey() const { return key_; }
+ Handle<Object> GetValue() const { return value_; }
+ PropertyDetails GetDetails() const { return details_; }
void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); }
};
+OStream& operator<<(OStream& os, const Descriptor& d);
+
+
class FieldDescriptor V8_FINAL : public Descriptor {
public:
FieldDescriptor(Handle<Name> key,
return GetValue();
}
-#ifdef OBJECT_PRINT
- void Print(FILE* out);
-#endif
-
Object* GetValue() const {
if (lookup_type_ == DESCRIPTOR_TYPE) {
return GetValueFromMap(holder()->map());
PropertyDetails details_;
};
+
+OStream& operator<<(OStream& os, const LookupResult& r);
} } // namespace v8::internal
#endif // V8_PROPERTY_H_
SealHandleScope shs(isolate);
ASSERT(args.length() == 1);
+ OFStream os(stdout);
#ifdef DEBUG
if (args[0]->IsString()) {
// If we have a string, assume it's a code "marker"
// and print some interesting cpu debugging info.
JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = it.frame();
- PrintF("fp = %p, sp = %p, caller_sp = %p: ",
- frame->fp(), frame->sp(), frame->caller_sp());
+ os << "fp = " << frame->fp() << ", sp = " << frame->sp()
+ << ", caller_sp = " << frame->caller_sp() << ": ";
} else {
- PrintF("DebugPrint: ");
+ os << "DebugPrint: ";
}
- args[0]->Print();
+ args[0]->Print(os);
if (args[0]->IsHeapObject()) {
- PrintF("\n");
- HeapObject::cast(args[0])->map()->Print();
+ os << "\n";
+ HeapObject::cast(args[0])->map()->Print(os);
}
#else
// ShortPrint is available in release mode. Print is not.
- args[0]->ShortPrint();
+ os << Brief(args[0]);
#endif
- PrintF("\n");
- Flush();
+ os << endl;
return args[0]; // return TOS
}
#ifdef DEBUG
// Debug print of the content of the current scope.
void DebugPrint() {
+ OFStream os(stdout);
ASSERT(!failed_);
switch (Type()) {
case ScopeIterator::ScopeTypeGlobal:
- PrintF("Global:\n");
- CurrentContext()->Print();
+ os << "Global:\n";
+ CurrentContext()->Print(os);
break;
case ScopeIterator::ScopeTypeLocal: {
- PrintF("Local:\n");
+ os << "Local:\n";
function_->shared()->scope_info()->Print();
if (!CurrentContext().is_null()) {
- CurrentContext()->Print();
+ CurrentContext()->Print(os);
if (CurrentContext()->has_extension()) {
Handle<Object> extension(CurrentContext()->extension(), isolate_);
if (extension->IsJSContextExtensionObject()) {
- extension->Print();
+ extension->Print(os);
}
}
}
}
case ScopeIterator::ScopeTypeWith:
- PrintF("With:\n");
- CurrentContext()->extension()->Print();
+ os << "With:\n";
+ CurrentContext()->extension()->Print(os);
break;
case ScopeIterator::ScopeTypeCatch:
- PrintF("Catch:\n");
- CurrentContext()->extension()->Print();
- CurrentContext()->get(Context::THROWN_OBJECT_INDEX)->Print();
+ os << "Catch:\n";
+ CurrentContext()->extension()->Print(os);
+ CurrentContext()->get(Context::THROWN_OBJECT_INDEX)->Print(os);
break;
case ScopeIterator::ScopeTypeClosure:
- PrintF("Closure:\n");
- CurrentContext()->Print();
+ os << "Closure:\n";
+ CurrentContext()->Print(os);
if (CurrentContext()->has_extension()) {
Handle<Object> extension(CurrentContext()->extension(), isolate_);
if (extension->IsJSContextExtensionObject()) {
- extension->Print();
+ extension->Print(os);
}
}
break;
if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) {
return isolate->heap()->exception();
}
- func->code()->PrintLn();
+ OFStream os(stdout);
+ func->code()->Print(os);
+ os << endl;
#endif // DEBUG
return isolate->heap()->undefined_value();
}
if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) {
return isolate->heap()->exception();
}
- func->shared()->construct_stub()->PrintLn();
+ OFStream os(stdout);
+ func->shared()->construct_stub()->Print(os);
+ os << endl;
#endif // DEBUG
return isolate->heap()->undefined_value();
}
}
-void SafepointTable::PrintEntry(unsigned index, FILE* out) const {
+void SafepointTable::PrintEntry(unsigned index, OStream& os) const { // NOLINT
disasm::NameConverter converter;
SafepointEntry entry = GetEntry(index);
uint8_t* bits = entry.bits();
ASSERT(IsAligned(kNumSafepointRegisters, kBitsPerByte));
const int first = kNumSafepointRegisters >> kBitsPerByteLog2;
int last = entry_size_ - 1;
- for (int i = first; i < last; i++) PrintBits(out, bits[i], kBitsPerByte);
+ for (int i = first; i < last; i++) PrintBits(os, bits[i], kBitsPerByte);
int last_bits = code_->stack_slots() - ((last - first) * kBitsPerByte);
- PrintBits(out, bits[last], last_bits);
+ PrintBits(os, bits[last], last_bits);
// Print the registers (if any).
if (!entry.HasRegisters()) return;
for (int j = 0; j < kNumSafepointRegisters; j++) {
if (entry.HasRegisterAt(j)) {
- PrintF(out, " | %s", converter.NameOfCPURegister(j));
+ os << " | " << converter.NameOfCPURegister(j);
}
}
}
}
-void SafepointTable::PrintBits(FILE* out, uint8_t byte, int digits) {
+void SafepointTable::PrintBits(OStream& os, // NOLINT
+ uint8_t byte, int digits) {
ASSERT(digits >= 0 && digits <= kBitsPerByte);
for (int i = 0; i < digits; i++) {
- PrintF(out, "%c", ((byte & (1 << i)) == 0) ? '0' : '1');
+ os << (((byte & (1 << i)) == 0) ? "0" : "1");
}
}
// Returns the entry for the given pc.
SafepointEntry FindEntry(Address pc) const;
- void PrintEntry(unsigned index, FILE* out = stdout) const;
+ void PrintEntry(unsigned index, OStream& os) const; // NOLINT
private:
static const uint8_t kNoRegisters = 0xFF;
return GetPcOffsetLocation(index) + kPcSize;
}
- static void PrintBits(FILE* out, uint8_t byte, int digits);
+ static void PrintBits(OStream& os, // NOLINT
+ uint8_t byte, int digits);
DisallowHeapAllocation no_allocation_;
Code* code_;
#ifdef DEBUG
void LargeObjectSpace::Print() {
+ OFStream os(stdout);
LargeObjectIterator it(this);
for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
- obj->Print();
+ obj->Print(os);
}
}
code->set_major_key(CodeStub::NoCache);
}
#ifdef ENABLE_DISASSEMBLER
- if (FLAG_print_code_stubs) code->Disassemble(name);
+ if (FLAG_print_code_stubs) {
+ OFStream os(stdout);
+ code->Disassemble(name, os);
+ }
#endif
return code;
}
#ifdef OBJECT_PRINT
// Print all the transitions.
- inline void PrintTransitions() {
- PrintTransitions(stdout);
- }
- void PrintTransitions(FILE* out);
+ void PrintTransitions(OStream& os); // NOLINT
#endif
#ifdef DEBUG
static void PrintObserved(Variable* var, Object* value, Type* type) {
OFStream os(stdout);
os << " observed " << (var->IsParameter() ? "param" : "local") << " ";
- var->name()->Print();
- os << " : ";
- value->ShortPrint();
- os << " -> ";
+ var->name()->Print(os);
+ os << " : " << Brief(value) << " -> ";
type->PrintTo(os);
os << endl;
}
void LStoreNamedField::PrintDataTo(StringStream* stream) {
object()->PrintTo(stream);
- hydrogen()->access().PrintTo(stream);
- stream->Add(" <- ");
+ OStringStream os;
+ os << hydrogen()->access() << " <- ";
+ stream->Add(os.c_str());
value()->PrintTo(stream);
}
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F2 f = FUNCTION_CAST<F2>(code->entry());
int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 3, 4, 0, 0, 0));
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 100, 0, 0, 0, 0));
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 10, 0, 0, 0, 0));
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F3 f = FUNCTION_CAST<F3>(code->entry());
t.i = 100000;
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F3 f = FUNCTION_CAST<F3>(code->entry());
t.a = 1.5;
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
int res = reinterpret_cast<int>(
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
int res = reinterpret_cast<int>(
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
int res = reinterpret_cast<int>(
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F4 fn = FUNCTION_CAST<F4>(code->entry());
d.a = 1.1;
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F4 fn = FUNCTION_CAST<F4>(code->entry());
d.a = 1.1;
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F4 fn = FUNCTION_CAST<F4>(code->entry());
d.a = 1.1;
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F3 f = FUNCTION_CAST<F3>(code->entry());
Object* dummy = CALL_GENERATED_CODE(f, &i, 0, 0, 0, 0);
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F3 f = FUNCTION_CAST<F3>(code->entry());
t.a = 1.5;
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F3 f = FUNCTION_CAST<F3>(code->entry());
t.left = BitCast<double>(kHoleNanInt64);
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F3 f = FUNCTION_CAST<F3>(code->entry());
t.src0 = 0x01020304;
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F3 f = FUNCTION_CAST<F3>(code->entry());
t.src0 = 0x01020304;
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef DEBUG
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F3 f = FUNCTION_CAST<F3>(code->entry());
Object* dummy;
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef OBJECT_PRINT
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F2 f = FUNCTION_CAST<F2>(code->entry());
int res = f(3, 4);
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef OBJECT_PRINT
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
int res = f(100);
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef OBJECT_PRINT
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
int res = f(10);
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef OBJECT_PRINT
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F6 f = FUNCTION_CAST<F6>(code->entry());
double res = f(12);
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef OBJECT_PRINT
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F7 f = FUNCTION_CAST<F7>(code->entry());
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef OBJECT_PRINT
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F4 f = FUNCTION_CAST<F4>(code->entry());
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef OBJECT_PRINT
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F8 f = FUNCTION_CAST<F8>(code->entry());
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
#ifdef OBJECT_PRINT
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F3 f = FUNCTION_CAST<F3>(code->entry());
Code::ComputeFlags(Code::STUB),
Handle<Code>());
#ifdef OBJECT_PRINT
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
#endif
F6 f = FUNCTION_CAST<F6>(code->entry());
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
USE(code);
#ifdef OBJECT_PRINT
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
byte* begin = code->instruction_start();
byte* end = begin + code->instruction_size();
disasm::Disassembler::Disassemble(stdout, begin, end);
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
USE(code);
#ifdef OBJECT_PRINT
- code->Print();
+ OFStream os(stdout);
+ code->Print(os);
byte* begin = code->instruction_start();
byte* end = begin + code->instruction_size();
disasm::Disassembler::Disassemble(stdout, begin, end);
*v8::Handle<v8::Function>::Cast(
CcTest::global()->Get(v8_str("g"))));
- DisallowHeapAllocation no_allocation;
- g->shared()->PrintLn();
+ OFStream os(stdout);
+ g->shared()->Print(os);
+ os << endl;
}
#endif // OBJECT_PRINT
}
-static SmartArrayPointer<const char> Parse(const char* input) {
+static void CheckParseEq(const char* input, const char* expected) {
V8::Initialize(NULL);
v8::HandleScope scope(CcTest::isolate());
Zone zone(CcTest::i_isolate());
&reader, false, &result, &zone));
CHECK(result.tree != NULL);
CHECK(result.error.is_null());
- SmartArrayPointer<const char> output = result.tree->ToString(&zone);
- return output;
+ OStringStream os;
+ result.tree->Print(os, &zone);
+ CHECK_EQ(expected, os.c_str());
}
#define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input))
-#define CHECK_PARSE_EQ(input, expected) CHECK_EQ(expected, Parse(input).get())
#define CHECK_SIMPLE(input, simple) CHECK_EQ(simple, CheckSimple(input));
#define CHECK_MIN_MAX(input, min, max) \
{ MinMaxPair min_max = CheckMinMaxMatch(input); \
CHECK_PARSE_ERROR("?");
- CHECK_PARSE_EQ("abc", "'abc'");
- CHECK_PARSE_EQ("", "%");
- CHECK_PARSE_EQ("abc|def", "(| 'abc' 'def')");
- CHECK_PARSE_EQ("abc|def|ghi", "(| 'abc' 'def' 'ghi')");
- CHECK_PARSE_EQ("^xxx$", "(: @^i 'xxx' @$i)");
- CHECK_PARSE_EQ("ab\\b\\d\\bcd", "(: 'ab' @b [0-9] @b 'cd')");
- CHECK_PARSE_EQ("\\w|\\d", "(| [0-9 A-Z _ a-z] [0-9])");
- CHECK_PARSE_EQ("a*", "(# 0 - g 'a')");
- CHECK_PARSE_EQ("a*?", "(# 0 - n 'a')");
- CHECK_PARSE_EQ("abc+", "(: 'ab' (# 1 - g 'c'))");
- CHECK_PARSE_EQ("abc+?", "(: 'ab' (# 1 - n 'c'))");
- CHECK_PARSE_EQ("xyz?", "(: 'xy' (# 0 1 g 'z'))");
- CHECK_PARSE_EQ("xyz??", "(: 'xy' (# 0 1 n 'z'))");
- CHECK_PARSE_EQ("xyz{0,1}", "(: 'xy' (# 0 1 g 'z'))");
- CHECK_PARSE_EQ("xyz{0,1}?", "(: 'xy' (# 0 1 n 'z'))");
- CHECK_PARSE_EQ("xyz{93}", "(: 'xy' (# 93 93 g 'z'))");
- CHECK_PARSE_EQ("xyz{93}?", "(: 'xy' (# 93 93 n 'z'))");
- CHECK_PARSE_EQ("xyz{1,32}", "(: 'xy' (# 1 32 g 'z'))");
- CHECK_PARSE_EQ("xyz{1,32}?", "(: 'xy' (# 1 32 n 'z'))");
- CHECK_PARSE_EQ("xyz{1,}", "(: 'xy' (# 1 - g 'z'))");
- CHECK_PARSE_EQ("xyz{1,}?", "(: 'xy' (# 1 - n 'z'))");
- CHECK_PARSE_EQ("a\\fb\\nc\\rd\\te\\vf", "'a\\x0cb\\x0ac\\x0dd\\x09e\\x0bf'");
- CHECK_PARSE_EQ("a\\nb\\bc", "(: 'a\\x0ab' @b 'c')");
- CHECK_PARSE_EQ("(?:foo)", "'foo'");
- CHECK_PARSE_EQ("(?: foo )", "' foo '");
- CHECK_PARSE_EQ("(foo|bar|baz)", "(^ (| 'foo' 'bar' 'baz'))");
- CHECK_PARSE_EQ("foo|(bar|baz)|quux", "(| 'foo' (^ (| 'bar' 'baz')) 'quux')");
- CHECK_PARSE_EQ("foo(?=bar)baz", "(: 'foo' (-> + 'bar') 'baz')");
- CHECK_PARSE_EQ("foo(?!bar)baz", "(: 'foo' (-> - 'bar') 'baz')");
- CHECK_PARSE_EQ("()", "(^ %)");
- CHECK_PARSE_EQ("(?=)", "(-> + %)");
- CHECK_PARSE_EQ("[]", "^[\\x00-\\uffff]"); // Doesn't compile on windows
- CHECK_PARSE_EQ("[^]", "[\\x00-\\uffff]"); // \uffff isn't in codepage 1252
- CHECK_PARSE_EQ("[x]", "[x]");
- CHECK_PARSE_EQ("[xyz]", "[x y z]");
- CHECK_PARSE_EQ("[a-zA-Z0-9]", "[a-z A-Z 0-9]");
- CHECK_PARSE_EQ("[-123]", "[- 1 2 3]");
- CHECK_PARSE_EQ("[^123]", "^[1 2 3]");
- CHECK_PARSE_EQ("]", "']'");
- CHECK_PARSE_EQ("}", "'}'");
- CHECK_PARSE_EQ("[a-b-c]", "[a-b - c]");
- CHECK_PARSE_EQ("[\\d]", "[0-9]");
- CHECK_PARSE_EQ("[x\\dz]", "[x 0-9 z]");
- CHECK_PARSE_EQ("[\\d-z]", "[0-9 - z]");
- CHECK_PARSE_EQ("[\\d-\\d]", "[0-9 - 0-9]");
- CHECK_PARSE_EQ("[z-\\d]", "[z - 0-9]");
+ CheckParseEq("abc", "'abc'");
+ CheckParseEq("", "%");
+ CheckParseEq("abc|def", "(| 'abc' 'def')");
+ CheckParseEq("abc|def|ghi", "(| 'abc' 'def' 'ghi')");
+ CheckParseEq("^xxx$", "(: @^i 'xxx' @$i)");
+ CheckParseEq("ab\\b\\d\\bcd", "(: 'ab' @b [0-9] @b 'cd')");
+ CheckParseEq("\\w|\\d", "(| [0-9 A-Z _ a-z] [0-9])");
+ CheckParseEq("a*", "(# 0 - g 'a')");
+ CheckParseEq("a*?", "(# 0 - n 'a')");
+ CheckParseEq("abc+", "(: 'ab' (# 1 - g 'c'))");
+ CheckParseEq("abc+?", "(: 'ab' (# 1 - n 'c'))");
+ CheckParseEq("xyz?", "(: 'xy' (# 0 1 g 'z'))");
+ CheckParseEq("xyz??", "(: 'xy' (# 0 1 n 'z'))");
+ CheckParseEq("xyz{0,1}", "(: 'xy' (# 0 1 g 'z'))");
+ CheckParseEq("xyz{0,1}?", "(: 'xy' (# 0 1 n 'z'))");
+ CheckParseEq("xyz{93}", "(: 'xy' (# 93 93 g 'z'))");
+ CheckParseEq("xyz{93}?", "(: 'xy' (# 93 93 n 'z'))");
+ CheckParseEq("xyz{1,32}", "(: 'xy' (# 1 32 g 'z'))");
+ CheckParseEq("xyz{1,32}?", "(: 'xy' (# 1 32 n 'z'))");
+ CheckParseEq("xyz{1,}", "(: 'xy' (# 1 - g 'z'))");
+ CheckParseEq("xyz{1,}?", "(: 'xy' (# 1 - n 'z'))");
+ CheckParseEq("a\\fb\\nc\\rd\\te\\vf", "'a\\x0cb\\x0ac\\x0dd\\x09e\\x0bf'");
+ CheckParseEq("a\\nb\\bc", "(: 'a\\x0ab' @b 'c')");
+ CheckParseEq("(?:foo)", "'foo'");
+ CheckParseEq("(?: foo )", "' foo '");
+ CheckParseEq("(foo|bar|baz)", "(^ (| 'foo' 'bar' 'baz'))");
+ CheckParseEq("foo|(bar|baz)|quux", "(| 'foo' (^ (| 'bar' 'baz')) 'quux')");
+ CheckParseEq("foo(?=bar)baz", "(: 'foo' (-> + 'bar') 'baz')");
+ CheckParseEq("foo(?!bar)baz", "(: 'foo' (-> - 'bar') 'baz')");
+ CheckParseEq("()", "(^ %)");
+ CheckParseEq("(?=)", "(-> + %)");
+ CheckParseEq("[]", "^[\\x00-\\uffff]"); // Doesn't compile on windows
+ CheckParseEq("[^]", "[\\x00-\\uffff]"); // \uffff isn't in codepage 1252
+ CheckParseEq("[x]", "[x]");
+ CheckParseEq("[xyz]", "[x y z]");
+ CheckParseEq("[a-zA-Z0-9]", "[a-z A-Z 0-9]");
+ CheckParseEq("[-123]", "[- 1 2 3]");
+ CheckParseEq("[^123]", "^[1 2 3]");
+ CheckParseEq("]", "']'");
+ CheckParseEq("}", "'}'");
+ CheckParseEq("[a-b-c]", "[a-b - c]");
+ CheckParseEq("[\\d]", "[0-9]");
+ CheckParseEq("[x\\dz]", "[x 0-9 z]");
+ CheckParseEq("[\\d-z]", "[0-9 - z]");
+ CheckParseEq("[\\d-\\d]", "[0-9 - 0-9]");
+ CheckParseEq("[z-\\d]", "[z - 0-9]");
// Control character outside character class.
- CHECK_PARSE_EQ("\\cj\\cJ\\ci\\cI\\ck\\cK",
- "'\\x0a\\x0a\\x09\\x09\\x0b\\x0b'");
- CHECK_PARSE_EQ("\\c!", "'\\c!'");
- CHECK_PARSE_EQ("\\c_", "'\\c_'");
- CHECK_PARSE_EQ("\\c~", "'\\c~'");
- CHECK_PARSE_EQ("\\c1", "'\\c1'");
+ CheckParseEq("\\cj\\cJ\\ci\\cI\\ck\\cK", "'\\x0a\\x0a\\x09\\x09\\x0b\\x0b'");
+ CheckParseEq("\\c!", "'\\c!'");
+ CheckParseEq("\\c_", "'\\c_'");
+ CheckParseEq("\\c~", "'\\c~'");
+ CheckParseEq("\\c1", "'\\c1'");
// Control character inside character class.
- CHECK_PARSE_EQ("[\\c!]", "[\\ c !]");
- CHECK_PARSE_EQ("[\\c_]", "[\\x1f]");
- CHECK_PARSE_EQ("[\\c~]", "[\\ c ~]");
- CHECK_PARSE_EQ("[\\ca]", "[\\x01]");
- CHECK_PARSE_EQ("[\\cz]", "[\\x1a]");
- CHECK_PARSE_EQ("[\\cA]", "[\\x01]");
- CHECK_PARSE_EQ("[\\cZ]", "[\\x1a]");
- CHECK_PARSE_EQ("[\\c1]", "[\\x11]");
-
- CHECK_PARSE_EQ("[a\\]c]", "[a ] c]");
- CHECK_PARSE_EQ("\\[\\]\\{\\}\\(\\)\\%\\^\\#\\ ", "'[]{}()%^# '");
- CHECK_PARSE_EQ("[\\[\\]\\{\\}\\(\\)\\%\\^\\#\\ ]", "[[ ] { } ( ) % ^ # ]");
- CHECK_PARSE_EQ("\\0", "'\\x00'");
- CHECK_PARSE_EQ("\\8", "'8'");
- CHECK_PARSE_EQ("\\9", "'9'");
- CHECK_PARSE_EQ("\\11", "'\\x09'");
- CHECK_PARSE_EQ("\\11a", "'\\x09a'");
- CHECK_PARSE_EQ("\\011", "'\\x09'");
- CHECK_PARSE_EQ("\\00011", "'\\x0011'");
- CHECK_PARSE_EQ("\\118", "'\\x098'");
- CHECK_PARSE_EQ("\\111", "'I'");
- CHECK_PARSE_EQ("\\1111", "'I1'");
- CHECK_PARSE_EQ("(x)(x)(x)\\1", "(: (^ 'x') (^ 'x') (^ 'x') (<- 1))");
- CHECK_PARSE_EQ("(x)(x)(x)\\2", "(: (^ 'x') (^ 'x') (^ 'x') (<- 2))");
- CHECK_PARSE_EQ("(x)(x)(x)\\3", "(: (^ 'x') (^ 'x') (^ 'x') (<- 3))");
- CHECK_PARSE_EQ("(x)(x)(x)\\4", "(: (^ 'x') (^ 'x') (^ 'x') '\\x04')");
- CHECK_PARSE_EQ("(x)(x)(x)\\1*", "(: (^ 'x') (^ 'x') (^ 'x')"
- " (# 0 - g (<- 1)))");
- CHECK_PARSE_EQ("(x)(x)(x)\\2*", "(: (^ 'x') (^ 'x') (^ 'x')"
- " (# 0 - g (<- 2)))");
- CHECK_PARSE_EQ("(x)(x)(x)\\3*", "(: (^ 'x') (^ 'x') (^ 'x')"
- " (# 0 - g (<- 3)))");
- CHECK_PARSE_EQ("(x)(x)(x)\\4*", "(: (^ 'x') (^ 'x') (^ 'x')"
- " (# 0 - g '\\x04'))");
- CHECK_PARSE_EQ("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\10",
- "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')"
- " (^ 'x') (^ 'x') (^ 'x') (^ 'x') (<- 10))");
- CHECK_PARSE_EQ("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\11",
- "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')"
- " (^ 'x') (^ 'x') (^ 'x') (^ 'x') '\\x09')");
- CHECK_PARSE_EQ("(a)\\1", "(: (^ 'a') (<- 1))");
- CHECK_PARSE_EQ("(a\\1)", "(^ 'a')");
- CHECK_PARSE_EQ("(\\1a)", "(^ 'a')");
- CHECK_PARSE_EQ("(?=a)?a", "'a'");
- CHECK_PARSE_EQ("(?=a){0,10}a", "'a'");
- CHECK_PARSE_EQ("(?=a){1,10}a", "(: (-> + 'a') 'a')");
- CHECK_PARSE_EQ("(?=a){9,10}a", "(: (-> + 'a') 'a')");
- CHECK_PARSE_EQ("(?!a)?a", "'a'");
- CHECK_PARSE_EQ("\\1(a)", "(^ 'a')");
- CHECK_PARSE_EQ("(?!(a))\\1", "(: (-> - (^ 'a')) (<- 1))");
- CHECK_PARSE_EQ("(?!\\1(a\\1)\\1)\\1", "(: (-> - (: (^ 'a') (<- 1))) (<- 1))");
- CHECK_PARSE_EQ("[\\0]", "[\\x00]");
- CHECK_PARSE_EQ("[\\11]", "[\\x09]");
- CHECK_PARSE_EQ("[\\11a]", "[\\x09 a]");
- CHECK_PARSE_EQ("[\\011]", "[\\x09]");
- CHECK_PARSE_EQ("[\\00011]", "[\\x00 1 1]");
- CHECK_PARSE_EQ("[\\118]", "[\\x09 8]");
- CHECK_PARSE_EQ("[\\111]", "[I]");
- CHECK_PARSE_EQ("[\\1111]", "[I 1]");
- CHECK_PARSE_EQ("\\x34", "'\x34'");
- CHECK_PARSE_EQ("\\x60", "'\x60'");
- CHECK_PARSE_EQ("\\x3z", "'x3z'");
- CHECK_PARSE_EQ("\\c", "'\\c'");
- CHECK_PARSE_EQ("\\u0034", "'\x34'");
- CHECK_PARSE_EQ("\\u003z", "'u003z'");
- CHECK_PARSE_EQ("foo[z]*", "(: 'foo' (# 0 - g [z]))");
+ CheckParseEq("[\\c!]", "[\\ c !]");
+ CheckParseEq("[\\c_]", "[\\x1f]");
+ CheckParseEq("[\\c~]", "[\\ c ~]");
+ CheckParseEq("[\\ca]", "[\\x01]");
+ CheckParseEq("[\\cz]", "[\\x1a]");
+ CheckParseEq("[\\cA]", "[\\x01]");
+ CheckParseEq("[\\cZ]", "[\\x1a]");
+ CheckParseEq("[\\c1]", "[\\x11]");
+
+ CheckParseEq("[a\\]c]", "[a ] c]");
+ CheckParseEq("\\[\\]\\{\\}\\(\\)\\%\\^\\#\\ ", "'[]{}()%^# '");
+ CheckParseEq("[\\[\\]\\{\\}\\(\\)\\%\\^\\#\\ ]", "[[ ] { } ( ) % ^ # ]");
+ CheckParseEq("\\0", "'\\x00'");
+ CheckParseEq("\\8", "'8'");
+ CheckParseEq("\\9", "'9'");
+ CheckParseEq("\\11", "'\\x09'");
+ CheckParseEq("\\11a", "'\\x09a'");
+ CheckParseEq("\\011", "'\\x09'");
+ CheckParseEq("\\00011", "'\\x0011'");
+ CheckParseEq("\\118", "'\\x098'");
+ CheckParseEq("\\111", "'I'");
+ CheckParseEq("\\1111", "'I1'");
+ CheckParseEq("(x)(x)(x)\\1", "(: (^ 'x') (^ 'x') (^ 'x') (<- 1))");
+ CheckParseEq("(x)(x)(x)\\2", "(: (^ 'x') (^ 'x') (^ 'x') (<- 2))");
+ CheckParseEq("(x)(x)(x)\\3", "(: (^ 'x') (^ 'x') (^ 'x') (<- 3))");
+ CheckParseEq("(x)(x)(x)\\4", "(: (^ 'x') (^ 'x') (^ 'x') '\\x04')");
+ CheckParseEq("(x)(x)(x)\\1*",
+ "(: (^ 'x') (^ 'x') (^ 'x')"
+ " (# 0 - g (<- 1)))");
+ CheckParseEq("(x)(x)(x)\\2*",
+ "(: (^ 'x') (^ 'x') (^ 'x')"
+ " (# 0 - g (<- 2)))");
+ CheckParseEq("(x)(x)(x)\\3*",
+ "(: (^ 'x') (^ 'x') (^ 'x')"
+ " (# 0 - g (<- 3)))");
+ CheckParseEq("(x)(x)(x)\\4*",
+ "(: (^ 'x') (^ 'x') (^ 'x')"
+ " (# 0 - g '\\x04'))");
+ CheckParseEq("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\10",
+ "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')"
+ " (^ 'x') (^ 'x') (^ 'x') (^ 'x') (<- 10))");
+ CheckParseEq("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\11",
+ "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')"
+ " (^ 'x') (^ 'x') (^ 'x') (^ 'x') '\\x09')");
+ CheckParseEq("(a)\\1", "(: (^ 'a') (<- 1))");
+ CheckParseEq("(a\\1)", "(^ 'a')");
+ CheckParseEq("(\\1a)", "(^ 'a')");
+ CheckParseEq("(?=a)?a", "'a'");
+ CheckParseEq("(?=a){0,10}a", "'a'");
+ CheckParseEq("(?=a){1,10}a", "(: (-> + 'a') 'a')");
+ CheckParseEq("(?=a){9,10}a", "(: (-> + 'a') 'a')");
+ CheckParseEq("(?!a)?a", "'a'");
+ CheckParseEq("\\1(a)", "(^ 'a')");
+ CheckParseEq("(?!(a))\\1", "(: (-> - (^ 'a')) (<- 1))");
+ CheckParseEq("(?!\\1(a\\1)\\1)\\1", "(: (-> - (: (^ 'a') (<- 1))) (<- 1))");
+ CheckParseEq("[\\0]", "[\\x00]");
+ CheckParseEq("[\\11]", "[\\x09]");
+ CheckParseEq("[\\11a]", "[\\x09 a]");
+ CheckParseEq("[\\011]", "[\\x09]");
+ CheckParseEq("[\\00011]", "[\\x00 1 1]");
+ CheckParseEq("[\\118]", "[\\x09 8]");
+ CheckParseEq("[\\111]", "[I]");
+ CheckParseEq("[\\1111]", "[I 1]");
+ CheckParseEq("\\x34", "'\x34'");
+ CheckParseEq("\\x60", "'\x60'");
+ CheckParseEq("\\x3z", "'x3z'");
+ CheckParseEq("\\c", "'\\c'");
+ CheckParseEq("\\u0034", "'\x34'");
+ CheckParseEq("\\u003z", "'u003z'");
+ CheckParseEq("foo[z]*", "(: 'foo' (# 0 - g [z]))");
CHECK_SIMPLE("", false);
CHECK_SIMPLE("a", true);
CHECK_SIMPLE("(?!a)?a\\1", false);
CHECK_SIMPLE("(?:(?=a))a\\1", false);
- CHECK_PARSE_EQ("a{}", "'a{}'");
- CHECK_PARSE_EQ("a{,}", "'a{,}'");
- CHECK_PARSE_EQ("a{", "'a{'");
- CHECK_PARSE_EQ("a{z}", "'a{z}'");
- CHECK_PARSE_EQ("a{1z}", "'a{1z}'");
- CHECK_PARSE_EQ("a{12z}", "'a{12z}'");
- CHECK_PARSE_EQ("a{12,", "'a{12,'");
- CHECK_PARSE_EQ("a{12,3b", "'a{12,3b'");
- CHECK_PARSE_EQ("{}", "'{}'");
- CHECK_PARSE_EQ("{,}", "'{,}'");
- CHECK_PARSE_EQ("{", "'{'");
- CHECK_PARSE_EQ("{z}", "'{z}'");
- CHECK_PARSE_EQ("{1z}", "'{1z}'");
- CHECK_PARSE_EQ("{12z}", "'{12z}'");
- CHECK_PARSE_EQ("{12,", "'{12,'");
- CHECK_PARSE_EQ("{12,3b", "'{12,3b'");
+ CheckParseEq("a{}", "'a{}'");
+ CheckParseEq("a{,}", "'a{,}'");
+ CheckParseEq("a{", "'a{'");
+ CheckParseEq("a{z}", "'a{z}'");
+ CheckParseEq("a{1z}", "'a{1z}'");
+ CheckParseEq("a{12z}", "'a{12z}'");
+ CheckParseEq("a{12,", "'a{12,'");
+ CheckParseEq("a{12,3b", "'a{12,3b'");
+ CheckParseEq("{}", "'{}'");
+ CheckParseEq("{,}", "'{,}'");
+ CheckParseEq("{", "'{'");
+ CheckParseEq("{z}", "'{z}'");
+ CheckParseEq("{1z}", "'{1z}'");
+ CheckParseEq("{12z}", "'{12z}'");
+ CheckParseEq("{12,", "'{12,'");
+ CheckParseEq("{12,3b", "'{12,3b'");
CHECK_MIN_MAX("a", 1, 1);
CHECK_MIN_MAX("abc", 3, 3);
TEST(ParserRegression) {
- CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])");
- CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')");
- CHECK_PARSE_EQ("{", "'{'");
- CHECK_PARSE_EQ("a|", "(| 'a' %)");
+ CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])");
+ CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')");
+ CheckParseEq("{", "'{'");
+ CheckParseEq("a|", "(| 'a' %)");
}
static void ExpectError(const char* input,
// 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";
- HeapStringAllocator allocator;
- StringStream accumulator(&allocator);
+ OStringStream os;
for (int i = 0; i <= kMaxCaptures; i++) {
- accumulator.Add("()");
+ os << "()";
}
- SmartArrayPointer<const char> many_captures(accumulator.ToCString());
- ExpectError(many_captures.get(), kTooManyCaptures);
+ ExpectError(os.c_str(), kTooManyCaptures);
}
// Enable possessive quantifier syntax.
FLAG_regexp_possessive_quantifier = true;
- CHECK_PARSE_EQ("a*+", "(# 0 - p 'a')");
- CHECK_PARSE_EQ("a++", "(# 1 - p 'a')");
- CHECK_PARSE_EQ("a?+", "(# 0 1 p 'a')");
- CHECK_PARSE_EQ("a{10,20}+", "(# 10 20 p 'a')");
- CHECK_PARSE_EQ("za{10,20}+b", "(: 'z' (# 10 20 p 'a') 'b')");
+ CheckParseEq("a*+", "(# 0 - p 'a')");
+ CheckParseEq("a++", "(# 1 - p 'a')");
+ CheckParseEq("a?+", "(# 0 1 p 'a')");
+ CheckParseEq("a{10,20}+", "(# 10 20 p 'a')");
+ CheckParseEq("za{10,20}+b", "(: 'z' (# 10 20 p 'a') 'b')");
// Disable possessive quantifier syntax.
FLAG_regexp_possessive_quantifier = false;
const int kNumSymbols = 30;
Handle<Symbol> symbols[kNumSymbols];
+ OFStream os(stdout);
for (int i = 0; i < kNumSymbols; ++i) {
symbols[i] = isolate->factory()->NewSymbol();
CHECK(symbols[i]->IsName());
CHECK(symbols[i]->IsSymbol());
CHECK(symbols[i]->HasHashCode());
CHECK_GT(symbols[i]->Hash(), 0);
- symbols[i]->ShortPrint();
- PrintF("\n");
+ os << Brief(*symbols[i]) << "\n";
#if OBJECT_PRINT
- symbols[i]->Print();
+ symbols[i]->Print(os);
#endif
#if VERIFY_HEAP
symbols[i]->ObjectVerify();