JP5164112B2 - Source code conversion method, server system, and server program - Google Patents

Source code conversion method, server system, and server program Download PDF

Info

Publication number
JP5164112B2
JP5164112B2 JP2008277002A JP2008277002A JP5164112B2 JP 5164112 B2 JP5164112 B2 JP 5164112B2 JP 2008277002 A JP2008277002 A JP 2008277002A JP 2008277002 A JP2008277002 A JP 2008277002A JP 5164112 B2 JP5164112 B2 JP 5164112B2
Authority
JP
Japan
Prior art keywords
string
character string
bytebuffer
type variable
source code
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.)
Expired - Fee Related
Application number
JP2008277002A
Other languages
Japanese (ja)
Other versions
JP2010108076A (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.)
International Business Machines Corp
Original Assignee
International Business Machines Corp
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 International Business Machines Corp filed Critical International Business Machines Corp
Priority to JP2008277002A priority Critical patent/JP5164112B2/en
Publication of JP2010108076A publication Critical patent/JP2010108076A/en
Application granted granted Critical
Publication of JP5164112B2 publication Critical patent/JP5164112B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、ソースコード変換方法に関する。特に、HTTPリクエストを文字列型変数に変換する際のオーバーヘッドを削減したソースコードに変換する方法に関する。   The present invention relates to a source code conversion method. In particular, the present invention relates to a method of converting an HTTP request into a source code with reduced overhead when converting into a character string type variable.

従来、文字列を表現するために、Groovy等のスクリプト開発環境、または、Java(登録商標)、およびC#(登録商標)等のいわゆる高級言語を用いるプログラム開発環境ではStringクラスが用意されている。このStringクラスには、以下の2つの特徴がある。
特徴1)Stringクラスは、多言語をサポートするために、文字列の表現にUnicode文字を用い、また、文字コードのエンコーディングにUTF−16を用いる。
特徴2)Stringクラスは、Immutableオブジェクトを生成するクラスである。Immutableとは、不変という意味であり、Immutable(不変)オブジェクトは、生成後に状態を変更することはできない。なお、以降、Java、C#については(登録商標)の注記を省略する。
Conventionally, in order to express a character string, a String class is prepared in a script development environment such as Groovy or a program development environment using a so-called high-level language such as Java (registered trademark) and C # (registered trademark). . This String class has the following two features.
Feature 1) The String class uses Unicode characters for character string representation and UTF-16 for character code encoding in order to support multiple languages.
Characteristic 2) The String class is a class that generates an Immutable object. Immutable means immutable, and an Immutable object cannot change state after generation. In the following, (registered trademark) notes are omitted for Java and C #.

Stringクラスは、JavaやC#で書かれたプログラムによって構築されるWebサーバにて、クライアントから受信したHTTPリクエストを解析するために用いることができる。具体的には、HTTPプロトコルに基づいてクライアントから受信したHTTPリクエストを、JavaやC#で書かれたプログラムによって構築されるWebサーバが、受信したHTTPリクエストをStringクラスに変換し、メッセージを解析する。図11を用いて、Javaで書かれたWebサーバにおける、HTTPリクエストをStringクラスに変換する処理について説明する。   The String class can be used to analyze an HTTP request received from a client on a Web server constructed by a program written in Java or C #. Specifically, a Web server constructed by a program written in Java or C # converts an HTTP request received from a client based on the HTTP protocol into a String class and analyzes the message . Processing for converting an HTTP request into a String class in a Web server written in Java will be described with reference to FIG.

図11は、従来技術に係る、HTTPリクエストのStringクラスへの変換処理を示す概要図である。白抜き矢印は、HTTPリクエストの流れ、および処理の流れを表している。この変換処理は、変換処理を備えたWebサーバが、HTTPリクエストを受信したことに応じて、処理が開始する。まず、クライアントから受信したHTTPリクエストは、一般的に、kernelからByteBufferオブジェクトbb1に読み込まれる。ByteBufferオブジェクトbb1は、ByteBufferクラス(Java言語においては、java.nio.ByteBuffer)から変数名bbとして生成されたByteBufferオブジェクトである。HTTPリクエストは文字列をパーセントエンコーディングしたUTF−8であるので、ByteBufferオブジェクトbb1に読み込まれたHTTPリクエストはUTF−8であり、図11に示すように1文字につき1バイト消費する。図11において、便宜上、ByteBufferオブジェクトbb1に読み込まれたHTTPリクエストはUTF−8の文字コードではなく、文字で表わす。   FIG. 11 is a schematic diagram showing a process of converting an HTTP request into a String class according to the prior art. White arrows represent the flow of HTTP requests and the flow of processing. This conversion process starts when the Web server equipped with the conversion process receives an HTTP request. First, an HTTP request received from a client is generally read from kernel to a ByteBuffer object bb1. The ByteBuffer object bb1 is a ByteBuffer object generated as a variable name bb from the ByteBuffer class (java.nio.ByteBuffer in the Java language). Since the HTTP request is UTF-8 in which a character string is percent-encoded, the HTTP request read into the ByteBuffer object bb1 is UTF-8 and consumes 1 byte per character as shown in FIG. In FIG. 11, for the sake of convenience, the HTTP request read into the ByteBuffer object bb1 is represented by characters instead of the UTF-8 character code.

次に、ByteBufferオブジェクトbb1に格納されたHTTPリクエストは、UTF−8にエンコーディングされたbyte[]配列として、Stringクラスのコンストラクタに、渡される。このコンストラクタは、String(bb.array(),“UTF-8”)で表される。コンストラクタ内で、byte[]配列のHTTPリクエストは、UTF−8からUTF−16へ変換される。UTF−16へ変換されたHTTPリクエストはコピーされ、このコピーをchar[]配列4に変換しStringオブジェクトs2に格納される。Stringオブジェクトs2は、Stringクラス(Java言語においては、java.lang.String)から変数名sとして生成されたStringオブジェクトである。char[]配列4はUTF−16であるので、図11に示すように1文字につき2バイト消費する。このようにして、Webサーバが受信したHTTPリクエストは、Stringクラスに変換される。   Next, the HTTP request stored in the ByteBuffer object bb1 is passed to the constructor of the String class as a byte [] array encoded in UTF-8. This constructor is represented by String (bb.array (), “UTF-8”). In the constructor, the HTTP request of byte [] array is converted from UTF-8 to UTF-16. The HTTP request converted to UTF-16 is copied, and this copy is converted into a char [] array 4 and stored in the String object s2. The String object s2 is a String object generated as a variable name s from the String class (java.lang.String in the Java language). Since the char [] array 4 is UTF-16, 2 bytes are consumed per character as shown in FIG. In this way, the HTTP request received by the Web server is converted into the String class.

ところで、JSP(Java Server Pages)等により動的コンテンツを生成する際の処理において、多言語に対応するために、JSP内のテキストはUTF−16に変換されている。そのため、HTTPリクエストのStringクラスへの変換処理において、HTTPリクエストをUTF−8からUTF−16へ変換するのと同じように、JSPの実行に際して、JSP内のテキストをUTF−16からUTF−8へ変換している。JSPの実行に際して、JSP内のテキストをUTF−16からUTF−8へ変換することはオーバーヘッドとなっており、そのオーバーヘッドを削減する方法が開示されている(特許文献1)。   By the way, in the processing when generating dynamic content by JSP (Java Server Pages) or the like, the text in the JSP is converted to UTF-16 in order to support multiple languages. Therefore, in the process of converting the HTTP request to the String class, the text in the JSP is changed from UTF-16 to UTF-8 when executing the JSP in the same way as converting the HTTP request from UTF-8 to UTF-16. It has been converted. When executing a JSP, converting the text in the JSP from UTF-16 to UTF-8 is an overhead, and a method for reducing the overhead is disclosed (Patent Document 1).

特開2005−332146号公報JP 2005-332146 A

上述したHTTPリクエストのStringクラスへの変換処理の中には、以下の3つのオーバーヘッドが存在するという課題がある。   There is a problem that the following three overheads exist in the conversion process of the HTTP request to the String class described above.

課題a)ByteBufferオブジェクトに格納されているHTTPリクエストのコピーによる、オーバーヘッドがある。Stringクラスから生成されるオブジェクトが「不変」であることを確実に保証するため、ByteBufferオブジェクトbbに格納されたHTTPリクエストは常に、コピーされ、コピーされたHTTPリクエストがchar[]配列に変換されてStringオブジェクトsに格納されるからである。   Problem a) There is an overhead due to a copy of the HTTP request stored in the ByteBuffer object. The HTTP request stored in the ByteBuffer object bb is always copied to ensure that the object generated from the String class is “immutable”, and the copied HTTP request is converted to a char [] array. This is because it is stored in the String object s.

課題b)HTTPリクエストのUTF−8からUTF−16へのエンコード変換による、オーバーヘッドがある。HTTPリクエストは文字列をパーセントエンコーディングしたUTF−8である。一方、Stringクラスは多言語をサポートするために、文字コードのエンコーディングにUTF−16を用いる。そのため、HTTPリクエストのUTF−8からUTF−16へのエンコード変換が必要であるからである。   Problem b) There is an overhead due to the encoding conversion of the HTTP request from UTF-8 to UTF-16. The HTTP request is UTF-8 in which a character string is percent-encoded. On the other hand, the String class uses UTF-16 for character code encoding in order to support multiple languages. Therefore, it is necessary to convert the encoding of the HTTP request from UTF-8 to UTF-16.

課題c)Stringオブジェクトにおいて文字列をUTF−16として保持することによる、オーバーヘッドがある。HTTPリクエストの多くはASCII文字(0x00−0x7f)であるため、Stringオブジェクトに文字列をUTF−16として格納することは、不要にメモリ消費する場合が多いためである。   Problem c) There is overhead due to holding a string as UTF-16 in a String object. Since many HTTP requests are ASCII characters (0x00-0x7f), storing a character string as UTF-16 in a String object often consumes memory unnecessarily.

HTTPリクエストのStringクラスへの変換処理には、これら3つのオーバーヘッドが存在する。特許文献1には、JSP内のテキストをUTF−16からUTF−8へ変換することによるオーバーヘッドを削減する方法が記載されている。しかし、それでは、HTTPリクエストのStringクラスへの変換処理における、課題b)のオーバーヘッドしか削減することができない。   These three overheads exist in the process of converting the HTTP request into the String class. Patent Document 1 describes a method of reducing overhead by converting text in JSP from UTF-16 to UTF-8. However, this can reduce only the overhead of the problem b) in the process of converting the HTTP request into the String class.

