Difference between revisions of "LSL Script Memory/ja"

From Second Life Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
{{Multi-lang}}{{LSL Header/ja}}{{RightToc}}
{{Multi-lang}}{{LSL Header/ja}}{{RightToc}}
'''現在翻訳作業中です...'''(これは翻訳作業者が、作業中であることを明示するために挿入した一文です。)
=スクリプトの容量=
=スクリプト・メモリー=
All scripts in LSL start out with 16 kilobytes of memory, and that memory is used up rapidly. Below is a list of code and the memory usage.


All of the following data was collected through [[llGetFreeMemory]](). As the LSL compiler is not a simple program, the data below may not be 100% accurate, in fact, much of it is wrong and can use corrections.
LSLにおける全てのスクリプトは16KBのメモリを使って動作し、あっというまに使い切ります。次にあるのはコードのメモリ消費量に関する一覧です。


There are still many bits that can be improved upon, and many more that can be taken into more detail. If anyone has any free time and doesn't know what to do, play around with the memory usage for different functions. A list of needed updates can be seen at the end of the page.
以下のデータ全ては[[llGetFreeMemory]]()を通して観測したものです。LSLコンパイラは単純なプログラムではないため、これらのデータを実際に調整用として、十二分に用いることできるかは疑わしいです。
 
さらに数ビット、及びそれ以上の改善ができる手段があります。もし暇な時間があってどうすればいいのかわからなければ、さまざまな関数のメモリ消費量周りを調べましょう。このページの終わりまで掲載されているリストを必要に応じて更新しましょう。


=変数=
=変数=
==変数をグローバルで宣言する==
==変数をグローバルで宣言する==
===Variable Memory Usage===
===変数のメモリ消費量===
<pre>
<pre>
integer  10
integer  10
Line 20: Line 20:
list    21 + list memory usage
list    21 + list memory usage
</pre>
</pre>
===List Memory Usage===
===リストのメモリ消費量===
<pre>
<pre>
integer  15
integer  15
Line 31: Line 31:
</pre>
</pre>
==default stateの内部で変数を宣言する==
==default stateの内部で変数を宣言する==
===Variable Memory Usage===
===変数のメモリ消費量===
<pre>
<pre>
integer  15
integer  15
Line 41: Line 41:
list    15 + list memory usage
list    15 + list memory usage
</pre>
</pre>
===List Memory Usage===
===リストのメモリ消費量===
<pre>
<pre>
integer  7
integer  7
Line 51: Line 51:
list    Lists Can Not Contain Lists
list    Lists Can Not Contain Lists
</pre>
</pre>
==Simply stating values==
==初期値==
===Putting a Value onto the Stack===
===スタックに入る値===
<pre>
<pre>
Integers 1 + 4 bytes for the value
Integers 1 + 4 bytes for the value
Line 62: Line 62:
List    1 + 4 for list length + list memory usage
List    1 + 4 for list length + list memory usage
</pre>
</pre>
To remove a value from the stack costs 1 byte.
スタックから除去するためのコストは1byteです。


===List Memory Usage===
===リストのメモリ消費量===
<pre>
<pre>
Integers 7
Integers 7
Line 75: Line 75:
</pre>
</pre>
==定数==
==定数==
All integer constants use 6 bytes of memory.
全てのinteger定数はメモリを6byte使用します。
===Other Constants===
===その他の定数===
<pre>
<pre>
ZERO_VECTOR  16
ZERO_VECTOR  16
Line 82: Line 82:
NULL_KEY      39
NULL_KEY      39
</pre>
</pre>
==Extras==
==例外==
6 bytes to reference variables
6byte分を参照する変数
==例==
==例==
<pre>
<pre>
Line 96: Line 96:
=関数=
=関数=
==関数の宣言==
==関数の宣言==
Functions require 16 bytes to be created, with 3 bytes per paramater, plus the return type.
関数は作成されるときに16byte、各パラメータと返り値の型にそれぞれ3byte必要とします。
===Return Types===
===返り値の型===
<pre>
<pre>
integer  4
integer  4
Line 107: Line 107:
list    4
list    4
</pre>
</pre>
==関数内の変数の宣言==
==関数内の変数として宣言==
===Variable Memory Usage===
===変数のメモリ消費量===
<pre>
<pre>
integer  11
integer  11
Line 118: Line 118:
list    11 + list memory usage
list    11 + list memory usage
</pre>
</pre>
===List Memory Usage===
===リストのメモリ消費量===
<pre>
<pre>
integer  7
integer  7
Line 128: Line 128:
list    Lists Can Not Contain Lists
list    Lists Can Not Contain Lists
</pre>
</pre>
==関数呼び出し==
==関数の呼び出し==
21 bytes to call a function with no return<br>
返り値なしの関数呼び出しには21byte、なんらかの返り値のある関数呼び出しには21byte。
21 bytes to call a function with any return + type of return<br>
引数の数を含めます。
Subtract number of parameters entered
 
