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

Side by Side Diff: src/interpreter/bytecodes.cc

Issue 2358523003: [Interpreter] Remove extra CHECKS added for crbug.com/642111. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 "src/interpreter/bytecodes.h" 5 #include "src/interpreter/bytecodes.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return size; 146 return size;
147 } 147 }
148 148
149 // static 149 // static
150 size_t Bytecodes::ReturnCount(Bytecode bytecode) { 150 size_t Bytecodes::ReturnCount(Bytecode bytecode) {
151 return bytecode == Bytecode::kReturn ? 1 : 0; 151 return bytecode == Bytecode::kReturn ? 1 : 0;
152 } 152 }
153 153
154 // static 154 // static
155 int Bytecodes::NumberOfOperands(Bytecode bytecode) { 155 int Bytecodes::NumberOfOperands(Bytecode bytecode) {
156 CHECK(bytecode <= Bytecode::kLast); 156 DCHECK(bytecode <= Bytecode::kLast);
157 switch (bytecode) { 157 switch (bytecode) {
158 #define CASE(Name, ...) \ 158 #define CASE(Name, ...) \
159 case Bytecode::k##Name: \ 159 case Bytecode::k##Name: \
160 return BytecodeTraits<__VA_ARGS__>::kOperandCount; 160 return BytecodeTraits<__VA_ARGS__>::kOperandCount;
161 BYTECODE_LIST(CASE) 161 BYTECODE_LIST(CASE)
162 #undef CASE 162 #undef CASE
163 } 163 }
164 UNREACHABLE(); 164 UNREACHABLE();
165 return 0; 165 return 0;
166 } 166 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 bool Bytecodes::IsWithoutExternalSideEffects(Bytecode bytecode) { 303 bool Bytecodes::IsWithoutExternalSideEffects(Bytecode bytecode) {
304 // These bytecodes only manipulate interpreter frame state and will 304 // These bytecodes only manipulate interpreter frame state and will
305 // never throw. 305 // never throw.
306 return (IsAccumulatorLoadWithoutEffects(bytecode) || 306 return (IsAccumulatorLoadWithoutEffects(bytecode) ||
307 IsRegisterLoadWithoutEffects(bytecode) || 307 IsRegisterLoadWithoutEffects(bytecode) ||
308 bytecode == Bytecode::kNop || IsJumpWithoutEffects(bytecode)); 308 bytecode == Bytecode::kNop || IsJumpWithoutEffects(bytecode));
309 } 309 }
310 310
311 // static 311 // static
312 OperandType Bytecodes::GetOperandType(Bytecode bytecode, int i) { 312 OperandType Bytecodes::GetOperandType(Bytecode bytecode, int i) {
313 CHECK_LE(bytecode, Bytecode::kLast); 313 DCHECK_LE(bytecode, Bytecode::kLast);
314 CHECK_LT(i, NumberOfOperands(bytecode)); 314 DCHECK_LT(i, NumberOfOperands(bytecode));
315 CHECK_GE(i, 0); 315 DCHECK_GE(i, 0);
316 return GetOperandTypes(bytecode)[i]; 316 return GetOperandTypes(bytecode)[i];
317 } 317 }
318 318
319 // static 319 // static
320 const OperandType* Bytecodes::GetOperandTypes(Bytecode bytecode) { 320 const OperandType* Bytecodes::GetOperandTypes(Bytecode bytecode) {
321 CHECK_LE(bytecode, Bytecode::kLast); 321 DCHECK_LE(bytecode, Bytecode::kLast);
322 switch (bytecode) { 322 switch (bytecode) {
323 #define CASE(Name, ...) \ 323 #define CASE(Name, ...) \
324 case Bytecode::k##Name: \ 324 case Bytecode::k##Name: \
325 return BytecodeTraits<__VA_ARGS__>::GetOperandTypes(); 325 return BytecodeTraits<__VA_ARGS__>::GetOperandTypes();
326 BYTECODE_LIST(CASE) 326 BYTECODE_LIST(CASE)
327 #undef CASE 327 #undef CASE
328 } 328 }
329 UNREACHABLE(); 329 UNREACHABLE();
330 return nullptr; 330 return nullptr;
331 } 331 }
332 332
333 // static 333 // static
334 const OperandTypeInfo* Bytecodes::GetOperandTypeInfos(Bytecode bytecode) { 334 const OperandTypeInfo* Bytecodes::GetOperandTypeInfos(Bytecode bytecode) {
335 DCHECK(bytecode <= Bytecode::kLast); 335 DCHECK(bytecode <= Bytecode::kLast);
336 switch (bytecode) { 336 switch (bytecode) {
337 #define CASE(Name, ...) \ 337 #define CASE(Name, ...) \
338 case Bytecode::k##Name: \ 338 case Bytecode::k##Name: \
339 return BytecodeTraits<__VA_ARGS__>::GetOperandTypeInfos(); 339 return BytecodeTraits<__VA_ARGS__>::GetOperandTypeInfos();
340 BYTECODE_LIST(CASE) 340 BYTECODE_LIST(CASE)
341 #undef CASE 341 #undef CASE
342 } 342 }
343 UNREACHABLE(); 343 UNREACHABLE();
344 return nullptr; 344 return nullptr;
345 } 345 }
346 346
347 // static 347 // static
348 OperandSize Bytecodes::GetOperandSize(Bytecode bytecode, int i, 348 OperandSize Bytecodes::GetOperandSize(Bytecode bytecode, int i,
349 OperandScale operand_scale) { 349 OperandScale operand_scale) {
350 CHECK_LT(i, NumberOfOperands(bytecode)); 350 DCHECK_LT(i, NumberOfOperands(bytecode));
351 OperandType operand_type = GetOperandType(bytecode, i); 351 OperandType operand_type = GetOperandType(bytecode, i);
352 return SizeOfOperand(operand_type, operand_scale); 352 return SizeOfOperand(operand_type, operand_scale);
353 } 353 }
354 354
355 // static 355 // static
356 int Bytecodes::GetOperandOffset(Bytecode bytecode, int i, 356 int Bytecodes::GetOperandOffset(Bytecode bytecode, int i,
357 OperandScale operand_scale) { 357 OperandScale operand_scale) {
358 DCHECK_LT(i, Bytecodes::NumberOfOperands(bytecode)); 358 DCHECK_LT(i, Bytecodes::NumberOfOperands(bytecode));
359 // TODO(oth): restore this to a statically determined constant. 359 // TODO(oth): restore this to a statically determined constant.
360 int offset = 1; 360 int offset = 1;
361 for (int operand_index = 0; operand_index < i; ++operand_index) { 361 for (int operand_index = 0; operand_index < i; ++operand_index) {
362 OperandSize operand_size = 362 OperandSize operand_size =
363 GetOperandSize(bytecode, operand_index, operand_scale); 363 GetOperandSize(bytecode, operand_index, operand_scale);
364 offset += static_cast<int>(operand_size); 364 offset += static_cast<int>(operand_size);
365 } 365 }
366 return offset; 366 return offset;
367 } 367 }
368 368
369 // static 369 // static
370 OperandSize Bytecodes::SizeOfOperand(OperandType operand_type, 370 OperandSize Bytecodes::SizeOfOperand(OperandType operand_type,
371 OperandScale operand_scale) { 371 OperandScale operand_scale) {
372 CHECK_LE(operand_type, OperandType::kLast); 372 DCHECK_LE(operand_type, OperandType::kLast);
373 CHECK_GE(operand_scale, OperandScale::kSingle); 373 DCHECK_GE(operand_scale, OperandScale::kSingle);
374 CHECK_LE(operand_scale, OperandScale::kLast); 374 DCHECK_LE(operand_scale, OperandScale::kLast);
375 return static_cast<OperandSize>( 375 return static_cast<OperandSize>(
376 ScaledOperandSize(operand_type, operand_scale)); 376 ScaledOperandSize(operand_type, operand_scale));
377 } 377 }
378 378
379 // static 379 // static
380 bool Bytecodes::IsConditionalJumpImmediate(Bytecode bytecode) { 380 bool Bytecodes::IsConditionalJumpImmediate(Bytecode bytecode) {
381 return bytecode == Bytecode::kJumpIfTrue || 381 return bytecode == Bytecode::kJumpIfTrue ||
382 bytecode == Bytecode::kJumpIfFalse || 382 bytecode == Bytecode::kJumpIfFalse ||
383 bytecode == Bytecode::kJumpIfToBooleanTrue || 383 bytecode == Bytecode::kJumpIfToBooleanTrue ||
384 bytecode == Bytecode::kJumpIfToBooleanFalse || 384 bytecode == Bytecode::kJumpIfToBooleanFalse ||
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 return os << Bytecodes::OperandScaleToString(operand_scale); 678 return os << Bytecodes::OperandScaleToString(operand_scale);
679 } 679 }
680 680
681 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type) { 681 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type) {
682 return os << Bytecodes::OperandTypeToString(operand_type); 682 return os << Bytecodes::OperandTypeToString(operand_type);
683 } 683 }
684 684
685 } // namespace interpreter 685 } // namespace interpreter
686 } // namespace internal 686 } // namespace internal
687 } // namespace v8 687 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698