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

Side by Side Diff: src/compiler/bytecode-graph-builder.cc

Issue 2008243002: [turbofan] The BytecodeGraphBuilder should never insert the empty frame state. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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/compiler/bytecode-graph-builder.h ('k') | no next file » | 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/compiler/bytecode-graph-builder.h" 5 #include "src/compiler/bytecode-graph-builder.h"
6 6
7 #include "src/compiler/bytecode-branch-analysis.h" 7 #include "src/compiler/bytecode-branch-analysis.h"
8 #include "src/compiler/linkage.h" 8 #include "src/compiler/linkage.h"
9 #include "src/compiler/operator-properties.h" 9 #include "src/compiler/operator-properties.h"
10 #include "src/interpreter/bytecodes.h" 10 #include "src/interpreter/bytecodes.h"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 348
349 // Connect to the loop end. 349 // Connect to the loop end.
350 Node* terminate = builder()->graph()->NewNode( 350 Node* terminate = builder()->graph()->NewNode(
351 builder()->common()->Terminate(), effect, control); 351 builder()->common()->Terminate(), effect, control);
352 builder()->exit_controls_.push_back(terminate); 352 builder()->exit_controls_.push_back(terminate);
353 } 353 }
354 354
355 355
356 bool BytecodeGraphBuilder::Environment::StateValuesRequireUpdate( 356 bool BytecodeGraphBuilder::Environment::StateValuesRequireUpdate(
357 Node** state_values, int offset, int count) { 357 Node** state_values, int offset, int count) {
358 if (!builder()->deoptimization_enabled_) {
359 return false;
360 }
361 if (*state_values == nullptr) { 358 if (*state_values == nullptr) {
362 return true; 359 return true;
363 } 360 }
364 DCHECK_EQ((*state_values)->InputCount(), count); 361 DCHECK_EQ((*state_values)->InputCount(), count);
365 DCHECK_LE(static_cast<size_t>(offset + count), values()->size()); 362 DCHECK_LE(static_cast<size_t>(offset + count), values()->size());
366 Node** env_values = (count == 0) ? nullptr : &values()->at(offset); 363 Node** env_values = (count == 0) ? nullptr : &values()->at(offset);
367 for (int i = 0; i < count; i++) { 364 for (int i = 0; i < count; i++) {
368 if ((*state_values)->InputAt(i) != env_values[i]) { 365 if ((*state_values)->InputAt(i) != env_values[i]) {
369 return true; 366 return true;
370 } 367 }
371 } 368 }
372 return false; 369 return false;
373 } 370 }
374 371
375 372
376 void BytecodeGraphBuilder::Environment::UpdateStateValues(Node** state_values, 373 void BytecodeGraphBuilder::Environment::UpdateStateValues(Node** state_values,
377 int offset, 374 int offset,
378 int count) { 375 int count) {
379 if (StateValuesRequireUpdate(state_values, offset, count)) { 376 if (StateValuesRequireUpdate(state_values, offset, count)) {
380 const Operator* op = common()->StateValues(count); 377 const Operator* op = common()->StateValues(count);
381 (*state_values) = graph()->NewNode(op, count, &values()->at(offset)); 378 (*state_values) = graph()->NewNode(op, count, &values()->at(offset));
382 } 379 }
383 } 380 }
384 381
385 382
386 Node* BytecodeGraphBuilder::Environment::Checkpoint( 383 Node* BytecodeGraphBuilder::Environment::Checkpoint(
387 BailoutId bailout_id, OutputFrameStateCombine combine) { 384 BailoutId bailout_id, OutputFrameStateCombine combine) {
388 if (!builder()->deoptimization_enabled_) {
389 return builder()->jsgraph()->EmptyFrameState();
390 }
391
392 // TODO(rmcilroy): Consider using StateValuesCache for some state values. 385 // TODO(rmcilroy): Consider using StateValuesCache for some state values.
393 UpdateStateValues(&parameters_state_values_, 0, parameter_count()); 386 UpdateStateValues(&parameters_state_values_, 0, parameter_count());
394 UpdateStateValues(&registers_state_values_, register_base(), 387 UpdateStateValues(&registers_state_values_, register_base(),
395 register_count()); 388 register_count());
396 UpdateStateValues(&accumulator_state_values_, accumulator_base(), 1); 389 UpdateStateValues(&accumulator_state_values_, accumulator_base(), 1);
397 390
398 const Operator* op = common()->FrameState( 391 const Operator* op = common()->FrameState(
399 bailout_id, combine, builder()->frame_state_function_info()); 392 bailout_id, combine, builder()->frame_state_function_info());
400 Node* result = graph()->NewNode( 393 Node* result = graph()->NewNode(
401 op, parameters_state_values_, registers_state_values_, 394 op, parameters_state_values_, registers_state_values_,
(...skipping 14 matching lines...) Expand all
416 return false; 409 return false;
417 } 410 }
418 } 411 }
419 } 412 }
420 return true; 413 return true;
421 } 414 }
422 415
423 416
424 bool BytecodeGraphBuilder::Environment::StateValuesAreUpToDate( 417 bool BytecodeGraphBuilder::Environment::StateValuesAreUpToDate(
425 int output_poke_offset, int output_poke_count) { 418 int output_poke_offset, int output_poke_count) {
426 if (!builder()->deoptimization_enabled_) return true;
427 // Poke offset is relative to the top of the stack (i.e., the accumulator). 419 // Poke offset is relative to the top of the stack (i.e., the accumulator).
428 int output_poke_start = accumulator_base() - output_poke_offset; 420 int output_poke_start = accumulator_base() - output_poke_offset;
429 int output_poke_end = output_poke_start + output_poke_count; 421 int output_poke_end = output_poke_start + output_poke_count;
430 return StateValuesAreUpToDate(&parameters_state_values_, 0, parameter_count(), 422 return StateValuesAreUpToDate(&parameters_state_values_, 0, parameter_count(),
431 output_poke_start, output_poke_end) && 423 output_poke_start, output_poke_end) &&
432 StateValuesAreUpToDate(&registers_state_values_, register_base(), 424 StateValuesAreUpToDate(&registers_state_values_, register_base(),
433 register_count(), output_poke_start, 425 register_count(), output_poke_start,
434 output_poke_end) && 426 output_poke_end) &&
435 StateValuesAreUpToDate(&accumulator_state_values_, accumulator_base(), 427 StateValuesAreUpToDate(&accumulator_state_values_, accumulator_base(),
436 1, output_poke_start, output_poke_end); 428 1, output_poke_start, output_poke_end);
437 } 429 }
438 430
439 BytecodeGraphBuilder::BytecodeGraphBuilder(Zone* local_zone, 431 BytecodeGraphBuilder::BytecodeGraphBuilder(Zone* local_zone,
440 CompilationInfo* info, 432 CompilationInfo* info,
441 JSGraph* jsgraph) 433 JSGraph* jsgraph)
442 : local_zone_(local_zone), 434 : local_zone_(local_zone),
443 jsgraph_(jsgraph), 435 jsgraph_(jsgraph),
444 bytecode_array_(handle(info->shared_info()->bytecode_array())), 436 bytecode_array_(handle(info->shared_info()->bytecode_array())),
445 exception_handler_table_( 437 exception_handler_table_(
446 handle(HandlerTable::cast(bytecode_array()->handler_table()))), 438 handle(HandlerTable::cast(bytecode_array()->handler_table()))),
447 feedback_vector_(handle(info->shared_info()->feedback_vector())), 439 feedback_vector_(handle(info->shared_info()->feedback_vector())),
448 frame_state_function_info_(common()->CreateFrameStateFunctionInfo( 440 frame_state_function_info_(common()->CreateFrameStateFunctionInfo(
449 FrameStateType::kInterpretedFunction, 441 FrameStateType::kInterpretedFunction,
450 bytecode_array()->parameter_count(), 442 bytecode_array()->parameter_count(),
451 bytecode_array()->register_count(), info->shared_info())), 443 bytecode_array()->register_count(), info->shared_info())),
452 deoptimization_enabled_(info->is_deoptimization_enabled()),
453 merge_environments_(local_zone), 444 merge_environments_(local_zone),
454 exception_handlers_(local_zone), 445 exception_handlers_(local_zone),
455 current_exception_handler_(0), 446 current_exception_handler_(0),
456 input_buffer_size_(0), 447 input_buffer_size_(0),
457 input_buffer_(nullptr), 448 input_buffer_(nullptr),
458 exit_controls_(local_zone) {} 449 exit_controls_(local_zone) {}
459 450
460 Node* BytecodeGraphBuilder::GetNewTarget() { 451 Node* BytecodeGraphBuilder::GetNewTarget() {
461 if (!new_target_.is_set()) { 452 if (!new_target_.is_set()) {
462 int params = bytecode_array()->parameter_count(); 453 int params = bytecode_array()->parameter_count();
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 // Phi does not exist yet, introduce one. 1684 // Phi does not exist yet, introduce one.
1694 value = NewPhi(inputs, value, control); 1685 value = NewPhi(inputs, value, control);
1695 value->ReplaceInput(inputs - 1, other); 1686 value->ReplaceInput(inputs - 1, other);
1696 } 1687 }
1697 return value; 1688 return value;
1698 } 1689 }
1699 1690
1700 } // namespace compiler 1691 } // namespace compiler
1701 } // namespace internal 1692 } // namespace internal
1702 } // namespace v8 1693 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698