===Return Types===
===返り値の型===
<pre>
integer  2
integer  2
float    2
float    2
Line 140: Line 141:
rotation 2
rotation 2
list    18 + list memory usage
list    18 + list memory usage
</pre>
==例==
==例==
<pre>
<pre>
Line 159: Line 161:
</pre>
</pre>
=演算子=
=演算子=
==List of Operators==  
==演算子一覧==  
<pre>
<pre>
+  1
+  1
Line 180: Line 182:
!= 1
!= 1
</pre>
</pre>
==Assignment==
==代入==
Assigning values to variables takes as many bytes as used minus one.
変数への値の代入には総バイト数から1引いた分を使用します。
===Examples===
======
<pre>
<pre>
string s; //12 bytes
string s; //12 bytes
Line 189: Line 191:
s = "";  //8 (6 (string) + 3 (null string) - 1) bytes
s = "";  //8 (6 (string) + 3 (null string) - 1) bytes
</pre>
</pre>
However...
しかしながら...
<pre>
<pre>
string s = ""; //12 bytes
string s = ""; //12 bytes
Line 197: Line 199:
i = i + 1 // 6 bytes (integer) + 6 bytes (integer) + 6 bytes (1) + 1 byte (addition) - 1 byte (assignment)
i = i + 1 // 6 bytes (integer) + 6 bytes (integer) + 6 bytes (1) + 1 byte (addition) - 1 byte (assignment)
</pre>
</pre>
==Statements==
==ステートメント==
<pre>
<pre>
if    6
if    6
Line 207: Line 209:
state 5
state 5
</pre>
</pre>
===Examples===
======
<pre>
<pre>
if (5 < 10) { // 6 (if) + 6 (integer) + 6 (integer) + 1 (compare)
if (5 < 10) { // 6 (if) + 6 (integer) + 6 (integer) + 1 (compare)
Line 218: Line 220:
}
}
</pre>
</pre>
==Typecasting==
==タイプキャスト==
<pre>
<pre>
integer  10
integer  10
Line 228: Line 230:
list    25
list    25
</pre>
</pre>
==States==
==ステート==
14 bytes for any event in a state + 1 for each parameter
ステート内におけるいずれかのイベントに14byte、各パラメータ毎に+1、新しいステートを作成する際に17byte必要です。
17 bytes to create a new state
=更新に必要なもの=
=Needed Updates=
このページに幾つかアップデートが必要な場合、最も必要なものを以下に挙げます。
Several updates are needed for this page, the most needed are listed below:
* 検証用の全データ
* Verification of all data
* 明確な説明
* Clarification of explanations
* 明確な関数の動き
* Investigations into how the functions work
** 関数の呼び出し
** Calling of functions
** 返り値の型がどんな結果を返すか
** How return types effect the return
* 以下のコードで、llGetFreeMemory()を呼び出して返ってくるさまざまな値。どんな影響がありましたか?また、それはなぜ?
* In the following code, the call to llGetFreeMemory() returns a different value. How is it affected? Why?
<pre>
<pre>
default {
default {

Latest revision as of 20:28, 25 December 2007

スクリプトの容量

LSLにおける全てのスクリプトは16KBのメモリを使って動作し、あっというまに使い切ります。次にあるのはコードのメモリ消費量に関する一覧です。

以下のデータ全てはllGetFreeMemory()を通して観測したものです。LSLコンパイラは単純なプログラムではないため、これらのデータを実際に調整用として、十二分に用いることできるかは疑わしいです。

さらに数ビット、及びそれ以上の改善ができる手段があります。もし暇な時間があってどうすればいいのかわからなければ、さまざまな関数のメモリ消費量周りを調べましょう。このページの終わりまで掲載されているリストを必要に応じて更新しましょう。

変数

変数をグローバルで宣言する

変数のメモリ消費量

integer  10
float    10
string   18 + 1 per character
key      18 + 1 per character
vector   18
rotation 22
list     21 + list memory usage

リストのメモリ消費量

integer  15
float    15
string   12 + 1 per character
key      12 + 1 per character
vector   23
rotation 27
list     Lists Can Not Contain Lists

default stateの内部で変数を宣言する

変数のメモリ消費量

integer  15
float    15
string   12 + 1 per character
key      12 + 1 per character
vector   31
rotation 39
list     15 + list memory usage

リストのメモリ消費量

integer  7
float    7
string   4 + 1 per character
key      4 + 1 per character
vector   23
rotation 30
list     Lists Can Not Contain Lists

初期値

スタックに入る値

Integers 1 + 4 bytes for the value
Float    1 + 4 bytes for the value
String   1 + bytes for characters + 1 byte for null
Key      1 + bytes for characters + 1 byte for null
Vector   1 + 3 * float cost
Rotation 1 + 4 * float cost
List     1 + 4 for list length + list memory usage

スタックから除去するためのコストは1byteです。

リストのメモリ消費量

Integers 7
Float    7
String   4 + 1 per character
Key      4 + 1 per character
Vector   23
Rotation 30
list     Lists Can Not Contain Lists

定数

全てのinteger定数はメモリを6byte使用します。

その他の定数

ZERO_VECTOR   16
ZERO_ROTATION 21
NULL_KEY      39

例外

6byte分を参照する変数

integer i; //10 bytes

default {
 state_entry() {
  list l = ["Testing", "This"] //15 (list) + 15 (string) + 8 (string)
 }
}

関数

関数の宣言

関数は作成されるときに16byte、各パラメータと返り値の型にそれぞれ3byte必要とします。

返り値の型

integer  4
float    4
string   4
key      4
vector   20
rotation 27
list     4

関数内の変数として宣言

変数のメモリ消費量

integer  11
float    11
string   8 + 1 per character
key      8 + 1 per character
vector   19
rotation 23
list     11 + list memory usage

リストのメモリ消費量

integer  7
float    7
string   4 + 1 per character
key      4 + 1 per character
vector   23
rotation 30
list     Lists Can Not Contain Lists

関数の呼び出し

返り値なしの関数呼び出しには21byte、なんらかの返り値のある関数呼び出しには21byte。 引数の数を含めます。

返り値の型

integer  2
float    2
string   10 + 1 per character returned
key      10 + 1 per character returned
vector   2
rotation 2
list     18 + list memory usage

list f() {  //16 (function) + 4 (return)
    list ret = [0]; //11 (list) + 7 (integer)
    return ret; 6 (list)
}  
string f() {
    return "";
}

default {
    state_entry() {
        f();   //21 (call to f) + 10 (returns string)
    }
}

演算子

演算子一覧

+  1
-  1
*  1
/  1
%  1
&  0
|  0
^  0
!  0
>> 0
<< 0
~  1
== 1
<= 1
<  1
>= 1
>  1
!= 1

代入

変数への値の代入には総バイト数から1引いた分を使用します。

string s; //12 bytes
s;        //6 bytes
"";       //3 bytes (see below)
s = "";   //8 (6 (string) + 3 (null string) - 1) bytes

しかしながら...

string s = ""; //12 bytes
integer i; //15 bytes
i = i + 1 // 6 bytes (integer) + 6 bytes (integer) + 6 bytes (1) + 1 byte (addition) - 1 byte (assignment)

ステートメント

if    6
while 11
for   11
do    6
jump  5
@     0
state 5

if (5 < 10) { // 6 (if) + 6 (integer) + 6 (integer) + 1 (compare)
//Do something here
}
while (1 < 2 & 3 < 4) { // 11 (while) + 4*6 (4 integers) + 2 (2 compares)
//Do something here
}

タイプキャスト

integer  10
float    10
string   10
key      10
vector   10
rotation 10
list     25

ステート

ステート内におけるいずれかのイベントに14byte、各パラメータ毎に+1、新しいステートを作成する際に17byte必要です。

更新に必要なもの

このページに幾つかアップデートが必要な場合、最も必要なものを以下に挙げます。

  • 検証用の全データ
  • 明確な説明
  • 明確な関数の動き
    • 関数の呼び出し
    • 返り値の型がどんな結果を返すか
  • 以下のコードで、llGetFreeMemory()を呼び出して返ってくるさまざまな値。どんな影響がありましたか?また、それはなぜ?
default {
     state_entry() {
          llOwnerSay((string)llGetFreeMemory());
          list l = ["", "", "", ""];
          llOwnerSay((string)llGetFreeMemory());
     }
}