本発明は、ソースコードに対して、HTTPリクエストのStringクラスへの変換処理におけるオーバーヘッドを削減したソースコードに自動変換する方法、サーバシステム、およびサーバプログラムを提供することを目的とする。   An object of the present invention is to provide a method, a server system, and a server program for automatically converting source code into source code with reduced overhead in conversion processing of an HTTP request into a String class.

本発明は、上記課題に鑑み、以下のような解決手段を提供する。なお、本願明細書に記載の用語「サーバ装置」とは、文字列の受信に応答して、文字列に記述されている情報に応じて処理を行う装置であって、例えば、文字列がHTTPリスエスである場合には、サーバ装置はWebサーバである。   In view of the above problems, the present invention provides the following solutions. The term “server device” described in the present specification is a device that performs processing according to information described in a character string in response to reception of the character string. For example, the character string is HTTP. In the case of a request, the server device is a Web server.

本発明は、プログラムの文字列操作におけるオーバーヘッドを削減するために、ソースコードを変換する方法を提供する。具体的には、文字列を直接的に保持する文字列型変数を、文字列を格納するバッファを参照することにより、間接的に文字列を保持参照文字列型変数に型変換したソースコードに変換する方法、およびサーバシステム、およびサーバプログラムを提供する。   The present invention provides a method for converting source code to reduce overhead in character string manipulation of a program. Specifically, a string type variable that directly holds a character string is referred to a buffer that stores the character string, and the character string is indirectly converted to a reference character string type variable that is converted into a reference code. A conversion method, a server system, and a server program are provided.

本発明の1つの態様によると、コンピュータを用いて、プログラムのソースコードをコード変換する方法を提供する。コード変換する方法は、文字列を保持する文字列型変数を特定するステップと、特定した前記文字列型変数を、前記文字列を格納するバッファへの参照を保持する参照文字列型変数に型変換するステップと、前記文字列型変数を前記参照文字列型変数に型変換した前記ソースコードを格納するステップと、を含む。   According to one aspect of the present invention, a method for transcoding a program source code using a computer is provided. The code conversion method includes a step of identifying a character string type variable that holds a character string, and types the identified character string type variable into a reference character string type variable that holds a reference to a buffer that stores the character string. And a step of storing the source code obtained by converting the character string type variable into the reference character string type variable.

本態様によると、文字列を保持する文字列型変数は、文字列を格納するバッファへの参照を保持する参照文字列型変数に型変換したソースコードに変換される。それにより、文字列型変数は、文字列に変わって参照(ポインタ)を保持することにより、文字列を格納するバッファから文字列型変数に文字列をコピーすることが無くなる。その結果、オーバーヘッドが削減される。   According to this aspect, a character string type variable that holds a character string is converted into a source code that is type-converted to a reference character string type variable that holds a reference to a buffer that stores the character string. As a result, the character string type variable is replaced with the character string and holds a reference (pointer), so that the character string is not copied from the buffer storing the character string to the character string type variable. As a result, overhead is reduced.

ここで、文字列型変数とは、文字を保持する変数であり、例えば、Java言語においてはjava.lang.Stringクラス、C#言語ではStringクラスである。バッファとは、プログラムが実行されている際に、データ、ここでは文字列を一時的に保存しておく記憶領域をいう。   Here, the character string type variable is a variable for holding a character, for example, a java.lang.String class in the Java language and a String class in the C # language. The buffer is a storage area for temporarily storing data, here a character string, when a program is executed.

また、本態様は、型変換するステップが、更に、バッファが「不変(Immutable)」であるか否かを判定するステップを含む。それにより、文字列型変数が「不変」であるという特徴を、型変換した参照文字列型変数も持つことができる。その結果、文字列型変数に文字列を保持しなくとも、「不変」という特徴は保たれ、オーバーヘッドが削減される。   In the aspect, the step of performing the type conversion further includes a step of determining whether or not the buffer is “Immutable”. Thereby, it is possible to have a reference character string type variable obtained by converting the character of the character string type variable being “invariant”. As a result, even if the character string is not stored in the character string type variable, the feature of “invariant” is maintained, and overhead is reduced.

本発明は、既存の技術と組み合わせることができ、そのように組み合わせた技術もまた、本発明の技術範囲に含まれる。更に、本発明の技法は、ソースコード変換方法の諸段階を、FPGA(現場でプログラム可能なゲートアレイ)、ASIC(特定用途向け集積回路)、これらと同等のハードウェアロジック素子、プログラム可能な集積回路、またはこれらの組み合わせが記憶し得るプログラムの形態、すなわちプログラム製品として提供し得る。具体的には、データ入出力、データバス、メモリバス、システムバス等を備えるカスタムLSI(大規模集積回路)の形態として、本発明に係るソースコード変換方法の実行手段、デバイス、組み込み装置等を提供でき、そのように集積回路に記憶されたプログラム製品の形態も、本発明の技術範囲に含まれる。   The present invention can be combined with existing technologies, and such combined technologies are also included in the technical scope of the present invention. Furthermore, the technique of the present invention provides the steps of the source code conversion method, including FPGA (field programmable gate array), ASIC (application specific integrated circuit), equivalent hardware logic elements, programmable integration. It may be provided as a program form that can be stored in the circuit or a combination thereof, that is, as a program product. Specifically, as a form of a custom LSI (Large Scale Integrated Circuit) having a data input / output, a data bus, a memory bus, a system bus, etc., an execution means, device, embedded device, etc. of the source code conversion method according to the present invention are provided. The form of a program product that can be provided and stored in such an integrated circuit is also within the scope of the present invention.

本発明によれば、ソースコードに対して、HTTPリクエストのStringクラスへの変換処理におけるオーバーヘッドを削減したソースコードに自動変換する方法、サーバシステム、およびサーバプログラムを提供することができる。また、オーバーヘッドを削減したソースコードにより、HTTPリクエストのStringクラスへの変換処理に要する時間を短縮することができる。   According to the present invention, it is possible to provide a method, a server system, and a server program for automatically converting source code into source code with reduced overhead in the process of converting an HTTP request into a String class. Moreover, the time required for the conversion process of the HTTP request to the String class can be shortened by the source code with reduced overhead.

以下、本発明の実施形態について図を参照しながら説明する。これらはあくまでも一例であって、本発明の技術的範囲はこれらに限られるものではない。以下、文字列がHTTPリクエストである場合について説明する。なお、文字列は、HTTPリクエストに限らず、文字列型変数に変換されるものであって、US−ASCII文字の文字列であればよい。   Hereinafter, embodiments of the present invention will be described with reference to the drawings. These are merely examples, and the technical scope of the present invention is not limited thereto. Hereinafter, a case where the character string is an HTTP request will be described. Note that the character string is not limited to an HTTP request, but is converted to a character string type variable, and may be a character string of US-ASCII characters.

本発明の一実施形態においては、ユーザが書いた任意のプログラム中に記述された、HTTPリクエストをStringクラスに変換する処理(以下、簡略化のため変換処理とする)記述を含むソースコードを、本発明における課題であるa)、b)、c)、3つのオーバーヘッドを削減したソースコードに自動的に変換する。具体的には、変換処理における3つのオーバーヘッドを削減したソースコードに変換するために、String(java.nio.ByteBuffer bb)を新設したStringクラスのコンストラクタを用いたソースコードに変換可能な条件を満たしているか判断する。判断した結果、条件を満たしている場合には、プログラマが作成したプログラムのソースコードに対して、String(java.nio.ByteBuffer bb)を新設したStringクラス(参照文字列型変数)のコンストラクタを用いたソースコードに変換する。   In one embodiment of the present invention, source code including a description of processing for converting an HTTP request into a String class (hereinafter referred to as conversion processing for simplification) described in an arbitrary program written by a user, A), b), and c), which are problems in the present invention, are automatically converted into source code with three overheads reduced. Specifically, in order to convert the source code to reduce the three overheads in the conversion process, satisfy the conditions that can be converted to the source code using the new constructor of the String class String (java.nio.ByteBuffer bb) Judgment is made. If the condition is satisfied as a result of the determination, use the constructor of the String class (reference string type variable) that newly created String (java.nio.ByteBuffer bb) for the source code of the program created by the programmer. Convert to the source code that was.

最初に、String(java.nio.ByteBuffer bb)について説明する。String(java.nio.ByteBuffer bb)は、Stringクラスのコンストラクタに新設される。このStringクラスは、従来のStringクラスとは異なり、次のような特徴を持つ。なお、以下区別するために、コンストラクタにString(java.nio.ByteBuffer bb)が新設されたコンストラクタを、String(ByteBuffer)コンストラクタとする。   First, String (java.nio.ByteBuffer bb) will be described. String (java.nio.ByteBuffer bb) is newly added to the constructor of the String class. Unlike the conventional String class, this String class has the following characteristics. In order to distinguish the following, the constructor in which String (java.nio.ByteBuffer bb) is newly established in the constructor is called the String (ByteBuffer) constructor.

特徴1)ByteBufferオブジェクトbb(バッファ)にASCII文字のみが含まれている場合は、Stringオブジェクトsの文字列保持を、Stringオブジェクトs内に文字列を保持せず、ByteBufferオブジェクトbbへのポインタを保持することで実現する。
特徴2)StringオブジェクトsがByteBufferオブジェクトbbへのポインタを保持している場合、Stringクラスのメソッドを経由して文字を取り出す際には、ポインタが指すByteBufferオブジェクトbbから必要な8ビット文字を読み出して、上位8ビットに00を付加してcharに変換して値を返す。詳細な処理については、後述する。
特徴3)StringオブジェクトsがByteBufferオブジェクトbbへのポインタを保持している場合、ASCII文字について保持している文字列とByteBufferオブジェクトbbに保持している文字列とは、いずれもUTF−8であって、同一エンコーディングである。そのため、従来、Stringオブジェクトsから文字列をbyte[]配列として取得する際に行っていた、String.getBytes(“UTF-8”)を用いたエンコーディング変換は行わない。
Characteristic 1) When only ASCII characters are included in the ByteBuffer object bb (buffer), hold the string of the String object s, hold the pointer to the ByteBuffer object bb without holding the string in the String object s It is realized by doing.
Feature 2) When the String object s holds a pointer to the ByteBuffer object bb, when retrieving the character via the String class method, the necessary 8-bit character is read from the ByteBuffer object bb pointed to by the pointer. , 00 is added to the upper 8 bits, converted to char, and a value is returned. Detailed processing will be described later.
Feature 3) When String object s holds a pointer to ByteBuffer object bb, the character string held for ASCII characters and the character string held in ByteBuffer object bb are both UTF-8. Are the same encoding. For this reason, encoding conversion using String.getBytes (“UTF-8”), which has been conventionally performed when acquiring a character string from a String object s as a byte [] array, is not performed.

