Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/interpreter/bytecode-traits.h" | 10 #include "src/interpreter/bytecode-traits.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 return kOperandSizes[static_cast<size_t>(operand_type)][scale_index]; | 282 return kOperandSizes[static_cast<size_t>(operand_type)][scale_index]; |
| 283 } | 283 } |
| 284 | 284 |
| 285 // static | 285 // static |
| 286 bool Bytecodes::BytecodeHasHandler(Bytecode bytecode, | 286 bool Bytecodes::BytecodeHasHandler(Bytecode bytecode, |
| 287 OperandScale operand_scale) { | 287 OperandScale operand_scale) { |
| 288 return operand_scale == OperandScale::kSingle || | 288 return operand_scale == OperandScale::kSingle || |
| 289 Bytecodes::IsBytecodeWithScalableOperands(bytecode); | 289 Bytecodes::IsBytecodeWithScalableOperands(bytecode); |
| 290 } | 290 } |
| 291 | 291 |
| 292 // static | |
| 293 bool Bytecodes::BytecodeIsReadOnly(Bytecode bytecode) { | |
| 294 // TODO(yangguo): whitelist more bytecodes. | |
| 295 if (IsWithoutExternalSideEffects(bytecode)) return true; | |
| 296 if (IsCallRuntime(bytecode)) return true; | |
|
jgruber
2017/01/10 12:46:37
Is CallRuntime really side-effect-free? What about
| |
| 297 if (IsCallOrNew(bytecode)) return true; | |
|
jgruber
2017/01/10 12:46:37
This is considered side-effect-free because we re-
Yang
2017/01/10 14:14:06
Yes.
| |
| 298 switch (bytecode) { | |
| 299 case Bytecode::kStackCheck: | |
| 300 case Bytecode::kLdaLookupSlot: | |
| 301 case Bytecode::kLdaGlobal: | |
| 302 case Bytecode::kLdaNamedProperty: | |
| 303 case Bytecode::kLdaKeyedProperty: | |
| 304 case Bytecode::kAdd: | |
| 305 case Bytecode::kReturn: | |
| 306 case Bytecode::kCreateCatchContext: | |
| 307 case Bytecode::kSetPendingMessage: | |
| 308 case Bytecode::kPushContext: | |
| 309 case Bytecode::kPopContext: | |
| 310 return true; | |
| 311 default: | |
| 312 return false; | |
| 313 } | |
| 314 } | |
| 315 | |
| 292 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { | 316 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { |
| 293 return os << Bytecodes::ToString(bytecode); | 317 return os << Bytecodes::ToString(bytecode); |
| 294 } | 318 } |
| 295 | 319 |
| 296 } // namespace interpreter | 320 } // namespace interpreter |
| 297 } // namespace internal | 321 } // namespace internal |
| 298 } // namespace v8 | 322 } // namespace v8 |
| OLD | NEW |