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

Side by Side Diff: src/compiler/interpreter-assembler.cc

Issue 1370893002: [Interpreter] Add support for short (16 bit) operands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rename to kIdx16 and add support for architectures which don't support unaligned accesses. Created 5 years, 2 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 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/compiler/interpreter-assembler.h" 5 #include "src/compiler/interpreter-assembler.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/compiler/graph.h" 10 #include "src/compiler/graph.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 120
121 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) { 121 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) {
122 return raw_assembler_->Store(kMachAnyTagged, RegisterFileRawPointer(), 122 return raw_assembler_->Store(kMachAnyTagged, RegisterFileRawPointer(),
123 RegisterFrameOffset(reg_index), value); 123 RegisterFrameOffset(reg_index), value);
124 } 124 }
125 125
126 126
127 Node* InterpreterAssembler::BytecodeOperand(int operand_index) { 127 Node* InterpreterAssembler::BytecodeOperand(int operand_index) {
128 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); 128 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_));
129 DCHECK(interpreter::OperandSize::kByte ==
oth 2015/10/01 15:12:15 DCHECK_EQ
rmcilroy 2015/10/01 16:25:07 Done.
130 interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index));
129 return raw_assembler_->Load( 131 return raw_assembler_->Load(
130 kMachUint8, BytecodeArrayTaggedPointer(), 132 kMachUint8, BytecodeArrayTaggedPointer(),
131 IntPtrAdd(BytecodeOffset(), Int32Constant(1 + operand_index))); 133 IntPtrAdd(BytecodeOffset(),
134 Int32Constant(interpreter::Bytecodes::GetOperandOffset(
135 bytecode_, operand_index))));
132 } 136 }
133 137
134 138
135 Node* InterpreterAssembler::BytecodeOperandSignExtended(int operand_index) { 139 Node* InterpreterAssembler::BytecodeOperandSignExtended(int operand_index) {
136 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); 140 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_));
141 DCHECK(interpreter::OperandSize::kByte ==
142 interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index));
137 Node* load = raw_assembler_->Load( 143 Node* load = raw_assembler_->Load(
138 kMachInt8, BytecodeArrayTaggedPointer(), 144 kMachInt8, BytecodeArrayTaggedPointer(),
139 IntPtrAdd(BytecodeOffset(), Int32Constant(1 + operand_index))); 145 IntPtrAdd(BytecodeOffset(),
146 Int32Constant(interpreter::Bytecodes::GetOperandOffset(
147 bytecode_, operand_index))));
140 // Ensure that we sign extend to full pointer size 148 // Ensure that we sign extend to full pointer size
141 if (kPointerSize == 8) { 149 if (kPointerSize == 8) {
142 load = raw_assembler_->ChangeInt32ToInt64(load); 150 load = raw_assembler_->ChangeInt32ToInt64(load);
143 } 151 }
144 return load; 152 return load;
145 } 153 }
146 154
147 155
148 Node* InterpreterAssembler::BytecodeOperandCount(int operand_index) { 156 Node* InterpreterAssembler::BytecodeOperandShort(int operand_index) {
149 DCHECK_EQ(interpreter::OperandType::kCount, 157 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_));
158 DCHECK(interpreter::OperandSize::kShort ==
oth 2015/10/01 15:12:14 DCHECK_EQ
rmcilroy 2015/10/01 16:25:07 Done.
159 interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index));
160 if (TargetSupportsUnalignedAccess()) {
161 return raw_assembler_->Load(
162 kMachUint16, BytecodeArrayTaggedPointer(),
163 IntPtrAdd(BytecodeOffset(),
164 Int32Constant(interpreter::Bytecodes::GetOperandOffset(
165 bytecode_, operand_index))));
166 } else {
167 int offset =
168 interpreter::Bytecodes::GetOperandOffset(bytecode_, operand_index);
169 Node* first_byte = raw_assembler_->Load(
170 kMachUint8, BytecodeArrayTaggedPointer(),
171 IntPtrAdd(BytecodeOffset(), Int32Constant(offset)));
172 Node* second_byte = raw_assembler_->Load(
173 kMachUint8, BytecodeArrayTaggedPointer(),
174 IntPtrAdd(BytecodeOffset(), Int32Constant(offset + 1)));
175 #if V8_TARGET_LITTLE_ENDIAN
176 return raw_assembler_->WordOr(WordShl(second_byte, kBitsPerByte),
177 first_byte);
178 #elif V8_TARGET_BIG_ENDIAN
179 return raw_assembler_->WordOr(WordShl(first_byte, kBitsPerByte),
180 second_byte);
181 #else
182 #error "Unknown Architecture"
183 #endif
184 }
185 }
186
187
188 Node* InterpreterAssembler::BytecodeOperandCount8(int operand_index) {
189 DCHECK_EQ(interpreter::OperandType::kCount8,
150 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); 190 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index));
151 return BytecodeOperand(operand_index); 191 return BytecodeOperand(operand_index);
152 } 192 }
153 193
154 194
155 Node* InterpreterAssembler::BytecodeOperandImm8(int operand_index) { 195 Node* InterpreterAssembler::BytecodeOperandImm8(int operand_index) {
156 DCHECK_EQ(interpreter::OperandType::kImm8, 196 DCHECK_EQ(interpreter::OperandType::kImm8,
157 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); 197 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index));
158 return BytecodeOperandSignExtended(operand_index); 198 return BytecodeOperandSignExtended(operand_index);
159 } 199 }
160 200
161 201
162 Node* InterpreterAssembler::BytecodeOperandIdx(int operand_index) { 202 Node* InterpreterAssembler::BytecodeOperandIdx8(int operand_index) {
163 DCHECK_EQ(interpreter::OperandType::kIdx, 203 DCHECK_EQ(interpreter::OperandType::kIdx8,
164 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); 204 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index));
165 return BytecodeOperand(operand_index); 205 return BytecodeOperand(operand_index);
166 } 206 }
167 207
168 208
169 Node* InterpreterAssembler::BytecodeOperandReg(int operand_index) { 209 Node* InterpreterAssembler::BytecodeOperandReg8(int operand_index) {
170 DCHECK_EQ(interpreter::OperandType::kReg, 210 DCHECK_EQ(interpreter::OperandType::kReg8,
171 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); 211 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index));
172 return BytecodeOperandSignExtended(operand_index); 212 return BytecodeOperandSignExtended(operand_index);
173 } 213 }
174 214
175 215
216 Node* InterpreterAssembler::BytecodeOperandIdx16(int operand_index) {
217 DCHECK_EQ(interpreter::OperandType::kIdx16,
218 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index));
219 return BytecodeOperandShort(operand_index);
220 }
221
222
176 Node* InterpreterAssembler::Int32Constant(int value) { 223 Node* InterpreterAssembler::Int32Constant(int value) {
177 return raw_assembler_->Int32Constant(value); 224 return raw_assembler_->Int32Constant(value);
178 } 225 }
179 226
180 227
181 Node* InterpreterAssembler::IntPtrConstant(intptr_t value) { 228 Node* InterpreterAssembler::IntPtrConstant(intptr_t value) {
182 return raw_assembler_->IntPtrConstant(value); 229 return raw_assembler_->IntPtrConstant(value);
183 } 230 }
184 231
185 232
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 472
426 void InterpreterAssembler::End() { 473 void InterpreterAssembler::End() {
427 DCHECK(!end_nodes_.empty()); 474 DCHECK(!end_nodes_.empty());
428 int end_count = static_cast<int>(end_nodes_.size()); 475 int end_count = static_cast<int>(end_nodes_.size());
429 Node* end = graph()->NewNode(raw_assembler_->common()->End(end_count), 476 Node* end = graph()->NewNode(raw_assembler_->common()->End(end_count),
430 end_count, &end_nodes_[0]); 477 end_count, &end_nodes_[0]);
431 graph()->SetEnd(end); 478 graph()->SetEnd(end);
432 } 479 }
433 480
434 481
482 // static
483 bool InterpreterAssembler::TargetSupportsUnalignedAccess() {
484 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
485 return false;
486 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC
487 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES);
488 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87
489 return true;
490 #else
491 #error "Unknown Architecture"
492 #endif
493 }
494
495
435 // RawMachineAssembler delegate helpers: 496 // RawMachineAssembler delegate helpers:
436 Isolate* InterpreterAssembler::isolate() { return raw_assembler_->isolate(); } 497 Isolate* InterpreterAssembler::isolate() { return raw_assembler_->isolate(); }
437 498
438 499
439 Graph* InterpreterAssembler::graph() { return raw_assembler_->graph(); } 500 Graph* InterpreterAssembler::graph() { return raw_assembler_->graph(); }
440 501
441 502
442 CallDescriptor* InterpreterAssembler::call_descriptor() const { 503 CallDescriptor* InterpreterAssembler::call_descriptor() const {
443 return raw_assembler_->call_descriptor(); 504 return raw_assembler_->call_descriptor();
444 } 505 }
445 506
446 507
447 Schedule* InterpreterAssembler::schedule() { 508 Schedule* InterpreterAssembler::schedule() {
448 return raw_assembler_->schedule(); 509 return raw_assembler_->schedule();
449 } 510 }
450 511
451 512
452 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } 513 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); }
453 514
454 515
455 } // namespace interpreter 516 } // namespace interpreter
456 } // namespace internal 517 } // namespace internal
457 } // namespace v8 518 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698