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

Side by Side Diff: src/objects.cc

Issue 1230753004: [Interpreter] Add BytecodeArray class and add to SharedFunctionInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Avoid outputting junk data in BytecodeArray::Print() and ByteArray::Print(). Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 13 matching lines...) Expand all
24 #include "src/deoptimizer.h" 24 #include "src/deoptimizer.h"
25 #include "src/elements.h" 25 #include "src/elements.h"
26 #include "src/execution.h" 26 #include "src/execution.h"
27 #include "src/field-index-inl.h" 27 #include "src/field-index-inl.h"
28 #include "src/field-index.h" 28 #include "src/field-index.h"
29 #include "src/full-codegen.h" 29 #include "src/full-codegen.h"
30 #include "src/heap/mark-compact.h" 30 #include "src/heap/mark-compact.h"
31 #include "src/heap/objects-visiting-inl.h" 31 #include "src/heap/objects-visiting-inl.h"
32 #include "src/hydrogen.h" 32 #include "src/hydrogen.h"
33 #include "src/ic/ic.h" 33 #include "src/ic/ic.h"
34 #include "src/interpreter/bytecodes.h"
34 #include "src/log.h" 35 #include "src/log.h"
35 #include "src/lookup.h" 36 #include "src/lookup.h"
36 #include "src/macro-assembler.h" 37 #include "src/macro-assembler.h"
37 #include "src/messages.h" 38 #include "src/messages.h"
38 #include "src/objects-inl.h" 39 #include "src/objects-inl.h"
39 #include "src/prototype.h" 40 #include "src/prototype.h"
40 #include "src/safepoint-table.h" 41 #include "src/safepoint-table.h"
41 #include "src/string-search.h" 42 #include "src/string-search.h"
42 #include "src/string-stream.h" 43 #include "src/string-stream.h"
43 #include "src/utils.h" 44 #include "src/utils.h"
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 case FIXED_ARRAY_TYPE: 1244 case FIXED_ARRAY_TYPE:
1244 os << "<FixedArray[" << FixedArray::cast(this)->length() << "]>"; 1245 os << "<FixedArray[" << FixedArray::cast(this)->length() << "]>";
1245 break; 1246 break;
1246 case FIXED_DOUBLE_ARRAY_TYPE: 1247 case FIXED_DOUBLE_ARRAY_TYPE:
1247 os << "<FixedDoubleArray[" << FixedDoubleArray::cast(this)->length() 1248 os << "<FixedDoubleArray[" << FixedDoubleArray::cast(this)->length()
1248 << "]>"; 1249 << "]>";
1249 break; 1250 break;
1250 case BYTE_ARRAY_TYPE: 1251 case BYTE_ARRAY_TYPE:
1251 os << "<ByteArray[" << ByteArray::cast(this)->length() << "]>"; 1252 os << "<ByteArray[" << ByteArray::cast(this)->length() << "]>";
1252 break; 1253 break;
1254 case BYTECODE_ARRAY_TYPE:
1255 os << "<BytecodeArray[" << BytecodeArray::cast(this)->length() << "]>";
1256 break;
1253 case FREE_SPACE_TYPE: 1257 case FREE_SPACE_TYPE:
1254 os << "<FreeSpace[" << FreeSpace::cast(this)->Size() << "]>"; 1258 os << "<FreeSpace[" << FreeSpace::cast(this)->Size() << "]>";
1255 break; 1259 break;
1256 #define TYPED_ARRAY_SHORT_PRINT(Type, type, TYPE, ctype, size) \ 1260 #define TYPED_ARRAY_SHORT_PRINT(Type, type, TYPE, ctype, size) \
1257 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ 1261 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
1258 os << "<External" #Type "Array[" \ 1262 os << "<External" #Type "Array[" \
1259 << External##Type##Array::cast(this)->length() << "]>"; \ 1263 << External##Type##Array::cast(this)->length() << "]>"; \
1260 break; \ 1264 break; \
1261 case FIXED_##TYPE##_ARRAY_TYPE: \ 1265 case FIXED_##TYPE##_ARRAY_TYPE: \
1262 os << "<Fixed" #Type "Array[" << Fixed##Type##Array::cast(this)->length() \ 1266 os << "<Fixed" #Type "Array[" << Fixed##Type##Array::cast(this)->length() \
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 break; 1473 break;
1470 case SYMBOL_TYPE: 1474 case SYMBOL_TYPE:
1471 Symbol::BodyDescriptor::IterateBody(this, v); 1475 Symbol::BodyDescriptor::IterateBody(this, v);
1472 break; 1476 break;
1473 1477
1474 case HEAP_NUMBER_TYPE: 1478 case HEAP_NUMBER_TYPE:
1475 case MUTABLE_HEAP_NUMBER_TYPE: 1479 case MUTABLE_HEAP_NUMBER_TYPE:
1476 case FLOAT32X4_TYPE: 1480 case FLOAT32X4_TYPE:
1477 case FILLER_TYPE: 1481 case FILLER_TYPE:
1478 case BYTE_ARRAY_TYPE: 1482 case BYTE_ARRAY_TYPE:
1483 case BYTECODE_ARRAY_TYPE:
1479 case FREE_SPACE_TYPE: 1484 case FREE_SPACE_TYPE:
1480 break; 1485 break;
1481 1486
1482 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 1487 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1483 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ 1488 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
1484 break; \ 1489 break; \
1485 \ 1490 \
1486 case FIXED_##TYPE##_ARRAY_TYPE: \ 1491 case FIXED_##TYPE##_ARRAY_TYPE: \
1487 reinterpret_cast<FixedTypedArrayBase*>(this) \ 1492 reinterpret_cast<FixedTypedArrayBase*>(this) \
1488 ->FixedTypedArrayBaseIterateBody(v); \ 1493 ->FixedTypedArrayBaseIterateBody(v); \
(...skipping 10295 matching lines...) Expand 10 before | Expand all | Expand 10 after
11784 11789
11785 os << "RelocInfo (size = " << relocation_size() << ")\n"; 11790 os << "RelocInfo (size = " << relocation_size() << ")\n";
11786 for (RelocIterator it(this); !it.done(); it.next()) { 11791 for (RelocIterator it(this); !it.done(); it.next()) {
11787 it.rinfo()->Print(GetIsolate(), os); 11792 it.rinfo()->Print(GetIsolate(), os);
11788 } 11793 }
11789 os << "\n"; 11794 os << "\n";
11790 } 11795 }
11791 #endif // ENABLE_DISASSEMBLER 11796 #endif // ENABLE_DISASSEMBLER
11792 11797
11793 11798
11799 void BytecodeArray::Disassemble(std::ostream& os) {
11800 Vector<char> buf = Vector<char>::New(50);
11801 int bytecode_size = 0;
rmcilroy 2015/07/20 11:39:46 Could you print out frame size / locals count here
oth 2015/07/20 13:47:31 Done.
11802 for (int i = 0; i < this->length(); i += bytecode_size) {
11803 interpreter::Bytecode bytecode = static_cast<interpreter::Bytecode>(get(i));
11804 bytecode_size = interpreter::Bytecodes::Size(bytecode);
11805
11806 SNPrintF(buf, "%p : ", GetFirstBytecodeAddress() + i);
11807 os << buf.start();
11808 for (int j = 0; j < bytecode_size; j++) {
11809 SNPrintF(buf, "%02x ", get(i + j));
11810 os << buf.start();
11811 }
11812 for (int j = bytecode_size; j < interpreter::Bytecodes::kMaximumSize; j++) {
11813 os << " ";
11814 }
11815 os << bytecode;
11816 }
11817 }
11818
11819
11794 // static 11820 // static
11795 void JSArray::Initialize(Handle<JSArray> array, int capacity, int length) { 11821 void JSArray::Initialize(Handle<JSArray> array, int capacity, int length) {
11796 DCHECK(capacity >= 0); 11822 DCHECK(capacity >= 0);
11797 array->GetIsolate()->factory()->NewJSArrayStorage( 11823 array->GetIsolate()->factory()->NewJSArrayStorage(
11798 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); 11824 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
11799 } 11825 }
11800 11826
11801 11827
11802 // Returns false if the passed-in index is marked non-configurable, which will 11828 // Returns false if the passed-in index is marked non-configurable, which will
11803 // cause the truncation operation to halt, and thus no further old values need 11829 // cause the truncation operation to halt, and thus no further old values need
(...skipping 4316 matching lines...) Expand 10 before | Expand all | Expand 10 after
16120 Handle<Object> new_value) { 16146 Handle<Object> new_value) {
16121 if (cell->value() != *new_value) { 16147 if (cell->value() != *new_value) {
16122 cell->set_value(*new_value); 16148 cell->set_value(*new_value);
16123 Isolate* isolate = cell->GetIsolate(); 16149 Isolate* isolate = cell->GetIsolate();
16124 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16150 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16125 isolate, DependentCode::kPropertyCellChangedGroup); 16151 isolate, DependentCode::kPropertyCellChangedGroup);
16126 } 16152 }
16127 } 16153 }
16128 } // namespace internal 16154 } // namespace internal
16129 } // namespace v8 16155 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698