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

Side by Side Diff: src/interpreter/bytecode-array-builder.h

Issue 1744123003: [debugger] fix break locations for assignments and return. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixes and addressed comments Created 4 years, 9 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/full-codegen/full-codegen.cc ('k') | src/interpreter/bytecode-array-builder.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 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ 5 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_
6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ 6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/interpreter/bytecode-register-allocator.h" 9 #include "src/interpreter/bytecode-register-allocator.h"
10 #include "src/interpreter/bytecodes.h" 10 #include "src/interpreter/bytecodes.h"
11 #include "src/interpreter/constant-array-builder.h" 11 #include "src/interpreter/constant-array-builder.h"
12 #include "src/interpreter/handler-table-builder.h" 12 #include "src/interpreter/handler-table-builder.h"
13 #include "src/interpreter/register-translator.h" 13 #include "src/interpreter/register-translator.h"
14 #include "src/interpreter/source-position-table.h" 14 #include "src/interpreter/source-position-table.h"
15 #include "src/zone-containers.h" 15 #include "src/zone-containers.h"
16 16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 19
20 class Isolate; 20 class Isolate;
21 21
22 namespace interpreter { 22 namespace interpreter {
23 23
24 class BytecodeLabel; 24 class BytecodeLabel;
25 class Register; 25 class Register;
26 26
27 class BytecodeArrayBuilder final : public ZoneObject, private RegisterMover { 27 class BytecodeArrayBuilder final : public ZoneObject, private RegisterMover {
28 public: 28 public:
29 BytecodeArrayBuilder(Isolate* isolate, Zone* zone, int parameter_count, 29 BytecodeArrayBuilder(Isolate* isolate, Zone* zone, int parameter_count,
30 int context_count, int locals_count); 30 int context_count, int locals_count,
31 FunctionLiteral* literal = nullptr);
31 ~BytecodeArrayBuilder(); 32 ~BytecodeArrayBuilder();
32 33
33 Handle<BytecodeArray> ToBytecodeArray(); 34 Handle<BytecodeArray> ToBytecodeArray();
34 35
35 // Get the number of parameters expected by function. 36 // Get the number of parameters expected by function.
36 int parameter_count() const { 37 int parameter_count() const {
37 DCHECK_GE(parameter_count_, 0); 38 DCHECK_GE(parameter_count_, 0);
38 return parameter_count_; 39 return parameter_count_;
39 } 40 }
40 41
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 251
251 // Exception handling. 252 // Exception handling.
252 BytecodeArrayBuilder& MarkHandler(int handler_id, bool will_catch); 253 BytecodeArrayBuilder& MarkHandler(int handler_id, bool will_catch);
253 BytecodeArrayBuilder& MarkTryBegin(int handler_id, Register context); 254 BytecodeArrayBuilder& MarkTryBegin(int handler_id, Register context);
254 BytecodeArrayBuilder& MarkTryEnd(int handler_id); 255 BytecodeArrayBuilder& MarkTryEnd(int handler_id);
255 256
256 // Creates a new handler table entry and returns a {hander_id} identifying the 257 // Creates a new handler table entry and returns a {hander_id} identifying the
257 // entry, so that it can be referenced by above exception handling support. 258 // entry, so that it can be referenced by above exception handling support.
258 int NewHandlerEntry() { return handler_table_builder()->NewHandlerEntry(); } 259 int NewHandlerEntry() { return handler_table_builder()->NewHandlerEntry(); }
259 260
261 void InitializeReturnPosition(FunctionLiteral* literal);
262
260 void SetStatementPosition(Statement* stmt); 263 void SetStatementPosition(Statement* stmt);
261 void SetExpressionPosition(Expression* expr); 264 void SetExpressionPosition(Expression* expr);
262 265
263 // Accessors 266 // Accessors
264 Zone* zone() const { return zone_; } 267 Zone* zone() const { return zone_; }
265 TemporaryRegisterAllocator* temporary_register_allocator() { 268 TemporaryRegisterAllocator* temporary_register_allocator() {
266 return &temporary_allocator_; 269 return &temporary_allocator_;
267 } 270 }
268 const TemporaryRegisterAllocator* temporary_register_allocator() const { 271 const TemporaryRegisterAllocator* temporary_register_allocator() const {
269 return &temporary_allocator_; 272 return &temporary_allocator_;
270 } 273 }
271 274
272 void EnsureReturn(FunctionLiteral* literal); 275 void EnsureReturn();
273 276
274 private: 277 private:
275 class PreviousBytecodeHelper; 278 class PreviousBytecodeHelper;
276 friend class BytecodeRegisterAllocator; 279 friend class BytecodeRegisterAllocator;
277 280
278 static Bytecode BytecodeForBinaryOperation(Token::Value op); 281 static Bytecode BytecodeForBinaryOperation(Token::Value op);
279 static Bytecode BytecodeForCountOperation(Token::Value op); 282 static Bytecode BytecodeForCountOperation(Token::Value op);
280 static Bytecode BytecodeForCompareOperation(Token::Value op); 283 static Bytecode BytecodeForCompareOperation(Token::Value op);
281 static Bytecode BytecodeForWideOperands(Bytecode bytecode); 284 static Bytecode BytecodeForWideOperands(Bytecode bytecode);
282 static Bytecode BytecodeForStoreIC(LanguageMode language_mode); 285 static Bytecode BytecodeForStoreIC(LanguageMode language_mode);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 void LeaveBasicBlock(); 330 void LeaveBasicBlock();
328 331
329 bool OperandIsValid(Bytecode bytecode, int operand_index, 332 bool OperandIsValid(Bytecode bytecode, int operand_index,
330 uint32_t operand_value) const; 333 uint32_t operand_value) const;
331 bool RegisterIsValid(Register reg, OperandType reg_type) const; 334 bool RegisterIsValid(Register reg, OperandType reg_type) const;
332 335
333 bool LastBytecodeInSameBlock() const; 336 bool LastBytecodeInSameBlock() const;
334 bool NeedToBooleanCast(); 337 bool NeedToBooleanCast();
335 bool IsRegisterInAccumulator(Register reg); 338 bool IsRegisterInAccumulator(Register reg);
336 339
337 // Set position for implicit return. 340 // Set position for return.
338 void SetReturnPosition(FunctionLiteral* fun); 341 void SetReturnPosition();
339 342
340 // Gets a constant pool entry for the |object|. 343 // Gets a constant pool entry for the |object|.
341 size_t GetConstantPoolEntry(Handle<Object> object); 344 size_t GetConstantPoolEntry(Handle<Object> object);
342 345
343 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } 346 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; }
344 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } 347 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; }
345 Isolate* isolate() const { return isolate_; } 348 Isolate* isolate() const { return isolate_; }
346 ConstantArrayBuilder* constant_array_builder() { 349 ConstantArrayBuilder* constant_array_builder() {
347 return &constant_array_builder_; 350 return &constant_array_builder_;
348 } 351 }
(...skipping 15 matching lines...) Expand all
364 ConstantArrayBuilder constant_array_builder_; 367 ConstantArrayBuilder constant_array_builder_;
365 HandlerTableBuilder handler_table_builder_; 368 HandlerTableBuilder handler_table_builder_;
366 SourcePositionTableBuilder source_position_table_builder_; 369 SourcePositionTableBuilder source_position_table_builder_;
367 size_t last_block_end_; 370 size_t last_block_end_;
368 size_t last_bytecode_start_; 371 size_t last_bytecode_start_;
369 bool exit_seen_in_block_; 372 bool exit_seen_in_block_;
370 int unbound_jumps_; 373 int unbound_jumps_;
371 int parameter_count_; 374 int parameter_count_;
372 int local_register_count_; 375 int local_register_count_;
373 int context_register_count_; 376 int context_register_count_;
377 int return_position_;
374 TemporaryRegisterAllocator temporary_allocator_; 378 TemporaryRegisterAllocator temporary_allocator_;
375 RegisterTranslator register_translator_; 379 RegisterTranslator register_translator_;
376 380
377 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); 381 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder);
378 }; 382 };
379 383
380 384
381 // A label representing a branch target in a bytecode array. When a 385 // A label representing a branch target in a bytecode array. When a
382 // label is bound, it represents a known position in the bytecode 386 // label is bound, it represents a known position in the bytecode
383 // array. For labels that are forward references there can be at most 387 // array. For labels that are forward references there can be at most
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 size_t offset_; 420 size_t offset_;
417 421
418 friend class BytecodeArrayBuilder; 422 friend class BytecodeArrayBuilder;
419 }; 423 };
420 424
421 } // namespace interpreter 425 } // namespace interpreter
422 } // namespace internal 426 } // namespace internal
423 } // namespace v8 427 } // namespace v8
424 428
425 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ 429 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_
OLDNEW
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | src/interpreter/bytecode-array-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698