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

Unified Diff: src/interpreter/bytecodes.cc

Issue 2041913002: [interpreter] Remove OperandScale from front stages of pipeline. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor clean-up. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: src/interpreter/bytecodes.cc
diff --git a/src/interpreter/bytecodes.cc b/src/interpreter/bytecodes.cc
index 46134b7f1d418c52dbecbfe82775ad20586f08cf..7b1dc0cb4a5c1dad352b201985e1d0ead3d24a82 100644
--- a/src/interpreter/bytecodes.cc
+++ b/src/interpreter/bytecodes.cc
@@ -6,6 +6,7 @@
#include <iomanip>
+#include "src/base/bits.h"
#include "src/frames.h"
#include "src/interpreter/bytecode-traits.h"
#include "src/interpreter/interpreter.h"
@@ -592,38 +593,20 @@ bool Bytecodes::IsUnsignedOperandType(OperandType operand_type) {
// static
OperandSize Bytecodes::SizeForSignedOperand(int value) {
- if (kMinInt8 <= value && value <= kMaxInt8) {
- return OperandSize::kByte;
- } else if (kMinInt16 <= value && value <= kMaxInt16) {
- return OperandSize::kShort;
- } else {
- return OperandSize::kQuad;
- }
+ uint32_t unsigned_value = (value >= 0) ? static_cast<uint32_t>(value)
+ : static_cast<uint32_t>(-1 - value);
+ // Signed operands require 1-bit for the sign, hence the multiplication by 2u;
+ return SizeForUnsignedOperand(unsigned_value * 2u);
rmcilroy 2016/06/07 10:32:46 I prefer the old approach we used here. Is there a
oth 2016/06/08 15:08:41 Done. This was just experimentation with slightly
}
// static
-OperandSize Bytecodes::SizeForUnsignedOperand(int value) {
- DCHECK_GE(value, 0);
- if (value <= kMaxUInt8) {
- return OperandSize::kByte;
- } else if (value <= kMaxUInt16) {
- return OperandSize::kShort;
- } else {
- return OperandSize::kQuad;
- }
-}
-
-OperandSize Bytecodes::SizeForUnsignedOperand(size_t value) {
- if (value <= static_cast<size_t>(kMaxUInt8)) {
- return OperandSize::kByte;
- } else if (value <= static_cast<size_t>(kMaxUInt16)) {
- return OperandSize::kShort;
- } else if (value <= kMaxUInt32) {
- return OperandSize::kQuad;
- } else {
- UNREACHABLE();
- return OperandSize::kQuad;
- }
+OperandSize Bytecodes::SizeForUnsignedOperand(uint32_t value) {
+ unsigned leading_zeros = base::bits::CountLeadingZeros32(value);
+ unsigned index = (32 - leading_zeros + 7) / 8;
+ const OperandSize kSizes[] = {OperandSize::kByte, OperandSize::kByte,
+ OperandSize::kShort, OperandSize::kQuad,
+ OperandSize::kQuad};
+ return kSizes[index];
}
OperandScale Bytecodes::OperandSizesToScale(OperandSize size0) {

Powered by Google App Engine
This is Rietveld 408576698