JP2013518352A - Method and apparatus for enhancing understanding of time complexity and flow in code - Google Patents

Method and apparatus for enhancing understanding of time complexity and flow in code Download PDF

Info

Publication number
JP2013518352A
JP2013518352A JP2012551300A JP2012551300A JP2013518352A JP 2013518352 A JP2013518352 A JP 2013518352A JP 2012551300 A JP2012551300 A JP 2012551300A JP 2012551300 A JP2012551300 A JP 2012551300A JP 2013518352 A JP2013518352 A JP 2013518352A
Authority
JP
Japan
Prior art keywords
branch
code
program
line
machine
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2012551300A
Other languages
Japanese (ja)
Other versions
JP5481571B2 (en
Inventor
ガイ,ナサニエル
ヒンクル,チャド
ジャウェド,マーク
レービン,スティーブ
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nintendo Co Ltd
Original Assignee
Nintendo Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nintendo Co Ltd filed Critical Nintendo Co Ltd
Publication of JP2013518352A publication Critical patent/JP2013518352A/en
Application granted granted Critical
Publication of JP5481571B2 publication Critical patent/JP5481571B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/75Structural analysis for program understanding

Abstract

矢印、字下げ、テキストの記号を用いるなどしてアセンブリコードおよび/またはマシンコードの書式を設定して、コードを読むプログラマによるプログラムのフローの理解を高める手法を利用した方法および装置。時間計算量の計算を見積もる異なった方法(例えばアップブランチ法および強連結部分グラフ法)には長所と短所があるが、併用することによる利点がある。  A method and apparatus that utilizes techniques for formatting assembly code and / or machine code using arrows, indentation, text symbols, etc., to improve programmers' understanding of program flow. There are advantages and disadvantages to different methods for estimating the calculation of time complexity (for example, the up-branch method and the strongly connected subgraph method), but there are advantages to using them together.

Description

(関連出願の相互参照)
本願は、2010年1月29日に出願された米国出願第61/299,477号の優先権を主張するものであり、その全内容は参照によって本明細書に組み込まれる。
(Cross-reference of related applications)
This application claims priority from US application 61 / 299,477, filed January 29, 2010, the entire contents of which are hereby incorporated by reference.

本明細書の技術は、コードにおける大まかな時間計算量を自動的に解析し、コンピュータのアセンブリコードおよび/またはマシンコードの書式を設定して、コードを読むユーザによる基礎的なフローの理解を高める方法および装置に関する。さらに詳細には、本明細書の技術は、矢印、字下げ、テキストの記号を用いるなどしてアセンブリコードおよび/またはマシンコードの書式を設定しグラフィカルに提示して、コードを読むプログラマによるプログラムのフローひいてはプログラムがどのように動作するかの理解を高める、視覚的手段を用いた手法に関する。   The techniques herein automatically analyze the rough time complexity in the code and format the computer assembly and / or machine code to improve the understanding of the basic flow by the user reading the code. It relates to a method and an apparatus. More particularly, the techniques herein can be used to format and present assembly code and / or machine code graphically using arrows, indentation, text symbols, etc. The present invention relates to a technique using visual means for improving understanding of the flow and how the program operates.

(背景技術および概要)
デジタルコンピュータが最初に発明された頃、プログラマはコンピュータのCPUが直接実行可能な2進数(1と0)または16進数(0〜F)でプログラムを書いていた。1960年代以降ずっと、多くのコンピュータのフロントパネルには、プログラマがコンピュータに2進数の命令を直接プログラムする際に使用できるスイッチが並んでいた。しかしながら、2進数でコードを書くのは大変な作業であり間違いも起こりやすかった。その結果、1950年代からプログラマはいわゆる「アセンブリ言語」で書き始めた。アセンブリ言語では2進数のマシンコード命令と人間が書いたアセンブリ言語命令とが1対1で対応していたが、機械語のオペレーションコード(オペコード)の代わりにニーモニック(覚えやすい短い記号列)が用いられ、マシンアドレスの代わりには記号が使用された。アセンブリ言語で書く場合でも、依然としてプログラマには自分がプログラムを書いている対象のハードウェアを深く理解する必要があったが、プログラマの作業は単純化され、間違いのもともなくなった。
(Background and overview)
When digital computers were first invented, programmers wrote programs in binary numbers (1 and 0) or hexadecimal numbers (0-F) that could be directly executed by the CPU of the computer. Since the 1960s, the front panel of many computers has been lined with switches that programmers can use to program binary instructions directly into the computer. However, writing code in binary numbers was a daunting task and error prone. As a result, programmers began to write in so-called "assembly language" from the 1950s. In assembly language, binary machine code instructions and human-written assembly language instructions have a one-to-one correspondence, but mnemonics (short memorized symbols) are used instead of machine language operation codes (opcodes). The symbol was used instead of the machine address. Even when writing in assembly language, programmers still needed a deep understanding of the hardware for which they were writing programs, but the programmer's work has been simplified and error free.

アセンブリコードはハードウェアの機能性と密接に絡み合っているため、優れたアセンブリ言語のプログラマであれば実行効率、信頼性、速度、プログラムの大きさを最適化できた。このことは、プログラマがリソースに制約のあるコンピューティングプラットフォームのパフォーマンスを余すところなく引き出したい場合に特に重要であった。   Because assembly code is intimately intertwined with hardware functionality, a good assembly language programmer could optimize execution efficiency, reliability, speed, and program size. This was especially important when programmers wanted to get the full performance of resource-constrained computing platforms.

半世紀余り経って、現代のコンピュータはプロセッサ速度、メモリの記憶容量、その他の性能特性の点で比較的膨大なリソースを有するようになっている。また、現在では様々な異なる種類のプロセッサや命令セットを有する膨大な数のコンピューティングプラットフォームが存在する。その結果、現代の大部分のコンピュータプログラムが主にJava、C++等の高水準言語で書かれている。このような高水準言語は、多数のコンピューティングプラットフォーム間での移植性や、特定のコンピューティングデバイスに対する人間のプログラマの細かい操作が不要であることなど、多くの利点を有する。典型的なコンピューティングプラットフォームは高水準言語を直接実行する。逆に、まず高水準命令がコンパイルまたは解釈されて、これらの命令を実行する特定のプロセッサが実行可能な、低水準の「マシンコード」を作成する。業界全体が、高水準言語から種々のプラットフォームにおけるマシンコードに最適な変換を行うコンパイラ、リンカ、その他のツールの開発を専門としているところもある。   Over half a century later, modern computers have a relatively large amount of resources in terms of processor speed, memory storage capacity, and other performance characteristics. There are also a vast number of computing platforms that currently have a variety of different types of processors and instruction sets. As a result, most modern computer programs are written primarily in high-level languages such as Java and C ++. Such high-level languages have many advantages, such as portability across multiple computing platforms and the absence of detailed human programmer manipulation of specific computing devices. A typical computing platform directly executes a high level language. Conversely, high-level instructions are first compiled or interpreted to create low-level “machine code” that can be executed by a particular processor executing those instructions. The entire industry specializes in developing compilers, linkers, and other tools that perform optimal conversions from high-level languages to machine code on various platforms.

一般的に言って、もしプログラマが今でもすべてのコードをアセンブラで書いていたら、今日我々が当然だと考える豊かなクロスプラットフォームのソフトウェアの機能性を提供することは非現実的または不可能であろう。実際、アセンブリを使いこなせる現代のプログラマは比較的珍しい。しかしながら、アセンブリ言語命令やマシンコード命令によって彼らの存在が今でも重要となる事例もある。   Generally speaking, if programmers are still writing all the code in assembler, it is impractical or impossible to provide the rich cross-platform software functionality that we take for granted today. Let's go. In fact, modern programmers who can master assembly are relatively rare. However, there are cases where their presence is still important by assembly language instructions and machine code instructions.

例えば、あるゲームをプログラムする際に極度の最適化が要求される状況がある。一例として、毎秒何百回、何千回と繰り返し実行されうるゲームプログラム内のプロセッサ集約型アルゴリズムにおける内側のループを、極限まで最適化することが必要な場合がある。現代の最適化コンパイラならばいかなる人間のプログラマよりも上手く最適化できるという意見がある一方、これには異論もあり、対象のハードウェアを十分に理解し、ある機能の遂行に必要な命令数を最小化することに創造力を傾けることができる人間に代わるものはないとも考える人々もいる。   For example, there are situations where extreme optimization is required when programming a game. As an example, it may be necessary to optimize the inner loop in a processor intensive algorithm in a game program that can be repeated hundreds or thousands of times per second. While there is an opinion that modern optimizing compilers can be optimized better than any human programmer, there is an objection to this that there is a good understanding of the target hardware and the number of instructions required to perform a certain function. Some think that there is no substitute for humans who can focus their creativity on minimization.

また、元々アセンブリで書かれた古いゲームコードを現在になって理解および/または変更しなければならないことがある。他に起こる興味深い状況としては、プログラマが特定のゲームのソースコードにアクセスできないにもかかわらず、ゲームコードの特定の箇所がどのように実行するかを理解しなければならないような場合がある。マシンコードを逆アセンブルしてニーモニックを用いたアセンブリ言語を得ることはできるが、このようなコードを理解することは、特に高水準言語で書くのに慣れているプログラマには困難となりうる。   Also, old game code originally written in assembly may now have to be understood and / or changed. Another interesting situation occurs when the programmer does not have access to the source code of a particular game, but must understand how a particular piece of game code executes. Although it is possible to disassemble machine code to obtain assembly language using mnemonics, understanding such code can be difficult, especially for programmers accustomed to writing in high-level languages.

通常、プログラマがマシンコードを直接扱うことはない。しかしながら、これらの命令を人の手でコーディングしたり、コンパイラで生成されたマシンコードを確認する必要が時として生じる。   Programmers usually do not deal directly with machine code. However, it is sometimes necessary to code these instructions manually or to check the machine code generated by the compiler.

よって、このような場合には、人間がより容易に理解できるようにマシンコードを視覚化できれば有益となる。本明細書に記載する技術は、協働してマシンコードを向上および変換させることにより、関数またはプログラムにおける制御のフローを人間がより容易に理解できるようにする特定の手法に向けられている。   Therefore, in such a case, it would be beneficial if the machine code could be visualized so that humans can more easily understand it. The techniques described herein are directed to a specific approach that enables humans to more easily understand the flow of control in a function or program by working together to improve and transform machine code.

どのようなコードを読む場合でも、プログラムのフローは全体的な理解をする上で非常に重要である。通常、フローはある機械命令から次の機械命令へと進む。しかしながら、条件分岐や無条件分岐は実行を条件付きまたは無条件で任意の命令へとスキップさせるため、フローが複雑になる。フローは、前に実行された命令に分岐することにより、命令のシーケンスが任意の回数実行される可能性のある「ループ」として知られる状態にもなりうる。   Regardless of what code you read, the flow of the program is very important for an overall understanding. Normally, the flow proceeds from one machine instruction to the next. However, conditional branches and unconditional branches cause execution to be skipped to any instruction with or without condition, and the flow becomes complicated. A flow can also be in a state known as a “loop” where a sequence of instructions can be executed any number of times by branching to previously executed instructions.

数学、計算機科学、および関連分野においては、ビッグO記法(ビッグオー記法、ランダウ記法、バッハマン・ランダウ記法、漸近記法としても知られる)によって、引数が特定の値または無限大に向かうときの関数の漸近挙動を、大抵はより簡単な関数に置き換えて記述する。ビッグO記法によって、ユーザは関数を単純化してこれらの増加率のみを扱うことができ、異なる関数でも増加率が同じであれば同じO記法で表すことも可能となる。この記法は純粋数学の一部として発展してきたが、現在では、アルゴリズムの解析にこれを用いてアルゴリズムによる計算リソースの使用状況を記述することがよくあり、アルゴリズムの最悪実行時間または平均実行時間、あるいはメモリ使用量をその入力の長さの関数としてビッグO記法を用いて表すことが多い。これによりアルゴリズム設計者は、コンピュータアーキテクチャやクロック速度とは関係のない方法でアルゴリズムの挙動を予測し、多数のアルゴリズムの中でどれを使用するかを判断できる。ビッグO記法は実行時間における乗法定数を切り捨て、入力サイズを小さくするような効率も無視するため、実際上の最速のアルゴリズムや実用的なサイズのデータセットに関する最速のアルゴリズムを必ずしも示すものではない。それでもこのアプローチは、入力サイズが大きくなる場合に種々のアルゴリズムのスケーラビリティを比較する上で依然として非常に有効である。ビッグO記法に置き換えて関数を記述した場合、大抵は関数の増加率における上界が得られるだけである。漸近的増加率における他の種類の有界性を記述するために、関連するいくつかの記法がo、Ω、ω、Θ等の記号を用いてビッグO記法に関連付けられる。また、ビッグO記法は多くの他の分野でも同様の推定を目的として用いられる。ウィキペディア「Big O Notation」を参照のこと。   In mathematics, computer science, and related fields, big O notation (also known as big-o notation, Landau notation, Bachman Landau notation, asymptotic notation), asymptotics of a function when an argument goes to a specific value or infinity Describe the behavior, usually replacing it with a simpler function. With the big O notation, the user can simplify the function and handle only these increasing rates, and even if different functions have the same increasing rate, they can be expressed in the same O notation. This notation has evolved as part of pure mathematics, but now it is often used for algorithm analysis to describe the usage of computational resources by the algorithm, and the worst or average execution time of the algorithm, Alternatively, memory usage is often expressed using big O notation as a function of its input length. This allows the algorithm designer to predict the behavior of the algorithm in a manner unrelated to the computer architecture and clock speed, and to determine which of the many algorithms to use. The Big O notation does not necessarily indicate the fastest practical algorithm or the fastest algorithm for a practically sized data set because it ignores the efficiency of truncating the multiplicative constant in execution time and reducing the input size. Nevertheless, this approach is still very effective in comparing the scalability of various algorithms as the input size increases. When a function is described by replacing it with the big O notation, the upper limit in the increase rate of the function is usually obtained. To describe other types of boundedness in asymptotic growth rates, several related notations are associated with the big O notation using symbols such as o, Ω, ω, Θ, and the like. The Big O notation is also used for the purpose of the same estimation in many other fields. See Wikipedia “Big O Notation”.

プログラムのフローおよび計算量を解析する別の手法も存在する。例示を目的とする非限定の手法の一例は、分岐状態を表す「字下げレベル」に基づくものである。一般的に言って、コンピュータプログラムにおける分岐状態やループ状態は、その分岐やループ内のコード部分を字下げして示すことが多い。したがって、ループ状態の4つのレベルは4レベルの字下げで示すことができる。例示を目的とする非限定の実施の一例は、このような文字配列の体裁を利用して、字下げレベルに基づいてプログラムの計算量を解析する。ある字下げレベルから他のレベルに移行することで計算量の変化を示すことができる。一般的に言って、字下げレベルが大きいほどプログラム構造はより複雑となる。このように、字下げレベルに基づく自動プログラム解析はプログラムの計算量の有用な尺度の一つとなりうる。   There are other methods for analyzing program flow and computational complexity. An example of a non-limiting approach for purposes of illustration is based on an “indentation level” that represents a branching state. Generally speaking, a branch state or a loop state in a computer program is often indicated by indenting a code portion in the branch or loop. Thus, the four levels of loop status can be indicated by four level indentation. An example of a non-limiting implementation for purposes of illustration uses such a character array appearance to analyze the computational complexity of the program based on the indentation level. Changing from one indentation level to another can show changes in computational complexity. Generally speaking, the greater the indentation level, the more complex the program structure. Thus, automatic program analysis based on the indentation level can be a useful measure of the computational complexity of the program.

例示を目的とする非限定の実施の一例では、前向き/下向きか後向き/上向きかいずれかの分岐矢印を自動的に生成し、これらを用いて、マシンコードが実行するプログラムのフローを視覚的に示す。こうして提示することで各マシンコード命令の分岐先が強調され、これにより、例えばプログラマ等のそれを読む人間がプログラムのフローをより容易かつ速やかに把握できる。   An example of a non-limiting implementation for illustrative purposes is to automatically generate a forward / downward or backward / upward branch arrow that can be used to visually represent the flow of the program executed by the machine code. Show. By presenting in this way, the branch destination of each machine code instruction is emphasized, so that a person who reads it, such as a programmer, can grasp the program flow more easily and quickly.

例示を目的とする非限定の実施の他の例では、種々のマシンコード命令行の字下げを自動的に生成し、これらを用いて、マシンコードが特定のマシンコード命令から他の命令に分岐してブロックへ自然に分割する様子を視覚的に示す。一部の実施では、分岐コマンドの分岐先にマシンコードの分岐命令において視覚的に注釈付けし、視覚的なマークを有するマシンコード命令に遭遇するまで字下げを継続する。   Another example of a non-limiting implementation for illustrative purposes is to automatically generate various machine code instruction line indentations that can be used to branch machine code from one machine code instruction to another. And visually show how it is divided naturally into blocks. In some implementations, the branch destination of the branch command is visually annotated in the machine code branch instruction, and indentation continues until a machine code instruction with a visual mark is encountered.

例示を目的とする非限定の実施のさらに他の例では、マシンコードのフローおよび計算量が、各マシンコードのブロックまたは各マシンコード命令に関連付けられた時間計算量を計算し、それに従ってマシンコードの種々のコンポーネントにマーク付けすることによって、自動的に解析され視覚的に注釈付けされる。   In yet another example of a non-limiting implementation for purposes of illustration, machine code flow and complexity calculates the time complexity associated with each block of machine code or each machine code instruction, and the machine code accordingly Are automatically analyzed and visually annotated by marking their various components.

プログラムの計算量を解析する別の方法は「強連結部分グラフ法」と称することができ、これを用いてプログラムアセンブリ命令の最悪のケースにおける大まかな時間計算量を検出できる。例示を目的とする非限定の実施の一例では、時間計算量はプログラムの構造的計算量とは異なる場合がある。このような手法はコードのフローと分岐命令の分岐先とに基づくことができ、時間計算量を入れ子のレベルに置き換えて検出してもよい。このような手法では、例えばコードのフローグラフを作成し、複数の強連結部分グラフを識別し、複数の強連結部分グラフの複数の集合を作成し、集合グラフを作成し、集合グラフにおける最長の経路を解析し、複数の集合をソートし、解釈、表示等のための時間計算量を割り当てる。   Another method for analyzing the computational complexity of a program can be referred to as a “strongly connected subgraph method”, which can be used to detect a rough temporal computational complexity in the worst case of a program assembly instruction. In one example of a non-limiting implementation for purposes of illustration, the time complexity may be different from the program's structural complexity. Such a technique can be based on the code flow and the branch destination of the branch instruction, and may be detected by replacing the time calculation amount with a nested level. In such a technique, for example, a code flow graph is created, multiple strongly connected subgraphs are identified, multiple sets of multiple strongly connected subgraphs are created, a set graph is created, and the longest in the set graph is created. Analyzes routes, sorts multiple sets, and allocates time complexity for interpretation, display, etc.

強連結部分グラフ法では、行単位の命令のシーケンスの内容を網羅的に調べ、閉路の様々な推移を識別する(各強連結部分グラフを表す)ことによって、プログラムの動的なフローの内容を調べる。このように入れ子のレベルを検出することにより、プログラムの実際の使用状況をその種々の部分から検出できる。   The strongly connected subgraph method comprehensively examines the contents of a sequence of instructions in units of lines, and identifies various transitions of cycles (representing each strongly connected subgraph), thereby enabling the contents of the dynamic flow of a program to be determined. Investigate. By detecting the nesting level in this way, the actual usage status of the program can be detected from its various parts.

時間計算量を計算する字下げレベルまたは「アップブランチ法」と、時間計算量を計算する強連結部分グラフ法とは相違点およびそれぞれの長所と短所を有する。例えばアップブランチ法では、アルゴリズムが行番号に基づいてグループ分けを行う性質上、実際にはコードの行が閉路の一部ではない可能性がある場合に、この行の時間計算量が誤って大きく判断されることがある。アップブランチ法は控えめなものであり、コードの最初か最後の行が複数の閉路間で共有される場合には閉路を含むとは認識せず、ある閉路が行番号に関して他の閉路と部分的に重複する場合にも閉路を含むとは認識しない。一方、強連結部分グラフ法は、ソースコードまたはアセンブリコードが実際には結果としてこの時間計算量とならない可能性がある場合でも、閉路を含むと積極的に認識する傾向がある。これは、例えば分岐を行うコードの各行の実際の計算が解析されないことによる。強連結部分グラフ法では、コードの行の時間計算量が誤って理論的に可能な時間計算量よりも小さく判断されることは決してないため、計算されるすべての時間計算量が最大値となる。   The indentation level or “up-branch method” for calculating the time complexity and the strongly connected subgraph method for calculating the time complexity have differences and respective advantages and disadvantages. For example, in the up-branch method, due to the nature of the algorithm grouping based on the line number, if the line of code may not actually be part of the cycle, the time complexity of this line will be increased by mistake. May be judged. The upbranch method is conservative and does not recognize that the first or last line of code is shared between multiple cycles, but does not recognize that it contains a cycle, and some cycles are partially compared to other cycles with respect to row numbers. It is not recognized that a cycle is included even if it overlaps with. On the other hand, the strongly connected subgraph method tends to positively recognize that the source code or the assembly code includes a cycle even if the result may not actually result in this amount of time calculation. This is because, for example, the actual calculation of each line of code that branches is not analyzed. In the strongly connected subgraph method, the time complexity of a line of code is never mistakenly determined to be less than the theoretically possible time complexity, so all the time complexity computed is the maximum. .

アップブランチ法による時間計算量アルゴリズムおよび強連結部分グラフ法による時間計算量アルゴリズムの長所と短所を踏まえて、これらを組み合わせた方策を採用できる。例えば、強連結部分グラフ法を用いて、理論的に可能な(例えばナイーブなコードのフローおよび分岐フローに基づいた)最悪時間計算量を決定してもよい。そして、コードの各行の最小時間計算量は、アップブランチと強連結部分グラフ法とのいずれかから選択して、時間計算量を控えめに推定しつつ、アップブランチ法に存在する実際よりも大きい誤った時間計算量を除外できる。   Based on the advantages and disadvantages of the time complexity algorithm based on the up-branch method and the time complexity algorithm based on the strongly connected subgraph method, it is possible to adopt a method combining these. For example, a strongly connected subgraph method may be used to determine the worst time complexity that is theoretically possible (eg, based on naive code flow and branch flow). And the minimum time complexity of each line of code is selected from either the upbranch or strongly connected subgraph method, and the time complexity is conservatively estimated, while the error is larger than the actual that exists in the upbranch method. Can eliminate the time complexity.

これらおよび他の特徴、効果は、例示を目的とする非限定の実施例の以下の詳細な説明を以下の内容の図面と照合して参照することにより、一層良く、一層十分理解されるであろう。   These and other features and advantages will be better and more fully understood by reference to the following detailed description of the non-limiting examples, given by way of illustration, in conjunction with the following drawings. Let's go.

図1は、非限定のコンピュータシステムの一例の内部構成を概略的に示す。FIG. 1 schematically illustrates the internal configuration of an example of a non-limiting computer system.

図2は、本発明によるコンピュータシステムの非限定の実施例を概略的に示す。FIG. 2 schematically shows a non-limiting embodiment of a computer system according to the invention.

図3は、例示を目的とする非限定のソフトウェアのフローチャートの一例を示す。FIG. 3 shows an example of a non-limiting software flowchart for illustrative purposes.

図4は、分岐先矢印を有するマシンコードのブロックの表現の非限定の実施例を概略的に示す。FIG. 4 schematically illustrates a non-limiting example of a representation of a block of machine code having a branching arrow.

図5は、字下げした分岐を有するマシンコードのブロックの表現の非限定の実施例を概略的に示す。FIG. 5 schematically shows a non-limiting example of a representation of a block of machine code with indented branches.

図6は、例示を目的とする非限定のソフトウェアのフローチャートの一例を示す。FIG. 6 shows an example of a non-limiting software flowchart for illustrative purposes.

図7は、時間計算量を区別するマークを有するマシンコードのブロックの表現の非限定の実施例を概略的に示す。FIG. 7 schematically illustrates a non-limiting example of a representation of a block of machine code having marks that distinguish time complexity.

図8は、例示を目的とする非限定のソフトウェアのフローチャートの一例を示す。FIG. 8 shows an example of a non-limiting software flowchart for illustrative purposes.

図9は、例示を目的とする非限定のソフトウェアのフローチャートの一例を示す。FIG. 9 shows an example of a non-limiting software flowchart for illustrative purposes.

図10は、例示を目的とする非限定のソフトウェアのフローチャートの一例を示す。FIG. 10 shows an example of a non-limiting software flowchart for illustrative purposes.

図11は、コードシーケンスとアップブランチ法を用いて得られたこのコードシーケンスの時間計算量との一例を示す。FIG. 11 shows an example of the code sequence and the time calculation amount of this code sequence obtained by using the up-branch method.

図12は、図11のコードシーケンスと強連結部分グラフ法を用いて得られたこのコードシーケンスの時間計算量とを示す。FIG. 12 shows the code sequence of FIG. 11 and the time complexity of this code sequence obtained using the strongly connected subgraph method.

図13は、図11のコードシーケンスとアップブランチ法および強連結部分グラフ法の組み合わせを用いて得られたこのコードシーケンスの時間計算量とを示す。FIG. 13 shows the time complexity of this code sequence obtained using the combination of the code sequence of FIG. 11 and the upbranch method and the strongly connected subgraph method.

本明細書に記載する手法は、コンピュータプラットフォーム、パーソナルコンピュータ、ネットワークサーバ、据置型または携帯型ビデオゲーム機、計算能力を有するその他のあらゆる種類の装置または構成を含む、あらゆる種類のコンピュータまたはゲームシステムにおいて実行可能である。以下に、例示を目的とする非限定の実施の一例を説明するが、その他の実施も可能である。   The techniques described herein can be used in any type of computer or gaming system, including computer platforms, personal computers, network servers, stationary or portable video game machines, and any other type of device or configuration that has computing power. It is feasible. An example of a non-limiting implementation for purposes of illustration is described below, but other implementations are possible.

図1は、本明細書に提示する本実施例が実装されたハードウェアプラットフォームの非限定の一例を示す。プラットフォーム100は、中央処理装置(CPU)101、ハードディスクドライブ(HDD)102等の不揮発性記憶装置またはフラッシュメモリデバイス、ランダムアクセスメモリ(RAM)103、グラフィックスプロセッサ104、入力装置インターフェイス105、通信インターフェイス106を含む。CPU101は、共通バス107を介して他の構成要素とやり取りしながらプラットフォームを制御する。RAM103は、CPU101が実行するオペレーティングシステムプログラムおよびアプリケーションプログラムの少なくとも一部を一時的に記憶する。記憶装置102は、ソフトウェアツールに加えて、(もしあれば)オペレーティングシステム(OS)およびアプリケーションプログラムも記憶する。図1では1つのコンピュータプラットフォームを示しているが、他の複数のコンピュータがネットワーク40に接続され、各コンピュータが本明細書に提示する本実施例で構成されてもよい。   FIG. 1 illustrates a non-limiting example of a hardware platform in which the present embodiment presented herein is implemented. The platform 100 includes a central processing unit (CPU) 101, a nonvolatile storage device such as a hard disk drive (HDD) 102 or a flash memory device, a random access memory (RAM) 103, a graphics processor 104, an input device interface 105, and a communication interface 106. including. The CPU 101 controls the platform while exchanging with other components via the common bus 107. The RAM 103 temporarily stores at least part of an operating system program and application programs executed by the CPU 101. In addition to software tools, the storage device 102 also stores an operating system (OS) and application programs (if any). Although one computer platform is shown in FIG. 1, a plurality of other computers may be connected to the network 40, and each computer may be configured in this embodiment as presented herein.

グラフィックスプロセッサ104は、CPU101からのコマンドに応じて映像を作成し画面10に表示する。入力装置インターフェイス105は、例えばキーボード20、マウス30、ゲームコントローラ32、34等の外部入力装置から信号を受け取る。これらの入力信号はバス107を介してCPU101に供給される。通信インターフェイス106によって、CPU101はネットワーク40上で他のコンピュータとデータ交換が可能になる。   The graphics processor 104 creates a video in response to a command from the CPU 101 and displays it on the screen 10. The input device interface 105 receives signals from external input devices such as a keyboard 20, a mouse 30, and game controllers 32 and 34. These input signals are supplied to the CPU 101 via the bus 107. The communication interface 106 allows the CPU 101 to exchange data with other computers over the network 40.

図2は、本明細書に提示する本実施例で構成される、プラットフォーム100で実行される処理機能を示すブロック図である。より具体的には、プラットフォーム100は、エディタ200、複数のソースファイル210、211、212等、コンパイラまたはアセンブラ201、複数のオブジェクトファイル221、222、223等、マシンコードエディタ202、複数の変更オブジェクトファイル231、232、233等、リンカ203、複数の実行ファイル241、242、243等、逆アセンブラ204、通信プロセッサ205等の演算要素を含む。   FIG. 2 is a block diagram illustrating processing functions performed on the platform 100 configured in the present embodiment presented in this specification. More specifically, the platform 100 includes an editor 200, a plurality of source files 210, 211, 212, etc., a compiler or assembler 201, a plurality of object files 221, 222, 223, etc., a machine code editor 202, and a plurality of changed object files. , 231, 232, etc., linker 203, plural execution files 241, 242, 243, etc., disassembler 204, communication processor 205, etc.

ソースファイル210、211、212は、プログラミング言語で書かれたソースコードの形式で処理を表す。オブジェクトファイル221、222、223は、コンピュータ100が直接実行可能な特定のマシンコードの形式で処理を表す。変更オブジェクトファイル231、232、233は、後述するように、ユーザがオブジェクトファイル221、222、223に対して行った変更を表す。実行ファイル241、242、243は、1つ以上の変更オブジェクトファイルを1つのファイルに結合することでそれぞれが作成された変更マシンコードファイルである。上記のファイルはすべて記憶装置102および/またはRAM103に記憶される。   Source files 210, 211, 212 represent processing in the form of source code written in a programming language. The object files 221, 222, and 223 represent processing in the form of specific machine code that can be directly executed by the computer 100. The changed object files 231, 232, and 233 represent changes made by the user to the object files 221, 222, and 223, as will be described later. The execution files 241, 242, and 243 are changed machine code files created by combining one or more changed object files into one file. All the above files are stored in the storage device 102 and / or the RAM 103.

逆アセンブラ204は、実行ファイル241、242、243をアセンブリ言語の「ソース」ファイル245、247、249に変換し、これらの「ソース」ファイルは一実施では、2進数(16進数)の機械命令とそれに1対1で対応するアセンブリ言語の「ソース」命令との両方を含んでおり、これらの「ソース」命令はオペコードのニーモニック、アドレスラベル、関数呼び出しラベルで構成される。   The disassembler 204 converts the executable files 241, 242, 243 into assembly language “source” files 245, 247, 249, which in one implementation are binary (hexadecimal) machine instructions and It includes both assembly language "source" instructions that correspond one-to-one, and these "source" instructions are composed of opcode mnemonics, address labels, and function call labels.

ユーザはエディタ200を用いてソースコードを書いたり編集したりできる。例えばプログラマ等のユーザは、例えばC++言語等の適切なプログラミング言語で命令のセットを入力する。そして、彼/彼女はエディタ200に保存コマンドを与え、エディタ200はその結果得られたソースファイルを記憶装置102に書きこむ。   The user can write or edit the source code using the editor 200. For example, a user such as a programmer enters a set of instructions in a suitable programming language such as C ++ language. Then, he / she gives a save command to the editor 200, and the editor 200 writes the resulting source file into the storage device 102.

コンパイラ201は、ソースファイルを受け取りマシンコードを生成する。これは記憶装置102にアクセスして、プログラマが書いたソースファイルを読み出し、ファイル内のソースコードの各行をパースし、ソースコードをコンピュータ100が理解可能なマシンコードに変換して行われる。この処理はコンパイルとして知られ、コンパイルの出力はオブジェクトコードと呼ばれる。コンパイラ201は、コンパイルされたオブジェクトコードをオブジェクトファイルとして記憶装置102に保存する。   The compiler 201 receives a source file and generates machine code. This is done by accessing the storage device 102, reading a source file written by the programmer, parsing each line of the source code in the file, and converting the source code into machine code understandable by the computer 100. This process is known as compilation, and the output of the compilation is called object code. The compiler 201 stores the compiled object code in the storage device 102 as an object file.

続いて、本明細書に提示する本実施例によれば、プログラマ等のユーザには、コンパイラ201が作成したマシンコードを確認し、場合によってはマシンコードや対応する高水準のソースコードの変更も行うという選択肢があり、これにより変更オブジェクトファイル231、232、233等のマシンコードの変更バージョンが、将来の確認、想定されるデバッグ、および/または想定される修正のためにより見やすく提示されることになる。本明細書に提示するこれらの変更手法は、コンパイラから出力されるマシンコードをユーザがその計算量だけでなくそのフローに関してもより良く理解することを助け、さらに、最適化コンパイラ201がソースコードをどのようにコンパイルするかをユーザが理解することも助ける。   Subsequently, according to this embodiment presented in this specification, a user such as a programmer confirms the machine code created by the compiler 201, and in some cases, the machine code and corresponding high-level source code can be changed. There is an option to do so that a modified version of the machine code, such as the modified object files 231, 232, 233, etc. will be presented in a more readable manner for future review, possible debugging, and / or possible modification. Become. These modification techniques presented herein help the user to better understand the machine code output from the compiler not only in terms of its computational complexity, but also in terms of its flow. It also helps the user understand how to compile.

リンカ203は、記憶装置102にアクセスし、ユーザが作成した1つ以上の変更オブジェクトコードファイルを読み出す。そして、リンカ203は、これらの変更オブジェクトコードファイルを単一のロードモジュールへ結合しながら、いくつかの部分を編集して解決済みの絶対アドレスおよび相対アドレスとともに命令の一貫したセットとして整理する。この処理はリンクとして知られる。リンカ203は、これらの実行ファイル241、242、243を記憶装置102に保存する。   The linker 203 accesses the storage device 102 and reads one or more changed object code files created by the user. Linker 203 then edits some parts to combine these modified object code files into a single load module and organizes them into a consistent set of instructions with resolved absolute and relative addresses. This process is known as linking. The linker 203 stores these execution files 241, 242, and 243 in the storage device 102.

通信プロセッサ205は、ネットワーク40内の他のコンピュータに加えて、ソースファイル、オブジェクトファイル、変更オブジェクトファイル、実行ファイル、アセンブリ言語ファイルのいずれとも通信している。   The communication processor 205 communicates with any of a source file, an object file, a modified object file, an execution file, and an assembly language file in addition to other computers in the network 40.

上記のように、マシンコードはコンピュータの中央処理装置(CPU)が直接実行する命令のセットである。一般に、マシンコードはほとんどの人々にとっては読んで理解するのが非常に困難である。これらのコンピュータの命令は、コンパイルされたコンピュータプログラムおよび/またはアセンブリコンピュータプログラムが最低水準で表現されたものと考えてもよく、CPUの実行対象と1対1で対応してもよい。各プロセッサファミリには固有のマシンコードの命令セットがある。これらの命令はマシンに対する異なるコマンドと対応している。   As described above, a machine code is a set of instructions that are executed directly by a central processing unit (CPU) of a computer. In general, machine code is very difficult for most people to read and understand. These computer instructions may be thought of as the lowest level representation of a compiled computer program and / or assembly computer program, and may correspond one-to-one with the CPU execution target. Each processor family has its own set of machine code instructions. These instructions correspond to different commands for the machine.

マシンコードの命令セットは、すべての命令の長さが同じであってもよく、また命令の長さが可変であってもよい。大部分の命令は1つ以上のフィールドを有し、これらによって実際の演算(例えば加算または比較)、アドレッシングモード、アドレス指定オフセット、または実際の値そのものに加えて、基本的な命令の種類(例えば算術、論理、ジャンプ等)も特定される。   In the machine code instruction set, the length of all instructions may be the same, or the length of the instructions may be variable. Most instructions have one or more fields that allow basic instruction types (e.g., in addition to actual operations (e.g., addition or comparison), addressing modes, addressing offsets, or actual values themselves). Arithmetic, logic, jumps, etc.) are also specified.