HTTPリクエストは文字列をパーセントエンコーディングしたUTF−8であるので、ByteBufferオブジェクトbbに格納されたHTTPリクエストは必ずUS−ASCII文字である。その事実を利用して、String(ByteBuffer)コンストラクタを用いることによって、Stringオブジェクトsを生成する際のUTF−8からUTF−16への変換を無くすことができ、本発明における課題であるb)のオーバーヘッドを削減できる。また、String(ByteBuffer)コンストラクタを用いることによって、入力されたByteBufferオブジェクトbbへのポインタをStringオブジェクトsが保持することができる。その結果、UTF−16を用いて文字列を保存することを無くすことができるので、課題c)で挙げたオーバーヘッドが削減できる。   Since the HTTP request is UTF-8 in which a character string is percent-encoded, the HTTP request stored in the ByteBuffer object bb is always a US-ASCII character. By utilizing the fact, by using the String (ByteBuffer) constructor, conversion from UTF-8 to UTF-16 when generating String objects s can be eliminated, and the problem of b) of the present invention is Overhead can be reduced. In addition, by using the String (ByteBuffer) constructor, the String object s can hold a pointer to the input ByteBuffer object bb. As a result, it is possible to eliminate storing character strings using UTF-16, so that the overhead mentioned in the problem c) can be reduced.

上述したString(ByteBuffer)コンストラクタを用いることができるソースコードには条件がある。そのため、プログラマが作成したソースコードが、String(ByteBuffer)コンストラクタを用いたソースコードに変換可能であるか確認する必要がある。変更可能であるためには、ByteBufferオブジェクトbbに、HTTPリクエストが書き込まれた後、ByteBufferオブジェクトbbの内容が変更されないこと、すなわち、ByteBufferオブジェクトbbが「不変」であることが条件である。この条件を満たすか否かは、以下の2つの方法で行うことができる。   There is a condition in the source code that can use the String (ByteBuffer) constructor described above. Therefore, it is necessary to check whether the source code created by the programmer can be converted into source code using the String (ByteBuffer) constructor. In order to be able to change, the condition is that the content of the ByteBuffer object bb is not changed after the HTTP request is written to the ByteBuffer object bb, that is, the ByteBuffer object bb is “invariant”. Whether or not this condition is satisfied can be determined by the following two methods.

方法1)コンパイラ・ツールによる構文解析を行う。解析のアルゴリズムについては、後述する。
方法2)プログラマが、アノテーション等によって、明示的に保証する。
Method 1) Perform syntax analysis using a compiler tool. The analysis algorithm will be described later.
Method 2) The programmer explicitly guarantees by annotation or the like.

HTTPリクエストが格納されたByteBufferオブジェクトbbがStringオブジェクトsが使用される区間で、ByteBufferオブジェクトbbが「不変」であることが上述した2つの方法により、保証できた場合のみ、String(ByteBuffer)コンストラクタを用いてStringオブジェクトsを生成するソースコードへと、自動的に変換する。なお、上述した2つの方法のうち少なくとも1つにて、ByteBufferオブジェクトbbが「不変」であることが保証されればよい。   The String (ByteBuffer) constructor is only used when the ByteBuffer object bb in which the HTTP request is stored can be guaranteed by the above two methods that the ByteBuffer object bb is “invariant” in the interval where the String object s is used. To automatically convert to the source code that generates String objects s. It should be ensured that the ByteBuffer object bb is “invariant” by at least one of the two methods described above.

上記方法にて、ByteBufferオブジェクトbbが「不変」であることを保証することにより、Stringクラスが「不変」であることが保証される。その結果、Stringクラスから生成されるオブジェクトが「不変」であることを保証するためのStringクラスのインスタンス内のchar[]配列へのコピーの必要が無くすことができるので、課題a)で挙げたオーバーヘッドを削減できる。   By ensuring that the ByteBuffer object bb is “immutable” by the above method, it is guaranteed that the String class is “immutable”. As a result, it is possible to eliminate the need to copy to the char [] array in the instance of the String class to ensure that the object generated from the String class is "immutable". Overhead can be reduced.

ByteBufferオブジェクトbbが「不変」であることが保証されているソースコードに、コンストラクタにString(java.nio.ByteBuffer bb)が新設されたStringクラスを用いてStringオブジェクトsを生成することにより、課題a)b)c)で挙げたオーバーヘッドを削減することができる。   By generating a String object s using the String class in which String (java.nio.ByteBuffer bb) is newly added to the constructor in the source code where it is guaranteed that the ByteBuffer object bb is "immutable", issue a B) The overhead mentioned in c) can be reduced.

図1は、本発明の一実施形態に係る、HTTPリクエストのStringクラスへの変換処理を示す概要図である。なお、図1に示す変換処理は、上述したString(ByteBuffer)コンストラクタを用いたソースコードによる変換処理である。白抜き矢印は、HTTPリクエストの流れ、および処理の流れを表している。変換処理は、変換処理を備えたWebサーバが、HTTPリクエストを受信したことに応じて、処理が開始する。まず、クライアントから受信したHTTPリクエストは、kernelからByteBufferオブジェクトbb1に読み込まれる。この処理は、図11に示す従来技術と同様である。   FIG. 1 is a schematic diagram showing processing for converting an HTTP request into a String class according to an embodiment of the present invention. The conversion process shown in FIG. 1 is a conversion process by source code using the above-described String (ByteBuffer) constructor. White arrows represent the flow of HTTP requests and the flow of processing. The conversion process starts in response to the Web server having the conversion process receiving an HTTP request. First, the HTTP request received from the client is read from kernel to the ByteBuffer object bb1. This process is the same as that of the prior art shown in FIG.

次に、ByteBufferオブジェクトbb1は、StringクラスのString(ByteBuffer)コンストラクタに渡される。String(ByteBuffer)コンストラクタにて作成されたStringオブジェクトsは、ByteBufferオブジェクトbb1へのポインタ3を格納する。このようにすることで、HTTPリクエストは、UTF−8からUTF−16へ変換されず、Stringオブジェクトs内のchar[]配列へのコピーもされず、StringオブジェクトsにUTF−16としてHTTPリクエストを保持することもない。すなわち、本発明における課題であるa)b)c)3つのオーバーヘッドの課題を解決することができる。   Next, the ByteBuffer object bb1 is passed to the String (ByteBuffer) constructor of the String class. The String object s created by the String (ByteBuffer) constructor stores a pointer 3 to the ByteBuffer object bb1. By doing so, the HTTP request is not converted from UTF-8 to UTF-16, copied to the char [] array in the String object s, and the HTTP request is sent to the String object s as UTF-16. There is no holding. That is, it is possible to solve the problems a), b), c) and three overheads, which are problems in the present invention.

次に、図1にて概要図を示した変換処理を、フローチャートを用いて説明する。最初に、図11にて概要図を示した、従来技術に係る変換処理のフローチャートについて説明する。図12は、従来技術に係る、HTTPリクエストのStringクラスへの変換処理のフローチャートである。
S10:Webサーバがクライアントから受信したHTTPリクエストは、WebサーバのkernelからByteBufferオブジェクトbbに読み込まれる。
S20:ByteBufferオブジェクトbbの内容をbyte[]配列として返すbb.array()を実行し、ByteBufferオブジェクトbbに格納されたHTTPリクエストをbyte[]配列に変換する。
Next, the conversion process whose outline is shown in FIG. 1 will be described using a flowchart. First, the flowchart of the conversion process according to the prior art, which is schematically shown in FIG. FIG. 12 is a flowchart of a process for converting an HTTP request into a String class according to the related art.
S10: The HTTP request received from the client by the Web server is read into the ByteBuffer object bb from the kernel of the Web server.
S20: bb.array () that returns the contents of the ByteBuffer object bb as a byte [] array is executed, and the HTTP request stored in the ByteBuffer object bb is converted into a byte [] array.

S30:ステップS20でbyte[]配列に変換されたHTTPリクエストと、エンコードしたい形式としてのUTF−8とを引数として、Stringクラスのコンストラクタを呼び出す。
S40:ステップS30で呼び出されたStringクラスのコンストラクタにて、byte[]配列に変換されたByteBufferオブジェクトbbのHTTPリクエストをUTF−8からUTF−16へ変換する。
S50:ステップS40でUTF−16へ変換されたHTTPリクエストはコピーされ、このコピーをchar[]配列に変換し、Stringオブジェクトsに保持する。
S30: The constructor of the String class is called with the HTTP request converted into the byte [] array in step S20 and UTF-8 as the format to be encoded as arguments.
S40: The HTTP request of the ByteBuffer object bb converted into the byte [] array is converted from UTF-8 to UTF-16 by the constructor of the String class called in step S30.
S50: The HTTP request converted into UTF-16 in step S40 is copied, and this copy is converted into a char [] array and held in the String object s.

次いで、本発明の一実施形態に係る変換処理のフローチャートを示す。図2は、本発明の一実施形態に係る、HTTPリクエストのStringクラスへの変換処理のフローチャートである。
S100:HTTPリクエストを、WebサーバのkernelからByteBufferオブジェクトbbに読み込む。本処理は、図12のステップS10と同じである。
S110:ByteBufferオブジェクトbbを引数として、StringクラスのString(ByteBuffer)コンストラクタを呼び出す。
S120:ByteBufferオブジェクトbbに格納されているHTTPリクエストが、ASCII文字のみであるか判断する。判断結果がYESの場合には、ステップS130へ処理を移す。一方、判断結果がNOの場合には、図1のステップS20に処理を移し、図12に示す従来技術に係る変換処理を行う。
S130:ByteBufferオブジェクトbbへのポインタを取得し、Stringオブジェクトsに保持する。
Then, the flowchart of the conversion process which concerns on one Embodiment of this invention is shown. FIG. 2 is a flowchart of processing for converting an HTTP request into a String class according to an embodiment of the present invention.
S100: The HTTP request is read from the kernel of the Web server into the ByteBuffer object bb. This process is the same as step S10 in FIG.
S110: Call String (ByteBuffer) constructor of String class with ByteBuffer object bb as an argument.
S120: It is determined whether the HTTP request stored in the ByteBuffer object bb is only ASCII characters. If the determination result is YES, the process proceeds to step S130. On the other hand, if the determination result is NO, the process moves to step S20 in FIG. 1 to perform the conversion process according to the conventional technique shown in FIG.
S130: A pointer to the ByteBuffer object bb is acquired and held in the String object s.

