Project

General

Profile

Actions

Bug #7463

closed

Correct processing of block structures and code in the root of pre, post and run methods

Added by Andrei Tatarnikov over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Urgent
Assignee:
Andrei Tatarnikov
Category:
-
Target version:
Start date:
08/12/2016
Due date:
% Done:

100%

Estimated time:
Detected in build:
svn
Platform:
Published in build:
2.3.46

Description

Currently, block sections and code placed outside of blocks (so-called external or global) are not handled correctly. The incorrect behavior includes unexpected exceptions, undesired split of code into parts processed separately, and wrong order of processing.

Here are basic requirements for the correct behavior:

  1. A block-like construct must not split global code into parts being processed separately, if the block is not run.
  2. If a block saved into a variable is run, global code before the point of call gets processed.
  3. Since it is not allowed to run blocks in the pre and post methods, program-level prologue and epilogue are always processed as a whole.

Here is in example with comments:

class BlockGlobalCodeTemplate < MiniMipsBaseTemplate
  def pre
    super

    # A: part of program prologue
    add s0, s0, s0

    # B: sequence block saved in an object-level variable
    @z = sequence {
      sub t1, t2, t3
      sub t3, t4, t5
    }

    # C: part of program prologue, must be processed with A as a whole
    sub s1, s2, s3

    # X: Prologue to be added to all test cases produced by block constructs
    prologue {
      pseudo '// Global prologue starts'
      pseudo '// Global prologue ends'
    }

    # Y: Epilogue to be added to all test cases produced by block constructs
    epilogue {
      pseudo '// Global epilogue starts'
      pseudo '// Global epilogue ends'
    }
  end

  def run
    # D: external code for linking test cases
    nop
    nop

    # E: sequence block saved in a local variable
    x = sequence {
      add t1, t2, t3
      add t3, t4, t5
    }

    # F: external code for linking test cases, must be processed as a whole with D
    nop
    nop

    # Processing: first - D and F as a whole, then - E.
    x.run

    # G: external code for linking test cases
    nop
    nop

    # H: sequence block saved in a local variable (is not processed) 
    y = sequence {
      add t1, t2, t3
      add t3, t4, t5
    }

    # I: external code for linking test cases, must be processed as a whole with G
    nop
    nop

    # Processing: first - G and I as a whole, then - B.
    @z.run
  end
end

The expected order of processing is the following:

  1. A and B as a whole
  2. D and F as a whole
  3. E (wrapped with X and Y)
  4. G and I as a whole
  5. B (wrapped with X and Y)

H is not processed (reported as a warning).

Actions #1

Updated by Andrei Tatarnikov over 8 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Done - r6952.

Note: global prologue and epilogue are added only to sequences produced by blocks defined after these prologue and epilogue.

Actions #2

Updated by Andrei Tatarnikov over 8 years ago

  • Status changed from Resolved to Closed
  • Published in build set to 2.3.46
Actions

Also available in: Atom PDF