| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 "test/cctest/interpreter/bytecode-expectations-printer.h" | 5 #include "test/cctest/interpreter/bytecode-expectations-printer.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 #include <iostream> | 8 #include <iostream> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 i::String* string) const { | 217 i::String* string) const { |
| 218 stream << '"'; | 218 stream << '"'; |
| 219 for (int i = 0, length = string->length(); i < length; ++i) { | 219 for (int i = 0, length = string->length(); i < length; ++i) { |
| 220 stream << i::AsEscapedUC16ForJSON(string->Get(i)); | 220 stream << i::AsEscapedUC16ForJSON(string->Get(i)); |
| 221 } | 221 } |
| 222 stream << '"'; | 222 stream << '"'; |
| 223 } | 223 } |
| 224 | 224 |
| 225 void BytecodeExpectationsPrinter::PrintConstant( | 225 void BytecodeExpectationsPrinter::PrintConstant( |
| 226 std::ostream& stream, i::Handle<i::Object> constant) const { | 226 std::ostream& stream, i::Handle<i::Object> constant) const { |
| 227 switch (const_pool_type_) { | 227 if (constant->IsSmi()) { |
| 228 case ConstantPoolType::kString: | 228 stream << "Smi ["; |
| 229 CHECK(constant->IsString()); | 229 i::Smi::cast(*constant)->SmiPrint(stream); |
| 230 stream << "]"; |
| 231 } else { |
| 232 stream << i::HeapObject::cast(*constant)->map()->instance_type(); |
| 233 if (constant->IsHeapNumber()) { |
| 234 stream << " ["; |
| 235 i::HeapNumber::cast(*constant)->HeapNumberPrint(stream); |
| 236 stream << "]"; |
| 237 } else if (constant->IsString()) { |
| 238 stream << " ["; |
| 230 PrintV8String(stream, i::String::cast(*constant)); | 239 PrintV8String(stream, i::String::cast(*constant)); |
| 231 break; | 240 stream << "]"; |
| 232 case ConstantPoolType::kNumber: | 241 } |
| 233 if (constant->IsSmi()) { | |
| 234 i::Smi::cast(*constant)->SmiPrint(stream); | |
| 235 } else if (constant->IsHeapNumber()) { | |
| 236 i::HeapNumber::cast(*constant)->HeapNumberPrint(stream); | |
| 237 } else { | |
| 238 UNREACHABLE(); | |
| 239 } | |
| 240 break; | |
| 241 case ConstantPoolType::kMixed: | |
| 242 if (constant->IsSmi()) { | |
| 243 stream << "kInstanceTypeDontCare"; | |
| 244 } else { | |
| 245 stream << "InstanceType::" | |
| 246 << i::HeapObject::cast(*constant)->map()->instance_type(); | |
| 247 } | |
| 248 break; | |
| 249 case ConstantPoolType::kUnknown: | |
| 250 default: | |
| 251 UNREACHABLE(); | |
| 252 return; | |
| 253 } | 242 } |
| 254 } | 243 } |
| 255 | 244 |
| 256 void BytecodeExpectationsPrinter::PrintFrameSize( | 245 void BytecodeExpectationsPrinter::PrintFrameSize( |
| 257 std::ostream& stream, i::Handle<i::BytecodeArray> bytecode_array) const { | 246 std::ostream& stream, i::Handle<i::BytecodeArray> bytecode_array) const { |
| 258 const int kPointerSize = sizeof(void*); | 247 const int kPointerSize = sizeof(void*); |
| 259 int frame_size = bytecode_array->frame_size(); | 248 int frame_size = bytecode_array->frame_size(); |
| 260 | 249 |
| 261 DCHECK_EQ(frame_size % kPointerSize, 0); | 250 DCHECK_EQ(frame_size % kPointerSize, 0); |
| 262 stream << "frame size: " << frame_size / kPointerSize | 251 stream << "frame size: " << frame_size / kPointerSize |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 333 |
| 345 stream << "---\n"; | 334 stream << "---\n"; |
| 346 PrintCodeSnippet(stream, snippet); | 335 PrintCodeSnippet(stream, snippet); |
| 347 PrintBytecodeArray(stream, bytecode_array); | 336 PrintBytecodeArray(stream, bytecode_array); |
| 348 stream << '\n'; | 337 stream << '\n'; |
| 349 } | 338 } |
| 350 | 339 |
| 351 } // namespace interpreter | 340 } // namespace interpreter |
| 352 } // namespace internal | 341 } // namespace internal |
| 353 } // namespace v8 | 342 } // namespace v8 |
| OLD | NEW |