続いて、プログラマが作成した、図11、12に示す従来技術に係る変換処理の記述が含まれているソースコードを、図1、2に示す本発明の一実施形態に係る変換処理の記述を含むソースコードに自動的に変換するアルゴリズムについて説明する。プログラマが作成したソースコードを、図1、2に示す変換処理の記述を含むソースコードに変換することにより、課題a)b)c)で挙げたオーバーヘッドを削減したソースコードとなる。   Subsequently, the source code including the description of the conversion processing according to the prior art shown in FIGS. 11 and 12 created by the programmer is described as the description of the conversion processing according to the embodiment of the present invention shown in FIGS. An algorithm for automatically converting to the included source code will be described. By converting the source code created by the programmer into the source code including the description of the conversion process shown in FIGS. 1 and 2, the source code can be reduced in the overheads mentioned in the problems a), b) and c).

図3は、本発明の一実施形態に係る、オーバーヘッドを削減するソースコードに変換するアルゴリズムを示すフローチャートである。本アルゴリズムは、プログラマが書いたソースコード内にHTTPリクエストを保持するByteBufferオブジェクトbbを指定する記述がある場合に、下記の通りに動作する。ByteBufferオブジェクトbbの指定方法としては、プログラム中に記述する、外部から設定ファイルで与える等の方法がある。本アルゴリズムは、コンパイラが備え、コンパイラにより実行される。本アルゴリズムにより作成された、オーバーヘッドを削減するソースコードは、ハードディスク等の記憶手段に格納される。なお、オーバーヘッドを削減するソースコードではなく、オーバーヘッドを削減するソースコードがコンパイラによってコンパイルされた結果生成されるオブジェクトコード(コンピュータ上で実行可能な形式)を記憶手段に格納してもよい。   FIG. 3 is a flowchart illustrating an algorithm for converting source code to reduce overhead according to an embodiment of the present invention. This algorithm operates as follows when there is a description specifying the ByteBuffer object bb that holds the HTTP request in the source code written by the programmer. As a method for specifying the ByteBuffer object bb, there are methods such as describing in a program or giving from a configuration file from the outside. This algorithm is provided in the compiler and executed by the compiler. The source code generated by this algorithm for reducing overhead is stored in a storage means such as a hard disk. Instead of the source code for reducing overhead, object code (format executable on a computer) generated as a result of compiling the source code for reducing overhead by a compiler may be stored in the storage means.

S200:ByteBufferオブジェクトbbが、「不変」であることを保証するための条件を満たしているか判断する。ByteBufferオブジェクトbbが「不変」であることを保証するための条件を満たしていない場合には、処理は終了し、満たしている場合には、ステップS210へ処理を移す。ByteBufferオブジェクトbbが「不変」であることを保証するための条件については後述する。上述したように、本発明の一実施形態において、HTTPリクエストは、Stringオブジェクトs内に、HTTPリクエストを格納しているByteBufferオブジェクトbbへのポインタを保持することにより参照できる。そのため、Stringクラスが「不変」であるという条件を満たすためには、ByteBufferオブジェクトbbが「不変」でなければならないからである。   S200: It is determined whether the condition for guaranteeing that the ByteBuffer object bb is “invariant” is satisfied. If the condition for guaranteeing that the ByteBuffer object bb is “invariant” is not satisfied, the process ends. If satisfied, the process proceeds to step S210. The conditions for ensuring that the ByteBuffer object bb is “invariant” will be described later. As described above, in one embodiment of the present invention, the HTTP request can be referred to by holding a pointer to the ByteBuffer object bb storing the HTTP request in the String object s. Therefore, in order to satisfy the condition that the String class is “immutable”, the ByteBuffer object bb must be “immutable”.

S210:bb.array()の戻り値(bとする)と、エンコードしたい形式としてのUTF−8を引数として、UTF−16に変換後の文字列を格納するStringオブジェクトを代入する変数(sとする)を代入先とした「s=new String(b,“UTF-8”)」という代入文が検知できたか判断する。ここで、変数sは、Stringオブジェクトであり、上述しているStringオブジェクトsと同じである。代入文が検知できた場合には、ステップS220へ処理は移り、検知できなかった場合には処理は終了する。   S210: Variables for substituting a String object for storing the converted character string in UTF-16 using the return value (b) of bb.array () and UTF-8 as the format to be encoded as arguments. It is determined whether or not an assignment statement “s = new String (b,“ UTF-8 ”)” with the assignment destination is detected. Here, the variable s is a String object, which is the same as the String object s described above. If the assignment statement can be detected, the process proceeds to step S220. If the assignment statement cannot be detected, the process ends.

S220:ステップS210で検知した「s=new String(b,"UTF-8")」の直後に、「s=new String(bb)」という代入文を生成する。
S230:ステップS210で検知した「s=new String(b,"UTF-8")」を削除する。
S240:ステップS230で削除した「s=new String(b,"UTF-8")」の引数のうち、プログラム中で使用されていない変数に関する代入文を削除する。
S220: Immediately after “s = new String (b,“ UTF-8 ”)” detected in step S210, an assignment statement “s = new String (bb)” is generated.
S230: “s = new String (b,“ UTF-8 ”)” detected in step S210 is deleted.
S240: Delete an assignment statement related to a variable that is not used in the program from among the arguments of “s = new String (b,“ UTF-8 ”)” deleted in step S230.

ByteBufferオブジェクトbbが「不変」であることを保証するための条件について説明する。ここでは、ByteBufferオブジェクトbbが「不変」であることを保証するための方法のうち、方法1)のコンパイラ・ツールにより解析を行う方法における条件について説明する。コンパイラ・ツールは、ユーザによってプログラム中に記述された、HTTPリクエストが格納されるByteBufferオブジェクトbbについて、メソッド中でByteBufferオブジェクトbbの値が生成されてから使用されなくなるまでの範囲において、以下の5つの条件の全てを満たしているかどうか解析する。   The conditions for guaranteeing that the ByteBuffer object bb is “invariant” will be described. Here, among the methods for ensuring that the ByteBuffer object bb is “invariant”, conditions in the method of performing analysis by the compiler tool of method 1) will be described. For the ByteBuffer object bb in which an HTTP request is stored, which is described in the program by the user, the compiler tool has the following five types within the range from the generation of the value of the ByteBuffer object bb in the method until it is no longer used. Analyze whether all the conditions are met.

この5つの条件全てが満たされていれば、ByteBufferオブジェクトbbにSocketChannel.read()によって値(HTTPリクエスト)が書き込まれてから使用が終了するまで値が書き換えられることがない。そのため、Stringオブジェクトsの中で、コンストラクタに渡されたByteBufferオブジェクトbbへのポインタを保持し続けることによって、Stringオブジェクトに文字列を保持しなくとも、Stringオブジェクトの「不変」は保証される。   If all of these five conditions are satisfied, the value is not rewritten until the use ends after the value (HTTP request) is written to the ByteBuffer object bb by SocketChannel.read (). Therefore, by keeping the pointer to the ByteBuffer object bb passed to the constructor in the String object s, “invariance” of the String object is guaranteed even if the String object does not hold the character string.

条件1)ByteBufferオブジェクトbbがインスタンス変数、または、クラス変数に代入されていない。
条件2)ByteBufferオブジェクトbbがメソッドの返値となっていない。
条件3)ByteBufferオブジェクトbbが、SocketChannel.read(ByteBuffer)メソッド以外の、メソッド呼び出しの引数、となっていない。
条件4)ByteBufferオブジェクトbbが、SocketChannel.read(ByteBuffer)で参照された後、左辺に現れない。
条件5)ByteBufferオブジェクトbbが、SocketChannel.read(ByteBuffer)で参照された後、bb.put()、bb.put*()メソッドが呼ばれていない。
Condition 1) ByteBuffer object bb is not assigned to an instance variable or class variable.
Condition 2) ByteBuffer object bb is not the return value of the method.
Condition 3) The ByteBuffer object bb is not an argument of a method call other than the SocketChannel.read (ByteBuffer) method.
Condition 4) ByteBuffer object bb does not appear on the left side after being referenced by SocketChannel.read (ByteBuffer).
Condition 5) The bb.put () and bb.put * () methods are not called after the ByteBuffer object bb is referenced in SocketChannel.read (ByteBuffer).

条件4)に示す、ByteBufferオブジェクトbbが左辺に現れないとは、ByteBufferオブジェクトbbの内容が書き換えられないということを示している。なお、ByteBufferオブジェクトbbが左辺に現れた場合、その直前までを解析対象としてもよい。また、条件5)に示す、bb.put*()とは、bb.putChar(int index,char value)等のputから始まるメソッドを意味する。bb.put()、bb.put*()メソッドが呼ばれていないとは、すなわち、ByteBufferオブジェクトbbの内容を書き換えるメソッドが呼ばれておらず、ByteBufferオブジェクトbbの内容が書き換えられないということを示している。   If the ByteBuffer object bb does not appear on the left side as shown in condition 4), it means that the contents of the ByteBuffer object bb cannot be rewritten. In addition, when the ByteBuffer object bb appears on the left side, the portion immediately before that may be the analysis target. Further, bb.put * () shown in condition 5) means a method starting from put such as bb.putChar (int index, char value). The bb.put () and bb.put * () methods are not called, that is, the method that rewrites the contents of the ByteBuffer object bb is not called, and the contents of the ByteBuffer object bb cannot be rewritten. Show.

なお、ByteBufferオブジェクトbbがObject Poolingを利用している場合、ByteBufferオブジェクトbbをPoolから取り出すメソッドが呼ばれてからPoolに返却するメソッドが呼ばれるまでの範囲が解析対象となる。この2つのメソッドは、プログラムで使われているObject Poolingの仕様より、コンパイラ・ツールはknownであるとする。ここで、Object Poolingとは、生成したオブジェクトをプール(Pool)に蓄積しておき、必要になった際にプールからオブジェクトを取り出して利用し、不要になった際にはオブジェクトをプールに戻すことである。Object Poolingを用いることは、利用する度にオブジェクトを生成する方法に比べ、速度が速いという利点がある。   Note that when the ByteBuffer object bb uses Object Pooling, the range from when the method for retrieving the ByteBuffer object bb from the Pool to the method for returning to the Pool is called becomes the analysis target. These two methods are assumed to be known as the compiler tool based on the Object Pooling specification used in the program. Here, Object Pooling is to store the generated objects in the pool (Pool), take out the objects from the pool when they are needed, and return the objects to the pool when they are no longer needed. It is. Using Object Pooling has the advantage that it is faster than the method of creating an object each time it is used.

