2014-04-24 11:44:22 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2014-04-24 11:44:22 +00:00
|
|
|
|
2015-08-20 07:44:00 +00:00
|
|
|
#include "src/objects.h"
|
2010-12-22 13:04:47 +00:00
|
|
|
|
2016-07-25 10:24:45 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/disasm.h"
|
2014-06-20 08:40:11 +00:00
|
|
|
#include "src/disassembler.h"
|
2015-07-24 12:02:41 +00:00
|
|
|
#include "src/interpreter/bytecodes.h"
|
2015-08-20 07:44:00 +00:00
|
|
|
#include "src/objects-inl.h"
|
2014-07-30 13:54:45 +00:00
|
|
|
#include "src/ostreams.h"
|
2015-08-13 06:55:21 +00:00
|
|
|
#include "src/regexp/jsregexp.h"
|
2010-12-22 13:04:47 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
|
2014-04-30 12:25:18 +00:00
|
|
|
void Object::Print() {
|
2014-07-07 09:57:29 +00:00
|
|
|
OFStream os(stdout);
|
|
|
|
this->Print(os);
|
2014-09-30 10:29:32 +00:00
|
|
|
os << std::flush;
|
2013-07-18 14:40:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void Object::Print(std::ostream& os) { // NOLINT
|
2014-04-30 12:25:18 +00:00
|
|
|
if (IsSmi()) {
|
2014-07-07 09:57:29 +00:00
|
|
|
Smi::cast(this)->SmiPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
} else {
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::cast(this)->HeapObjectPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void HeapObject::PrintHeader(std::ostream& os, const char* id) { // NOLINT
|
2016-04-07 15:27:35 +00:00
|
|
|
os << reinterpret_cast<void*>(this) << ": [";
|
|
|
|
if (id != nullptr) {
|
|
|
|
os << id;
|
|
|
|
} else {
|
|
|
|
os << map()->instance_type();
|
|
|
|
}
|
|
|
|
os << "]";
|
2013-07-18 14:40:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
|
2010-12-22 13:04:47 +00:00
|
|
|
InstanceType instance_type = map()->instance_type();
|
|
|
|
|
2013-02-15 09:27:10 +00:00
|
|
|
HandleScope scope(GetIsolate());
|
2010-12-22 13:04:47 +00:00
|
|
|
if (instance_type < FIRST_NONSTRING_TYPE) {
|
2014-07-07 09:57:29 +00:00
|
|
|
String::cast(this)->StringPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (instance_type) {
|
2013-03-01 10:34:31 +00:00
|
|
|
case SYMBOL_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
Symbol::cast(this)->SymbolPrint(os);
|
2013-03-01 10:34:31 +00:00
|
|
|
break;
|
2010-12-22 13:04:47 +00:00
|
|
|
case MAP_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
Map::cast(this)->MapPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
|
|
|
case HEAP_NUMBER_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapNumber::cast(this)->HeapNumberPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
2014-07-01 15:02:31 +00:00
|
|
|
case MUTABLE_HEAP_NUMBER_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "<mutable ";
|
|
|
|
HeapNumber::cast(this)->HeapNumberPrint(os);
|
|
|
|
os << ">";
|
2014-07-01 15:02:31 +00:00
|
|
|
break;
|
2015-08-11 09:45:25 +00:00
|
|
|
case SIMD128_VALUE_TYPE:
|
|
|
|
Simd128Value::cast(this)->Simd128ValuePrint(os);
|
2015-08-03 13:02:39 +00:00
|
|
|
break;
|
2011-09-22 11:30:04 +00:00
|
|
|
case FIXED_DOUBLE_ARRAY_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(os);
|
2011-09-22 11:30:04 +00:00
|
|
|
break;
|
2010-12-22 13:04:47 +00:00
|
|
|
case FIXED_ARRAY_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
FixedArray::cast(this)->FixedArrayPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
|
|
|
case BYTE_ARRAY_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
ByteArray::cast(this)->ByteArrayPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
2015-07-24 12:02:41 +00:00
|
|
|
case BYTECODE_ARRAY_TYPE:
|
|
|
|
BytecodeArray::cast(this)->BytecodeArrayPrint(os);
|
|
|
|
break;
|
2015-12-03 13:18:19 +00:00
|
|
|
case TRANSITION_ARRAY_TYPE:
|
|
|
|
TransitionArray::cast(this)->TransitionArrayPrint(os);
|
|
|
|
break;
|
2011-09-19 18:36:47 +00:00
|
|
|
case FREE_SPACE_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
FreeSpace::cast(this)->FreeSpacePrint(os);
|
2011-09-19 18:36:47 +00:00
|
|
|
break;
|
2014-01-24 16:01:15 +00:00
|
|
|
|
2014-07-07 09:57:29 +00:00
|
|
|
#define PRINT_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
|
|
|
|
case Fixed##Type##Array::kInstanceType: \
|
|
|
|
Fixed##Type##Array::cast(this)->FixedTypedArrayPrint(os); \
|
|
|
|
break;
|
2014-01-16 17:08:45 +00:00
|
|
|
|
2014-01-24 16:01:15 +00:00
|
|
|
TYPED_ARRAYS(PRINT_FIXED_TYPED_ARRAY)
|
|
|
|
#undef PRINT_FIXED_TYPED_ARRAY
|
2014-01-16 17:08:45 +00:00
|
|
|
|
2010-12-22 13:04:47 +00:00
|
|
|
case FILLER_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "filler";
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
|
|
|
case JS_OBJECT_TYPE: // fall through
|
2016-04-12 10:31:38 +00:00
|
|
|
case JS_API_OBJECT_TYPE:
|
2016-03-04 11:51:55 +00:00
|
|
|
case JS_SPECIAL_API_OBJECT_TYPE:
|
2010-12-22 13:04:47 +00:00
|
|
|
case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
|
2013-04-15 12:29:44 +00:00
|
|
|
case JS_GENERATOR_OBJECT_TYPE:
|
2015-11-19 16:11:00 +00:00
|
|
|
case JS_PROMISE_TYPE:
|
2016-06-27 08:13:52 +00:00
|
|
|
case JS_ARGUMENTS_TYPE:
|
|
|
|
case JS_ERROR_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSObject::cast(this)->JSObjectPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
2016-04-07 15:27:35 +00:00
|
|
|
case JS_ARRAY_TYPE:
|
|
|
|
JSArray::cast(this)->JSArrayPrint(os);
|
|
|
|
break;
|
2015-11-03 13:20:21 +00:00
|
|
|
case JS_REGEXP_TYPE:
|
|
|
|
JSRegExp::cast(this)->JSRegExpPrint(os);
|
|
|
|
break;
|
2010-12-22 13:04:47 +00:00
|
|
|
case ODDBALL_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
Oddball::cast(this)->to_string()->Print(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
2015-12-27 06:30:53 +00:00
|
|
|
case JS_BOUND_FUNCTION_TYPE:
|
|
|
|
JSBoundFunction::cast(this)->JSBoundFunctionPrint(os);
|
|
|
|
break;
|
2010-12-22 13:04:47 +00:00
|
|
|
case JS_FUNCTION_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSFunction::cast(this)->JSFunctionPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
|
|
|
case JS_GLOBAL_PROXY_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSGlobalProxy::cast(this)->JSGlobalProxyPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
|
|
|
case JS_GLOBAL_OBJECT_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSGlobalObject::cast(this)->JSGlobalObjectPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
|
|
|
case JS_VALUE_TYPE:
|
2015-11-02 08:25:19 +00:00
|
|
|
JSValue::cast(this)->JSValuePrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
2012-03-09 11:11:55 +00:00
|
|
|
case JS_DATE_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSDate::cast(this)->JSDatePrint(os);
|
2012-03-09 11:11:55 +00:00
|
|
|
break;
|
2010-12-22 13:04:47 +00:00
|
|
|
case CODE_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
Code::cast(this)->CodePrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
2011-05-13 10:58:25 +00:00
|
|
|
case JS_PROXY_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSProxy::cast(this)->JSProxyPrint(os);
|
2011-05-13 10:58:25 +00:00
|
|
|
break;
|
2013-08-01 08:36:21 +00:00
|
|
|
case JS_SET_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSSet::cast(this)->JSSetPrint(os);
|
2013-08-01 08:36:21 +00:00
|
|
|
break;
|
|
|
|
case JS_MAP_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSMap::cast(this)->JSMapPrint(os);
|
2013-08-01 08:36:21 +00:00
|
|
|
break;
|
2014-04-17 17:45:32 +00:00
|
|
|
case JS_SET_ITERATOR_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSSetIterator::cast(this)->JSSetIteratorPrint(os);
|
2014-04-17 17:45:32 +00:00
|
|
|
break;
|
|
|
|
case JS_MAP_ITERATOR_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSMapIterator::cast(this)->JSMapIteratorPrint(os);
|
2014-04-17 17:45:32 +00:00
|
|
|
break;
|
2011-08-03 11:55:13 +00:00
|
|
|
case JS_WEAK_MAP_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSWeakMap::cast(this)->JSWeakMapPrint(os);
|
2011-08-03 11:55:13 +00:00
|
|
|
break;
|
2013-07-22 08:32:24 +00:00
|
|
|
case JS_WEAK_SET_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSWeakSet::cast(this)->JSWeakSetPrint(os);
|
2013-07-22 08:32:24 +00:00
|
|
|
break;
|
2011-05-19 11:47:34 +00:00
|
|
|
case FOREIGN_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
Foreign::cast(this)->ForeignPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
|
|
|
case SHARED_FUNCTION_INFO_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
2011-02-02 13:31:52 +00:00
|
|
|
case JS_MESSAGE_OBJECT_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSMessageObject::cast(this)->JSMessageObjectPrint(os);
|
2011-02-02 13:31:52 +00:00
|
|
|
break;
|
2013-06-12 15:03:44 +00:00
|
|
|
case CELL_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
Cell::cast(this)->CellPrint(os);
|
2013-06-12 15:03:44 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_CELL_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
PropertyCell::cast(this)->PropertyCellPrint(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
2014-10-14 14:43:45 +00:00
|
|
|
case WEAK_CELL_TYPE:
|
|
|
|
WeakCell::cast(this)->WeakCellPrint(os);
|
|
|
|
break;
|
2013-03-28 12:50:18 +00:00
|
|
|
case JS_ARRAY_BUFFER_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSArrayBuffer::cast(this)->JSArrayBufferPrint(os);
|
2013-04-18 12:46:38 +00:00
|
|
|
break;
|
2013-04-16 14:16:30 +00:00
|
|
|
case JS_TYPED_ARRAY_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSTypedArray::cast(this)->JSTypedArrayPrint(os);
|
2013-04-18 12:46:38 +00:00
|
|
|
break;
|
2013-06-21 13:02:38 +00:00
|
|
|
case JS_DATA_VIEW_TYPE:
|
2014-07-07 09:57:29 +00:00
|
|
|
JSDataView::cast(this)->JSDataViewPrint(os);
|
2013-06-21 13:02:38 +00:00
|
|
|
break;
|
2010-12-22 13:04:47 +00:00
|
|
|
#define MAKE_STRUCT_CASE(NAME, Name, name) \
|
|
|
|
case NAME##_TYPE: \
|
2014-07-07 09:57:29 +00:00
|
|
|
Name::cast(this)->Name##Print(os); \
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
|
|
|
STRUCT_LIST(MAKE_STRUCT_CASE)
|
|
|
|
#undef MAKE_STRUCT_CASE
|
|
|
|
|
|
|
|
default:
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "UNKNOWN TYPE " << map()->instance_type();
|
2010-12-22 13:04:47 +00:00
|
|
|
UNREACHABLE();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-11 09:45:25 +00:00
|
|
|
void Simd128Value::Simd128ValuePrint(std::ostream& os) { // NOLINT
|
|
|
|
#define PRINT_SIMD128_VALUE(TYPE, Type, type, lane_count, lane_type) \
|
|
|
|
if (Is##Type()) return Type::cast(this)->Type##Print(os);
|
|
|
|
SIMD128_TYPES(PRINT_SIMD128_VALUE)
|
|
|
|
#undef PRINT_SIMD128_VALUE
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-03 13:02:39 +00:00
|
|
|
void Float32x4::Float32x4Print(std::ostream& os) { // NOLINT
|
|
|
|
char arr[100];
|
|
|
|
Vector<char> buffer(arr, arraysize(arr));
|
|
|
|
os << std::string(DoubleToCString(get_lane(0), buffer)) << ", "
|
|
|
|
<< std::string(DoubleToCString(get_lane(1), buffer)) << ", "
|
|
|
|
<< std::string(DoubleToCString(get_lane(2), buffer)) << ", "
|
|
|
|
<< std::string(DoubleToCString(get_lane(3), buffer));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-18 20:39:43 +00:00
|
|
|
#define SIMD128_INT_PRINT_FUNCTION(type, lane_count) \
|
|
|
|
void type::type##Print(std::ostream& os) { \
|
|
|
|
char arr[100]; \
|
|
|
|
Vector<char> buffer(arr, arraysize(arr)); \
|
|
|
|
os << std::string(IntToCString(get_lane(0), buffer)); \
|
|
|
|
for (int i = 1; i < lane_count; i++) { \
|
|
|
|
os << ", " << std::string(IntToCString(get_lane(i), buffer)); \
|
|
|
|
} \
|
2015-08-03 13:02:39 +00:00
|
|
|
}
|
2015-08-18 20:39:43 +00:00
|
|
|
SIMD128_INT_PRINT_FUNCTION(Int32x4, 4)
|
2015-08-25 12:35:06 +00:00
|
|
|
SIMD128_INT_PRINT_FUNCTION(Uint32x4, 4)
|
2015-08-18 20:39:43 +00:00
|
|
|
SIMD128_INT_PRINT_FUNCTION(Int16x8, 8)
|
2015-08-25 12:35:06 +00:00
|
|
|
SIMD128_INT_PRINT_FUNCTION(Uint16x8, 8)
|
2015-08-18 20:39:43 +00:00
|
|
|
SIMD128_INT_PRINT_FUNCTION(Int8x16, 16)
|
2015-08-25 12:35:06 +00:00
|
|
|
SIMD128_INT_PRINT_FUNCTION(Uint8x16, 16)
|
2015-08-18 20:39:43 +00:00
|
|
|
#undef SIMD128_INT_PRINT_FUNCTION
|
|
|
|
|
|
|
|
|
|
|
|
#define SIMD128_BOOL_PRINT_FUNCTION(type, lane_count) \
|
|
|
|
void type::type##Print(std::ostream& os) { \
|
|
|
|
char arr[100]; \
|
|
|
|
Vector<char> buffer(arr, arraysize(arr)); \
|
|
|
|
os << std::string(get_lane(0) ? "true" : "false"); \
|
|
|
|
for (int i = 1; i < lane_count; i++) { \
|
|
|
|
os << ", " << std::string(get_lane(i) ? "true" : "false"); \
|
|
|
|
} \
|
2015-08-03 13:02:39 +00:00
|
|
|
}
|
2015-08-18 20:39:43 +00:00
|
|
|
SIMD128_BOOL_PRINT_FUNCTION(Bool32x4, 4)
|
|
|
|
SIMD128_BOOL_PRINT_FUNCTION(Bool16x8, 8)
|
|
|
|
SIMD128_BOOL_PRINT_FUNCTION(Bool8x16, 16)
|
|
|
|
#undef SIMD128_BOOL_PRINT_FUNCTION
|
2015-08-03 13:02:39 +00:00
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void ByteArray::ByteArrayPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "byte array, data starts at " << GetDataStartAddress();
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-24 12:02:41 +00:00
|
|
|
void BytecodeArray::BytecodeArrayPrint(std::ostream& os) { // NOLINT
|
|
|
|
Disassemble(os);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void FreeSpace::FreeSpacePrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "free space, size " << Size();
|
2011-09-19 18:36:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-16 17:08:45 +00:00
|
|
|
template <class Traits>
|
2014-09-30 10:29:32 +00:00
|
|
|
void FixedTypedArray<Traits>::FixedTypedArrayPrint(
|
|
|
|
std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "fixed " << Traits::Designator();
|
2014-01-16 17:08:45 +00:00
|
|
|
}
|
|
|
|
|
2011-04-21 07:15:43 +00:00
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSObject::PrintProperties(std::ostream& os) { // NOLINT
|
2010-12-22 13:04:47 +00:00
|
|
|
if (HasFastProperties()) {
|
|
|
|
DescriptorArray* descs = map()->instance_descriptors();
|
2012-10-10 12:31:50 +00:00
|
|
|
for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) {
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n ";
|
2014-07-07 09:57:29 +00:00
|
|
|
descs->GetKey(i)->NamePrint(os);
|
|
|
|
os << ": ";
|
2010-12-22 13:04:47 +00:00
|
|
|
switch (descs->GetType(i)) {
|
2015-01-19 17:49:13 +00:00
|
|
|
case DATA: {
|
2014-06-10 14:01:08 +00:00
|
|
|
FieldIndex index = FieldIndex::ForDescriptor(map(), i);
|
2014-11-11 10:24:52 +00:00
|
|
|
if (IsUnboxedDoubleField(index)) {
|
|
|
|
os << "<unboxed double> " << RawFastDoublePropertyAt(index);
|
|
|
|
} else {
|
|
|
|
os << Brief(RawFastPropertyAt(index));
|
|
|
|
}
|
2015-11-03 13:20:21 +00:00
|
|
|
os << " (data field at offset " << index.property_index() << ")";
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-01-19 17:49:13 +00:00
|
|
|
case ACCESSOR: {
|
2014-12-16 13:22:23 +00:00
|
|
|
FieldIndex index = FieldIndex::ForDescriptor(map(), i);
|
2015-11-03 13:20:21 +00:00
|
|
|
os << " (accessor field at offset " << index.property_index() << ")";
|
2014-12-16 13:22:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-01-19 17:49:13 +00:00
|
|
|
case DATA_CONSTANT:
|
2015-11-03 13:20:21 +00:00
|
|
|
os << Brief(descs->GetConstant(i)) << " (data constant)";
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
2015-01-19 17:49:13 +00:00
|
|
|
case ACCESSOR_CONSTANT:
|
2015-11-03 13:20:21 +00:00
|
|
|
os << Brief(descs->GetCallbacksObject(i)) << " (accessor constant)";
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-11-02 14:57:59 +00:00
|
|
|
} else if (IsJSGlobalObject()) {
|
2015-06-01 16:24:59 +00:00
|
|
|
global_dictionary()->Print(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
} else {
|
2014-07-07 09:57:29 +00:00
|
|
|
property_dictionary()->Print(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-07 09:57:29 +00:00
|
|
|
template <class T>
|
2014-09-30 10:29:32 +00:00
|
|
|
static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT
|
2014-01-16 17:08:45 +00:00
|
|
|
T* p = T::cast(object);
|
|
|
|
for (int i = 0; i < p->length(); i++) {
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n " << i << ": " << p->get_scalar(i);
|
2014-01-16 17:08:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSObject::PrintElements(std::ostream& os) { // NOLINT
|
2011-09-22 11:30:04 +00:00
|
|
|
// Don't call GetElementsKind, its validation code can cause the printer to
|
|
|
|
// fail when debugging.
|
|
|
|
switch (map()->elements_kind()) {
|
2012-05-23 14:24:29 +00:00
|
|
|
case FAST_HOLEY_SMI_ELEMENTS:
|
|
|
|
case FAST_SMI_ELEMENTS:
|
|
|
|
case FAST_HOLEY_ELEMENTS:
|
2016-01-29 18:57:26 +00:00
|
|
|
case FAST_ELEMENTS:
|
|
|
|
case FAST_STRING_WRAPPER_ELEMENTS: {
|
2010-12-22 13:04:47 +00:00
|
|
|
// Print in array notation for non-sparse arrays.
|
|
|
|
FixedArray* p = FixedArray::cast(elements());
|
|
|
|
for (int i = 0; i < p->length(); i++) {
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n " << i << ": " << Brief(p->get(i));
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-05-23 14:24:29 +00:00
|
|
|
case FAST_HOLEY_DOUBLE_ELEMENTS:
|
2011-07-22 09:04:16 +00:00
|
|
|
case FAST_DOUBLE_ELEMENTS: {
|
|
|
|
// Print in array notation for non-sparse arrays.
|
2012-05-09 15:18:50 +00:00
|
|
|
if (elements()->length() > 0) {
|
|
|
|
FixedDoubleArray* p = FixedDoubleArray::cast(elements());
|
|
|
|
for (int i = 0; i < p->length(); i++) {
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n " << i << ": ";
|
2012-05-09 15:18:50 +00:00
|
|
|
if (p->is_the_hole(i)) {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "<the hole>";
|
2012-05-09 15:18:50 +00:00
|
|
|
} else {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << p->get_scalar(i);
|
2012-05-09 15:18:50 +00:00
|
|
|
}
|
2011-07-22 09:04:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-01-16 17:08:45 +00:00
|
|
|
|
|
|
|
|
2014-07-07 09:57:29 +00:00
|
|
|
#define PRINT_ELEMENTS(Kind, Type) \
|
|
|
|
case Kind: { \
|
|
|
|
DoPrintElements<Type>(os, elements()); \
|
|
|
|
break; \
|
|
|
|
}
|
2014-01-16 17:08:45 +00:00
|
|
|
|
|
|
|
PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array)
|
|
|
|
PRINT_ELEMENTS(UINT8_CLAMPED_ELEMENTS, FixedUint8ClampedArray)
|
|
|
|
PRINT_ELEMENTS(INT8_ELEMENTS, FixedInt8Array)
|
|
|
|
PRINT_ELEMENTS(UINT16_ELEMENTS, FixedUint16Array)
|
|
|
|
PRINT_ELEMENTS(INT16_ELEMENTS, FixedInt16Array)
|
|
|
|
PRINT_ELEMENTS(UINT32_ELEMENTS, FixedUint32Array)
|
|
|
|
PRINT_ELEMENTS(INT32_ELEMENTS, FixedInt32Array)
|
2014-07-07 09:57:29 +00:00
|
|
|
PRINT_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array)
|
|
|
|
PRINT_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array)
|
2014-01-16 17:08:45 +00:00
|
|
|
|
|
|
|
#undef PRINT_ELEMENTS
|
|
|
|
|
2010-12-22 13:04:47 +00:00
|
|
|
case DICTIONARY_ELEMENTS:
|
2016-01-29 18:57:26 +00:00
|
|
|
case SLOW_STRING_WRAPPER_ELEMENTS:
|
2016-06-02 15:02:08 +00:00
|
|
|
SeededNumberDictionary::cast(elements())->Print(os);
|
2010-12-22 13:04:47 +00:00
|
|
|
break;
|
2015-07-02 14:38:37 +00:00
|
|
|
case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
|
|
|
|
case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: {
|
2011-06-16 14:12:58 +00:00
|
|
|
FixedArray* p = FixedArray::cast(elements());
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n parameter map:";
|
2011-06-16 14:12:58 +00:00
|
|
|
for (int i = 2; i < p->length(); i++) {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << " " << (i - 2) << ":" << Brief(p->get(i));
|
2011-06-16 14:12:58 +00:00
|
|
|
}
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n context: " << Brief(p->get(0))
|
2015-11-03 13:20:21 +00:00
|
|
|
<< "\n arguments: " << Brief(p->get(1));
|
2011-06-16 14:12:58 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-01-29 18:57:26 +00:00
|
|
|
case NO_ELEMENTS:
|
|
|
|
break;
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-02 08:25:19 +00:00
|
|
|
static void JSObjectPrintHeader(std::ostream& os, JSObject* obj,
|
|
|
|
const char* id) { // NOLINT
|
|
|
|
obj->PrintHeader(os, id);
|
2011-09-22 11:30:04 +00:00
|
|
|
// Don't call GetElementsKind, its validation code can cause the printer to
|
|
|
|
// fail when debugging.
|
2016-04-07 15:27:35 +00:00
|
|
|
os << "\n - map = " << reinterpret_cast<void*>(obj->map()) << " [";
|
|
|
|
if (obj->HasFastProperties()) {
|
|
|
|
os << "FastProperties";
|
|
|
|
} else {
|
|
|
|
os << "DictionaryProperties";
|
2016-03-31 10:11:46 +00:00
|
|
|
}
|
|
|
|
PrototypeIterator iter(obj->GetIsolate(), obj);
|
|
|
|
os << "]\n - prototype = " << reinterpret_cast<void*>(iter.GetCurrent());
|
2016-04-07 15:27:35 +00:00
|
|
|
os << "\n - elements = " << Brief(obj->elements()) << " ["
|
|
|
|
<< ElementsKindToString(obj->map()->elements_kind());
|
|
|
|
if (obj->elements()->map() == obj->GetHeap()->fixed_cow_array_map()) {
|
|
|
|
os << " (COW)";
|
2016-03-31 10:11:46 +00:00
|
|
|
}
|
2016-04-07 15:27:35 +00:00
|
|
|
os << "]";
|
2016-07-26 15:24:32 +00:00
|
|
|
if (obj->GetInternalFieldCount() > 0) {
|
|
|
|
os << "\n - internal fields: " << obj->GetInternalFieldCount();
|
|
|
|
}
|
2015-11-02 08:25:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-03 13:20:21 +00:00
|
|
|
static void JSObjectPrintBody(std::ostream& os, JSObject* obj, // NOLINT
|
|
|
|
bool print_elements = true) {
|
2016-05-27 14:25:07 +00:00
|
|
|
os << "\n - properties = {";
|
2015-11-02 08:25:19 +00:00
|
|
|
obj->PrintProperties(os);
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n }\n";
|
2016-05-27 14:25:07 +00:00
|
|
|
if (print_elements && obj->elements()->length() > 0) {
|
|
|
|
os << " - elements = {";
|
|
|
|
obj->PrintElements(os);
|
|
|
|
os << "\n }\n";
|
|
|
|
}
|
2016-07-26 15:24:32 +00:00
|
|
|
int internal_fields = obj->GetInternalFieldCount();
|
|
|
|
if (internal_fields > 0) {
|
|
|
|
os << " - internal fields = {";
|
|
|
|
for (int i = 0; i < internal_fields; i++) {
|
|
|
|
os << "\n " << Brief(obj->GetInternalField(i));
|
|
|
|
}
|
|
|
|
os << "\n }\n";
|
|
|
|
}
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-02 08:25:19 +00:00
|
|
|
void JSObject::JSObjectPrint(std::ostream& os) { // NOLINT
|
2016-04-07 15:27:35 +00:00
|
|
|
JSObjectPrintHeader(os, this, nullptr);
|
|
|
|
JSObjectPrintBody(os, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSArray::JSArrayPrint(std::ostream& os) { // NOLINT
|
|
|
|
JSObjectPrintHeader(os, this, "JSArray");
|
|
|
|
os << "\n - length = " << Brief(this->length());
|
2015-11-02 08:25:19 +00:00
|
|
|
JSObjectPrintBody(os, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-03 13:20:21 +00:00
|
|
|
void JSRegExp::JSRegExpPrint(std::ostream& os) { // NOLINT
|
|
|
|
JSObjectPrintHeader(os, this, "JSRegExp");
|
|
|
|
os << "\n - data = " << Brief(data());
|
|
|
|
JSObjectPrintBody(os, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void Symbol::SymbolPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "Symbol");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - hash: " << Hash();
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - name: " << Brief(name());
|
2016-06-06 12:58:10 +00:00
|
|
|
if (name()->IsUndefined(GetIsolate())) {
|
2014-10-24 12:36:45 +00:00
|
|
|
os << " (" << PrivateSymbolToName() << ")";
|
|
|
|
}
|
2014-08-12 15:28:20 +00:00
|
|
|
os << "\n - private: " << is_private();
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n";
|
2013-03-01 10:34:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void Map::MapPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "Map");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - type: " << instance_type();
|
|
|
|
os << "\n - instance size: " << instance_size();
|
2015-08-11 19:36:04 +00:00
|
|
|
if (IsJSObjectMap()) {
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - inobject properties: " << GetInObjectProperties();
|
2015-08-11 19:36:04 +00:00
|
|
|
}
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - elements kind: " << ElementsKindToString(elements_kind());
|
|
|
|
os << "\n - unused property fields: " << unused_property_fields();
|
2016-03-07 19:25:12 +00:00
|
|
|
os << "\n - enum length: ";
|
|
|
|
if (EnumLength() == kInvalidEnumCacheSentinel) {
|
|
|
|
os << "invalid";
|
|
|
|
} else {
|
|
|
|
os << EnumLength();
|
|
|
|
}
|
2016-02-06 18:10:08 +00:00
|
|
|
if (is_deprecated()) os << "\n - deprecated_map";
|
|
|
|
if (is_stable()) os << "\n - stable_map";
|
|
|
|
if (is_dictionary_map()) os << "\n - dictionary_map";
|
2016-02-08 13:49:47 +00:00
|
|
|
if (has_hidden_prototype()) os << "\n - has_hidden_prototype";
|
2016-07-13 11:32:35 +00:00
|
|
|
if (has_named_interceptor()) os << "\n - named_interceptor";
|
2016-02-06 18:10:08 +00:00
|
|
|
if (has_indexed_interceptor()) os << "\n - indexed_interceptor";
|
|
|
|
if (is_undetectable()) os << "\n - undetectable";
|
|
|
|
if (is_callable()) os << "\n - callable";
|
|
|
|
if (is_constructor()) os << "\n - constructor";
|
|
|
|
if (is_access_check_needed()) os << "\n - access_check_needed";
|
|
|
|
if (!is_extensible()) os << "\n - non-extensible";
|
2015-07-02 09:05:39 +00:00
|
|
|
if (is_prototype_map()) {
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - prototype_map";
|
|
|
|
os << "\n - prototype info: " << Brief(prototype_info());
|
2015-07-02 09:05:39 +00:00
|
|
|
} else {
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - back pointer: " << Brief(GetBackPointer());
|
2015-07-02 09:05:39 +00:00
|
|
|
}
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "")
|
|
|
|
<< "#" << NumberOfOwnDescriptors() << ": "
|
|
|
|
<< Brief(instance_descriptors());
|
2014-11-11 10:24:52 +00:00
|
|
|
if (FLAG_unbox_double_fields) {
|
|
|
|
os << "\n - layout descriptor: " << Brief(layout_descriptor());
|
|
|
|
}
|
2015-11-03 13:20:21 +00:00
|
|
|
int nof_transitions = TransitionArray::NumberOfTransitions(raw_transitions());
|
|
|
|
if (nof_transitions > 0) {
|
|
|
|
os << "\n - transitions #" << nof_transitions << ": "
|
|
|
|
<< Brief(raw_transitions());
|
|
|
|
TransitionArray::PrintTransitions(os, raw_transitions(), false);
|
2012-07-05 13:54:20 +00:00
|
|
|
}
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - prototype: " << Brief(prototype());
|
2015-02-24 20:50:06 +00:00
|
|
|
os << "\n - constructor: " << Brief(GetConstructor());
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - code cache: " << Brief(code_cache());
|
|
|
|
os << "\n - dependent code: " << Brief(dependent_code());
|
2015-12-09 09:27:36 +00:00
|
|
|
os << "\n - construction counter: " << construction_counter();
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n";
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void TypeFeedbackInfo::TypeFeedbackInfoPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "TypeFeedbackInfo");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - ic_total_count: " << ic_total_count()
|
2014-08-05 17:06:01 +00:00
|
|
|
<< ", ic_with_type_info_count: " << ic_with_type_info_count()
|
|
|
|
<< ", ic_generic_count: " << ic_generic_count() << "\n";
|
2012-02-20 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(
|
|
|
|
std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "AliasedArgumentsEntry");
|
|
|
|
os << "\n - aliased_context_slot: " << aliased_context_slot();
|
2012-02-24 14:34:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void FixedArray::FixedArrayPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "FixedArray");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - length: " << length();
|
2010-12-22 13:04:47 +00:00
|
|
|
for (int i = 0; i < length(); i++) {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n [" << i << "]: " << Brief(get(i));
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n";
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void FixedDoubleArray::FixedDoubleArrayPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "FixedDoubleArray");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - length: " << length();
|
2011-09-22 11:30:04 +00:00
|
|
|
for (int i = 0; i < length(); i++) {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n [" << i << "]: ";
|
2012-02-02 11:22:26 +00:00
|
|
|
if (is_the_hole(i)) {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "<the hole>";
|
2012-02-02 11:22:26 +00:00
|
|
|
} else {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << get_scalar(i);
|
2012-02-02 11:22:26 +00:00
|
|
|
}
|
2011-09-22 11:30:04 +00:00
|
|
|
}
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n";
|
2011-09-22 11:30:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-03 13:18:19 +00:00
|
|
|
void TransitionArray::TransitionArrayPrint(std::ostream& os) { // NOLINT
|
|
|
|
HeapObject::PrintHeader(os, "TransitionArray");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - capacity: " << length();
|
2015-12-03 13:18:19 +00:00
|
|
|
for (int i = 0; i < length(); i++) {
|
|
|
|
os << "\n [" << i << "]: " << Brief(get(i));
|
|
|
|
if (i == kNextLinkIndex) os << " (next link)";
|
|
|
|
if (i == kPrototypeTransitionsIndex) os << " (prototype transitions)";
|
|
|
|
if (i == kTransitionLengthIndex) os << " (number of transitions)";
|
|
|
|
}
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:08:09 +00:00
|
|
|
template void FeedbackVectorSpecBase<StaticFeedbackVectorSpec>::Print();
|
|
|
|
template void FeedbackVectorSpecBase<FeedbackVectorSpec>::Print();
|
|
|
|
|
|
|
|
template <typename Derived>
|
|
|
|
void FeedbackVectorSpecBase<Derived>::Print() {
|
|
|
|
OFStream os(stdout);
|
|
|
|
FeedbackVectorSpecPrint(os);
|
|
|
|
os << std::flush;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Derived>
|
|
|
|
void FeedbackVectorSpecBase<Derived>::FeedbackVectorSpecPrint(
|
|
|
|
std::ostream& os) { // NOLINT
|
|
|
|
int slot_count = This()->slots();
|
|
|
|
os << " - slot_count: " << slot_count;
|
|
|
|
if (slot_count == 0) {
|
|
|
|
os << " (empty)\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int slot = 0, name_index = 0; slot < slot_count;) {
|
|
|
|
FeedbackVectorSlotKind kind = This()->GetKind(slot);
|
|
|
|
int entry_size = TypeFeedbackMetadata::GetSlotSize(kind);
|
|
|
|
DCHECK_LT(0, entry_size);
|
|
|
|
|
|
|
|
os << "\n Slot #" << slot << " " << kind;
|
|
|
|
if (TypeFeedbackMetadata::SlotRequiresName(kind)) {
|
|
|
|
os << ", " << Brief(*This()->GetName(name_index++));
|
|
|
|
}
|
|
|
|
|
|
|
|
slot += entry_size;
|
|
|
|
}
|
|
|
|
os << "\n";
|
|
|
|
}
|
2015-12-03 13:18:19 +00:00
|
|
|
|
2015-10-07 10:33:22 +00:00
|
|
|
void TypeFeedbackMetadata::Print() {
|
|
|
|
OFStream os(stdout);
|
|
|
|
TypeFeedbackMetadataPrint(os);
|
|
|
|
os << std::flush;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TypeFeedbackMetadata::TypeFeedbackMetadataPrint(
|
|
|
|
std::ostream& os) { // NOLINT
|
|
|
|
HeapObject::PrintHeader(os, "TypeFeedbackMetadata");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - length: " << length();
|
2015-10-07 10:33:22 +00:00
|
|
|
if (length() == 0) {
|
|
|
|
os << " (empty)\n";
|
|
|
|
return;
|
|
|
|
}
|
2016-06-24 14:08:09 +00:00
|
|
|
os << "\n - slot_count: " << slot_count();
|
2015-10-07 10:33:22 +00:00
|
|
|
|
|
|
|
TypeFeedbackMetadataIterator iter(this);
|
|
|
|
while (iter.HasNext()) {
|
|
|
|
FeedbackVectorSlot slot = iter.Next();
|
|
|
|
FeedbackVectorSlotKind kind = iter.kind();
|
|
|
|
os << "\n Slot " << slot << " " << kind;
|
2016-06-24 14:08:09 +00:00
|
|
|
if (TypeFeedbackMetadata::SlotRequiresName(kind)) {
|
|
|
|
os << ", " << Brief(iter.name());
|
|
|
|
}
|
2015-10-07 10:33:22 +00:00
|
|
|
}
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-15 12:21:57 +00:00
|
|
|
void TypeFeedbackVector::Print() {
|
|
|
|
OFStream os(stdout);
|
|
|
|
TypeFeedbackVectorPrint(os);
|
|
|
|
os << std::flush;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TypeFeedbackVector::TypeFeedbackVectorPrint(std::ostream& os) { // NOLINT
|
|
|
|
HeapObject::PrintHeader(os, "TypeFeedbackVector");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - length: " << length();
|
2015-07-15 12:21:57 +00:00
|
|
|
if (length() == 0) {
|
|
|
|
os << " (empty)\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-07 10:33:22 +00:00
|
|
|
TypeFeedbackMetadataIterator iter(metadata());
|
2015-10-01 13:48:05 +00:00
|
|
|
while (iter.HasNext()) {
|
|
|
|
FeedbackVectorSlot slot = iter.Next();
|
|
|
|
FeedbackVectorSlotKind kind = iter.kind();
|
|
|
|
|
2016-06-24 14:08:09 +00:00
|
|
|
os << "\n Slot " << slot << " " << kind;
|
|
|
|
if (TypeFeedbackMetadata::SlotRequiresName(kind)) {
|
|
|
|
os << ", " << Brief(iter.name());
|
|
|
|
}
|
|
|
|
os << " ";
|
2015-10-01 13:48:05 +00:00
|
|
|
switch (kind) {
|
|
|
|
case FeedbackVectorSlotKind::LOAD_IC: {
|
|
|
|
LoadICNexus nexus(this, slot);
|
|
|
|
os << Code::ICState2String(nexus.StateFromFeedback());
|
|
|
|
break;
|
|
|
|
}
|
2016-06-14 13:20:42 +00:00
|
|
|
case FeedbackVectorSlotKind::LOAD_GLOBAL_IC: {
|
|
|
|
LoadGlobalICNexus nexus(this, slot);
|
|
|
|
os << Code::ICState2String(nexus.StateFromFeedback());
|
|
|
|
break;
|
|
|
|
}
|
2015-10-01 13:48:05 +00:00
|
|
|
case FeedbackVectorSlotKind::KEYED_LOAD_IC: {
|
|
|
|
KeyedLoadICNexus nexus(this, slot);
|
|
|
|
os << Code::ICState2String(nexus.StateFromFeedback());
|
|
|
|
break;
|
2015-07-15 12:21:57 +00:00
|
|
|
}
|
2015-10-01 13:48:05 +00:00
|
|
|
case FeedbackVectorSlotKind::CALL_IC: {
|
|
|
|
CallICNexus nexus(this, slot);
|
|
|
|
os << Code::ICState2String(nexus.StateFromFeedback());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FeedbackVectorSlotKind::STORE_IC: {
|
|
|
|
StoreICNexus nexus(this, slot);
|
|
|
|
os << Code::ICState2String(nexus.StateFromFeedback());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FeedbackVectorSlotKind::KEYED_STORE_IC: {
|
|
|
|
KeyedStoreICNexus nexus(this, slot);
|
|
|
|
os << Code::ICState2String(nexus.StateFromFeedback());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FeedbackVectorSlotKind::GENERAL:
|
|
|
|
break;
|
|
|
|
case FeedbackVectorSlotKind::INVALID:
|
|
|
|
case FeedbackVectorSlotKind::KINDS_NUMBER:
|
|
|
|
UNREACHABLE();
|
|
|
|
break;
|
|
|
|
}
|
2015-07-15 12:21:57 +00:00
|
|
|
|
2015-10-01 13:48:05 +00:00
|
|
|
int entry_size = iter.entry_size();
|
|
|
|
for (int i = 0; i < entry_size; i++) {
|
|
|
|
int index = GetIndex(slot) + i;
|
|
|
|
os << "\n [" << index << "]: " << Brief(get(index));
|
2015-07-15 12:21:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSValue::JSValuePrint(std::ostream& os) { // NOLINT
|
2015-11-02 08:25:19 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSValue");
|
|
|
|
os << "\n - value = " << Brief(value());
|
|
|
|
JSObjectPrintBody(os, this);
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSMessageObject::JSMessageObjectPrint(std::ostream& os) { // NOLINT
|
2015-11-02 08:25:19 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSMessageObject");
|
|
|
|
os << "\n - type: " << type();
|
2015-05-18 08:34:05 +00:00
|
|
|
os << "\n - arguments: " << Brief(argument());
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - start_position: " << start_position();
|
|
|
|
os << "\n - end_position: " << end_position();
|
|
|
|
os << "\n - script: " << Brief(script());
|
|
|
|
os << "\n - stack_frames: " << Brief(stack_frames());
|
2015-11-02 08:25:19 +00:00
|
|
|
JSObjectPrintBody(os, this);
|
2011-02-02 13:31:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void String::StringPrint(std::ostream& os) { // NOLINT
|
2013-02-28 17:03:34 +00:00
|
|
|
if (StringShape(this).IsInternalized()) {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "#";
|
2010-12-22 13:04:47 +00:00
|
|
|
} else if (StringShape(this).IsCons()) {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "c\"";
|
2010-12-22 13:04:47 +00:00
|
|
|
} else {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\"";
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char truncated_epilogue[] = "...<truncated>";
|
|
|
|
int len = length();
|
|
|
|
if (!FLAG_use_verbose_printer) {
|
|
|
|
if (len > 100) {
|
|
|
|
len = 100 - sizeof(truncated_epilogue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < len; i++) {
|
2014-07-07 11:00:53 +00:00
|
|
|
os << AsUC16(Get(i));
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
if (len != length()) {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << truncated_epilogue;
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
2014-07-07 09:57:29 +00:00
|
|
|
if (!StringShape(this).IsInternalized()) os << "\"";
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void Name::NamePrint(std::ostream& os) { // NOLINT
|
2014-10-23 11:31:33 +00:00
|
|
|
if (IsString()) {
|
2014-07-07 09:57:29 +00:00
|
|
|
String::cast(this)->StringPrint(os);
|
2014-10-23 11:31:33 +00:00
|
|
|
} else {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << Brief(this);
|
2014-10-23 11:31:33 +00:00
|
|
|
}
|
2013-03-04 15:00:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-09 11:19:55 +00:00
|
|
|
static const char* const weekdays[] = {
|
|
|
|
"???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
|
|
|
};
|
|
|
|
|
2013-07-05 09:52:11 +00:00
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSDate::JSDatePrint(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSDate");
|
|
|
|
os << "\n - value = " << Brief(value());
|
2012-03-09 11:11:55 +00:00
|
|
|
if (!year()->IsSmi()) {
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n - time = NaN\n";
|
2012-03-09 11:11:55 +00:00
|
|
|
} else {
|
2014-07-07 09:57:29 +00:00
|
|
|
// TODO(svenpanne) Add some basic formatting to our streams.
|
2015-06-05 11:15:31 +00:00
|
|
|
ScopedVector<char> buf(100);
|
2014-07-07 09:57:29 +00:00
|
|
|
SNPrintF(
|
2015-11-03 13:20:21 +00:00
|
|
|
buf, "\n - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
|
2014-07-07 09:57:29 +00:00
|
|
|
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();
|
2012-03-09 11:11:55 +00:00
|
|
|
}
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintBody(os, this);
|
2012-03-09 11:11:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSProxy::JSProxyPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "JSProxy");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - map = " << reinterpret_cast<void*>(map());
|
2015-11-13 14:13:50 +00:00
|
|
|
os << "\n - target = ";
|
|
|
|
target()->ShortPrint(os);
|
|
|
|
os << "\n - handler = ";
|
|
|
|
handler()->ShortPrint(os);
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - hash = ";
|
2015-11-13 14:13:50 +00:00
|
|
|
hash()->ShortPrint(os);
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n";
|
2011-05-13 10:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSSet::JSSetPrint(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSSet");
|
2014-07-07 09:57:29 +00:00
|
|
|
os << " - table = " << Brief(table());
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintBody(os, this);
|
2013-08-01 08:36:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSMap::JSMapPrint(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSMap");
|
2014-07-07 09:57:29 +00:00
|
|
|
os << " - table = " << Brief(table());
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintBody(os, this);
|
2013-08-01 08:36:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-07 09:57:29 +00:00
|
|
|
template <class Derived, class TableType>
|
2014-09-30 10:29:32 +00:00
|
|
|
void
|
|
|
|
OrderedHashTableIterator<Derived, TableType>::OrderedHashTableIteratorPrint(
|
|
|
|
std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n - table = " << Brief(table());
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - index = " << Brief(index());
|
|
|
|
os << "\n - kind = " << Brief(kind());
|
|
|
|
os << "\n";
|
2014-04-17 17:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-07 09:57:29 +00:00
|
|
|
template void OrderedHashTableIterator<
|
|
|
|
JSSetIterator,
|
2014-09-30 10:29:32 +00:00
|
|
|
OrderedHashSet>::OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT
|
2014-04-17 17:45:32 +00:00
|
|
|
|
|
|
|
|
2014-07-07 09:57:29 +00:00
|
|
|
template void OrderedHashTableIterator<
|
|
|
|
JSMapIterator,
|
2014-09-30 10:29:32 +00:00
|
|
|
OrderedHashMap>::OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT
|
2014-04-17 17:45:32 +00:00
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSSetIterator::JSSetIteratorPrint(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSSetIterator");
|
2014-07-07 09:57:29 +00:00
|
|
|
OrderedHashTableIteratorPrint(os);
|
2014-04-17 17:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSMapIterator::JSMapIteratorPrint(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSMapIterator");
|
2014-07-07 09:57:29 +00:00
|
|
|
OrderedHashTableIteratorPrint(os);
|
2014-04-17 17:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSWeakMap::JSWeakMapPrint(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSWeakMap");
|
|
|
|
os << "\n - table = " << Brief(table());
|
|
|
|
JSObjectPrintBody(os, this);
|
2011-08-03 11:55:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSWeakSet::JSWeakSetPrint(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSWeakSet");
|
|
|
|
os << "\n - table = " << Brief(table());
|
|
|
|
JSObjectPrintBody(os, this);
|
2013-07-22 08:32:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSArrayBuffer::JSArrayBufferPrint(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSArrayBuffer");
|
|
|
|
os << "\n - backing_store = " << backing_store();
|
|
|
|
os << "\n - byte_length = " << Brief(byte_length());
|
2015-05-07 15:55:23 +00:00
|
|
|
if (was_neutered()) os << " - neutered\n";
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintBody(os, this, !was_neutered());
|
2013-03-28 12:50:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSTypedArray::JSTypedArrayPrint(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSTypedArray");
|
|
|
|
os << "\n - buffer = " << Brief(buffer());
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - byte_offset = " << Brief(byte_offset());
|
|
|
|
os << "\n - byte_length = " << Brief(byte_length());
|
|
|
|
os << "\n - length = " << Brief(length());
|
2015-05-07 15:55:23 +00:00
|
|
|
if (WasNeutered()) os << " - neutered\n";
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintBody(os, this, !WasNeutered());
|
2013-04-16 14:16:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSDataView::JSDataViewPrint(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintHeader(os, this, "JSDataView");
|
|
|
|
os << "\n - buffer =" << Brief(buffer());
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - byte_offset = " << Brief(byte_offset());
|
|
|
|
os << "\n - byte_length = " << Brief(byte_length());
|
2015-05-07 15:55:23 +00:00
|
|
|
if (WasNeutered()) os << " - neutered\n";
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintBody(os, this, !WasNeutered());
|
2013-06-21 13:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-27 06:30:53 +00:00
|
|
|
void JSBoundFunction::JSBoundFunctionPrint(std::ostream& os) { // NOLINT
|
|
|
|
JSObjectPrintHeader(os, this, "JSBoundFunction");
|
|
|
|
os << "\n - bound_target_function = " << Brief(bound_target_function());
|
|
|
|
os << "\n - bound_this = " << Brief(bound_this());
|
|
|
|
os << "\n - bound_arguments = " << Brief(bound_arguments());
|
|
|
|
JSObjectPrintBody(os, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSFunction::JSFunctionPrint(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintHeader(os, this, "Function");
|
|
|
|
os << "\n - initial_map = ";
|
2014-07-07 09:57:29 +00:00
|
|
|
if (has_initial_map()) os << Brief(initial_map());
|
|
|
|
os << "\n - shared_info = " << Brief(shared());
|
2015-12-16 11:24:48 +00:00
|
|
|
os << "\n - name = " << Brief(shared()->name());
|
2016-03-09 11:33:10 +00:00
|
|
|
os << "\n - formal_parameter_count = "
|
|
|
|
<< shared()->internal_formal_parameter_count();
|
2015-11-03 16:42:21 +00:00
|
|
|
if (shared()->is_generator()) {
|
|
|
|
os << "\n - generator";
|
2016-05-31 17:13:58 +00:00
|
|
|
} else if (shared()->is_async()) {
|
|
|
|
os << "\n - async";
|
2015-11-03 16:42:21 +00:00
|
|
|
}
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - context = " << Brief(context());
|
2015-12-27 06:30:53 +00:00
|
|
|
os << "\n - literals = " << Brief(literals());
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - code = " << Brief(code());
|
2015-11-03 13:20:21 +00:00
|
|
|
JSObjectPrintBody(os, this);
|
2014-07-07 09:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void SharedFunctionInfo::SharedFunctionInfoPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "SharedFunctionInfo");
|
2016-03-09 11:33:10 +00:00
|
|
|
os << "\n - name = " << Brief(name());
|
|
|
|
os << "\n - formal_parameter_count = " << internal_formal_parameter_count();
|
|
|
|
os << "\n - expected_nof_properties = " << expected_nof_properties();
|
|
|
|
os << "\n - ast_node_count = " << ast_node_count();
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - instance class name = ";
|
|
|
|
instance_class_name()->Print(os);
|
|
|
|
os << "\n - code = " << Brief(code());
|
2012-06-14 15:33:15 +00:00
|
|
|
if (HasSourceCode()) {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - source code = ";
|
2012-07-27 09:54:56 +00:00
|
|
|
String* source = String::cast(Script::cast(script())->source());
|
|
|
|
int start = start_position();
|
|
|
|
int length = end_position() - start;
|
2016-07-25 10:24:45 +00:00
|
|
|
std::unique_ptr<char[]> source_string = source->ToCString(
|
2015-07-13 12:38:06 +00:00
|
|
|
DISALLOW_NULLS, FAST_STRING_TRAVERSAL, start, length, NULL);
|
2014-07-07 09:57:29 +00:00
|
|
|
os << source_string.get();
|
2012-06-14 15:33:15 +00:00
|
|
|
}
|
2010-12-22 13:04:47 +00:00
|
|
|
// Script files are often large, hard to read.
|
2014-07-07 09:57:29 +00:00
|
|
|
// os << "\n - script =";
|
|
|
|
// script()->Print(os);
|
2016-02-19 02:50:58 +00:00
|
|
|
if (is_named_expression()) {
|
|
|
|
os << "\n - named expression";
|
|
|
|
} else if (is_anonymous_expression()) {
|
|
|
|
os << "\n - anonymous expression";
|
|
|
|
} else if (is_declaration()) {
|
|
|
|
os << "\n - declaration";
|
|
|
|
}
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - function token position = " << function_token_position();
|
|
|
|
os << "\n - start position = " << start_position();
|
|
|
|
os << "\n - end position = " << end_position();
|
|
|
|
os << "\n - debug info = " << Brief(debug_info());
|
|
|
|
os << "\n - length = " << length();
|
2016-05-24 15:11:55 +00:00
|
|
|
os << "\n - num_literals = " << num_literals();
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - optimized_code_map = " << Brief(optimized_code_map());
|
2016-05-27 08:09:12 +00:00
|
|
|
os << "\n - feedback_metadata = ";
|
|
|
|
feedback_metadata()->TypeFeedbackMetadataPrint(os);
|
2015-07-24 12:02:41 +00:00
|
|
|
if (HasBytecodeArray()) {
|
|
|
|
os << "\n - bytecode_array = " << bytecode_array();
|
|
|
|
}
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n";
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSGlobalProxy::JSGlobalProxyPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "global_proxy ";
|
|
|
|
JSObjectPrint(os);
|
|
|
|
os << "native context : " << Brief(native_context());
|
|
|
|
os << "\n";
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void JSGlobalObject::JSGlobalObjectPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "global ";
|
|
|
|
JSObjectPrint(os);
|
|
|
|
os << "native context : " << Brief(native_context());
|
|
|
|
os << "\n";
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void Cell::CellPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "Cell");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - value: " << Brief(value());
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n";
|
2013-06-12 15:03:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void PropertyCell::PropertyCellPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "PropertyCell");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - value: " << Brief(value());
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n - details: " << property_details();
|
2016-07-07 12:32:15 +00:00
|
|
|
PropertyCellType cell_type = property_details().cell_type();
|
|
|
|
os << "\n - cell_type: ";
|
|
|
|
if (value()->IsTheHole(GetIsolate())) {
|
|
|
|
switch (cell_type) {
|
|
|
|
case PropertyCellType::kUninitialized:
|
|
|
|
os << "Uninitialized";
|
|
|
|
break;
|
|
|
|
case PropertyCellType::kInvalidated:
|
|
|
|
os << "Invalidated";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
os << "??? " << static_cast<int>(cell_type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (cell_type) {
|
|
|
|
case PropertyCellType::kUndefined:
|
|
|
|
os << "Undefined";
|
|
|
|
break;
|
|
|
|
case PropertyCellType::kConstant:
|
|
|
|
os << "Constant";
|
|
|
|
break;
|
|
|
|
case PropertyCellType::kConstantType:
|
|
|
|
os << "ConstantType"
|
|
|
|
<< " (";
|
|
|
|
switch (GetConstantType()) {
|
|
|
|
case PropertyCellConstantType::kSmi:
|
|
|
|
os << "Smi";
|
|
|
|
break;
|
|
|
|
case PropertyCellConstantType::kStableMap:
|
|
|
|
os << "StableMap";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
os << ")";
|
|
|
|
break;
|
|
|
|
case PropertyCellType::kMutable:
|
|
|
|
os << "Mutable";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n";
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-14 14:43:45 +00:00
|
|
|
void WeakCell::WeakCellPrint(std::ostream& os) { // NOLINT
|
|
|
|
HeapObject::PrintHeader(os, "WeakCell");
|
2014-12-02 14:25:17 +00:00
|
|
|
if (cleared()) {
|
|
|
|
os << "\n - cleared";
|
|
|
|
} else {
|
|
|
|
os << "\n - value: " << Brief(value());
|
|
|
|
}
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n";
|
2014-10-14 14:43:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void Code::CodePrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "Code");
|
2016-02-23 13:40:38 +00:00
|
|
|
os << "\n";
|
2010-12-22 13:04:47 +00:00
|
|
|
#ifdef ENABLE_DISASSEMBLER
|
|
|
|
if (FLAG_use_verbose_printer) {
|
2014-07-07 09:57:29 +00:00
|
|
|
Disassemble(NULL, os);
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void Foreign::ForeignPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "foreign address : " << foreign_address();
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n";
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-18 15:08:36 +00:00
|
|
|
void AccessorInfo::AccessorInfoPrint(std::ostream& os) { // NOLINT
|
|
|
|
HeapObject::PrintHeader(os, "AccessorInfo");
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - name: " << Brief(name());
|
2015-09-28 13:10:13 +00:00
|
|
|
os << "\n - flag: " << flag();
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - getter: " << Brief(getter());
|
|
|
|
os << "\n - setter: " << Brief(setter());
|
2016-04-20 08:01:08 +00:00
|
|
|
os << "\n - js_getter: " << Brief(js_getter());
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - data: " << Brief(data());
|
|
|
|
os << "\n";
|
2013-02-12 14:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void Box::BoxPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "Box");
|
|
|
|
os << "\n - value: " << Brief(value());
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-07 10:42:45 +00:00
|
|
|
void PrototypeInfo::PrototypeInfoPrint(std::ostream& os) { // NOLINT
|
|
|
|
HeapObject::PrintHeader(os, "PrototypeInfo");
|
|
|
|
os << "\n - prototype users: " << Brief(prototype_users());
|
2015-08-08 22:56:15 +00:00
|
|
|
os << "\n - registry slot: " << registry_slot();
|
2015-04-07 10:42:45 +00:00
|
|
|
os << "\n - validity cell: " << Brief(validity_cell());
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
[es6] Parameter scopes for sloppy eval
This CL is a nightmare! For the utterly irrelevant edge case of a sloppy function with non-simple parameters and a call to direct eval, like here,
let x = 1;
function f(g = () => x) {
var y
eval("var x = 2")
return g() + x // f() = 3
}
we have to do all of the following, on top of the declaration block ("varblock") contexts we already introduce around the body:
- Introduce the ability for varblock contexts to have both a ScopeInfo and an extension object (e.g., the body varblock in the example will contain both a static var y and a dynamic var x). No other scope needs that. Since there are no context slots left, a special new struct is introduced that pairs up scope info and extension object.
- When declaring lookup slots in the runtime, this new struct is allocated in the case where an extension object has to be added to a block scope (at which point the block's extension slot still contains a plain ScopeInfo).
- While at it, introduce some abstraction to access context extension slots in a more controlled manner, in order to keep special-casing to a minimum.
- Make sure that even empty varblock contexts do not get optimised away when they contain a sloppy eval, so that they can host the potential extension object.
- Extend dynamic search for declaration contexts (used by sloppy direct eval) to recognize varblock contexts.
- In the parser, if a function has a sloppy direct eval, introduce an additional varblock scope around each non-simple (desugared) parameter, as required by the spec to contain possible dynamic var bindings.
- In the pattern rewriter, add the ability to hoist the named variables the pattern declares to an outer scope. That is required because the actual destructuring has to be evaluated inside the protecting varblock scope, but the bindings that the desugaring introduces are in the outer scope.
- ScopeInfos need to save the information whether a block is a varblock, to make sloppy eval calls work correctly that deserialise them as part of the scope chain.
- Add the ability to materialize block scopes with extension objects in the debugger. Likewise, enable setting extension variables in block scopes via the debugger interface.
- While at it, refactor and unify some respective code in the debugger.
Sorry, this CL is large. I could try to split it up, but everything is rather entangled.
@mstarzinger: Please review the changes to contexts.
@yangguo: Please have a look at the debugger stuff.
R=littledan@chromium.org, mstarzinger@chromium.org, yangguo@chromium.org
BUG=v8:811,v8:2160
LOG=N
Review URL: https://codereview.chromium.org/1292753007
Cr-Commit-Position: refs/heads/master@{#30295}
2015-08-21 10:58:35 +00:00
|
|
|
void SloppyBlockWithEvalContextExtension::
|
|
|
|
SloppyBlockWithEvalContextExtensionPrint(std::ostream& os) { // NOLINT
|
|
|
|
HeapObject::PrintHeader(os, "SloppyBlockWithEvalContextExtension");
|
|
|
|
os << "\n - scope_info: " << Brief(scope_info());
|
|
|
|
os << "\n - extension: " << Brief(extension());
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void AccessorPair::AccessorPairPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "AccessorPair");
|
|
|
|
os << "\n - getter: " << Brief(getter());
|
|
|
|
os << "\n - setter: " << Brief(setter());
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void AccessCheckInfo::AccessCheckInfoPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "AccessCheckInfo");
|
2015-10-23 08:13:24 +00:00
|
|
|
os << "\n - callback: " << Brief(callback());
|
2016-06-27 11:48:04 +00:00
|
|
|
os << "\n - named_interceptor: " << Brief(named_interceptor());
|
|
|
|
os << "\n - indexed_interceptor: " << Brief(indexed_interceptor());
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - data: " << Brief(data());
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void InterceptorInfo::InterceptorInfoPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
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";
|
2012-01-10 16:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void CallHandlerInfo::CallHandlerInfoPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "CallHandlerInfo");
|
|
|
|
os << "\n - callback: " << Brief(callback());
|
|
|
|
os << "\n - data: " << Brief(data());
|
|
|
|
os << "\n";
|
2010-12-22 13:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void FunctionTemplateInfo::FunctionTemplateInfoPrint(
|
|
|
|
std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "FunctionTemplateInfo");
|
|
|
|
os << "\n - class name: " << Brief(class_name());
|
|
|
|
os << "\n - tag: " << Brief(tag());
|
2016-02-03 09:52:45 +00:00
|
|
|
os << "\n - serial_number: " << Brief(serial_number());
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - property_list: " << Brief(property_list());
|
2014-07-07 09:57:29 +00:00
|
|
|
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");
|
2015-01-23 09:07:11 +00:00
|
|
|
os << "\n - instantiated: " << (instantiated() ? "true" : "false");
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void ObjectTemplateInfo::ObjectTemplateInfoPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "ObjectTemplateInfo");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - tag: " << Brief(tag());
|
|
|
|
os << "\n - serial_number: " << Brief(serial_number());
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - property_list: " << Brief(property_list());
|
|
|
|
os << "\n - property_accessors: " << Brief(property_accessors());
|
|
|
|
os << "\n - constructor: " << Brief(constructor());
|
2016-07-01 19:16:53 +00:00
|
|
|
os << "\n - internal_field_count: " << internal_field_count();
|
|
|
|
os << "\n - immutable_proto: " << (immutable_proto() ? "true" : "false");
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void AllocationSite::AllocationSitePrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "AllocationSite");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - weak_next: " << Brief(weak_next());
|
2014-07-07 09:57:29 +00:00
|
|
|
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: ";
|
2013-11-14 12:05:09 +00:00
|
|
|
if (transition_info()->IsSmi()) {
|
|
|
|
ElementsKind kind = GetElementsKind();
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "Array allocation with ElementsKind " << ElementsKindToString(kind);
|
2013-07-08 15:00:12 +00:00
|
|
|
} else if (transition_info()->IsJSArray()) {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "Array literal " << Brief(transition_info());
|
|
|
|
} else {
|
|
|
|
os << "unknown transition_info" << Brief(transition_info());
|
2013-01-08 09:03:16 +00:00
|
|
|
}
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n";
|
2013-01-08 09:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void AllocationMemento::AllocationMementoPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "AllocationMemento");
|
2016-02-06 18:10:08 +00:00
|
|
|
os << "\n - allocation site: ";
|
2013-07-08 10:02:16 +00:00
|
|
|
if (IsValid()) {
|
2014-07-07 09:57:29 +00:00
|
|
|
GetAllocationSite()->Print(os);
|
2013-07-08 10:02:16 +00:00
|
|
|
} else {
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "<invalid>\n";
|
2013-07-08 10:02:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void Script::ScriptPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "Script");
|
|
|
|
os << "\n - source: " << Brief(source());
|
|
|
|
os << "\n - name: " << Brief(name());
|
2015-09-28 13:10:13 +00:00
|
|
|
os << "\n - line_offset: " << line_offset();
|
|
|
|
os << "\n - column_offset: " << column_offset();
|
|
|
|
os << "\n - type: " << type();
|
|
|
|
os << "\n - id: " << id();
|
2014-07-07 09:57:29 +00:00
|
|
|
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());
|
2016-04-18 13:20:45 +00:00
|
|
|
os << "\n - eval from position: " << eval_from_position();
|
2015-06-25 12:19:55 +00:00
|
|
|
os << "\n - shared function infos: " << Brief(shared_function_infos());
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void DebugInfo::DebugInfoPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "DebugInfo");
|
|
|
|
os << "\n - shared: " << Brief(shared());
|
2016-02-10 14:19:31 +00:00
|
|
|
os << "\n - code: " << Brief(abstract_code());
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - break_points: ";
|
|
|
|
break_points()->Print(os);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void BreakPointInfo::BreakPointInfoPrint(std::ostream& os) { // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
HeapObject::PrintHeader(os, "BreakPointInfo");
|
2016-01-28 12:11:55 +00:00
|
|
|
os << "\n - code_offset: " << code_offset();
|
2015-09-28 13:10:13 +00:00
|
|
|
os << "\n - source_position: " << source_position();
|
|
|
|
os << "\n - statement_position: " << statement_position();
|
2014-07-07 09:57:29 +00:00
|
|
|
os << "\n - break_point_objects: " << Brief(break_point_objects());
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-11 10:24:52 +00:00
|
|
|
static void PrintBitMask(std::ostream& os, uint32_t value) { // NOLINT
|
|
|
|
for (int i = 0; i < 32; i++) {
|
|
|
|
if ((i & 7) == 0) os << " ";
|
|
|
|
os << (((value & 1) == 0) ? "_" : "x");
|
|
|
|
value >>= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LayoutDescriptor::Print() {
|
|
|
|
OFStream os(stdout);
|
|
|
|
this->Print(os);
|
|
|
|
os << std::flush;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LayoutDescriptor::Print(std::ostream& os) { // NOLINT
|
|
|
|
os << "Layout descriptor: ";
|
2016-06-14 10:08:44 +00:00
|
|
|
if (IsOddball() && IsUninitialized(HeapObject::cast(this)->GetIsolate())) {
|
2014-11-11 10:24:52 +00:00
|
|
|
os << "<uninitialized>";
|
|
|
|
} else if (IsFastPointerLayout()) {
|
|
|
|
os << "<all tagged>";
|
|
|
|
} else if (IsSmi()) {
|
|
|
|
os << "fast";
|
|
|
|
PrintBitMask(os, static_cast<uint32_t>(Smi::cast(this)->value()));
|
|
|
|
} else {
|
|
|
|
os << "slow";
|
2015-04-21 15:58:20 +00:00
|
|
|
int len = length();
|
2014-11-11 10:24:52 +00:00
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
if (i > 0) os << " |";
|
|
|
|
PrintBitMask(os, get_scalar(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-08 09:26:04 +00:00
|
|
|
#endif // OBJECT_PRINT
|
|
|
|
|
|
|
|
|
|
|
|
#if TRACE_MAPS
|
|
|
|
|
|
|
|
|
|
|
|
void Name::NameShortPrint() {
|
|
|
|
if (this->IsString()) {
|
|
|
|
PrintF("%s", String::cast(this)->ToCString().get());
|
|
|
|
} else {
|
|
|
|
DCHECK(this->IsSymbol());
|
|
|
|
Symbol* s = Symbol::cast(this);
|
2016-06-06 12:58:10 +00:00
|
|
|
if (s->name()->IsUndefined(GetIsolate())) {
|
2014-12-08 09:26:04 +00:00
|
|
|
PrintF("#<%s>", s->PrivateSymbolToName());
|
|
|
|
} else {
|
|
|
|
PrintF("<%s>", String::cast(s->name())->ToCString().get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Name::NameShortPrint(Vector<char> str) {
|
|
|
|
if (this->IsString()) {
|
|
|
|
return SNPrintF(str, "%s", String::cast(this)->ToCString().get());
|
|
|
|
} else {
|
|
|
|
DCHECK(this->IsSymbol());
|
|
|
|
Symbol* s = Symbol::cast(this);
|
2016-06-06 12:58:10 +00:00
|
|
|
if (s->name()->IsUndefined(GetIsolate())) {
|
2014-12-08 09:26:04 +00:00
|
|
|
return SNPrintF(str, "#<%s>", s->PrivateSymbolToName());
|
|
|
|
} else {
|
|
|
|
return SNPrintF(str, "<%s>", String::cast(s->name())->ToCString().get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // TRACE_MAPS
|
|
|
|
|
|
|
|
|
2014-12-09 14:20:01 +00:00
|
|
|
#if defined(DEBUG) || defined(OBJECT_PRINT)
|
2014-12-08 09:26:04 +00:00
|
|
|
// This method is only meant to be called from gdb for debugging purposes.
|
|
|
|
// Since the string can also be in two-byte encoding, non-Latin1 characters
|
|
|
|
// will be ignored in the output.
|
|
|
|
char* String::ToAsciiArray() {
|
|
|
|
// Static so that subsequent calls frees previously allocated space.
|
|
|
|
// This also means that previous results will be overwritten.
|
|
|
|
static char* buffer = NULL;
|
|
|
|
if (buffer != NULL) delete[] buffer;
|
|
|
|
buffer = new char[length() + 1];
|
|
|
|
WriteToFlat(this, reinterpret_cast<uint8_t*>(buffer), 0, length());
|
|
|
|
buffer[length()] = 0;
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DescriptorArray::Print() {
|
|
|
|
OFStream os(stdout);
|
|
|
|
this->PrintDescriptors(os);
|
|
|
|
os << std::flush;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT
|
|
|
|
HandleScope scope(GetIsolate());
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "Descriptor array #" << number_of_descriptors();
|
2014-12-08 09:26:04 +00:00
|
|
|
for (int i = 0; i < number_of_descriptors(); i++) {
|
|
|
|
Descriptor desc;
|
|
|
|
Get(i, &desc);
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n " << i << ": " << desc;
|
2014-12-08 09:26:04 +00:00
|
|
|
}
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-23 11:31:33 +00:00
|
|
|
void TransitionArray::Print() {
|
|
|
|
OFStream os(stdout);
|
2015-03-06 14:08:33 +00:00
|
|
|
TransitionArray::PrintTransitions(os, this);
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "\n" << std::flush;
|
2014-10-23 11:31:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-06 14:08:33 +00:00
|
|
|
void TransitionArray::PrintTransitions(std::ostream& os, Object* transitions,
|
2014-10-23 11:31:33 +00:00
|
|
|
bool print_header) { // NOLINT
|
2015-03-06 14:08:33 +00:00
|
|
|
int num_transitions = NumberOfTransitions(transitions);
|
2014-10-23 11:31:33 +00:00
|
|
|
if (print_header) {
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "Transition array #" << num_transitions << ":";
|
2014-10-23 11:31:33 +00:00
|
|
|
}
|
2015-03-06 14:08:33 +00:00
|
|
|
for (int i = 0; i < num_transitions; i++) {
|
|
|
|
Name* key = GetKey(transitions, i);
|
|
|
|
Map* target = GetTarget(transitions, i);
|
2016-04-07 15:27:35 +00:00
|
|
|
os << "\n ";
|
2014-12-08 09:26:04 +00:00
|
|
|
#ifdef OBJECT_PRINT
|
2014-10-23 11:31:33 +00:00
|
|
|
key->NamePrint(os);
|
2014-12-08 09:26:04 +00:00
|
|
|
#else
|
|
|
|
key->ShortPrint(os);
|
|
|
|
#endif
|
2014-07-07 09:57:29 +00:00
|
|
|
os << ": ";
|
2015-03-06 14:08:33 +00:00
|
|
|
Heap* heap = key->GetHeap();
|
|
|
|
if (key == heap->nonextensible_symbol()) {
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "(transition to non-extensible)";
|
2015-03-06 14:08:33 +00:00
|
|
|
} else if (key == heap->sealed_symbol()) {
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "(transition to sealed)";
|
2015-03-06 14:08:33 +00:00
|
|
|
} else if (key == heap->frozen_symbol()) {
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "(transition to frozen)";
|
2015-03-06 14:08:33 +00:00
|
|
|
} else if (key == heap->elements_transition_symbol()) {
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "(transition to " << ElementsKindToString(target->elements_kind())
|
2014-12-10 15:18:44 +00:00
|
|
|
<< ")";
|
2015-12-10 17:27:44 +00:00
|
|
|
} else if (key == heap->strict_function_transition_symbol()) {
|
|
|
|
os << " (transition to strict function)";
|
2014-10-23 11:31:33 +00:00
|
|
|
} else {
|
2014-12-10 15:18:44 +00:00
|
|
|
PropertyDetails details = GetTargetDetails(key, target);
|
2015-11-03 13:20:21 +00:00
|
|
|
os << "(transition to ";
|
2015-01-19 17:49:13 +00:00
|
|
|
if (details.location() == kDescriptor) {
|
2014-12-16 13:22:23 +00:00
|
|
|
os << "immutable ";
|
|
|
|
}
|
2015-01-19 17:49:13 +00:00
|
|
|
os << (details.kind() == kData ? "data" : "accessor");
|
|
|
|
if (details.location() == kDescriptor) {
|
2015-03-06 14:08:33 +00:00
|
|
|
Object* value =
|
|
|
|
target->instance_descriptors()->GetValue(target->LastAdded());
|
|
|
|
os << " " << Brief(value);
|
2012-07-05 13:54:20 +00:00
|
|
|
}
|
2014-12-16 13:22:23 +00:00
|
|
|
os << "), attrs: " << details.attributes();
|
2012-07-05 13:54:20 +00:00
|
|
|
}
|
2015-11-03 13:20:21 +00:00
|
|
|
os << " -> " << Brief(target);
|
2012-07-05 13:54:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-08 09:26:04 +00:00
|
|
|
void JSObject::PrintTransitions(std::ostream& os) { // NOLINT
|
2015-11-03 13:20:21 +00:00
|
|
|
Object* transitions = map()->raw_transitions();
|
|
|
|
int num_transitions = TransitionArray::NumberOfTransitions(transitions);
|
|
|
|
if (num_transitions == 0) return;
|
|
|
|
os << "\n - transitions";
|
|
|
|
TransitionArray::PrintTransitions(os, transitions, false);
|
2014-11-07 16:03:11 +00:00
|
|
|
}
|
2014-12-09 14:20:01 +00:00
|
|
|
#endif // defined(DEBUG) || defined(OBJECT_PRINT)
|
2015-06-01 22:46:54 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|