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

Side by Side Diff: src/interpreter/bytecode-array-writer.cc

Issue 2223523002: [Interpreter] Avoid dereferencing handles on BytecodeGenerator for AST operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_const_array
Patch Set: Rebase Created 4 years, 4 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 | « src/globals.h ('k') | src/interpreter/bytecode-generator.cc » ('j') | 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/bytecode-array-writer.h" 5 #include "src/interpreter/bytecode-array-writer.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/interpreter/bytecode-label.h" 8 #include "src/interpreter/bytecode-label.h"
9 #include "src/interpreter/bytecode-register.h" 9 #include "src/interpreter/bytecode-register.h"
10 #include "src/interpreter/constant-array-builder.h" 10 #include "src/interpreter/constant-array-builder.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 Bytecode jump_bytecode = Bytecodes::FromByte(bytecodes()->at(jump_location)); 247 Bytecode jump_bytecode = Bytecodes::FromByte(bytecodes()->at(jump_location));
248 DCHECK(Bytecodes::IsJumpImmediate(jump_bytecode)); 248 DCHECK(Bytecodes::IsJumpImmediate(jump_bytecode));
249 size_t operand_location = jump_location + 1; 249 size_t operand_location = jump_location + 1;
250 DCHECK_EQ(bytecodes()->at(operand_location), k8BitJumpPlaceholder); 250 DCHECK_EQ(bytecodes()->at(operand_location), k8BitJumpPlaceholder);
251 if (Bytecodes::SizeForSignedOperand(delta) == OperandSize::kByte) { 251 if (Bytecodes::SizeForSignedOperand(delta) == OperandSize::kByte) {
252 // The jump fits within the range of an Imm operand, so cancel 252 // The jump fits within the range of an Imm operand, so cancel
253 // the reservation and jump directly. 253 // the reservation and jump directly.
254 constant_array_builder()->DiscardReservedEntry(OperandSize::kByte); 254 constant_array_builder()->DiscardReservedEntry(OperandSize::kByte);
255 bytecodes()->at(operand_location) = static_cast<uint8_t>(delta); 255 bytecodes()->at(operand_location) = static_cast<uint8_t>(delta);
256 } else { 256 } else {
257 // TODO(5203): Remove this temporary exception.
258 AllowHandleAllocation allow_handles;
257 // The jump does not fit within the range of an Imm operand, so 259 // The jump does not fit within the range of an Imm operand, so
258 // commit reservation putting the offset into the constant pool, 260 // commit reservation putting the offset into the constant pool,
259 // and update the jump instruction and operand. 261 // and update the jump instruction and operand.
260 size_t entry = constant_array_builder()->CommitReservedEntry( 262 size_t entry = constant_array_builder()->CommitReservedEntry(
261 OperandSize::kByte, handle(Smi::FromInt(delta), isolate())); 263 OperandSize::kByte, handle(Smi::FromInt(delta), isolate()));
262 DCHECK_LE(entry, kMaxUInt32); 264 DCHECK_LE(entry, kMaxUInt32);
263 DCHECK_EQ(Bytecodes::SizeForUnsignedOperand(static_cast<uint32_t>(entry)), 265 DCHECK_EQ(Bytecodes::SizeForUnsignedOperand(static_cast<uint32_t>(entry)),
264 OperandSize::kByte); 266 OperandSize::kByte);
265 jump_bytecode = GetJumpWithConstantOperand(jump_bytecode); 267 jump_bytecode = GetJumpWithConstantOperand(jump_bytecode);
266 bytecodes()->at(jump_location) = Bytecodes::ToByte(jump_bytecode); 268 bytecodes()->at(jump_location) = Bytecodes::ToByte(jump_bytecode);
267 bytecodes()->at(operand_location) = static_cast<uint8_t>(entry); 269 bytecodes()->at(operand_location) = static_cast<uint8_t>(entry);
268 } 270 }
269 } 271 }
270 272
271 void BytecodeArrayWriter::PatchJumpWith16BitOperand(size_t jump_location, 273 void BytecodeArrayWriter::PatchJumpWith16BitOperand(size_t jump_location,
272 int delta) { 274 int delta) {
273 Bytecode jump_bytecode = Bytecodes::FromByte(bytecodes()->at(jump_location)); 275 Bytecode jump_bytecode = Bytecodes::FromByte(bytecodes()->at(jump_location));
274 DCHECK(Bytecodes::IsJumpImmediate(jump_bytecode)); 276 DCHECK(Bytecodes::IsJumpImmediate(jump_bytecode));
275 size_t operand_location = jump_location + 1; 277 size_t operand_location = jump_location + 1;
276 uint8_t operand_bytes[2]; 278 uint8_t operand_bytes[2];
277 if (Bytecodes::SizeForSignedOperand(delta) <= OperandSize::kShort) { 279 if (Bytecodes::SizeForSignedOperand(delta) <= OperandSize::kShort) {
278 constant_array_builder()->DiscardReservedEntry(OperandSize::kShort); 280 constant_array_builder()->DiscardReservedEntry(OperandSize::kShort);
279 WriteUnalignedUInt16(operand_bytes, static_cast<uint16_t>(delta)); 281 WriteUnalignedUInt16(operand_bytes, static_cast<uint16_t>(delta));
280 } else { 282 } else {
283 // TODO(5203): Remove this temporary exception.
284 AllowHandleAllocation allow_handles;
281 jump_bytecode = GetJumpWithConstantOperand(jump_bytecode); 285 jump_bytecode = GetJumpWithConstantOperand(jump_bytecode);
282 bytecodes()->at(jump_location) = Bytecodes::ToByte(jump_bytecode); 286 bytecodes()->at(jump_location) = Bytecodes::ToByte(jump_bytecode);
283 size_t entry = constant_array_builder()->CommitReservedEntry( 287 size_t entry = constant_array_builder()->CommitReservedEntry(
284 OperandSize::kShort, handle(Smi::FromInt(delta), isolate())); 288 OperandSize::kShort, handle(Smi::FromInt(delta), isolate()));
285 WriteUnalignedUInt16(operand_bytes, static_cast<uint16_t>(entry)); 289 WriteUnalignedUInt16(operand_bytes, static_cast<uint16_t>(entry));
286 } 290 }
287 DCHECK(bytecodes()->at(operand_location) == k8BitJumpPlaceholder && 291 DCHECK(bytecodes()->at(operand_location) == k8BitJumpPlaceholder &&
288 bytecodes()->at(operand_location + 1) == k8BitJumpPlaceholder); 292 bytecodes()->at(operand_location + 1) == k8BitJumpPlaceholder);
289 bytecodes()->at(operand_location++) = operand_bytes[0]; 293 bytecodes()->at(operand_location++) = operand_bytes[0];
290 bytecodes()->at(operand_location) = operand_bytes[1]; 294 bytecodes()->at(operand_location) = operand_bytes[1];
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 node->set_bytecode(node->bytecode(), k32BitJumpPlaceholder); 388 node->set_bytecode(node->bytecode(), k32BitJumpPlaceholder);
385 break; 389 break;
386 } 390 }
387 } 391 }
388 EmitBytecode(node); 392 EmitBytecode(node);
389 } 393 }
390 394
391 } // namespace interpreter 395 } // namespace interpreter
392 } // namespace internal 396 } // namespace internal
393 } // namespace v8 397 } // namespace v8
OLDNEW
« no previous file with comments | « src/globals.h ('k') | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698