また、ByteBufferオブジェクトbbがObject Poolingを利用している場合、上記の条件1)から条件5)によるソースコードの静的解析だけではStringオブジェクトの「不変」を保証できないので、Stringオブジェクトと共有されているByteBufferクラスへの書き込みがあった場合に、内容を保持するByteBufferオブジェクトを新規に作成するCopy−On−Writeメカニズムを導入して、Stringオブジェクトの「不変」を保証する。ただし、Copy−On−Writeメカニズムを導入して、Stringオブジェクトの「不変」を保証する必要があるのは、Stringオブジェクトが使用される区間内に、ByteBufferオブジェクトbbがプールに戻される場合である。   In addition, when the ByteBuffer object bb uses Object Pooling, it cannot be guaranteed that the String object is “invariant” by static analysis of the source code according to the above conditions 1) to 5). Introduce a Copy-On-Write mechanism that creates a new ByteBuffer object that retains the contents when the ByteBuffer class is written, and guarantees the "invariance" of the String object. However, it is necessary to introduce the Copy-On-Write mechanism to guarantee the “invariance” of the String object when the ByteBuffer object bb is returned to the pool within the interval in which the String object is used.

ここで、Copy−On−Writeメカニズムとは、オブジェクトの複製を要求された際には、コピーをした振りをして、とりあえず原本をそのまま参照させ、原本またはコピーのどちらかに書き込みが行われようとした際に、それを検出し、その時点で初めて新たな空き領域を探して割り当て、コピーを実行する技術である。   Here, the Copy-On-Write mechanism means that when a copy of an object is requested, the copy is pretending to be referred to as it is and the original or copy is written. This is a technology that detects this, searches for and allocates a new free area for the first time, and executes copying.

図3に示したフローチャートを用いて、コード変換するサーバシステムにおける各手段について説明する。特定手段は、図3のステップS210処理、すなわち、ソースコードからStringオブジェクトを代入する変数(s)を代入先とした「s=new String(b,“UTF-8”)」という代入文を検知する処理を行う。変換手段は、図3のステップS220およびS230の処理、すなわち、特定手段にて検知した代入文「s=new String(b,“UTF-8”)」を、代入文「s=new String(bb)」に変換する。格納手段は、変換手段にて、代入文「s=new String(bb)」に変換されたソースコードを、ハードディスク等の記憶手段に格納する。   Each means in the server system for code conversion will be described with reference to the flowchart shown in FIG. The identifying means detects the assignment statement “s = new String (b,“ UTF-8 ”)” in step S210 of FIG. 3, that is, the variable (s) that substitutes the String object from the source code. Perform the process. The conversion means performs the processing of steps S220 and S230 of FIG. 3, that is, the assignment statement “s = new String (b,“ UTF-8 ”)” detected by the specifying means, and the assignment statement “s = new String (bb ) ". The storage means stores the source code converted into the assignment statement “s = new String (bb)” by the conversion means in a storage means such as a hard disk.

ここで、コンストラクタにString(java.nio.ByteBuffer bb)を新設したStringクラスの特徴の1つである、StringオブジェクトsがByteBufferオブジェクトbbへのポインタを保持している場合の、Stringクラスのメソッドを経由して文字を取り出す処理について説明する。図4は、本発明の一実施形態に係る、ByteBufferオブジェクトbbへポインタを保持するStringオブジェクトsにおける、文字取得処理のフローチャートである。   Here, the String class method when the String object s holds a pointer to the ByteBuffer object bb, which is one of the features of the String class that newly created String (java.nio.ByteBuffer bb) in the constructor, A process for extracting characters via the network will be described. FIG. 4 is a flowchart of character acquisition processing in the String object s that holds a pointer to the ByteBuffer object bb according to an embodiment of the present invention.

S300:StringオブジェクトsにByteBufferオブジェクトbbへのポインタが保持されているか判断する。ポインタが保持されている場合には、処理をステップS310へ移し、保持されていない場合には、Stringオブジェクトs内にchar[]配列が保持されているので、char[]配列を取得し、戻り値として返す。
S310:Stringオブジェクトsに保持されているポインタが示すByteBufferオブジェクトbbから、必要な8ビット文字を読み出す。
S320:ステップS310にて読み出した8ビット文字の上位8ビットに00を付加して、char[]配列に変換する。
S330:戻り値として、ステップS320にて変換されたchar[]配列を返す。
S300: It is determined whether a pointer to the ByteBuffer object bb is held in the String object s. If the pointer is held, the process proceeds to step S310. If the pointer is not held, the char [] array is held in the String object s, so the char [] array is acquired and returned. Returns as a value.
S310: A necessary 8-bit character is read from the ByteBuffer object bb indicated by the pointer held in the String object s.
S320: 00 is added to the upper 8 bits of the 8-bit character read in step S310 to convert it into a char [] array.
S330: The char [] array converted in step S320 is returned as a return value.

このようにして、StringオブジェクトsがByteBufferオブジェクトbbへのポインタを保持している場合において、ByteBufferオブジェクトbbから文字を取り出すことができる。   In this way, when the String object s holds a pointer to the ByteBuffer object bb, a character can be extracted from the ByteBuffer object bb.

図5は、本発明の一実施形態に係るStringクラスの実装を示す図である。図5を用いて、本発明の実装の詳細について説明する。まず、コンストラクタにString(java.nio.ByteBuffer bb)が新設されたStringクラスの例を、Java言語のjava.lang.Stringクラスを用いて示す。図5では、java.lang.Stringクラスの内部で使われるフィールドと、代表的なメソッドとして文字列を設定するjava.lang.Stringクラスのコンストラクタ(String(ByteBuffer)コンストラクタ)、java.lang.Stringの文字列から1文字取り出すcharAt()メソッド、用意したbyte[]配列にjava.lang.Stringの文字列をコピーするgetBytes()メソッド、を示す。   FIG. 5 is a diagram showing the implementation of the String class according to an embodiment of the present invention. Details of the implementation of the present invention will be described with reference to FIG. First, an example of the String class in which String (java.nio.ByteBuffer bb) is newly established in the constructor is shown using the java.lang.String class of Java language. In Fig. 5, the fields used inside the java.lang.String class, the java.lang.String class constructor (String (ByteBuffer) constructor) that sets a string as a representative method, and the java.lang.String The charAt () method for extracting one character from a character string, and the getBytes () method for copying a java.lang.String character string to the prepared byte [] array are shown.

String(ByteBuffer)コンストラクタ10では、入力されたByteBufferオブジェクトbbが指す文字列を検査し、もし0x80以上の文字が含まれていた場合には通常のUTF−16表現で文字列を保持する。それ以外の場合は、入力されたByteBufferオブジェクトbbを保持する。charAt()メソッド11では、ByteBufferオブジェクトbbがそのまま保持されていた場合、ByteBufferオブジェクトbbから必要な8ビット文字を読み出して、上位8ビットに00を付加してcharに変換して値を返す。getBytes()メソッド12では、ByteBufferオブジェクトbbがそのまま保持されていた場合、ByteBufferオブジェクトbbが指す文字列はUTF−8であるので、そのままbyte[]配列にコピーする。   The String (ByteBuffer) constructor 10 checks the character string pointed to by the input ByteBuffer object bb. If a character of 0x80 or more is included, the character string is held in a normal UTF-16 representation. In other cases, the input ByteBuffer object bb is retained. In the charAt () method 11, when the ByteBuffer object bb is held as it is, the necessary 8-bit character is read from the ByteBuffer object bb, 00 is added to the upper 8 bits, and the value is converted to char. In the getBytes () method 12, when the ByteBuffer object bb is held as it is, the character string pointed to by the ByteBuffer object bb is UTF-8, so it is copied to the byte [] array as it is.

次に、Copy−On−Writeについて、Java言語のjava.nio.ByteBufferクラスの例を用いて説明する。ByteBufferオブジェクトが保持するバッファの内容を変更するメソッドが呼ばれたときにCopy−on−writeが必要であるかどうかを示す、SoftReferenceクラスのsrefフィールドを、ByteBufferクラスに追加する。ここで、バッファとは、プログラムが実行されている際のデータのやり取り時に、処理速度や転送速度の差を補うためにデータを一時的に保存しておく記憶領域のことをいう。   Next, Copy-On-Write will be described using an example of java.nio.ByteBuffer class of Java language. An sref field of the SoftReference class is added to the ByteBuffer class indicating whether Copy-on-write is necessary when a method for changing the contents of the buffer held by the ByteBuffer object is called. Here, the buffer refers to a storage area in which data is temporarily stored in order to compensate for a difference in processing speed or transfer speed when exchanging data when the program is executed.

まず、String(ByteBuffer bb,int,int)の中で、byte[]配列でデータを保持すると決定した場合、bb.duplicate()した値をvalue13として、Stringクラスに保存する。そして、そのvalue13を参照する新しいソフト参照(SoftReference)を作成し、bb.srefに代入する。ByteBufferオブジェクトが保持するバッファの内容が変更されると、このbb.srefを利用してCopy−on−writeが必要であるかどうか判断する。具体的には、ByteBufferオブジェクトが保持するバッファの内容を変更するメソッド(例えばput()メソッド等)で以下の処理を行う。   First, when it is determined that the data is held in the byte [] array in String (ByteBuffer bb, int, int), the value obtained by bb.duplicate () is stored in the String class as value13. Then, a new soft reference (SoftReference) referring to the value 13 is created and assigned to bb.sref. When the contents of the buffer held by the ByteBuffer object are changed, this bb.sref is used to determine whether Copy-on-write is necessary. Specifically, the following processing is performed by a method (for example, put () method) that changes the contents of the buffer held by the ByteBuffer object.

1)bb.sref=nullであれば、StringオブジェクトはByteBufferオブジェクトが保持するバッファの内容を参照していないので、通常の処理を行う。
2)bb.sref.get()=nullであれば、すでにStringオブジェクトはガベージコレクション(garbage collection;GC)されているので、通常の処理を行う。ここで、ガベージコレクション(GC)とは、プログラムが動的に確保したメモリ領域のうち、不要になった領域を自動的に解放する機能である。
3)bb.sref.get()!=nullであれば、新しいバッファを確保してこれまでのバッファの内容をコピーする。
1) If bb.sref = null, the String object does not refer to the contents of the buffer held by the ByteBuffer object, so normal processing is performed.
2) If bb.sref.get () = null, the String object has already been garbage collected (GC) and normal processing is performed. Here, garbage collection (GC) is a function of automatically releasing an unnecessary area among memory areas dynamically allocated by a program.
3) bb.sref.get ()! If = null, a new buffer is secured and the contents of the previous buffer are copied.

