OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_COMPILER_AST_GRAPH_BUILDER_H_ | 5 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_ |
6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ | 6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ |
7 | 7 |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 | 10 |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 int parameters_count() const { return parameters_count_; } | 341 int parameters_count() const { return parameters_count_; } |
342 int locals_count() const { return locals_count_; } | 342 int locals_count() const { return locals_count_; } |
343 int stack_height() { | 343 int stack_height() { |
344 return static_cast<int>(values()->size()) - parameters_count_ - | 344 return static_cast<int>(values()->size()) - parameters_count_ - |
345 locals_count_; | 345 locals_count_; |
346 } | 346 } |
347 | 347 |
348 // Operations on parameter or local variables. The parameter indices are | 348 // Operations on parameter or local variables. The parameter indices are |
349 // shifted by 1 (receiver is parameter index -1 but environment index 0). | 349 // shifted by 1 (receiver is parameter index -1 but environment index 0). |
350 void Bind(Variable* variable, Node* node) { | 350 void Bind(Variable* variable, Node* node) { |
351 DCHECK(variable->IsStackAllocated()); | 351 if (variable->is_this()) { |
352 if (variable->IsParameter()) { | 352 values()->at(0) = node; |
353 values()->at(variable->index() + 1) = node; | |
354 } else { | 353 } else { |
355 DCHECK(variable->IsStackLocal()); | 354 DCHECK(variable->IsStackAllocated()); |
356 values()->at(variable->index() + parameters_count_) = node; | 355 if (variable->IsParameter()) { |
| 356 values()->at(variable->index() + 1) = node; |
| 357 } else { |
| 358 DCHECK(variable->IsStackLocal()); |
| 359 values()->at(variable->index() + parameters_count_) = node; |
| 360 } |
357 } | 361 } |
358 } | 362 } |
359 Node* Lookup(Variable* variable) { | 363 Node* Lookup(Variable* variable) { |
360 DCHECK(variable->IsStackAllocated()); | 364 if (variable->is_this()) { |
361 if (variable->IsParameter()) { | 365 return values()->at(0); |
362 return values()->at(variable->index() + 1); | |
363 } else { | 366 } else { |
364 DCHECK(variable->IsStackLocal()); | 367 DCHECK(variable->IsStackAllocated()); |
365 return values()->at(variable->index() + parameters_count_); | 368 if (variable->IsParameter()) { |
| 369 return values()->at(variable->index() + 1); |
| 370 } else { |
| 371 DCHECK(variable->IsStackLocal()); |
| 372 return values()->at(variable->index() + parameters_count_); |
| 373 } |
366 } | 374 } |
367 } | 375 } |
368 | 376 |
369 Node* Context() const { return contexts_.back(); } | 377 Node* Context() const { return contexts_.back(); } |
370 void PushContext(Node* context) { contexts()->push_back(context); } | 378 void PushContext(Node* context) { contexts()->push_back(context); } |
371 void PopContext() { contexts()->pop_back(); } | 379 void PopContext() { contexts()->pop_back(); } |
372 | 380 |
373 // Operations on the operand stack. | 381 // Operations on the operand stack. |
374 void Push(Node* node) { | 382 void Push(Node* node) { |
375 values()->push_back(node); | 383 values()->push_back(node); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 483 |
476 // Prepare environment to be used as loop header. | 484 // Prepare environment to be used as loop header. |
477 void PrepareForLoop(BitVector* assigned, bool is_osr = false); | 485 void PrepareForLoop(BitVector* assigned, bool is_osr = false); |
478 }; | 486 }; |
479 | 487 |
480 } // namespace compiler | 488 } // namespace compiler |
481 } // namespace internal | 489 } // namespace internal |
482 } // namespace v8 | 490 } // namespace v8 |
483 | 491 |
484 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 492 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
OLD | NEW |