図3は、本明細書に提示する本実施例による、マシンコードを変更して人間による理解を高める方法の、例示を目的とする非限定のソフトウェアのフローチャートの一例を示す。まずステップS1において、コンピュータ100は、ユーザが書いて入力した、例えばC言語のソースコードを受け取る。続いてステップS2において、コンピュータ100のコンパイラ201は、受け取ったソースコードをマシンコードにコンパイルする(あるいはコンパイラ201は、中間のアセンブリ言語コードを作成し、その後これを図示しないアセンブラがマシンコードに変換してもよい)。ユーザはマシンコードを受け取り(ステップS3)、それを調べ、後述する手法の1つを用いてそのプログラムを適宜変更する(ステップS4)。そして、コンピュータ100は、変更されたコードを受け取り、リンカ203を介して実行ファイルを生成し(ステップS5)、ステップS6において、これが出力コードとして出力される。   FIG. 3 illustrates an example non-limiting software flowchart for purposes of illustration of a method for modifying machine code to enhance human understanding according to the present example presented herein. First, in step S1, the computer 100 receives, for example, C language source code written and input by the user. Subsequently, in step S2, the compiler 201 of the computer 100 compiles the received source code into machine code (or the compiler 201 creates intermediate assembly language code, which is then converted into machine code by an assembler (not shown). May be) The user receives the machine code (step S3), examines it, and changes the program as appropriate using one of the methods described below (step S4). The computer 100 receives the changed code, generates an execution file via the linker 203 (step S5), and outputs it as an output code in step S6.

一実施例によれば、命令フローの理解を結果的に要するコードの見直しや変更は、以下の3つの主な方法で支援される。   According to one embodiment, code review and changes that result in an understanding of the instruction flow are supported in three main ways:

(マシンコードにおける矢印注釈付き分岐)
マシンコードの分岐命令は、大抵は分岐先のオフセットまたはアドレスを特定するだけである。分岐先の追跡はとりわけ精神的な労力を要するため、分岐から分岐先の命令まで矢印を描くことでマシンコードを単純化してもよい。一部の分岐が前の機械命令に関連付けられ、一部が後続の機械命令に関連付けられることを考慮すると、これらの矢印は規則的に整理できる。
(Branch with arrow annotation in machine code)
Machine code branch instructions usually only specify the offset or address of the branch destination. Since tracking the branch destination requires particularly mental effort, the machine code may be simplified by drawing an arrow from the branch to the branch destination instruction. Considering that some branches are associated with previous machine instructions and some are associated with subsequent machine instructions, these arrows can be organized regularly.

一実施例では、前向き/下向きの分岐矢印はすべてコードの左側に現れ、後向き/上向きの分岐矢印はすべてコードの右に現れる。こうして提示することで、矢印は図4に示すように反時計回りの規則的なフローを有する。例えば図4で分かるように、コードの左側には4本の前向き/下向きの分岐矢印が存在し、コードの右側には2本の後向き/上向きの分岐矢印が存在する。   In one embodiment, all forward / downward branch arrows appear on the left side of the code and all backward / upward branch arrows appear on the right side of the code. By presenting in this way, the arrow has a regular counterclockwise flow as shown in FIG. For example, as can be seen in FIG. 4, there are four forward / downward branch arrows on the left side of the code, and two backward / upward branch arrows on the right side of the code.

また、分岐先が同一の矢印同士を縦方向の進行で合体させて、混雑や矢印の数を減らしてもよい。例えば、これらの矢印は共通の縦方向セクションを有するように描かれてもよい。   Further, arrows having the same branch destination may be merged in the vertical direction to reduce the number of congestions and arrows. For example, these arrows may be drawn to have a common longitudinal section.

規則的なコードの提示を保つためには、分岐先が近い分岐を分岐先が遠い矢印よりもコードの近くに配置するべきである。例えば図4で分かるように、コードの左側において、分岐先が「cmplw r9, r5」の分岐は分岐先が「cmplw r8, r4」の分岐よりも長いため、後者の分岐がコードにより近く描かれている。   In order to maintain regular code presentation, the branch that is closer to the branch should be placed closer to the code than the arrow that is farther away. For example, as can be seen in FIG. 4, on the left side of the code, the branch whose branch destination is “cmplw r9, r5” is longer than the branch whose branch destination is “cmplw r8, r4”, so the latter branch is drawn closer to the code. ing.

本実施例では、コード内の他の関数に戻ったり結合したりする分岐は、単一の横方向の矢印または両矢印で表されるのが最も望ましい。例えば、コード内の他の関数に結合する分岐は、命令の右に向かう単一の横方向の両矢印で表され、戻り分岐は、命令の右に向かう単一の横方向の右向き矢印で表される(図4のコードの最後の命令行の右に向かう矢印を参照)。   In this embodiment, the branch back to and from other functions in the code is most preferably represented by a single horizontal arrow or double arrow. For example, a branch that connects to other functions in the code is represented by a single horizontal double arrow pointing to the right of the instruction, and a return branch is represented by a single horizontal right arrow pointing to the right of the instruction. (See the arrow pointing to the right of the last instruction line in the code of FIG. 4).

(マシンコードにおける字下げ注釈付き分岐)
典型的には、マシンコードは字下げを含まない(しかし、高水準言語は字下げを含むことが多い)。言い換えれば、すべての命令行が縦方向に揃っている。この書式では、プログラムのフローを追跡する際に視覚的な洞察ができない。よって、外見的に理解するために、コードの論理ブロックに基づいてこれを可能にすることが望ましい。好ましい実施例では、すべての機械命令が順次反復される。
(Branch with indentation annotation in machine code)
Typically, machine code does not include indentation (but high-level languages often include indentation). In other words, all command lines are aligned vertically. This format does not provide visual insight when tracking program flow. It is therefore desirable to make this possible based on the logical block of code for an apparent understanding. In the preferred embodiment, all machine instructions are repeated sequentially.

一実施例では、関数内の下向きの分岐に遭遇すると、その分岐先に字下げフリーズシンボルでマーク付けする(なお、この行はさらに字下げするべきではない)。例えば図5で分かるように、3番目の行で関数内の下向きの分岐に遭遇し、分岐先である行28に「*」等の字下げフリーズシンボルでマーク付けする。同様に、下向きの分岐の分岐先に対応する行15、17、25にもそれぞれ字下げフリーズシンボルでマーク付けする。   In one embodiment, when a downward branch in a function is encountered, the branch destination is marked with an indentation freeze symbol (note that this line should not be further indented). For example, as can be seen in FIG. 5, a downward branch in the function is encountered on the third line, and the branch destination line 28 is marked with an indentation freeze symbol such as “*”. Similarly, the lines 15, 17 and 25 corresponding to the branch destinations of the downward branch are also marked with indentation freeze symbols.

本実施例では、関数内の上向きまたは下向きの分岐に遭遇すると、字下げフリーズシンボルに遭遇するか関数の終わりに到達するまですべての後続の行が字下げされる。そして、分岐に続く行で処理が再開される。例えば図5のコード表現の場合、行2で分岐に遭遇するため、後続の行3は字下げされ、以降の各行が、行28で字下げフリーズシンボルに遭遇するまで字下げされる。この字下げの効果により、分岐命令に続くコードの重要性が強調される。   In this example, when an upward or downward branch in a function is encountered, all subsequent lines are indented until an indentation freeze symbol is encountered or the end of the function is reached. Then, the process is resumed at the line following the branch. For example, in the code representation of FIG. 5, because a branch is encountered at line 2, subsequent line 3 is indented, and each subsequent line is indented until an indentation freeze symbol is encountered at line 28. This indentation emphasizes the importance of the code following the branch instruction.

図6は、字下げアルゴリズムの一例を示すものであり、これに従って、各機械命令の字下げレベルをそれが分岐命令の分岐先でない限りタブ1つインクリメントする。   FIG. 6 shows an example of an indentation algorithm, and according to this, the indentation level of each machine instruction is incremented by one tab unless it is a branch destination of a branch instruction.

まず、すべての機械命令を字下げレベルがゼロとなるように初期化する(ステップS10)。続いてアルゴリズムはコード内のすべての機械命令のリストを最初から最後までたどる。例えば図5に示すコードの場合、アルゴリズムは最初の「li r10,0」から最後の「blr」まですべての機械命令を検討する。次にアルゴリズムは、分岐機械命令に遭遇したか否かを判定する(ステップS12)。答えが否定の場合、アルゴリズムは戻り、機械命令のリストをたどり続ける。一方、答えが肯定の場合、アルゴリズムは、遭遇した分岐が下向きの分岐であるか否かを判定する(ステップS14)。判定に対する答えが否定の場合、アルゴリズムはステップS15A(後述する)へ進む。答えが肯定の場合、アルゴリズムは検討中の機械命令において、分岐の分岐先にフリーズトークンでマーク付けし(ステップS15)、次のステップへ進む。   First, all machine instructions are initialized so that the indentation level becomes zero (step S10). The algorithm then follows a list of all machine instructions in the code from start to finish. For example, in the code shown in FIG. 5, the algorithm considers all machine instructions from the first “line 10,0” to the last “blr”. Next, the algorithm determines whether a branch machine instruction has been encountered (step S12). If the answer is negative, the algorithm returns and continues to follow the list of machine instructions. On the other hand, if the answer is affirmative, the algorithm determines whether the encountered branch is a downward branch (step S14). If the answer to the determination is negative, the algorithm proceeds to step S15A (described later). If the answer is affirmative, the algorithm marks the branch destination of the branch with a freeze token in the machine instruction under consideration (step S15) and proceeds to the next step.

下向きの分岐の分岐先を指定する機械命令においてフリーズトークンでマーク付けした後、ステップS15Aにおいて、アルゴリズムは各行の字下げレベルをインクリメントしながら後続の一連の機械命令をたどる。各機械命令を終えるごとに、アルゴリズムは、フリーズトークンに遭遇したか否かを判定する(ステップS17)。答えが否定の場合、アルゴリズムはステップS16へ進む。一方、答えが肯定の場合、アルゴリズムはその機械命令行の字下げレベルをインクリメントせず、ステップS12へ戻る(現在の行番号が最後の行番号ではないものとして、ステップS12A、S12B参照)。最後にアルゴリズムは、機械命令がすべての機械命令のリストの最後であるか否かを判定する(ステップS12A)。そうであればアルゴリズムは終了し(ステップS20)、そうでなければ、現在の行番号をインクリメントした後にステップS12に戻る。   After marking with a freeze token in a machine instruction that specifies the branch destination of a downward branch, in step S15A, the algorithm follows a series of subsequent machine instructions while incrementing the indentation level of each line. As each machine instruction ends, the algorithm determines whether a freeze token has been encountered (step S17). If the answer is no, the algorithm proceeds to step S16. On the other hand, if the answer is affirmative, the algorithm does not increment the indentation level of the machine instruction line and returns to step S12 (assuming that the current line number is not the last line number, see steps S12A and S12B). Finally, the algorithm determines whether the machine instruction is the last in the list of all machine instructions (step S12A). If so, the algorithm ends (step S20). If not, the current line number is incremented and the process returns to step S12.

図6の字下げアルゴリズムの適用例が図5に示される。下向きの分岐に遭遇する最初の命令行は3番目の行である。したがって、その行が分岐する分岐先にフリーズトークンを用いてマーク付けし、そして、次の行(行3)はタブ1つ字下げされ、各後続の行は、行28にフリーズトークンがあることから行28まで字下げされる。行4に続く後続の行5〜11は字下げされ、この処理は最後の行「blr」(命令の右に向かう単一の横方向の右向き矢印で表される戻り分岐)に到達するまで継続する。他の実施例では、フリーズシンボルの配置や字下げを行う場合には無条件分岐のみを検討する。これにより、外観が若干異なる/より分かりやすくなる。   An application example of the indentation algorithm of FIG. 6 is shown in FIG. The first instruction line that encounters a downward branch is the third line. Therefore, the branch destination of that line is marked with a freeze token, and the next line (line 3) is indented by one tab, and each subsequent line has a freeze token at line 28 To inline 28. Subsequent lines 5-11 following line 4 are indented and the process continues until the last line "blr" (return branch represented by a single horizontal right arrow pointing to the right of the instruction) is reached. To do. In other embodiments, only unconditional branching is considered when placing freeze symbols or indenting. This makes the appearance slightly different / more understandable.

(マシンコードにおけるアップブランチ法を用いた時間計算量注釈付きブロック)
他の実施例では、マシンコードの各行に、分岐の結果生じる時間計算量の推定を表す視覚的指標でマーク付けできる。これは、分岐の結果としての重要な特徴とプログラムのフローとを視覚的に判別するさらに他の方法である。典型的なマシンコードでは、コード内に多数のループが設けられていると、プログラマは行や複数の行によるブロックの計算量を速やかに読んで理解することができない。
(Block with time complexity annotation using upbranch method in machine code)
In other embodiments, each line of machine code can be marked with a visual indicator that represents an estimate of the time complexity resulting from the branch. This is yet another way of visually distinguishing important features and program flow as a result of branching. In typical machine code, if there are a large number of loops in the code, the programmer cannot quickly read and understand the computational complexity of the line or block of lines.

例えば、いかなるループも含まないコードは実行時間が一定であると判断され、典型的にはビッグO記法でO(1)として表される。一方、単一のループで構成されるコードは時間計算量がオーダーnまたはO(n)であると判断され、このときnはループの実行が可能な任意の回数である。さらに、コードのループが他のコードのループ内に存在する場合、つまりコードが入れ子のループを有する場合、内側のコードのループは時間計算量がオーダーnまたはO(n)であると判断される。このとき、外側のループはn回実行可能であり、内側のループは外側のループ1周につきn回実行可能であるため、結果として内側のループは合計n×n回反復される。同様に、コードのループ内のコードのループ内のコードのループから成る三重のループでは、最も内側のループの時間計算量がオーダーnまたはO(n)となる。 For example, code that does not contain any loops is determined to have a constant execution time and is typically represented as O (1) in big O notation. On the other hand, a code composed of a single loop is determined to have a time calculation amount of order n or O (n), where n is an arbitrary number of times the loop can be executed. Further, if a code loop exists within another code loop, that is, if the code has a nested loop, the inner code loop determines that the time complexity is of order n 2 or O (n 2 ). Is done. At this time, the outer loop can be executed n times and the inner loop can be executed n times per outer loop, so that the inner loop is repeated a total of n × n times. Similarly, in a triple loop consisting of a code loop within a code loop within a code loop, the time complexity of the innermost loop is of the order n 3 or O (n 3 ).

例えば図7に示すように、3番目の行と最後から2番目の行との間の命令行から成るブロックは単一のループで構成されるため、O(n)で表される。一方、行4と行26との間の行から成るブロックは他のループ内のループで構成されるため、O(n)で表される。 For example, as shown in FIG. 7, a block composed of an instruction line between the third line and the penultimate line is composed of a single loop, and is represented by O (n). On the other hand, a block composed of rows between row 4 and row 26 is composed of loops in other loops, and is represented by O (n 2 ).

コードの各行の時間計算量を知らせることは、そのコードの構造およびフローを理解するのに役立つため、重要な時間計算量のセクションにはそれぞれ強調表示の色やその他の視覚的表示で視覚的にマーク付けしてもよい。この手法の一実施例としては、図7に示すように、例えば時間計算量がO(1)のコードのセクションは白で、時間計算量がO(n)のコードのセクションは黄で、時間計算量がO(n)のコードのセクションはオレンジ色でそれぞれ色をつける(一般に特許はカラー印刷されないため、これらの異なる色を陰影で表現している)。他の実施例としては、時間計算量が悪化するコードには特定の色の単色グラデーションで色をつける。 Informing the time complexity of each line of code helps to understand the structure and flow of the code, so each important time complexity section is visually highlighted with a highlighted color or other visual indication. It may be marked. As an example of this technique, as shown in FIG. 7, for example, the section of the code with the time complexity O (1) is white, the section of the code with the time complexity O (n) is yellow, and the time The sections of the code with O (n 2 ) complexity are orange and colored (generally patents are not color printed, so these different colors are represented by shading). As another embodiment, a code whose time calculation amount is deteriorated is colored with a single color gradation of a specific color.

例えば図7に示すように、計算量がレベルO(n)のセクションは、例えば黄色(薄い陰影)で表現され、計算量がレベルO(n)のセクションは、例えばオレンジ色(中間の陰影)で表現される。 For example, as shown in FIG. 7, a section whose calculation amount is level O (n) is expressed in yellow (light shading), for example, and a section whose calculation amount is level O (n 2 ) is orange (intermediate shading), for example. ).

マシンコード命令の各ブロック全体の時間計算量を指定するだけでなく、一実施例では、個別のマシンコード命令の時間計算量も指定する。   In addition to specifying the time complexity of each entire block of machine code instructions, in one embodiment, the time complexity of individual machine code instructions is also specified.

マシンコードにおいてループは、前のマシンコード命令へ条件付きまたは無条件で分岐するマシンコード命令で決定できる。このループは、マシンコード分岐の分岐先とこのマシンコード分岐自体との間で表されるすべてのマシンコード命令のセットである。あるマシンコード命令の時間計算量は、ループが他のループ内に存在するには完全に含まれていなければならないという要件で、このマシンコード命令が内部に存在するループの最大数で決定できる。マシンコード命令がいかなるループの中にも存在しない場合、時間計算量はO(1)である。マシンコード命令が1つだけのループ内に存在する場合、時間計算量はO(n)である。マシンコード命令が2つのループ(ループ内のループ)内に存在する場合、時間計算量はO(n)である。マシンコード命令が3つのループ(ループ内のループ内のループ)内に存在する場合、時間計算量はO(n)である。マシンコード命令の時間計算量のこの定義は一定のパターンに従って無限に続く。 In machine code, a loop can be determined by a machine code instruction that branches conditionally or unconditionally to the previous machine code instruction. This loop is a set of all machine code instructions represented between the branch destination of the machine code branch and the machine code branch itself. The time complexity of a machine code instruction can be determined by the maximum number of loops in which this machine code instruction resides, with the requirement that the loop must be fully contained in order to exist in another loop. If the machine code instruction is not in any loop, the time complexity is O (1). If the machine code instruction exists in only one loop, the time complexity is O (n). If the machine code instruction exists in two loops (loops within a loop), the time complexity is O (n 2 ). If machine code instructions are present in three loops (loops within a loop), the time complexity is O (n 3 ). This definition of the time complexity of machine code instructions continues indefinitely according to a certain pattern.

本明細書に提示する非限定のアップブランチ法の一例は、コードが書かれたインラインの順序に基づいて時間計算量を推定するヒューリスティックな手法を提供する。人間のプログラマは入れ子を反映した順序でコードを書くことが多い。例えば、コードの一部分がエントリーポイントを含み、その後に多数のインオーダー命令が続き、その後にループが続いてエントリーポイントへ戻っている場合、この人間のプログラマがインオーダー命令をループの一部となるように意図したことが推測できる。この前提が必ず正しいとは限らないが、コードの他の部分からごくわずかにアクセスされるか、あるいは決してアクセスされない命令やコードの断片がコードのブロック内に存在することもあり、結果的にこれらはループの一部ではない。それにもかかわらず、プログラマがループ内の命令を定義するコードを書く際には、そのような命令もこのループの実行回数と同じだけ実行される可能性が高いため、本質的にはこのループに属している。このようにアップブランチ法は、ループに属する命令を、これらの命令をプログラマが書いたときの順序に基づいて推測するのに有用となりうるヒューリスティック解析を提供する。さらに、多くの場合、同じコードに対して異なるヒューリスティックな手法を実行して、アップブランチ法による時間計算量が正確でない状況を検出することで、アップブランチ法の精度を確認できる。   An example of a non-limiting upbranch method presented herein provides a heuristic approach to estimating time complexity based on the inline order in which the code is written. Human programmers often write code in an order that reflects nesting. For example, if a piece of code contains an entry point, followed by a number of in-order instructions, followed by a loop and returning to the entry point, this human programmer makes the in-order instruction part of the loop I can guess what I intended. This assumption is not always true, but there may be instructions or code fragments in the block of code that are accessed only slightly from other parts of the code or never accessed. Is not part of the loop. Nevertheless, when a programmer writes code that defines instructions in a loop, it is likely that such instructions will be executed as many times as the loop executes, so essentially this loop belong to. Thus, the up-branch method provides a heuristic analysis that can be useful for inferring instructions belonging to a loop based on the order in which the programmer wrote these instructions. Furthermore, in many cases, the accuracy of the upbranch method can be confirmed by executing a different heuristic method on the same code and detecting a situation in which the time calculation amount by the upbranch method is not accurate.

図8は、非限定のアルゴリズムの一例を示すものであり、これに従って、関数内のあるマシンコード命令の時間計算量が決定される(アップブランチ法と呼ぶ)。以下、種々の計算量レベルを、ゼロ=O(1)、1=O(n)、2=O(n)、3=O(n)等で表す。 FIG. 8 shows an example of a non-limiting algorithm, and the time calculation amount of a certain machine code instruction in the function is determined according to this (referred to as an up-branch method). Hereinafter, various calculation amount levels are represented by zero = O (1), 1 = O (n), 2 = O (n 2 ), 3 = O (n 3 ), and the like.

まずステップS30において、アルゴリズムはすべてのマシンコード命令を時間計算量がゼロとなるように初期化する。次に、前の命令に分岐するすべての条件分岐または無条件分岐のリストを構築し(ステップS31)、続いて、すべての上向きの分岐のリストを、スキップするマシンコード命令の数が小さい方から大きい方へソートする(ステップS32)。そして、アルゴリズムはすべての上向きの分岐のリストをループし(ステップS33)、各分岐について、分岐が1の時間計算量を表すとして分岐が表せる最大時間計算量を求める(ステップS34)。分岐の最大時間計算量は図9のフローチャートによって決定される。続いてアルゴリズムは、分岐の分岐先から開始してマシンコード分岐自体で終了するまですべてのマシンコード命令をループし(ステップS35)、この分岐が表す最大時間計算量がこのマシンコード命令に関する前に記憶された時間計算量よりも大きい場合、この分岐が表す最大時間計算量をこのマシンコード命令に関する新たな時間計算量として記憶し(ステップS36)、終了する(ステップS37)。   First, in step S30, the algorithm initializes all machine code instructions so that the time complexity is zero. Next, a list of all conditional branches or unconditional branches that branch to the previous instruction is constructed (step S31), and then, the list of all upward branches is started from the smaller number of machine code instructions to be skipped. Sort to the larger one (step S32). Then, the algorithm loops through a list of all upward branches (step S33), and for each branch, obtains the maximum time calculation amount that the branch can represent assuming that the branch represents one time calculation amount (step S34). The maximum amount of time for branching is determined by the flowchart of FIG. Subsequently, the algorithm loops through all machine code instructions starting from the branch destination and ending with the machine code branch itself (step S35), and the maximum amount of time represented by this branch is If it is larger than the stored time calculation amount, the maximum time calculation amount represented by this branch is stored as a new time calculation amount relating to this machine code instruction (step S36), and the process is terminated (step S37).

また、図9に示す以下のアルゴリズムは、初期的な計算量(明細書の最後に記載する疑似コード)を与えられると、ある分岐に関する最大時間計算量を決定できる。   Further, the following algorithm shown in FIG. 9 can determine the maximum time complexity for a certain branch given an initial complexity (pseudo code described at the end of the specification).

当該分岐について、アルゴリズムはこの分岐よりもスキップする命令の数が多いすべての分岐をループし(ステップS40)、ステップS41において、当該分岐がこの反復で検討中の分岐内に完全に含まれる場合、計算量は、現在の計算量とこの反復で検討中の分岐の計算量とのうち量が大きい方に等しい(このアルゴリズムを現在の計算量とともに再帰的に呼び出すことで決定される)。最後にステップS42において、アルゴリズムは計算量の値を返し、終了する(ステップS43)。   For that branch, the algorithm loops through all branches that skip more instructions than this branch (step S40), and if in step S41 the branch is completely contained within the branch under consideration in this iteration, The computational complexity is equal to the larger of the current computational complexity and the computational complexity of the branch under consideration in this iteration (determined by recursively calling this algorithm with the current computational complexity). Finally, in step S42, the algorithm returns the value of the calculation amount and ends (step S43).

(アセンブリコードにおける強連結部分グラフ法を用いた時間計算量注釈付きの行)
一実施例では、以下のアルゴリズム(強連結部分グラフ法と称する)によって、アセンブリコードの命令の最悪のケースにおける大まかな時間計算量が検出される。この方法はコードのフローと分岐命令の分岐先とに基づくものである。O(n)に置き換えた時間計算量を検出できる。
(Annotated line with time complexity using strongly connected subgraph method in assembly code)
In one embodiment, the following algorithm (referred to as a strongly connected subgraph method) detects the rough time complexity in the worst case of assembly code instructions. This method is based on the code flow and the branch destination of the branch instruction. It is possible to detect the time calculation amount replaced with O (n p ).

図10は、非限定のアルゴリズムの一例を示すものであり、これに従って、あるアセンブリコード命令の時間計算量が決定される。   FIG. 10 shows an example of a non-limiting algorithm, and the time complexity of an assembly code instruction is determined accordingly.

(コードのフローグラフを作成)
まずステップS50において、コードのフローグラフを作成する。より具体的には、アセンブリコードの各行をノードとしてこれらのノードがプログラムの制御フローに従って接続された有向グラフを作成する。例えば3行からなるアセンブリプログラムの場合、通常、コードのフローはある行から次の行へと進むため、これに対応するコードのフローグラフは{1→2,2→3,3→null}となる。最初のコード命令が行3への条件ジャンプであれば、新たなグラフは{1→2,1→3,2→3,3→null}となる。
(Create code flow graph)
First, in step S50, a code flow graph is created. More specifically, a directed graph in which each line of the assembly code is used as a node and these nodes are connected according to the control flow of the program is created. For example, in the case of an assembly program consisting of three lines, since the code flow usually proceeds from one line to the next, the corresponding code flow graph is {1 → 2, 2 → 3, 3 → null}. Become. If the first code instruction is a conditional jump to line 3, the new graph will be {1 → 2, 1 → 3, 2 → 3, 3 → null}.

(各強連結部分グラフを識別)
次にステップS51において、アルゴリズムは各強連結部分グラフを識別する。深さ優先探索を開始ノードから行って、コードのフローグラフのすべての強連結部分グラフを識別する。強連結部分グラフは、閉路を形成するあらゆるノードまたはノードのあらゆるグループである。より正確に言えば、AからBへの経路が存在しBからAへの経路が存在する場合(つまり、閉路が形成される場合)、ノードAおよびBは強連結部分グラフを形成する。強連結部分グラフが深さ優先探索中に識別されるのは、探索対象である次のノードが現在の走査に既に含まれるノードである場合である。こうして識別された強連結部分グラフは、現在の走査に含まれることが判明したノード(根ノードと呼ぶ)から開始して現在の探索走査の最終ノードまでが記録される。例えば深さ優先探索において経路{1,2,3,4,5,2}が探索される場合、強連結部分グラフ{2,3,4,5}が記録され、前の走査の最終ノードが葉(子を持たない終端ノード)であるかのように深さ優先探索を続行する。2つ以上の強連結部分グラフが同一である場合、これらの同一の強連結部分グラフのうち1つだけが保持される。
(Identifies each strongly connected subgraph)
Next, in step S51, the algorithm identifies each strongly connected subgraph. A depth-first search is performed from the start node to identify all strongly connected subgraphs of the code flow graph. A strongly connected subgraph is any node or any group of nodes that form a cycle. More precisely, nodes A and B form a strongly connected subgraph if there is a path from A to B and a path from B to A (ie, a closed circuit is formed). A strongly connected subgraph is identified during a depth-first search if the next node to be searched is a node already included in the current scan. The strongly connected subgraph thus identified is recorded starting from a node found to be included in the current scan (referred to as a root node) up to the last node of the current search scan. For example, when the path {1, 2, 3, 4, 5, 2} is searched in the depth-first search, the strongly connected subgraph {2, 3, 4, 5} is recorded, and the last node of the previous scan is Continue the depth-first search as if it were a leaf (a terminal node with no children). If two or more strongly connected subgraphs are the same, only one of these identical strongly connected subgraphs is retained.