図6は、本発明の一実施形態に係る、ByteBufferオブジェクトが保持するバッファの内容が変更される前に、StringがGCされた場合のCopy−on−writeの動作概要を示す図である。図6(a)は、ByteBufferオブジェクトとバッファとの関係図を示す。String(ByteBuffer bb)の中で、byte[]配列でデータを保持する場合には、ByteBufferオブジェクトbb100が参照するバッファ200の内容を、文字列の値として使用する。ここで、バッファ200は、kernelからByteBufferオブジェクトbb100に読み込まれたデータを保持するために、ByteBufferオブジェクトbb100が内部的に使用するbyte[]配列である。   FIG. 6 is a diagram showing an overview of the operation of Copy-on-write when String is GC before the contents of the buffer held by the ByteBuffer object are changed according to an embodiment of the present invention. FIG. 6A shows a relationship diagram between the ByteBuffer object and the buffer. When data is held in a byte [] array in String (ByteBuffer bb), the contents of the buffer 200 referred to by the ByteBuffer object bb100 are used as the value of the character string. Here, the buffer 200 is a byte [] array used internally by the ByteBuffer object bb100 in order to hold data read from the kernel to the ByteBuffer object bb100.

図6(b)は、バッファ200の内容を参照するStringオブジェクトの関係図を示す。String(ByteBuffer bb)の中で、バッファ200の内容を参照するために、bb.duplicate()した値を、Stringオブジェクトsに保存する。そして、bb.duplicate()した値を参照するSoftReference110を作成し、bb.srefに代入する。具体的には、ByteBufferオブジェクトbb100をshallow copyし、ByteBufferオブジェクトs_bb101を作成し、Stringオブジェクトs120にByteBufferオブジェクトs_bb101を参照させる。それにより、Stringオブジェクトs120は、ByteBufferオブジェクトs_bb101が参照するバッファ200の内容を文字列の値として使用することができる。Stringオブジェクトs120に、ByteBufferオブジェクトs_bb101を参照させた後、ByteBufferオブジェクトs_bb101を参照するSoftReference110を作成する。SoftReference110により、ByteBufferオブジェクトbb100とByteBufferオブジェクトs_bb101とを関連付けることができる。   FIG. 6B shows a relationship diagram of String objects that refer to the contents of the buffer 200. In order to refer to the contents of the buffer 200 in String (ByteBuffer bb), the value of bb.duplicate () is stored in the String object s. Then, SoftReference 110 that refers to the value obtained by bb.duplicate () is created and assigned to bb.sref. Specifically, the ByteBuffer object bb100 is shallow copied, a ByteBuffer object s_bb101 is created, and the String object s120 is referred to the ByteBuffer object s_bb101. Thereby, the String object s120 can use the contents of the buffer 200 referred to by the ByteBuffer object s_bb101 as the value of the character string. After making the String object s120 refer to the ByteBuffer object s_bb101, a SoftReference 110 that refers to the ByteBuffer object s_bb101 is created. By SoftReference 110, the ByteBuffer object bb100 and the ByteBuffer object s_bb101 can be associated with each other.

図6(c)は、Stringオブジェクトs120が変更される前に、Stringオブジェクトs120がGCされた場合の関係図である。Stringオブジェクトs120がGCされると、SoftReference110の持つ値がnullになる。このとき、バッファ200はStringオブジェクトs120から参照されていないので、バッファ200の内容を変更することができる。   FIG. 6C is a relationship diagram when the String object s120 is GC before the String object s120 is changed. When the String object s120 is GC, the value of the SoftReference 110 becomes null. At this time, since the buffer 200 is not referenced from the String object s120, the contents of the buffer 200 can be changed.

図7は、本発明の一実施形態に係る、StringオブジェクトがGCされる前に、バッファの内容が変更された場合のCopy−on−writeの動作概要を示す図である。図7(a)、(b)は図6と同様である。図7(c)は、Stringオブジェクトs120がGCされる前に、バッファ200の内容が変更された場合の関係図である。SoftReference110の持つ値がnullでない場合には、Stringオブジェクトs120がGCされていないため、バッファ200の内容を変更してしまうと、Stringオブジェクトs120の「不変」が保たれなくなる。そこで、Copy−On−Writeのメカニズムを用いて、バッファ200の内容がコピーされる。コピーされたバッファ201をByteBufferオブジェクトbb100が保持し、ByteBufferオブジェクトs_bb101とのSoftReference110が消滅する。このようにして、Stringクラスの「不変」が保持される。   FIG. 7 is a diagram showing an overview of copy-on-write operation when the contents of a buffer are changed before the String object is GCed according to an embodiment of the present invention. 7A and 7B are the same as FIG. FIG. 7C is a relationship diagram when the contents of the buffer 200 are changed before the String object s120 is GCed. If the value of the SoftReference 110 is not null, the String object s120 is not GC, and therefore, if the contents of the buffer 200 are changed, the “invariant” of the String object s120 cannot be maintained. Therefore, the contents of the buffer 200 are copied using a copy-on-write mechanism. The copied buffer 201 is held by the ByteBuffer object bb100, and the SoftReference 110 with the ByteBuffer object s_bb101 disappears. In this way, the “invariant” of the String class is retained.

最後に、本発明の一実施形態の適用例について述べる。図8に、簡単なサーバソースコードの例を示す。図8に示した簡単なサーバソースコードの処理について説明する。80番ポートからByteBufferオブジェクトbbにHTTPリクエストのデータを読み込むと処置が開始する。まず、ByteBufferオブジェクトbbに読み込まれたHTTPリクエストを、UTF−8からUTF−16へ変換し、UTF−16に変換されたHTTPリクエストを保持するStringオブジェクトsを生成する。次に、生成されたStringオブジェクトsが保持するUTF−16に変換されたHTTPリクエストのパーセントエンコーディングをデコードする。最後に、デコードされたHTTPリクエストを、標準出力に書き出し、処理を終了する。   Finally, an application example of one embodiment of the present invention will be described. FIG. 8 shows an example of a simple server source code. The simple server source code processing shown in FIG. 8 will be described. When the HTTP request data is read from the 80th port to the ByteBuffer object bb, the procedure starts. First, the HTTP request read into the ByteBuffer object bb is converted from UTF-8 to UTF-16, and String objects s that hold the HTTP request converted to UTF-16 are generated. Next, the percent encoding of the HTTP request converted into UTF-16 held by the generated String object s is decoded. Finally, the decoded HTTP request is written to the standard output, and the process ends.

まず、プログラマが、「ByteBuffer bb=ByteBuffer.allocateDirect(8192);」のByteBufferオブジェクトbbを指定している記述を見つける。次にByteBufferオブジェクトbbが書き換えられることがないか上述した条件を満たすかチェックを行う。図8に示されたソースコード内のByteBufferオブジェクトbbは、bb.array()メソッドしか呼んでいない、インスタンス変数・クラス変数に代入されていない、SocketChannel.read()メソッドでのみ引数となっている、メソッドの返値となっていない、のでbbがSocketChannel.read()メソッドで値が書き込まれてからは値が書き換えられることがない。従って、bbを本発明の一実施形態に係る新設のString(ByteBuffer)コンストラクタに渡すことができるので、サーバソースコードを本発明における課題であるa)b)c)3つのオーバーヘッドを削減するソースコードに変換することができる。   First, the programmer finds a description specifying the ByteBuffer object bb of “ByteBuffer bb = ByteBuffer.allocateDirect (8192);”. Next, it is checked whether the ByteBuffer object bb is not rewritten and the above-mentioned conditions are satisfied. The ByteBuffer object bb in the source code shown in Fig. 8 is an argument only in the SocketChannel.read () method that only calls the bb.array () method, is not assigned to an instance variable / class variable. Since the value is not returned by the method, the value will not be rewritten after bb is written by the SocketChannel.read () method. Therefore, since bb can be passed to the new String (ByteBuffer) constructor according to an embodiment of the present invention, the server source code is a problem in the present invention a) b) c) Source code that reduces three overheads Can be converted to

図8に示したサーバソースコードは、図3に示したアルゴリズムに従って、図9のように書き換えることができ、変換処理におけるa)、b)、c)のオーバーヘッドを削減できる。なお、Java言語の仕様を満たすためにString(ByteBuffer)コンストラクタは非publicとしているので、実際にはリフレクション等を用いて、String(ByteBuffer)コンストラクタを呼び出す必要がある。   The server source code shown in FIG. 8 can be rewritten as shown in FIG. 9 according to the algorithm shown in FIG. 3, and the overheads a), b), and c) in the conversion process can be reduced. Since the String (ByteBuffer) constructor is non-public in order to satisfy the specifications of the Java language, it is actually necessary to call the String (ByteBuffer) constructor using reflection or the like.

本発明は、プログラムがStringとして表現するバッファの内容が1バイトで表現できるもののみであったときに、本発明の一実施形態に係る変換処理を行い、その他の場合は従来技術に係る変換処理を行うものである。このため、パーセントエンコーディングで表現できないデータがあった場合には、従来技術で変換処理が行われる。もし、パーセントエンコーディングで表現できないURI(Uniform Resource Identifier)として正しくない文字(例えば0xff)がユーザが指定したHTTPリクエストが格納されたバッファに存在した場合には、図5に示すように、String(ByteBuffer bb,int start,int length)メソッドの「value=StringCoding.decode(bb.array(),start,length);」が実行され、従来技術に係る変換処理でStringオブジェクトが生成され、バッファの内容を失うことなく本発明を適用しない結果と同じStringオブジェクトが得られる。   The present invention performs conversion processing according to an embodiment of the present invention when the contents of the buffer expressed by the program as String are only one that can be expressed by 1 byte, and in other cases, conversion processing according to the prior art Is to do. For this reason, when there is data that cannot be expressed in percent encoding, conversion processing is performed by the conventional technique. If an invalid character (for example, 0xff) as a URI (Uniform Resource Identifier) that cannot be expressed in percent encoding is present in the buffer storing the HTTP request specified by the user, as shown in FIG. bb, int start, int length) method `` value = StringCoding.decode (bb.array (), start, length); '' is executed, a String object is generated by the conversion processing according to the prior art, and the contents of the buffer are changed The same String object is obtained without losing the result of applying the present invention.

また、POSTコマンド等によって、HTTPメッセージにメッセージボディ(rfc2616)が存在した場合も、例えばユーザが指定したHTTPリクエストが格納されたバッファに0xffが存在した場合には、図5に示すように、String(ByteBufferbb,int start,int length)メソッドの「value=StringCoding.decode(bb.array(),start,length);」が実行され、従来技術に係る変換処理でStringオブジェクトが生成され、バッファの内容を失うことなく本発明を適用しない結果と同じStringオブジェクトが得られる。   Further, even when the message body (rfc2616) is present in the HTTP message by a POST command or the like, for example, when 0xff exists in the buffer storing the HTTP request specified by the user, as shown in FIG. `` Value = StringCoding.decode (bb.array (), start, length); '' of the (ByteBufferbb, int start, int length) method is executed, a String object is generated by the conversion processing according to the conventional technology, and the buffer contents The same String object as the result of not applying the present invention without losing is obtained.

図10は、本発明の一実施形態に係る、オーバーヘッドを削減するソースコードに変換するサーバ装置のハードウェア構成を示す図である。図10においては、オーバーヘッドを削減するソースコードに変換する装置を情報処理装置1000とし、そのハードウェア構成を例示する。以下は、コンピュータを典型とする情報処理装置として全般的な構成を説明するが、その環境に応じて必要最小限な構成を選択できることはいうまでもない。   FIG. 10 is a diagram illustrating a hardware configuration of a server device that converts to source code that reduces overhead according to an embodiment of the present invention. In FIG. 10, an information processing apparatus 1000 is used as an apparatus that converts source code to reduce overhead, and the hardware configuration thereof is illustrated. In the following, an overall configuration of an information processing apparatus typified by a computer will be described, but it goes without saying that the minimum required configuration can be selected according to the environment.

情報処理装置1000は、CPU(Central Processing Unit)1010、バスライン1005、通信I/F1040、メインメモリ1050、BIOS(Basic Input Output System)1060、パラレルポート1080、USBポート1090、グラフィック・コントローラ1020、VRAM1024、音声プロセッサ1030、I/Oコントローラ1070、ならびにキーボードおよびマウス・アダプタ1100等の入力手段を備える。I/Oコントローラ1070には、フレキシブル・ディスク(FD)ドライブ1072、ハードディスク1074、光ディスク・ドライブ1076、半導体メモリ1078等の記憶手段を接続することができる。   The information processing apparatus 1000 includes a CPU (Central Processing Unit) 1010, a bus line 1005, a communication I / F 1040, a main memory 1050, a BIOS (Basic Input Output System) 1060, a parallel port 1080, a USB port 1090, a graphic controller 1020, and a VRAM 1024. , An audio processor 1030, an I / O controller 1070, and input means such as a keyboard and mouse adapter 1100. Storage means such as a flexible disk (FD) drive 1072, a hard disk 1074, an optical disk drive 1076, and a semiconductor memory 1078 can be connected to the I / O controller 1070.

音声プロセッサ1030には、マイクロホン1036、増幅回路1032、およびスピーカ1034が接続される。また、グラフィック・コントローラ1020には、表示装置1022が接続されている。   A microphone 1036, an amplifier circuit 1032, and a speaker 1034 are connected to the audio processor 1030. A display device 1022 is connected to the graphic controller 1020.

BIOS1060は、情報処理装置1000の起動時にCPU1010が実行するブートプログラムや、情報処理装置1000のハードウェアに依存するプログラム等を格納する。FD(フレキシブル・ディスク)ドライブ1072は、フレキシブル・ディスク1071からプログラムまたはデータを読み取り、I/Oコントローラ1070を介してメインメモリ1050またはハードディスク1074に提供する。図10には、情報処理装置1000の内部にハードディスク1074が含まれる例を示したが、バスライン1005またはI/Oコントローラ1070に外部機器接続用インタフェース(図示せず)を接続し、情報処理装置1000の外部にハードディスクを接続または増設してもよい。   The BIOS 1060 stores a boot program executed by the CPU 1010 when the information processing apparatus 1000 is activated, a program depending on the hardware of the information processing apparatus 1000, and the like. An FD (flexible disk) drive 1072 reads a program or data from the flexible disk 1071 and provides it to the main memory 1050 or the hard disk 1074 via the I / O controller 1070. FIG. 10 shows an example in which the information processing apparatus 1000 includes a hard disk 1074. However, an external device connection interface (not shown) is connected to the bus line 1005 or the I / O controller 1070, and the information processing apparatus A hard disk may be connected or added to the outside of 1000.

光ディスク・ドライブ1076としては、例えば、DVD−ROMドライブ、CD−ROMドライブ、DVD−RAMドライブ、CD−RAMドライブを使用することができる。この際は各ドライブに対応した光ディスク1077を使用する必要がある。光ディスク・ドライブ1076は光ディスク1077からプログラムまたはデータを読み取り、I/Oコントローラ1070を介してメインメモリ1050またはハードディスク1074に提供することもできる。   As the optical disk drive 1076, for example, a DVD-ROM drive, a CD-ROM drive, a DVD-RAM drive, or a CD-RAM drive can be used. In this case, it is necessary to use the optical disk 1077 corresponding to each drive. The optical disk drive 1076 can also read a program or data from the optical disk 1077 and provide it to the main memory 1050 or the hard disk 1074 via the I / O controller 1070.

情報処理装置1000に提供されるコンピュータプログラムは、フレキシブル・ディスク1071、光ディスク1077、またはメモリーカード等の記録媒体に格納されて利用者によって提供される。このコンピュータプログラムは、I/Oコントローラ1070を介して、記録媒体から読み出され、または通信I/F1040を介してダウンロードされることによって、情報処理装置1000にインストールされ実行される。コンピュータプログラムが情報処理装置に働きかけて行わせる動作は、既に説明した装置における動作と同一であるので省略する。   The computer program provided to the information processing apparatus 1000 is stored in a recording medium such as the flexible disk 1071, the optical disk 1077, or a memory card and provided by the user. The computer program is read from the recording medium via the I / O controller 1070 or downloaded via the communication I / F 1040 to be installed and executed in the information processing apparatus 1000. The operation that the computer program causes the information processing apparatus to perform is the same as the operation in the apparatus that has already been described.

前述のコンピュータプログラムは、外部の記憶媒体に格納されてもよい。記憶媒体としてはフレキシブル・ディスク1071、光ディスク1077、またはメモリーカードの他に、MD等の光磁気記録媒体、テープ媒体を用いることができる。また、専用通信回線やインターネットに接続されたサーバシステムに設けたハードディスクまたは光ディスク・ライブラリ等の記憶装置を記録媒体として使用し、通信回線を介してコンピュータプログラムを情報処理装置1000に提供してもよい。   The aforementioned computer program may be stored in an external storage medium. As the storage medium, in addition to the flexible disk 1071, the optical disk 1077, or the memory card, a magneto-optical recording medium such as MD or a tape medium can be used. In addition, a storage device such as a hard disk or an optical disk library provided in a server system connected to a dedicated communication line or the Internet may be used as a recording medium, and a computer program may be provided to the information processing apparatus 1000 via the communication line. .

以上の例は、情報処理装置1000について主に説明したが、コンピュータに、情報処理装置で説明した機能を有するプログラムをインストールして、そのコンピュータを情報処理装置として動作させることにより上記で説明した情報処理装置と同様な機能を実現することができる。   In the above example, the information processing apparatus 1000 has been mainly described. However, the information described above is obtained by installing a program having the function described in the information processing apparatus in a computer and causing the computer to operate as the information processing apparatus. Functions similar to those of the processing device can be realized.

本装置は、ハードウェア、ソフトウェア、またはハードウェアおよびソフトウェアの組み合わせとして実現可能である。ハードウェアとソフトウェアの組み合わせによる実施では、所定のプログラムを有するコンピュータ・システムでの実施が典型的な例として挙げられる。係る場合、該所定のプログラムが該コンピュータ・システムにロードされ実行されることにより、該プログラムは、コンピュータ・システムに本発明に係る処理を実行させる。このプログラムは、任意の言語、コード、または表記によって表現可能な命令群から構成される。そのような命令群は、システムが特定の機能を直接実行すること、または(1)他の言語、コード、もしくは表記への変換、(2)他の媒体への複製、のいずれか一方もしくは双方が行われた後に、実行することを可能にするものである。もちろん、本発明は、そのようなプログラム自体のみならず、プログラムを記録した媒体を含むプログラム製品もその範囲に含むものである。本発明の機能を実行するためのプログラムは、フレキシブル・ディスク、MO、CD−ROM、DVD、ハードディスク装置、ROM、MRAM、RAM等の任意のコンピュータ可読媒体に格納することができる。係るプログラムは、コンピュータ可読媒体への格納のために、通信回線で接続する他のコンピュータ・システムからダウンロードしたり、他の媒体から複製したりすることができる。また、係るプログラムは、圧縮し、または複数に分割して、単一または複数の記録媒体に格納することもできる。   The apparatus can be implemented as hardware, software, or a combination of hardware and software. A typical example of implementation using a combination of hardware and software is implementation on a computer system having a predetermined program. In such a case, the predetermined program is loaded into the computer system and executed, whereby the program causes the computer system to execute the processing according to the present invention. This program is composed of a group of instructions that can be expressed in any language, code, or notation. Such instructions may be either or both of the system directly performing a specific function, or (1) conversion to another language, code, or notation, and (2) copying to another medium. Can be executed after the Of course, the present invention includes not only such a program itself but also a program product including a medium on which the program is recorded. The program for executing the functions of the present invention can be stored in any computer-readable medium such as a flexible disk, MO, CD-ROM, DVD, hard disk device, ROM, MRAM, and RAM. Such a program can be downloaded from another computer system connected via a communication line or copied from another medium for storage in a computer-readable medium. Further, such a program can be compressed or divided into a plurality of parts and stored in a single or a plurality of recording media.

以上、本発明を実施形態に則して説明したが、本発明は上述した実施形態に限るものではない。また、本発明の実施形態に記載された効果は、本発明から生じる最も好適な効果を列挙したに過ぎず、本発明による効果は、本発明の実施形態または実施例に記載されたものに限定されるものではない。   Although the present invention has been described based on the embodiment, the present invention is not limited to the above-described embodiment. The effects described in the embodiments of the present invention are only the most preferable effects resulting from the present invention, and the effects of the present invention are limited to those described in the embodiments or examples of the present invention. Is not to be done.