(強連結部分グラフの集合を作成)
各強連結部分グラフを識別した後、ステップS52において、これらを同じ根ノードを共有する種々の集合に配置する。例えば強連結部分グラフ{2,3,4}および{2,3,5}は同じ根ノード2を有するため、同じ集合に含まれることになる。
(Create a set of strongly connected subgraphs)
After identifying each strongly connected subgraph, in step S52 they are placed in various sets that share the same root node. For example, the strongly connected subgraphs {2, 3, 4} and {2, 3, 5} have the same root node 2 and are therefore included in the same set.

強連結部分グラフを集合に追加する前に、この強連結部分グラフがこの集合内の他の強連結部分グラフの部分集合であるかが確認される。他のグラフの部分集合であるグラフは、他のグラフの連続部分と同一のグラフとして定義される。例えばグラフ{2,3,4}はグラフ{2,3,4,5}の部分集合である。この強連結部分グラフがこの集合内の他の強連結部分グラフの部分集合である場合、この集合には追加されず、逆に他の適切な集合に、同じ根ノードを有しかつその集合内のどの強連結部分グラフの部分集合でもないことを条件として追加される。強連結部分グラフをどの集合にも追加できない場合、この特定の強連結部分グラフが固有の集合を定義する。   Before adding a strongly connected subgraph to the set, it is checked whether this strongly connected subgraph is a subset of the other strongly connected subgraphs in this set. A graph that is a subset of another graph is defined as the same graph as a continuous portion of another graph. For example, the graph {2, 3, 4} is a subset of the graph {2, 3, 4, 5}. If this strongly connected subgraph is a subset of another strongly connected subgraph in this set, it is not added to this set, but conversely in another suitable set that has the same root node and is in that set It is added on condition that it is not a subset of any strongly connected subgraph. If a strongly connected subgraph cannot be added to any set, this particular strongly connected subgraph defines a unique set.

(集合グラフを作成)
強連結部分グラフの種々の集合が作成された後、ステップS53において、以下のアルゴリズムを用いてこれらの集合の新たな集合グラフを構築する。
(Create a set graph)
After various sets of strongly connected subgraphs are created, in step S53, new set graphs of these sets are constructed using the following algorithm.

ある集合C1が異なる集合C2内の他の強連結部分グラフ内に含まれる根ノードを有し、C2内のいずれの強連結部分グラフもC1内の強連結部分グラフの部分集合ではない場合(ノードのシーケンスの移動を考慮したとしても)、C1はC2の子として、例えばC2→C1のように定義される。例えば集合C1が{3,4,5}を含み、集合C2が{2,3,4}を含む場合、C1はC2の子である。さらなる例として、集合C3が{2,3}を含み、集合C4が{3,2,4}を含む場合、C3はC4の子であるが、C4はC3の子ではない(C3がC4の部分集合であるため)。一旦グラフが完成すると、C1がC2の子でC2がC1の子であるノードC1およびC2の各集合については、これらのノードをお互いに非連結にする。   A set C1 has a root node contained in another strongly connected subgraph in a different set C2, and any strongly connected subgraph in C2 is not a subset of the strongly connected subgraph in C1 (node C1 is defined as a child of C2, for example, C2 → C1. For example, if set C1 contains {3, 4, 5} and set C2 contains {2, 3, 4}, C1 is a child of C2. As a further example, if set C3 contains {2,3} and set C4 contains {3,2,4}, C3 is a child of C4, but C4 is not a child of C3 (C3 is a C4 child) Because it is a subset). Once the graph is complete, for each set of nodes C1 and C2 where C1 is a child of C2 and C2 is a child of C1, these nodes are disconnected from each other.

(集合グラフにおける各ノードの最長の経路を解析)
次にステップS54において、集合グラフにおける最長の経路を解析する。これらの集合の新たに作成された集合グラフを用いて、親を持たないノードへ到達するまで各ノードを後向きにノード走査したときの最長の数を求める。例えばC1→C2、C1→C3、C2→C3の場合、C1が親を持たない唯一のノードで走査コストはゼロであり、C2は走査コストが1であり(C1へ到達するのに1ノード走査する)、C3は走査コストが2である(C2を経由してC1へ到達するのに2ノード走査する)。
(Analysis of the longest path of each node in the set graph)
Next, in step S54, the longest path in the set graph is analyzed. Using the newly created set graph of these sets, the longest number is obtained when each node is scanned backwards until a node having no parent is reached. For example, if C1 → C2, C1 → C3, C2 → C3, C1 is the only node that has no parent and the scan cost is zero, and C2 has a scan cost of 1 (one node scan to reach C1) C3 has a scanning cost of 2 (two nodes are scanned to reach C1 via C2).

(集合をソート)
ステップS54におけるノード走査による識別に続いて、ステップS55において、ノード走査の数を基準として用いて、数が小さい方から大きい方へ集合のソート済みリストLを作成する。
(Sort set)
Subsequent to the identification by node scanning in step S54, in step S55, a sorted list L of sets is created from the smaller number to the larger number using the number of node scans as a reference.

(時間計算量を割り当て)
次にステップS56において、各ノード(つまり、コードの各行)に時間計算量(例えば自然数0、1、2、・・・p)を割り当てる。まずコードの各行について、時間計算量をゼロに初期化する。そして、ソート済みリストLの各集合について、(この集合の各強連結部分グラフ内の)コードの各個別の行の時間計算量をノード走査の値プラス1として割り当てる。
(Allocate time calculation)
Next, in step S56, a time calculation amount (for example, natural numbers 0, 1, 2,..., P) is assigned to each node (that is, each line of the code). First, the time complexity is initialized to zero for each line of code. Then, for each set of sorted list L, the time complexity of each individual line of code (in each strongly connected subgraph of this set) is assigned as the value of node scan plus one.

(時間計算量を置き換え)
最後にステップS57において、各行に割り当てられた時間計算量に応じて、この行の計算量を以下のようにビッグO記法で表す。
0→O(n)=O(1)
1→O(n)=O(n)
2→O(n
3→O(n
4→O(n
・・・
p→O(n
プログラムは終了(ステップS58)
(Replace time calculation)
Finally, in step S57, the calculation amount of this row is expressed in the big O notation as follows according to the time calculation amount assigned to each row.
0 → O (n 0 ) = O (1)
1 → O (n 1 ) = O (n)
2 → O (n 2 )
3 → O (n 3 )
4 → O (n 4 )
...
p → O (n p )
The program ends (step S58)

(例)
上記の強連結部分グラフ法を用いて、例えば以下のアセンブリコードプログラムの一例に関して時間計算量を検出できる。
Example assembly program(アセンブリプログラム例) #1
1: Do work(実行)
2: Do work(実行)
3: Do work(実行)
4: Conditionally branch to line 3(条件付きで行3に分岐)
5: Conditionally branch to line 7(条件付きで行7に分岐)
6: Do work(実行)
7: Conditionally branch to line 2(条件付きで行2に分岐)
8: Do work(実行)
Step 1: Create a code flow graph(コードのフローグラフを作成)
1 → 2
2 → 3
3 → 4
4 → 3, 4 → 5
5 → 6, 5 → 7
6 → 7
7 → 2, 7 → 8
8 → null
Step 2: Identify strongly connected subgraphs(各強連結部分グラフを識別)
1
1,2
1,2,3
1,2,3,4
1,2,3,4, (3) Found
strongly connected subgraph(強連結部分グラフを発見): 3,4
1,2,3,4,5
1,2,3,4,5,7
1,2,3,4,5,7, (2) Found
strongly connected subgraph(強連結部分グラフを発見): 2,3,4,5,7
1,2,3,4,5,7,8
1,2,3,4,5,6
1,2,3,4,5,6,7
1,2,3,4,5,6,7 (2) Found
strongly connected subgraph(強連結部分グラフを発見): 2,3,4,5,6,7
1,2,3,4,5,6,7,8
List of all strongly connected subgraphs(すべての強連結部分グラフのリスト):
2,3,4,5,6,7
2,3,4,5,7
3,4
Step 3: Create collections of strongly connected
subgraphs(強連結部分グラフの集合を作成)
Collection(集合) A:
3,4
Collection(集合) B:
2,3,4,5,6,7
2,3,4,5,7
Step 4: Create a collection graph(集合グラフを作成)
B → A
Step 5: Analyze the longest path in collection
graph(集合グラフにおける最長の経路を解析)
Collection(集合) A: 1
Collection(集合) B: 0
Step 6: Sort collections(集合をソート)
Collection(集合) B: 0
Collection(集合) A: 1
Step 7: Assign time complexity(時間計算量を割り当て)
1: 0
2: 1
3: 2
4: 2
5: 1
6: 1
7: 1
8: 0
Step 8: Interpret time complexity(時間計算量を置き換え)
1: O(1)
2: O(n)
3: O(n2)
4: O(n2)
5: O(n)
6: O(n)
7: O(n)
8: O(1)

Example assembly program(アセンブリプログラム例) #2
1: Do work(実行)
2: Conditionally branch to line 1(条件付きで行1に分岐)
3: Conditionally branch to line 1(条件付きで行1に分岐)
4: Do work(実行)
Step 1: Create a code flow graph(コードのフローグラフを作成)
1 → 2
2 → 3, 2 → 1
3 → 4, 3 → 1
4 → null
Step 2: Identify strongly connected subgraphs(各強連結部分グラフを識別)
1
1,2
1,2, (1) Found
strongly connected subgraph(強連結部分グラフを発見): 1,2
1,2,3
1,2,3, (1) Found strongly
connected subgraph(強連結部分グラフを発見): 1,2,3
1,2,3,4
List of all strongly connected subgraphs(すべての強連結部分グラフのリスト):
1,2
1,2,3
Step 3: Create collections of strongly connected
subgraphs(強連結部分グラフの集合を作成)
Step 3a: Collection(集合) A:
1,2
1,2,3
Step 3b: Collection(集合) A:
1,2,3

Collection(集合) B:
1,2 (was
a subset of {1,2,3} in collection A)(集合Aの{1,2,3}の部分集合だった)
Step 4: Create a collection graph(集合グラフを作成)
A → B
Step 5: Analyze the longest path in collection
graph(集合グラフにおける最長の経路を解析)
Collection(集合) A: 0
Collection(集合) B: 1
Step 6: Sort collections(集合をソート)
Collection(集合) A: 0
Collection(集合) B: 1
Step 7: Assign time complexity(時間計算量を割り当て)
1: 2
2: 2
3: 1
4: 0
Step 8: Interpret time complexity(時間計算量を置き換え)
1: O(n2)
2: O(n2)
3: O(n)
4: O(1)
Example assembly program(アセンブリプログラム例) #3
1: Conditionally branch to line 3(条件付きで行3に分岐)
2: Conditionally branch to line 4(条件付きで行4に分岐)
3: Conditionally branch to line 2(条件付きで行2に分岐)
4: Conditionally branch to line 3(条件付きで行3に分岐)
Step 1: Create a code flow graph(コードのフローグラフを作成)
1 → 2, 1 → 3
2 → 3, 2 → 4
3 → 4, 3 → 2
4 → 3, 4 → null
Step 2: Identify strongly connected subgraphs(各強連結部分グラフを識別)
1
1,3
1,3,2
1,3,2,4
1,3,2,4, (3) Found strongly connected subgraph(強連結部分グラフを発見): 3,2,4
1,3,2,
(3) Found strongly connected subgraph(強連結部分グラフを発見): 3,2
1,3,4
1,3,4, (3)
Found strongly connected
subgraph(強連結部分グラフを発見): 3,4
1,2
1,2,4
1,2,4,3
1,2,4,3,
(2) Found strongly connected subgraph(強連結部分グラフを発見): 2,4,3
1,2,4,3,
(4) Found strongly
connected subgraph(強連結部分グラフを発見): 4,3
1,2,3
1,2,3,
(2) Found
strongly connected subgraph(強連結部分グラフを発見): 2,3
1,2,3,4
1,2,3,4, (3) Found
strongly connected subgraph(強連結部分グラフを発見): 3,4
List of all strongly connected subgraphs
(eliminating any duplicates)(すべての強連結部分グラフのリスト(いかなる重複も除外)):
3,2,4
3,2
3,4
2,4,3
4,3
2,3
Step 3: Create collections of strongly connected
subgraphs(強連結部分グラフの集合を作成)
Step 3a:
Collection(集合) A:
2,3
2,4,3
Collection(集合) B:
3,2
3,2,4
3,4
Collection(集合) C:
4,3
Step 3b:
Collection(集合) A:
2,4,3
2,3
Collection(集合) B:
3,2,4
3,4
Collection(集合) C:
4,3
Collection(集合) D:
3,2 (was
a subset of {3,2,4} in collection B)(集合Bの{3,2,4}の部分集合だった)
Step 4: Create a collection graph(集合グラフを作成)
Step 4a:
A → B
B → C
A → D
B → A
B → C
B → D
C → D
Step 4c:
A → B, B → A Break
both connections between A and B(AB間の両連結を非連結にする)
A → C
A → D
B → C
B → D
C → D
Step 5: Analyze the longest path in collection
graph(集合グラフにおける最長の経路を解析)
Collection(集合) A: 0
Collection(集合) B: 0
Collection(集合) C: 1
Collection(集合) D: 2
Step 6: Sort collections(集合をソート)
Collection(集合) A: 0
Collection(集合) B: 0
Collection(集合) C: 1
Collection(集合) D: 2
Step 7: Assign time complexity(時間計算量を割り当て)
1: 0
2: 3
3: 3
4: 2
Step 8: Interpret time complexity(時間計算量を置き換え)
1: O(1)
2: O(n3)
3: O(n3)
4: O(n2)
(Example)
Using the above-described strongly connected subgraph method, for example, the time complexity can be detected for an example of the following assembly code program.
Example assembly program # 1
1: Do work
2: Do work
3: Do work
4: Conditionally branch to line 3
5: Conditionally branch to line 7
6: Do work
7: Conditionally branch to line 2
8: Do work
Step 1: Create a code flow graph
1 → 2
2 → 3
3 → 4
4 → 3, 4 → 5
5 → 6, 5 → 7
6 → 7
7 → 2, 7 → 8
8 → null
Step 2: Identify strongly connected subgraphs
1
1,2
1,2,3
1,2,3,4
1,2,3,4, (3) Found
strongly connected subgraph: 3,4
1,2,3,4,5
1,2,3,4,5,7
1,2,3,4,5,7, (2) Found
strongly connected subgraph: 2,3,4,5,7
1,2,3,4,5,7,8
1,2,3,4,5,6
1,2,3,4,5,6,7
1,2,3,4,5,6,7 (2) Found
strongly connected subgraph: 2,3,4,5,6,7
1,2,3,4,5,6,7,8
List of all strongly connected subgraphs:
2,3,4,5,6,7
2,3,4,5,7
3,4
Step 3: Create collections of strongly connected
subgraphs (creates a set of strongly connected subgraphs)
Collection A:
3,4
Collection B:
2,3,4,5,6,7
2,3,4,5,7
Step 4: Create a collection graph
B → A
Step 5: Analyze the longest path in collection
graph (analyze the longest path in a set graph)
Collection A: 1
Collection B: 0
Step 6: Sort collections
Collection B: 0
Collection A: 1
Step 7: Assign time complexity
Ten
twenty one
3: 2
4: 2
5: 1
6: 1
7: 1
8: 0
Step 8: Interpret time complexity (replaces time complexity)
1: O (1)
2: O (n)
3: O (n 2 )
4: O (n 2 )
5: O (n)
6: O (n)
7: O (n)
8: O (1)

Example assembly program # 2
1: Do work
2: Conditionally branch to line 1
3: Conditionally branch to line 1 (conditionally branch to line 1)
4: Do work
Step 1: Create a code flow graph
1 → 2
2 → 3, 2 → 1
3 → 4, 3 → 1
4 → null
Step 2: Identify strongly connected subgraphs
1
1,2
1,2, (1) Found
strongly connected subgraph: 1,2
1,2,3
1,2,3, (1) Found strongly
connected subgraph: 1,2,3
1,2,3,4
List of all strongly connected subgraphs:
1,2
1,2,3
Step 3: Create collections of strongly connected
subgraphs (creates a set of strongly connected subgraphs)
Step 3a: Collection A:
1,2
1,2,3
Step 3b: Collection A:
1,2,3

Collection B:
1,2 (was
a subset of {1,2,3} in collection A) (It was a subset of {1,2,3} of set A)
Step 4: Create a collection graph
A → B
Step 5: Analyze the longest path in collection
graph (analyze the longest path in a set graph)
Collection A: 0
Collection B: 1
Step 6: Sort collections
Collection A: 0
Collection B: 1
Step 7: Assign time complexity
1: 2
twenty two
3: 1
4: 0
Step 8: Interpret time complexity (replaces time complexity)
1: O (n 2 )
2: O (n 2 )
3: O (n)
4: O (1)
Example assembly program # 3
1: Conditionally branch to line 3
2: Conditionally branch to line 4
3: Conditionally branch to line 2 (conditionally branch to line 2)
4: Conditionally branch to line 3
Step 1: Create a code flow graph
1 → 2, 1 → 3
2 → 3, 2 → 4
3 → 4, 3 → 2
4 → 3, 4 → null
Step 2: Identify strongly connected subgraphs
1
1,3
1,3,2
1,3,2,4
1,3,2,4, (3) Found strongly connected subgraph: 3,2,4
1,3,2,
(3) Found strongly connected subgraph: 3,2
1,3,4
1,3,4, (3)
Found strongly connected
subgraph (found strongly connected subgraph): 3,4
1,2
1,2,4
1,2,4,3
1,2,4,3,
(2) Found strongly connected subgraph: 2,4,3
1,2,4,3,
(4) Found strongly
connected subgraph: 4,3
1,2,3
1,2,3,
(2) Found
strongly connected subgraph: 2,3
1,2,3,4
1,2,3,4, (3) Found
strongly connected subgraph: 3,4
List of all strongly connected subgraphs
(eliminating any duplicates) (list of all strongly connected subgraphs (exclude any duplicates)):
3,2,4
3,2
3,4
2,4,3
4,3
2,3
Step 3: Create collections of strongly connected
subgraphs (creates a set of strongly connected subgraphs)
Step 3a:
Collection A:
2,3
2,4,3
Collection B:
3,2
3,2,4
3,4
Collection C:
4,3
Step 3b:
Collection A:
2,4,3
2,3
Collection B:
3,2,4
3,4
Collection C:
4,3
Collection D:
3,2 (was
a subset of {3,2,4} in collection B) (It was a subset of {3,2,4} of set B)
Step 4: Create a collection graph
Step 4a:
A → B
B → C
A → D
B → A
B → C
B → D
C → D
Step 4c:
A → B, B → A Break
both connections between A and B
A → C
A → D
B → C
B → D
C → D
Step 5: Analyze the longest path in collection
graph (analyze the longest path in a set graph)
Collection A: 0
Collection B: 0
Collection C: 1
Collection D: 2
Step 6: Sort collections
Collection A: 0
Collection B: 0
Collection C: 1
Collection D: 2
Step 7: Assign time complexity
Ten
twenty three
3: 3
4: 2
Step 8: Interpret time complexity (replaces time complexity)
1: O (1)
2: O (n 3 )
3: O (n 3 )
4: O (n 2 )

(時間計算量検出アルゴリズムの組み合わせ)
本願では、時間計算量を計算する2つの方法として、アップブランチ法および強連結部分グラフ法を開示した。これらの相違点に加えて長所と短所を一覧にして以下に示す。
・アップブランチ法では、アルゴリズムが行番号に基づいてグループ分けを行う性質上、実際にはコードの行が閉路の一部ではない可能性がある場合に、このコードの行の時間計算量が誤って大きく判断されることがある(アセンブリプログラム例No.4を参照)。
・アップブランチ法は控えめなものであり、コードの最初か最後の行が複数の閉路間で共有される場合には閉路を含むとは認識せず、ある閉路が行番号に関して他の閉路と部分的に重複する場合にも閉路を含むとは認識しない(アセンブリプログラム例No.5を参照)。
・強連結部分グラフ法は、ソースコードまたはアセンブリコードが実際には結果としてこの時間計算量とならない可能性がある場合でも、閉路を含むと積極的に認識する。これは分岐を行うコードの各行の実際の計算が解析されないことによる。これによっても時間計算量の精度が下がることになるため、O(log n)等の計算量は得られない。
・強連結部分グラフ法では、コードの行の時間計算量が理論的に可能な時間計算量よりも小さく判断されることは決してないため、計算されるすべての時間計算量が最大値となる。
(Combination of time complexity detection algorithms)
In the present application, the up-branch method and the strongly connected subgraph method are disclosed as two methods for calculating the time complexity. In addition to these differences, the advantages and disadvantages are listed below.
In the up-branch method, due to the nature of the algorithm grouping based on the line number, the time complexity of this line of code is incorrect when there is a possibility that the line of code is not actually part of the cycle. (See assembly program example No. 4).
The up-branch method is conservative and does not recognize that it contains a cycle if the first or last line of code is shared between multiple cycles, and some cycles are part of other cycles with respect to row numbers Even when they overlap each other, it is not recognized that a cycle is included (see assembly program example No. 5).
The strongly connected subgraph method actively recognizes that it contains a cycle even if the source code or assembly code may not actually result in this time complexity. This is because the actual computation of each line of code that does branching is not analyzed. This also reduces the accuracy of the time calculation amount, so that a calculation amount such as O (log n) cannot be obtained.
In the strongly connected subgraph method, the time complexity of a line of code is never judged smaller than the theoretically possible time complexity, so all the time complexity calculated is the maximum value.

アップブランチ法による時間計算量アルゴリズムおよび強連結部分グラフ法による時間計算量アルゴリズムの上記の長所と短所を踏まえて、以下の方策を取ることが有利である。
・強連結部分グラフ法を用いて、理論的に可能な最悪時間計算量を決定する。
・コードの各行の最小時間計算量は、アップブランチ法と強連結部分グラフ法とのいずれかから選択する(アセンブリプログラム例No.4およびNo.5を参照)。これにより、時間計算量を控えめに推定しつつ、アップブランチ法に存在する実際よりも大きい誤った時間計算量をいずれも除外する。
In view of the above advantages and disadvantages of the time complexity algorithm based on the upbranch method and the time complexity algorithm based on the strongly connected subgraph method, it is advantageous to take the following measures.
-Determine the theoretically possible worst-time complexity using the strongly connected subgraph method.
The minimum time complexity of each line of code is selected from either the up-branch method or the strongly connected subgraph method (see assembly program examples No. 4 and No. 5). Thereby, while estimating the time calculation amount conservatively, any erroneous time calculation amount larger than the actual one existing in the upbranch method is excluded.

(その他の例)
時間計算量を計算する上に開示する2つの方法を用い、その結果を以下の2つのアセンブリプログラム例のために比較した。

Example assembly program(アセンブリプログラム例) #4
1: Conditionally branch to line 3(条件付きで行3に分岐)
2: Unconditionally branch to line 4 (this code
line is not in a cycle)(無条件で行4に分岐(このコードの行は閉路内にはない))
3: Conditionally branch to line 1(条件付きで行1に分岐)
4: Do work(実行)

Up Branch Method of computing time complexity(時間計算量を計算するアップブランチ法):
1: O(n)
2: O(n)
3: O(n)
4: O(1)

Strongly Connected Subgraph Method of computing
time complexity(時間計算量を計算する強連結部分グラフ法):
1: O(n)
2: O(1)
3: O(n)
4: O(1)

Minimum between each time complexity method
(conservative with no errors)(各時間計算量方法のうち最小値(控えめで誤りがない))
1: Min ((O(n), O(n)) = O(n)
2: Min ((O(1), O(n)) = O(1)
3: Min ((O(n), O(n)) = O(n)
4: Min ((O(1), O(1)) = O(1)
Example assembly program(アセンブリプログラム例) #5
1: Conditionally branch to line 3(条件付きで行3に分岐)
2: Unconditionally branch to line 5 (this code
line is not in a cycle)(無条件で行5に分岐(このコードの行は閉路内にはない))
3: Conditionally branch to line 1(条件付きで行1に分岐)
4: Conditionally branch to line 1(条件付きで行1に分岐)
5: Do work(実行)

Up Branch Method of computing time complexity(時間計算量を計算するアップブランチ法):
1: O(n)
2: O(n)
3: O(n)
4: O(n)
5: O(1)

Strongly Connected Subgraph Method of computing
time complexity(時間計算量を計算する強連結部分グラフ法):
1: O(n2)
2: O(1)
3: O(n2)
4: O(n)
5: O(1)

Minimum between each time complexity method
(conservative with no errors)(各時間計算量方法のうち最小値(控えめで誤りがない))
1: Min ((O(n), O(n2)) = O(n)
2: Min ((O(1), O(n)) = O(1)
3: Min ((O(n), O(n2)) = O(n)
4: Min ((O(n), O(n)) = O(n)

4: Min ((O(1), O(1)) = O(1)
(Other examples)
Using the two methods disclosed above to calculate the time complexity, the results were compared for the following two example assembly programs.

Example assembly program # 4
1: Conditionally branch to line 3
2: Unconditionally branch to line 4 (this code
line is not in a cycle) (unconditionally branch to line 4 (the line of this code is not in a cycle))
3: Conditionally branch to line 1 (conditionally branch to line 1)
4: Do work

Up Branch Method of computing time complexity:
1: O (n)
2: O (n)
3: O (n)
4: O (1)

Strongly connected subgraph method of computing
time complexity (strongly connected subgraph method for computing time complexity):
1: O (n)
2: O (1)
3: O (n)
4: O (1)

Minimum between each time complexity method
(conservative with no errors) (minimum value of each time calculation method (moderate and error-free))
1: Min ((O (n), O (n)) = O (n)
2: Min ((O (1), O (n)) = O (1)
3: Min ((O (n), O (n)) = O (n)
4: Min ((O (1), O (1)) = O (1)
Example assembly program # 5
1: Conditionally branch to line 3
2: Unconditionally branch to line 5 (this code
line is not in a cycle) (unconditionally branch to line 5 (the line of this code is not in a cycle))
3: Conditionally branch to line 1 (conditionally branch to line 1)
4: Conditionally branch to line 1
5: Do work

Up Branch Method of computing time complexity:
1: O (n)
2: O (n)
3: O (n)
4: O (n)
5: O (1)

Strongly connected subgraph method of computing
time complexity (strongly connected subgraph method for computing time complexity):
1: O (n 2 )
2: O (1)
3: O (n 2 )
4: O (n)
5: O (1)

Minimum between each time complexity method
(conservative with no errors) (minimum value of each time calculation method (moderate and error-free))
1: Min ((O (n), O (n 2 )) = O (n)
2: Min ((O (1), O (n)) = O (1)
3: Min ((O (n), O (n 2 )) = O (n)
4: Min ((O (n), O (n)) = O (n)

4: Min ((O (1), O (1)) = O (1)

図11および図12は、複雑なコードシーケンスと、アップブランチ法および強連結部分グラフ法をそれぞれ用いて得られた対応する時間計算量の解析結果との一例を示す。より具体的には、図11は、コードシーケンスと、アップブランチ法を用いて得られたこのコードシーケンスの時間計算量との一例を示す。図12は、全く同じコードシーケンスと、強連結部分グラフ法を用いて得られた時間計算量の結果とを示す。図11および図12で分かるように、これらの2つの方法は性質や閉路検出のアプローチ等が異なるため、一部のコードの行の時間計算量の尺度についての値が異なる。したがって、上述のように、コードの各行の最小時間計算量の尺度をアップブランチ法と強連結部分グラフ法とのいずれかから選択することで、2つの方法を組み合わせればよい。これを図13に示す。これにより、時間計算量を控えめに推定したものを表し、アップブランチ法に本質的に起因する実際よりも大きい誤った時間計算量をいずれも除外する。   FIG. 11 and FIG. 12 show examples of complex code sequences and corresponding time complexity analysis results obtained using the up-branch method and the strongly connected subgraph method, respectively. More specifically, FIG. 11 shows an example of a code sequence and the time calculation amount of this code sequence obtained using the up-branch method. FIG. 12 shows the exact same code sequence and the time complexity results obtained using the strongly connected subgraph method. As can be seen in FIG. 11 and FIG. 12, these two methods differ in nature, approach to cycle detection, etc., so the values for the time complexity measure of some lines of code are different. Therefore, as described above, the two methods may be combined by selecting the scale of the minimum time complexity of each line of the code from either the up-branch method or the strongly connected subgraph method. This is shown in FIG. This represents a conservative estimate of the time complexity, and excludes any erroneous time complexity that is larger than actual due to the up-branch method.

以下に、例示を目的とする非限定のアルゴリズムの実施の一例を追加説明する。   In the following, an additional example of implementation of a non-limiting algorithm for illustrative purposes will be described.

分岐機械命令行から分岐先の機械命令行に伸びるグラフィカルな矢印であって、
a.複数の下向きの分岐がマシンコードの左側に現れ、
i.分岐の元となる行における、iiに接続する横線と、
ii.横線から分岐先の命令行まで下向きに進行する、iiiに接続する縦線と、
iii.分岐の分岐先における、分岐先の命令を指す右向き矢印を有する横線とから成り、
b.複数の上向きの分岐がマシンコードの右側に現れ、
i.分岐の元となる行における、iiに接続する横線と、
ii.横線から分岐先の命令行まで上向きに進行する、iiiに接続する縦線と、
iii.分岐の分岐先における、分岐先の命令を指す左向き矢印を有する横線とから成り、
c.互いの比較的近くに下向きおよび上向きに分岐する交互配置の機械命令が存在する場合に、下向きおよび上向きの分岐を組み合わせて反時計回りのフローを形成し、
d.共通の分岐先を共有する分岐は、任意でそれらの縦線が互いに重なるように描かれ、
e.共通の分岐先を共有しない分岐は、それらの縦線が互いに重ならないように描かれ、
f.より近い分岐先を有する分岐は、より遠い分岐先を有する分岐よりもコードに近く位置する縦線を有するべきであり、
g.他の関数に結合する分岐は、命令の右に向かう単一の横方向の両矢印で表され、
h.戻り分岐は、命令の右に向かう単一の横方向の右向き矢印で表される、グラフィカルな矢印。
A graphical arrow extending from a branch machine instruction line to a branch machine instruction line,
a. Multiple downward branches appear on the left side of the machine code,
i. A horizontal line connected to ii in the row that is the source of the branch;
ii. A vertical line connected to iii, progressing downward from the horizontal line to the branch instruction line;
iii. Consisting of a horizontal line with a right-pointing arrow pointing to the branch destination instruction at the branch destination of the branch,
b. Multiple upward branches appear on the right side of the machine code,
i. A horizontal line connected to ii in the row that is the source of the branch;
ii. A vertical line connected to iii, progressing upward from the horizontal line to the branch instruction line;
iii. Consisting of a horizontal line with a left-pointing arrow pointing to the branch destination instruction at the branch destination of the branch,
c. When there are interleaved machine instructions that branch downward and upward relatively close to each other, the downward and upward branches are combined to form a counterclockwise flow;
d. Branches that share a common branch destination are optionally drawn with their vertical lines overlapping each other,
e. Branches that do not share a common branch destination are drawn so that their vertical lines do not overlap each other,
f. A branch with a closer branch destination should have a vertical line located closer to the code than a branch with a farther branch destination;
g. A branch that joins another function is represented by a single horizontal double arrow pointing to the right of the instruction,
h. A return branch is a graphical arrow, represented by a single horizontal right arrow pointing to the right of the instruction.

分岐機械命令に続く機械命令はそれらが分岐命令の分岐先でない限り、以下のアルゴリズムに従ってタブ1つ字下げされる。
a.すべての機械命令を字下げレベルがゼロとなるように初期化する。
b.機械命令のリストを最初から最後までたどる。
c.分岐機械命令に遭遇した場合、以下を実行する。
i.分岐が下向きの場合、その分岐先にフリーズトークンでマーク付けする。
ii.各行の字下げレベルをインクリメントしながら一連の機械命令をたどる。
iii.フリーズトークンに遭遇した場合、その行の字下げレベルはインクリメントせず、ステップcを停止し、ステップbを続行する。
Machine instructions following a branch machine instruction are indented one tab according to the following algorithm, unless they are the branch destination of a branch instruction.
a. Initialize all machine instructions so that the indentation level is zero.
b. Follow the machine instruction list from beginning to end.
c. If a branch machine instruction is encountered, do the following:
i. If the branch is downward, mark that branch with a freeze token.
ii. Follow a series of machine instructions, incrementing the indentation level of each line.
iii. If a freeze token is encountered, the indentation level for that line is not incremented, step c is stopped, and step b is continued.

コンピュータの時間計算量はコードの重要な特性であり、コードのブロックをそれぞれ対応する時間計算量で視覚的に示すことで視覚化できる。関数内のすべてのマシンコード命令の時間計算量は、ゼロ=O(1)、1=O(n)、2=O(n)、3=O(n)等として、以下のアップブランチアルゴリズムによって決定できる。
a.すべてのマシンコード命令を時間計算量がゼロとなるように初期化する。
b.複数の前の命令に分岐するすべての条件分岐または無条件分岐のリストを構築する。
c.すべての前への分岐のリストを、スキップするマシンコード命令の数が小さい方から大きい方へソートする。
d.すべての前への分岐のリストをループする。
i.この分岐について、分岐が1の時間計算量を表すとして分岐が表せる最大時間計算量を求める。
ii.分岐の分岐先から開始してマシンコード分岐自体で終了するまですべてのマシンコード命令をループする。
a.この分岐が表す最大時間計算量がこのマシンコード命令に関する前に記憶された時間計算量よりも大きい場合、この分岐が表す最大時間計算量をこのマシンコード命令に関する新たな時間計算量として記憶する。
Computer time complexity is an important property of code and can be visualized by visually showing each block of code with a corresponding time complexity. The time complexity of all machine code instructions in the function is zero = O (1), 1 = O (n), 2 = O (n 2 ), 3 = O (n 3 ), etc. Can be determined by algorithm.
a. Initialize all machine code instructions so that the time complexity is zero.
b. Build a list of all conditional or unconditional branches that branch to multiple previous instructions.
c. Sort the list of all previous branches from the smallest number of machine code instructions to skip to the largest.
d. Loop through the list of all previous branches.
i. For this branch, the maximum time calculation amount that can be represented by the branch is calculated assuming that the branch represents a time calculation amount of one.
ii. Loop from all machine code instructions starting at the branch destination and ending at the machine code branch itself.
a. If the maximum time complexity represented by this branch is greater than the previously stored time computation associated with this machine code instruction, the maximum time computation represented by this branch is stored as a new time computation associated with this machine code instruction.

以下のアルゴリズムは、初期的な計算量(明細書の後に記載する疑似コード)を与えられると、ある分岐に関する最大時間計算量を決定できる。
a.前の命令に分岐するすべての条件分岐または無条件分岐のリストが与えられると、スキップするマシンコード命令の数が小さい方から大きい方へソートする。
b.当該分岐について、この分岐よりもスキップする命令の数が多いすべての分岐をループする。
i.当該分岐がこの反復で検討中の分岐内に完全に含まれる場合、
a.計算量は、現在の計算量とこの反復で検討中の分岐の計算量とのうち量が大きい方に等しい(このアルゴリズムを現在の計算量とともに再帰的に呼び出すことで決定される)。
c.計算量を返す。
The following algorithm can determine the maximum amount of time complexity for a branch given the initial complexity (pseudocode that follows the specification).
a. Given a list of all conditional or unconditional branches that branch to the previous instruction, sort from the smaller number of machine code instructions to skip.
b. For that branch, loop over all branches that have more instructions to skip than this branch.
i. If the branch is completely contained within the branch under consideration in this iteration,
a. The computational complexity is equal to the larger of the current computational complexity and the computational complexity of the branch under consideration in this iteration (determined by recursively calling this algorithm with the current computational complexity).
c. Returns the amount of computation.

アップブランチ法によるマーク付け時間計算量アルゴリズムのソースコードの一例を以下に示す。

Figure 2013518352
An example of the source code for the markup time complexity algorithm by the upbranch method is shown below.
Figure 2013518352

上に開示する手法を用いてマシンコードまたはアセンブリコードを視覚的に変換することにより、例えばプログラマ等のユーザによる見直しや理解がより容易となり、場合によっては速度向上を目的として修正もできる。これらの方法はあらゆる種類のコンパイラが作成するマシンコードにおいて使用でき、開示する方法はコンピュータに限定されず、計算能力を有するあらゆる種類のマシンと連動して使用できる。   By visually converting the machine code or assembly code using the method disclosed above, it becomes easier for a user such as a programmer to review and understand, and in some cases, it can be corrected for the purpose of speed improvement. These methods can be used in machine code created by any type of compiler, and the disclosed method is not limited to computers, and can be used in conjunction with any type of machine having computing power.

例示を目的とする非限定の実施の例に関して本明細書の技術を説明してきたが、本発明はこの開示に限定されるものではない。本発明は、特許請求の範囲によって定義され、本明細書が具体的に開示するか否かにかかわらずすべての対応する構成および等価な構成を対象とすることが意図される。   Although the technology herein has been described with reference to non-limiting examples for purposes of illustration, the present invention is not limited to this disclosure. The present invention is defined by the claims, and is intended to cover all corresponding and equivalent configurations, whether or not specifically disclosed herein.

Claims (25)

コンピュータのメモリデバイスに記憶された実行可能なプログラムに関連付けられた時間計算量を検出する方法であって、
(1)前記記憶されたプログラムをコンピュータプロセッサで自動的に解析して、そのコード内のループに基づいて前記プログラムの時間計算量を検出することと、
(2)前記記憶されたプログラムを前記プロセッサで自動的に解析して、前記プログラム内の前記コードのフローと分岐命令の分岐先とに基づいて前記プログラムの時間計算量を検出することと、
(1)で検出される時間計算量と(2)で検出される時間計算量との最小時間計算量を前記プログラムの時間計算量として自動的に決定することとを備える、方法。
A method for detecting a time complexity associated with an executable program stored in a memory device of a computer comprising:
(1) automatically analyzing the stored program by a computer processor and detecting a time calculation amount of the program based on a loop in the code;
(2) automatically analyzing the stored program by the processor and detecting a time calculation amount of the program based on a flow of the code in the program and a branch destination of a branch instruction;
And automatically determining a minimum time calculation amount of the time calculation amount detected in (1) and the time calculation amount detected in (2) as the time calculation amount of the program.
実行可能なマシンコードプログラムを記憶した非一時的でコンピュータ読み取り可能な記憶媒体であって、前記プログラムはマイクロプロセッサにステップのシーケンスを実行するように命令し、グラフィカルに表される前記プログラムは複数の機械命令行を備え、
グラフィカルな矢印が分岐機械命令行から分岐先の機械命令行まで伸びて、
a.下向きの分岐に対応する矢印は、マシンコードの左側に現れ、かつ、
分岐の元となる行に始まる横線であって、前記横線が前記横線からその分岐先の命令行まで下向きに進行する縦線に接続され、前記縦線が前記分岐の分岐先における、前記分岐先の命令を指す右向き矢印を有する横線に接続されるような横線を備え、
b.上向きの分岐に対応する矢印は、前記マシンコードの右側に現れ、
分岐の元となる行に始まる横線であって、前記横線が前記横線からその分岐先の命令行まで上向きに進行する縦線に接続され、前記縦線が前記分岐の分岐先における、前記分岐先の命令を指す左向き矢印を有する横線に接続されるような横線を備える、記憶媒体。
A non-transitory computer readable storage medium storing an executable machine code program, the program instructing a microprocessor to execute a sequence of steps, wherein the program represented graphically includes a plurality of programs With machine instruction lines,
A graphical arrow extends from the branch machine instruction line to the branch machine instruction line,
a. The arrow corresponding to the downward branch appears on the left side of the machine code, and
The horizontal line starting from the branch source line, wherein the horizontal line is connected to a vertical line that progresses downward from the horizontal line to the instruction line of the branch destination, and the vertical line is the branch destination at the branch destination of the branch With a horizontal line connected to a horizontal line with a right-pointing arrow pointing to
b. The arrow corresponding to the upward branch appears on the right side of the machine code,
A horizontal line starting from a branch source line, wherein the horizontal line is connected to a vertical line progressing upward from the horizontal line to the instruction line of the branch destination, and the vertical line is the branch destination at the branch destination of the branch A storage medium comprising a horizontal line connected to a horizontal line having a left-pointing arrow pointing to the instruction.
互いの比較的近くに下向きおよび上向きに分岐する交互配置の機械命令が存在する場合に、下向きおよび上向きの分岐の組み合わせが反時計回りのフローを有する、請求項2に記載の非一時的でコンピュータ読み取り可能な記憶媒体。   The non-transitory computer of claim 2, wherein the combination of downward and upward branches has a counterclockwise flow when there are alternating machine instructions that branch downward and upward relatively close to each other. A readable storage medium. 共通の分岐先を共有する分岐は、それらの縦線が互いに重なるように描かれ、共通の分岐先を共有しない分岐は、それらの縦線が重ならないように描かれる、請求項2に記載の非一時的でコンピュータ読み取り可能な記憶媒体。   The branches that share a common branch destination are drawn such that their vertical lines overlap each other, and the branches that do not share a common branch destination are drawn so that their vertical lines do not overlap. A non-transitory computer-readable storage medium. より近い分岐先を有する分岐は、より遠い分岐先を有する分岐よりも前記コードに近く位置する縦線を有する、請求項2に記載の非一時的でコンピュータ読み取り可能な記憶媒体。   The non-transitory computer-readable storage medium of claim 2, wherein a branch having a closer branch destination has a vertical line located closer to the code than a branch having a farther branch destination. 前記コード内の他の関数に結合する分岐は、命令の右に向かう単一の横方向の両矢印で表される、請求項2に記載の非一時的でコンピュータ読み取り可能な記憶媒体。   The non-transitory computer-readable storage medium of claim 2, wherein a branch coupled to another function in the code is represented by a single horizontal double arrow pointing to the right of the instruction. 戻り分岐は、命令の右に向かう単一の横方向の右向き矢印で表される、請求項2に記載の非一時的でコンピュータ読み取り可能な記憶媒体。   The non-transitory computer readable storage medium of claim 2, wherein the return branch is represented by a single lateral right arrow pointing to the right of the instruction. 実行可能なマシンコードプログラムを記憶した非一時的でコンピュータ読み取り可能な記憶媒体であって、前記プログラムはマイクロプロセッサにステップのシーケンスを実行するように命令し、グラフィカルに表される前記プログラムは複数の機械命令行を備え、
分岐機械命令の直後に続く機械命令はそれが分岐命令の分岐先でない限り1タブ字下げされる、非一時的でコンピュータ読み取り可能な記憶媒体。
A non-transitory computer readable storage medium storing an executable machine code program, the program instructing a microprocessor to execute a sequence of steps, wherein the program represented graphically includes a plurality of programs With machine instruction lines,
A non-transitory computer-readable storage medium in which a machine instruction immediately following a branch machine instruction is indented by one tab unless it is the branch destination of a branch instruction.
関数内の下向きの分岐に遭遇すると、その分岐先は字下げフリーズシンボルでマーク付けされる、請求項8に記載の非一時的でコンピュータ読み取り可能な記憶媒体。   9. The non-transitory computer readable storage medium of claim 8, wherein when a downward branch in a function is encountered, the branch destination is marked with an indentation freeze symbol. 関数内の上向きまたは下向きの分岐に遭遇すると、字下げフリーズシンボルに遭遇するか前記関数の終わりに到達するまですべての後続の行が字下げされる、請求項8に記載の非一時的でコンピュータ読み取り可能な記憶媒体。   9. The non-transitory computer of claim 8, wherein upon encountering an upward or downward branch in a function, all subsequent lines are indented until an indentation freeze symbol is encountered or the end of the function is reached. A readable storage medium. 実行可能なマシンコードプログラムを記憶した非一時的でコンピュータ読み取り可能な記憶媒体であって、前記プログラムはマイクロプロセッサにステップのシーケンスを実行するように命令し、グラフィカルに表される前記プログラムは複数の機械命令行を備え、
コードのブロックはそれぞれ対応する時間計算量に従って視覚的にマーク付けされ、前記時間計算量は前記プログラムのフロー中で前記ブロックが関連付けられた前記コード内のループの数を含む、非一時的でコンピュータ読み取り可能な記憶媒体。
A non-transitory computer readable storage medium storing an executable machine code program, the program instructing a microprocessor to execute a sequence of steps, wherein the program represented graphically includes a plurality of programs With machine instruction lines,
Each block of code is visually marked according to a corresponding time complexity, the time complexity including the number of loops in the code with which the block is associated in the program flow. A readable storage medium.
jを0以上の整数とするj個のループを有するブロックの時間計算量はオーダーnであると判断され、nをループが実行される任意の回数とするO(n)記法で視覚的にマーク付けされる、請求項11に記載の非一時的でコンピュータ読み取り可能な記憶媒体。 The time complexity of a block having j loops where j is an integer greater than or equal to 0 is determined to be order n, and visually expressed in O (n j ) notation where n is an arbitrary number of times the loop is executed. The non-transitory computer readable storage medium of claim 11, which is marked. 前記コードの各計算量のセクションは、視覚的な表示によって追加で視覚的にマーク付けされる、請求項11に記載の非一時的でコンピュータ読み取り可能な記憶媒体。   The non-transitory computer-readable storage medium of claim 11, wherein each computational complexity section of the code is additionally visually marked by a visual display. 前記視覚的な表示は強調表示色のグラデーションを含む、請求項13に記載の非一時的でコンピュータ読み取り可能な記憶媒体。   The non-transitory computer-readable storage medium of claim 13, wherein the visual indication includes a highlight color gradation. ある機械命令行の時間計算量が視覚的にマーク付けされ、前記時間計算量は前記機械命令行が内部に存在する連続したループの最大数を示す、請求項11に記載の非一時的でコンピュータ読み取り可能な記憶媒体。   The non-transitory computer of claim 11, wherein a time complexity of a machine instruction line is visually marked, and the time complexity indicates a maximum number of consecutive loops in which the machine instruction line exists. A readable storage medium. 実行可能なマシンコードプログラムの各命令行に関連付けられた時間計算量を検出する方法であって、各命令行はそれに対応する時間計算量に従って視覚的にマーク付けされ、
前記コードプログラムの個別の行に対応するノードが前記プログラムの制御フローに基づいて接続されるようにコードのフローグラフを作成することと、
閉路を形成する、前記コードのフローグラフ内の複数のノードのあらゆるグループに対応する複数の強連結部分グラフを識別することと、
前記複数の強連結部分グラフを、1つの集合の各強連結部分グラフが同じ根ノードを共有するように複数の集合にグループ分けすることと、
前記複数の集合のうちの1つの集合に含まれる根ノードが他の集合に含まれるか否かに基づいて前記複数の集合の有向グラフを構築することによって、集合グラフを作成することと、
親を持たないノードに到達するまで前記各集合の各ノードをノードを繰り返すことなく後向きにノード走査したときの最長の数を求めることによって、前記集合グラフにおける最長の経路を解析することと、
前記最長の経路の解析におけるノード走査の数を用いて、数が小さい方から大きい方への複数の集合のソート済みリストを作成することによって、複数の集合をソートすることと、
ノード走査の値に基づいて、p=0,1,2,・・・である時間計算量値pをコードの各命令行に割り当てることと、
前記マシンコードプログラムの各行について時間計算量の尺度O(n)を割り当てることとを備える、方法。
A method of detecting a time complexity associated with each instruction line of an executable machine code program, wherein each instruction line is visually marked according to a corresponding time complexity,
Creating a code flow graph such that nodes corresponding to individual lines of the code program are connected based on the control flow of the program;
Identifying a plurality of strongly connected subgraphs corresponding to any group of a plurality of nodes in the flow graph of the code forming a cycle;
Grouping the plurality of strongly connected subgraphs into a plurality of sets such that each strongly connected subgraph of a set shares the same root node;
Creating a set graph by constructing a directed graph of the plurality of sets based on whether a root node included in one set of the plurality of sets is included in another set; and
Analyzing the longest path in the set graph by finding the longest number when each node of each set is scanned backward without repeating the nodes until a node having no parent is reached;
Using the number of node scans in the analysis of the longest path to sort the sets by creating a sorted list of sets from the smallest to the largest;
Assigning a time complexity value p, where p = 0, 1, 2,... To each instruction line of code, based on the value of the node scan;
Assigning a time complexity measure O (n p ) for each line of the machine code program.
コンピュータのマシンコードの書式を設定してユーザによるプログラムの基礎的なフローの理解を高める装置であって、
ユーザが入力したソースコードを受け取り、対応するソースファイルを生成するエディタと、
前記ソースファイルを受け取り、マシンコードで構成されるオブジェクトファイルを生成するコンパイラと、
前記オブジェクトファイルを受け取り、前記オブジェクトファイルの状態を変更して、グラフィカルに表される前記プログラムが複数の機械命令行で構成されるように変更オブジェクトファイルを作成するマシンコードエディタであって、
グラフィカルな矢印が分岐機械命令行から分岐先の機械命令行まで伸びて、
分岐機械命令の直後に続く機械命令はそれが分岐命令の分岐先でない限り1タブ字下げされ、
コードのブロックはそれぞれ対応する時間計算量に従って視覚的にマーク付けされ、前記時間計算量は前記プログラムのフロー中で前記ブロックが関連付けられた前記コード内のループの数を含む、マシンコードエディタと、
前記変更オブジェクトファイルを受け取り、出力ファイルとして出力される実行ファイルを生成するリンカとを備える、装置。
A device that sets the machine code format of a computer to enhance the user's understanding of the basic flow of a program,
An editor that receives the source code entered by the user and generates a corresponding source file;
A compiler that receives the source file and generates an object file composed of machine code;
A machine code editor that receives the object file, changes the state of the object file, and creates a modified object file such that the graphically represented program is composed of a plurality of machine instruction lines;
A graphical arrow extends from the branch machine instruction line to the branch machine instruction line,
A machine instruction immediately following a branch machine instruction is indented by one tab unless it is the branch destination of a branch instruction,
A machine code editor, wherein each block of code is visually marked according to a corresponding time complexity, wherein the time complexity includes the number of loops in the code with which the block is associated in the flow of the program;
An apparatus comprising: a linker that receives the change object file and generates an execution file that is output as an output file.
コンピュータのマシンコードの書式を設定してユーザによるプログラムの基礎的なフローの理解を高める方法であって、
ユーザが入力したソースコードをエディタで受け取り、対応するソースファイルを生成することと、
前記エディタが生成した前記ソースファイルをコンパイラで受け取り、マシンコードで構成されるオブジェクトファイルを生成することと、
前記コンパイラが生成した前記オブジェクトファイルをマシンコードエディタで受け取り、前記オブジェクトファイルの状態を変更して、グラフィカルに表される前記プログラムが複数の機械命令行を備えるように変更オブジェクトファイルを作成することであって、
グラフィカルな矢印が分岐機械命令行から分岐先の機械命令行まで伸びて、
分岐機械命令の直後に続く機械命令はそれが分岐命令の分岐先でない限り1タブ字下げされ、
コードのブロックはそれぞれ対応する時間計算量に従って視覚的にマーク付けされ、前記時間計算量は前記プログラムのフロー中で前記ブロックが関連付けられた前記コード内のループの数を含むことと、
前記マシンコードエディタが生成した前記変更オブジェクトファイルをリンカで受け取り、出力ファイルとして出力される実行ファイルを生成することとを備える、方法。
A method of formatting the machine code of a computer to enhance the user's understanding of the basic program flow,
Receiving the source code entered by the user in the editor and generating the corresponding source file;
Receiving the source file generated by the editor with a compiler and generating an object file composed of machine code;
The object file generated by the compiler is received by a machine code editor, the state of the object file is changed, and the changed object file is created so that the graphically represented program includes a plurality of machine instruction lines. There,
A graphical arrow extends from the branch machine instruction line to the branch machine instruction line,
A machine instruction immediately following a branch machine instruction is indented by one tab unless it is the branch destination of a branch instruction,
Each block of code is visually marked according to a corresponding time complexity, the time complexity comprising the number of loops in the code with which the block is associated in the flow of the program;
Receiving the modified object file generated by the machine code editor with a linker and generating an executable file to be output as an output file.
コードを記憶する非一時的なメモリデバイスにアクセスするコンピュータプロセッサによって実行され、コードを動的に実行する必要なしにコードの時間計算量を推定するコンピュータの動作方法であって、
前記コードの複数の分岐を決定するステップと、
前記複数の分岐のうち第1の決定された分岐が、前記複数の分岐のうちの、前記第1の分岐よりもスキップする命令の数が多い他の決定された分岐内に完全に含まれるか否かを確認するステップと、
前記確認ステップにおいて前記第1の分岐が完全に含まれると確認された場合、前記第1の分岐に関連付けられた増加した時間計算量を示すステップと、
前記コードの最大時間計算量を推定するために、前記コード内の前記複数の分岐のうち複数のさらに決定された分岐について、上述のステップの少なくとも一部を再帰的に実行するステップとを前記コンピュータプロセッサが実行する、方法。
A computer operating method that is executed by a computer processor accessing a non-transitory memory device that stores code and that estimates the time complexity of the code without the need to dynamically execute the code,
Determining a plurality of branches of the code;
Whether the first determined branch of the plurality of branches is completely included in other determined branches that have more instructions to skip than the first branch of the plurality of branches A step to check whether or not,
If the confirmation step confirms that the first branch is completely included, indicating an increased amount of time complexity associated with the first branch;
Recursively executing at least some of the steps described above for a plurality of further determined branches of the plurality of branches in the code to estimate a maximum time complexity of the code. The method that the processor performs.
前記コード内の各決定された分岐について、前記実行ステップが再帰的に実行される、請求項19に記載の方法。   The method of claim 19, wherein for each determined branch in the code, the execution step is performed recursively. 前記複数の分岐は複数の命令を含み、前記実行ステップは、前記複数の命令に関連付けられた、前に割り当てられた時間計算量の値と、前記複数の分岐に関連付けられた前記示された時間計算量とを比較して、前記複数の命令のそれぞれについて時間計算量を割り当てる、請求項19に記載の方法。   The plurality of branches includes a plurality of instructions, and the executing step includes a previously allocated time complexity value associated with the plurality of instructions and the indicated time associated with the plurality of branches. 20. The method of claim 19, wherein a time complexity is assigned for each of the plurality of instructions by comparing with a complexity. 前記決定ステップは、前記コードの順序付き静的リストにおいて、前記複数の決定された分岐が前記順序付きリストの複数の前の部分に分岐するか否かを判定することを備える、請求項19に記載の方法。   The determining step comprises determining, in the ordered static list of codes, whether the plurality of determined branches branch to a plurality of previous portions of the ordered list. The method described. 前記決定ステップは、所定の方向に分岐する前記コード内の複数の分岐を決定する、請求項19に記載の方法。   The method of claim 19, wherein the determining step determines a plurality of branches in the code that branch in a predetermined direction. 前記所定の方向は上向きを含む、請求項23に記載の方法。   24. The method of claim 23, wherein the predetermined direction includes upward. 人間によって知覚可能な表示を提供するために、前記推定される最大時間計算量を表示装置上に表示することをさらに含む、請求項19に記載の方法。   20. The method of claim 19, further comprising displaying the estimated maximum time complexity on a display device to provide a human perceptible display.
JP2012551300A 2010-01-29 2011-01-28 How to improve understanding of time complexity and flow in code Active JP5481571B2 (en)

Applications Claiming Priority (5)

Application Number Priority Date Filing Date Title
US29947710P 2010-01-29 2010-01-29
US61/299,477 2010-01-29
US12/872,200 2010-08-31
US12/872,200 US8516467B2 (en) 2010-01-29 2010-08-31 Method and apparatus for enhancing comprehension of code time complexity and flow
PCT/US2011/022844 WO2011094482A2 (en) 2010-01-29 2011-01-28 Method and apparatus for enhancing comprehension of code time complexity and flow

Publications (2)

Publication Number Publication Date
JP2013518352A true JP2013518352A (en) 2013-05-20
JP5481571B2 JP5481571B2 (en) 2014-04-23

Family

ID=44320132

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2012551300A Active JP5481571B2 (en) 2010-01-29 2011-01-28 How to improve understanding of time complexity and flow in code

Country Status (4)

Country Link
US (1) US8516467B2 (en)
EP (1) EP2529303A4 (en)
JP (1) JP5481571B2 (en)
WO (1) WO2011094482A2 (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8806464B2 (en) * 2012-04-26 2014-08-12 Hewlett-Packard Development Company, L.P. Process flow optimized directed graph traversal
WO2014080354A2 (en) * 2012-11-21 2014-05-30 Varun Aggarwal Reporting scores on computer programming ability under a taxonomy of test cases
US9274797B2 (en) * 2012-12-19 2016-03-01 International Business Machines Corporation Computer processor with instruction for execution based on available instruction sets
EP2958044B1 (en) * 2014-06-20 2019-09-18 Secure-IC SAS A computer implemented method and a system for controlling dynamically the execution of a code
US10846196B1 (en) 2017-06-09 2020-11-24 Azul Systems, Inc. Code optimization for connected managed runtime environments
CN111124424B (en) * 2019-12-27 2023-09-19 珠海金山数字网络科技有限公司 Method and device for analyzing algorithm complexity

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11212823A (en) * 1998-01-23 1999-08-06 Fujitsu Ltd Execution analysis method and device, and storage medium storing execution analysis program
US20080288929A1 (en) * 2007-05-16 2008-11-20 International Business Machines Corporation Method and apparatus for run-time statistics dependent program execution using source-coding
US20080320457A1 (en) * 2007-06-19 2008-12-25 Microsoft Corporation Intermediate Code Metrics
US20090144698A1 (en) * 2007-11-29 2009-06-04 Microsoft Corporation Prioritizing quality improvements to source code

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4315315A (en) * 1971-03-09 1982-02-09 The Johns Hopkins University Graphical automatic programming
US6651244B1 (en) * 1999-07-26 2003-11-18 Cisco Technology, Inc. System and method for determining program complexity
JP2003256203A (en) * 2002-03-01 2003-09-10 Mitsubishi Electric Corp System and method for developing automatic machine application program, program for executing the method and storage medium stored with the program
US7085917B2 (en) * 2003-05-12 2006-08-01 International Business Machines Corporation Multi-pipe dispatch and execution of complex instructions in a superscalar processor
US7937694B2 (en) * 2004-02-13 2011-05-03 Microsoft Corporation Fast flattening of nested streams
US7493609B2 (en) * 2004-08-30 2009-02-17 International Business Machines Corporation Method and apparatus for automatic second-order predictive commoning
US20070044075A1 (en) * 2005-08-17 2007-02-22 Maarten Koning Method for analysis of source code and display of corresponding output through a marking scheme
US7805705B2 (en) * 2006-08-04 2010-09-28 Apple Inc. Graphically depicting program code depth
GB2443277B (en) * 2006-10-24 2011-05-18 Advanced Risc Mach Ltd Performing diagnostics operations upon an asymmetric multiprocessor apparatus
US7949422B1 (en) * 2007-06-22 2011-05-24 Vermont Machine Tool Corporation Machine tool control system
KR100945247B1 (en) * 2007-10-04 2010-03-03 한국전자통신연구원 The method and apparatus for analyzing exploit code in non-executable file using virtual environment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11212823A (en) * 1998-01-23 1999-08-06 Fujitsu Ltd Execution analysis method and device, and storage medium storing execution analysis program
US20080288929A1 (en) * 2007-05-16 2008-11-20 International Business Machines Corporation Method and apparatus for run-time statistics dependent program execution using source-coding
US20080320457A1 (en) * 2007-06-19 2008-12-25 Microsoft Corporation Intermediate Code Metrics
US20090144698A1 (en) * 2007-11-29 2009-06-04 Microsoft Corporation Prioritizing quality improvements to source code

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
CSNJ200910077175; 辰己 丈夫: 'WWWで利用できる計算次数測定システム' 第58回(平成11年前期)全国大会講演論文集(1) , 19990309, pp.1-355-356, 社団法人情報処理学会 *
JPN6014004028; Jan Gustafsson et al.: 'A Tool for Automatic Flow Analysis of C-programs for WCET Calculation' Proceedings of the Eighth IEEE International Workshop on Object-Oriented Real-Time Dependable System , 20030115, pp.106-112, IEEE *
JPN6014004030; 辰己 丈夫: 'WWWで利用できる計算次数測定システム' 第58回(平成11年前期)全国大会講演論文集(1) , 19990309, pp.1-355-356, 社団法人情報処理学会 *
JPN6014004033; Keiji Yamamoto et al.: 'Portable Execution Time Analysis Method' Proceedings of the 12th IEEE International Conference on Embedded and Real-Time Computing Systems an , 20060816, pp.267-270, IEEE *
JPN7014000384; Sumit Gulwani et al.: 'SPEED:Precise and Efficient Static Estimation of Program Computational Complexity' Proceedings of the 36th annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages ( , 20090121, pp.127-139, ACM *

Also Published As

Publication number Publication date
WO2011094482A2 (en) 2011-08-04
WO2011094482A3 (en) 2011-11-17
EP2529303A4 (en) 2014-08-06
JP5481571B2 (en) 2014-04-23
US20110191760A1 (en) 2011-08-04
US8516467B2 (en) 2013-08-20
EP2529303A2 (en) 2012-12-05

Similar Documents

Publication Publication Date Title
US8806464B2 (en) Process flow optimized directed graph traversal
JP3685717B2 (en) Determining the destination of a dynamic branch
JP5481571B2 (en) How to improve understanding of time complexity and flow in code
TWI493464B (en) System and method for late bound programmatic assistance
US7904892B2 (en) Systems and methods for identifying and displaying dependencies
CN102207901B (en) Method and apparatus for analyzing software
US7805705B2 (en) Graphically depicting program code depth
US8286135B2 (en) Performance visualization including hierarchical display of performance data
US20110271258A1 (en) Software Development Tool
US20110271250A1 (en) Software Development Tool
US8839210B2 (en) Program performance analysis apparatus
US20110214108A1 (en) Architecture, system and method for generating visualizations from running executable code
CN110825386B (en) Code compiling method and device and storage medium
JP2015043198A (en) Analysis system, analysis method and analysis program
JP2017004281A (en) Compile program and compile method
US20100275188A1 (en) Intermediate Language Representation and Modification
Angerer et al. Configuration-aware change impact analysis (t)
KR102013582B1 (en) Apparatus and method for detecting error and determining corresponding position in source code of mixed mode application program source code thereof
JP2021533485A (en) Control flow systems, non-transient readable media, and methods for improving program functionality
US6360360B1 (en) Object-oriented compiler mechanism for automatically selecting among multiple implementations of objects
JP5048949B2 (en) Software tools including asynchronous program flow modeling
US8589898B2 (en) Method and apparatus for analyzing software including a calibrated value
CN113867704A (en) Code test processing method and device, electronic equipment and storage medium
JP2008276735A (en) Program code converter and program code conversion method
US20090064092A1 (en) Visual programming language optimization

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20130924

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20131125

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20140203

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20140217

R150 Certificate of patent or registration of utility model

Ref document number: 5481571

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250