本発明の一実施形態に係る、HTTPリクエストのStringクラスへの変換処理を示す概要図である。It is a schematic diagram which shows the conversion process to the String class of the HTTP request based on one Embodiment of this invention. 本発明の一実施形態に係る、HTTPリクエストのStringクラスへの変換処理のフローチャートである。It is a flowchart of the conversion process to the String class of the HTTP request based on one Embodiment of this invention. 本発明の一実施形態に係る、オーバーヘッドを削減するソースコードに変換するアルゴリズムを示すフローチャートである。It is a flowchart which shows the algorithm which converts into the source code which reduces overhead according to one Embodiment of this invention. 本発明の一実施形態に係る、ByteBufferオブジェクトbbへポインタを保持するStringオブジェクトsにおける、文字取得処理のフローチャートである。It is a flowchart of the character acquisition process in the String object s holding a pointer to the ByteBuffer object bb according to an embodiment of the present invention. 本発明の一実施形態に係る、Stringクラスの実装を示す図である。It is a figure which shows implementation of the String class based on one Embodiment of this invention. 本発明の一実施形態に係る、ByteBufferオブジェクトが保持するバッファの内容が変更される前に、StringがGCされた場合のCopy−On−Writeの動作概要を示す図である。It is a figure which shows the operation | movement outline | summary of Copy-On-Write when String is GC before the content of the buffer which ByteBuffer object hold | maintains changes based on one Embodiment of this invention. 本発明の一実施形態に係る、StringオブジェクトがGCされる前に、バッファの内容が変更された場合のCopy−On−Writeの動作概要を示す図である。It is a figure which shows the operation | movement outline | summary of Copy-On-Write when the content of a buffer is changed before String object is GC according to one Embodiment of this invention. サーバプログラム例を示す図である。It is a figure which shows the server program example. オーバーヘッドを削減するソースコードに変換されたサーバプログラム例を示す図である。It is a figure which shows the server program example converted into the source code which reduces an overhead. 本発明の一実施形態に係る、オーバーヘッドを削減するソースコードに変換するサーバ装置のハードウェア構成を示す図である。It is a figure which shows the hardware constitutions of the server apparatus converted into the source code which reduces overhead based on one Embodiment of this invention. 従来技術に係る、HTTPリクエストのStringクラスへの変換処理を示す概要図である。It is a schematic diagram which shows the conversion process to the String class of the HTTP request based on a prior art. 従来技術に係る、HTTPリクエストのStringクラスへの変換処理のフローチャートである。It is a flowchart of the conversion process to the String class of the HTTP request based on a prior art.

符号の説明Explanation of symbols

1 ByteBufferオブジェクトbb
2 Stringオブジェクトs
3 ポインタ
4 char[]配列
1 ByteBuffer object bb
2 String objects
3 Pointer 4 char [] array

Claims (9)

コンピュータを用いて、プログラムのソースコードをコード変換する方法であって、
文字列を保持する文字列型変数を特定するステップと、
特定した前記文字列型変数を、前記文字列を格納するバッファへの参照を保持する参照文字列型変数に型変換するステップと、
前記文字列型変数を前記参照文字列型変数に型変換した前記ソースコードを格納するステップと、
を含む、コード変換する方法。
A method of transcoding a program source code using a computer,
Identifying a string variable that holds the string;
Converting the identified string type variable into a reference string type variable that holds a reference to a buffer that stores the string; and
Storing the source code obtained by converting the character string type variable into the reference character string type variable;
Including transcoding.
前記型変換するステップは、更に、前記バッファが不変であるか否かを判定するステップを含む、請求項1に記載の方法。   The method of claim 1, wherein the step of converting further comprises determining whether the buffer is immutable. 前記判定するステップは、コンパイラが、前記ソースコードに対し構文解析をして得られた情報に基づいて、判定する、請求項2に記載の方法。   The method according to claim 2, wherein in the determining step, a compiler determines based on information obtained by parsing the source code. 前記型変換するステップは、更に、
前記判定が真である場合は、前記参照文字列型変数への型変換を実行し、
さもなければ前記参照文字列型変数への型変換を実行しない、請求項2に記載の方法。
The step of converting the type further includes:
If the determination is true, perform type conversion to the reference string type variable,
3. The method of claim 2, wherein otherwise no type conversion to the reference string type variable is performed.
参照文字列型変数は、前記文字列がASCII文字列である場合には、前記文字列を格納するバッファへの参照を保持し、
さもなければ、前記文字列を保持する、請求項1に記載の方法。
The reference character string type variable holds a reference to a buffer for storing the character string when the character string is an ASCII character string.
Otherwise, the method of claim 1, wherein the string is retained.
前記文字列が、HTTPリクエストである請求項1に記載の方法。   The method of claim 1, wherein the string is an HTTP request. サーバ装置を用いて、文字列の受信に応答して受信した前記文字列の表現を変更するプログラムのソースコードを、コード変換するサーバプログラムであって、
コンピュータが
前記文字列を保持する文字列型変数を特定するステップと、
特定した前記文字列型変数を、前記文字列を格納するバッファへの参照を保持する参照文字列型変数に型変換するステップと、
前記文字列型変数を前記参照文字列型変数に型変換した前記ソースコードを格納するステップと、
を実行する、サーバプログラム。
A server program for converting the source code of a program for changing the expression of the character string received in response to reception of the character string using a server device,
A computer identifying a string variable holding the string;
Converting the identified string type variable into a reference string type variable that holds a reference to a buffer that stores the string; and
Storing the source code obtained by converting the character string type variable into the reference character string type variable;
A server program that executes
文字列の受信に応答して、受信した前記文字列の表現を変更するプログラムのソースコードを、コード変換するサーバシステムであって、
前記文字列を保持する文字列型変数を特定する特定手段と、
特定した前記文字列型変数を、前記文字列を格納するバッファへの参照を保持する参照文字列型変数に型変換する変換手段と、
前記文字列型変数を前記参照文字列型変数に型変換した前記ソースコードを格納する格納手段と、
を含む、サーバシステム。
A server system for transcoding a source code of a program for changing the expression of the received character string in response to reception of the character string;
A specifying means for specifying a character string type variable that holds the character string;
Conversion means for converting the identified character string type variable into a reference character string type variable that holds a reference to a buffer that stores the character string;
Storage means for storing the source code obtained by converting the character string type variable into the reference character string type variable;
Including server system.
サーバ装置を用いて、HTTPリクエストの受信に応答して、受信した前記HTTPリクエストの表現を変更するプログラムのソースコードを、コード変換するサーバプログラムであって、
コンピュータが
前記HTTPリクエストを保持する文字列型変数を特定するステップと、
特定した前記文字列型変数を、前記HTTPリクエストを格納するバッファへの参照を保持する参照文字列型変数に型変換するステップと、
前記文字列型変数を前記参照文字列型変数に型変換した前記ソースコードを格納するステップと、を含み、
更に、前記バッファが不変であるか否かを判定するステップを含み、
前記判定が真である場合は、前記参照文字列型変数への型変換を実行し、
さもなければ前記参照文字列型変数への型変換を実行せず、
前記参照文字列型変数は、前記HTTPリクエストがASCII文字列でない場合には、前記HTTPリクエストを保持する、サーバプログラム。
A server program for transcoding a source code of a program for changing the expression of the received HTTP request in response to reception of an HTTP request using a server device,
A computer identifying a string variable holding the HTTP request;
Converting the identified string type variable into a reference string type variable that holds a reference to a buffer that stores the HTTP request; and
Storing the source code obtained by converting the character string type variable into the reference character string type variable,
Further comprising determining whether the buffer is immutable;
If the determination is true, perform type conversion to the reference string type variable,
Otherwise, do not perform type conversion to the reference string type variable,
The reference character string type variable is a server program that holds the HTTP request when the HTTP request is not an ASCII character string.
JP2008277002A 2008-10-28 2008-10-28 Source code conversion method, server system, and server program Expired - Fee Related JP5164112B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2008277002A JP5164112B2 (en) 2008-10-28 2008-10-28 Source code conversion method, server system, and server program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2008277002A JP5164112B2 (en) 2008-10-28 2008-10-28 Source code conversion method, server system, and server program

Publications (2)

Publication Number Publication Date
JP2010108076A JP2010108076A (en) 2010-05-13
JP5164112B2 true JP5164112B2 (en) 2013-03-13

Family

ID=42297497

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2008277002A Expired - Fee Related JP5164112B2 (en) 2008-10-28 2008-10-28 Source code conversion method, server system, and server program

Country Status (1)

Country Link
JP (1) JP5164112B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113660307B (en) * 2021-07-19 2024-01-19 中国电子科技集团公司第十五研究所 Algorithm comprehensive integrated service system

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3537032B2 (en) * 1999-10-27 2004-06-14 日本電気株式会社 Data type conversion method between different programming languages
US6996824B2 (en) * 2001-05-09 2006-02-07 Sun Microsystems, Inc. Frameworks for efficient representation of string objects in Java programming environments
US7162712B2 (en) * 2002-06-26 2007-01-09 Sun Microsystems, Inc. Method and apparatus for creating string objects in a programming language
JP4129981B2 (en) * 2004-04-02 2008-08-06 インターナショナル・ビジネス・マシーンズ・コーポレーション Compiler, compiler program, recording medium, control method, and central processing unit
US20080147696A1 (en) * 2006-12-19 2008-06-19 International Business Machines Corporation Method for reducing memory size allocated by a string class using unicode
JP2008226010A (en) * 2007-03-14 2008-09-25 Hitachi Ltd Compile method and compile device
JP2009129127A (en) * 2007-11-22 2009-06-11 Fujitsu Ltd Invariable object extraction processing program for program, processor, processing method, and storage medium for storing program

Also Published As

Publication number Publication date
JP2010108076A (en) 2010-05-13

Similar Documents

Publication Publication Date Title
US7913253B2 (en) Performing draw operations in a native code portion using cached drawing resources
JP3041222B2 (en) Source code creation system and method
US6854123B1 (en) Method, system, and program for mapping standard application program interfaces (APIs) to user interface APIs
TWI536263B (en) Projecting native application programming interfaces of an operating system into other programming languages
US8850414B2 (en) Direct access of language metadata
US8677328B2 (en) Generating a dynamic content creation program
US20040095387A1 (en) Virtualized and realized user interface controls
US6941520B1 (en) Method, system, and program for using a user interface program to generate a user interface for an application program
KR20130111220A (en) Distributing and parallelizing workloads in a computing platform
JP2001526421A (en) Apparatus and method for allowing object oriented programs written in different framework versions to communicate
US10303449B2 (en) Compiling non-native constants
US20070169069A1 (en) Method and apparatus for using pre-translated files in a virtual machine
US9038033B1 (en) Techniques and mechanisms for web application minification
US8606766B2 (en) Method and system to handle java class versioning
CN116934330A (en) Method for calling intelligent contract, executing method, computer equipment and storage medium
JPWO2011158478A1 (en) Data processing system and data processing method
US7458071B2 (en) Compilation method, compiler apparatus and compiler
JP4768984B2 (en) Compiling method, compiling program, and compiling device
US9760380B2 (en) Using grammar to serialize and de-serialize objects
JP5164112B2 (en) Source code conversion method, server system, and server program
KR100319765B1 (en) Method And Apparatus For Using Dynamic Document Capable Of Visual Screen Design And High Speed
CN117519691B (en) Application processing method, device, computer equipment and storage medium
JP4776972B2 (en) Cache generation method, apparatus, program, and recording medium
CN116931948A (en) Method for optimizing wasm byte code, execution method, computer equipment and storage medium
CN116931949A (en) Method for optimizing wasm byte code, execution method, computer equipment and storage medium

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20110908

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: 20121002

RD14 Notification of resignation of power of sub attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7434

Effective date: 20121003

R155 Notification before disposition of declining of application

Free format text: JAPANESE INTERMEDIATE CODE: R155

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20121212

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20151228

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees