From a065e04d529da1d847b5062a12c46d916408bf32 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 21:46:22 -0500 Subject: update based on https://github.com/mdn/yari/issues/2028 --- .../jsapi_reference/alphabetical_list/index.html | 228 ----- .../spidermonkey/jsapi_reference/index.html | 926 --------------------- .../jsapi_reference/js_compilefile/index.html | 66 -- .../jsapi_reference/js_constructobject/index.html | 63 -- .../jsapi_reference/js_defineobject/index.html | 126 --- .../jsapi_reference/js_destroycontext/index.html | 55 -- .../jsapi_reference/js_destroyruntime/index.html | 45 - .../jsapi_reference/js_dumpheap/index.html | 110 --- .../jsapi_reference/js_evaluatescript/index.html | 93 --- .../jsapi_reference/js_getgcparameter/index.html | 323 ------- .../jsapi_reference/js_getruntime/index.html | 47 -- .../js_getruntimeprivate/index.html | 59 -- .../jsapi_reference/js_init/index.html | 35 - .../jsapi_reference/js_lock/index.html | 37 - .../jsapi_reference/js_newcontext/index.html | 93 --- .../jsapi_reference/js_newobject/index.html | 104 --- .../jsapi_reference/js_newruntime/index.html | 52 -- .../jsapi_reference/js_setgczeal/index.html | 141 ---- .../jsapi_reference/js_shutdown/index.html | 34 - .../jsapi_reference/js_threadsafe/index.html | 114 --- .../spidermonkey/jsapi_reference/jsint/index.html | 42 - .../jsapi_reference/jsruntime/index.html | 23 - .../spidermonkey/jsapi_reference/jstype/index.html | 52 -- 23 files changed, 2868 deletions(-) delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/alphabetical_list/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_compilefile/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_constructobject/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_defineobject/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_destroycontext/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_destroyruntime/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_dumpheap/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_evaluatescript/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getgcparameter/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getruntime/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getruntimeprivate/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_init/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_lock/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newcontext/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newobject/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newruntime/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_setgczeal/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_shutdown/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_threadsafe/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/jsint/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/jsruntime/index.html delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/jstype/index.html (limited to 'files/ja/mozilla/projects/spidermonkey/jsapi_reference') diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/alphabetical_list/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/alphabetical_list/index.html deleted file mode 100644 index 4bf1ac4123..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/alphabetical_list/index.html +++ /dev/null @@ -1,228 +0,0 @@ ---- -title: Alphabetical List -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/Alphabetical_List -tags: - - JSAPI_Reference - - SpiderMonkey ---- -

参照: グループ別一覧, カテゴリ表示 (自動).

- diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/index.html deleted file mode 100644 index 5bb96c5566..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/index.html +++ /dev/null @@ -1,926 +0,0 @@ ---- -title: JSAPI リファレンス -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference -tags: - - JSAPI_Reference - - JavaScript - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference ---- - - -

JSAPI は、SpiderMonkey JavaScript エンジンのための C API です。JSAPI の使用方法を学ぶには、JSAPI User Guide および JSAPI Phrasebook をご覧ください。

- -
補足: FOSS のページに、Spidermonkey と JASPI の使用を助ける、他のライブラリやプログラムへのリンクがあります。
- -

アルファベット順一覧

- -

- -

ランタイムとコンテキスト

- - - - - - - - - - - -

ロケールコールバック:

- - - -

ロケールコールバック型:

- - - -

- -

スクリプト

- -

一部の JavaScript コードは直接実行されます:

- - - -

JavaScript コードを可能な JSScript へとコンパイルする代わりに、複数のアイテムを実行することができます。

- - - -

JavaScript コードを関数へとコンパイルすることもできます:

- - - -

- -

エラーハンドリング

- - - -

次の関数は、C/C++ 関数に JavaScript 例外のスローとキャッチを許可します。:

- - - - - -

これらの関数は、エラーを例外に、例外をエラーに翻訳します:

- - - -

- -

値と型

- - - -

jsval 定数:

- - - -

jsval の型をチェックする関数とマクロ:

- - - -

関数の引数を圧縮または展開する高レベル型変換ルーチン。

- - - - - -

次の関数は JS 値を変数型に変換します。これらは任意の型の jsval に安全に適用することができます。これらは新しいオブジェクトを返します。例えば、JS_ValueToObject(cx, s)s は新しい String ラッパーオブジェクトを作成する文字列です。これらの関数は JavaScript メソッドを呼び出します。例えば、JS_ValueToString(cx, obj)obj.toString() を呼び出します。

- - - -

高速な未チェックの型キャストマクロ。これらのマクロは正しい型として知られていない値に適用してはいけません。C のキャストのように、正しくない値に適用するとクラッシュの原因となります。これらは新しいオブジェクトを作成したり JavaScript コード内に呼び出したりすることはありません。

- - - -

typeof のように振る舞う関数:

- - - -

=== のように振る舞う関数:

- - - -

- -

メモリ管理

- -

これらの関数は、標準 C 関数の malloc 系のように動作します。ただし、エラーは errno ではなく、SpiderMonkey のエラー API を使用して報告されます:

- - - -

JavaScript オブジェクト、文字列、浮動小数点数はガーベッジコレクションの対象となります。これらの関数は、ガーベッジコレクタ(GC) へのアクセスを提供します:

- - - -

これら残りの API は、アプリケーションがガーベッジコレクションを行う前に、オブジェクトをガーベッジコレクタによる破壊から保護します。

- -

変数が root の場合、その変数へのポインタはガーベッジコレクタによって開放されません。ルートオブジェクトに対しての失敗は、よくある奇妙なクラッシュの原因です。

- - - -

ローカルのルートのスコープは、オブジェクトを別の方法でガーベッジコレクタから保護します。

- - - -

SpiderMonkey 1.8 (未リリース) の新機能 オブジェクトが、SpiderMonkey のデータ構造 ("slots") に格納されていない、他のガーベッジコレクタの対象への参照を含む場合、このオブジェクトは、ガーベッジコレクタのこれらの参照へのトラバース (traverse)を有効にするため、JSTraceOp フックを実装しなければなりません。しかし、ガーベッジコレクタは手の届く範囲のオブジェクトのみを整理しますが、すべてのオブジェクトを見つけることはできないため、クラッシュを引き起こします。(SpiderMonkey 1.7 以前のバージョンでは JSMarkOp フックが代わりに使用されます。これは SpiderMonkey 1.8 のリリース後は非推奨です。)

- -

トレース API は、ガーベッジコレクタと JSTraceOp フックによって使用されます。JSAPI アプリケーションもまた、これらの API をオブジェクトグラフを検査するために使用します。(例えば、これらの API は JS ガーベッジコレクタと他のガーベッジコレクタの、とても円滑な統合をサポートします。)

- - - -

その他の GC API:

- - - -

- -

数値

- - - -

- -

文字列

- - - - - -

Interning 文字列は SpiderMonkey エンジンに、可能ならば既存の文字列オブジェクトを再使用するように伝えます。

- - - -

external strings のための文字データはアプリケーションによって提供されるメモリに格納されます。アプリケーションはこれを、SpiderMonkey のヒープとアプリケーションのメモリの間で、データを先や後へコピーすることを防止するために使用します。

- - - -

- -

オブジェクト

- - - - - -

- -

プロパティ

- -

これらの関数は、直接スクリプトがオブジェクトのプロパティにアクセスする方法に相当します:

- - - -

次の低レベルの関数は、JSAPI アプリケーションが、プロパティの実装方法の詳細へのアクセスを許可します。"Define" は "set" の低レベル版であり、追加の設定へのアクセスを提供し、setter を呼び出しません。同様に、"lookup" は "get" の低レベル版であり、追加のオプションを与え、getter を呼び出しません。

- - - -

次の関数は、JS_GetProperty および JS_GetPropertyById のように振る舞います。ただし、E4X XML オブジェクト上の操作は除きます。

- - - -

SpiderMonkey 拡張は lvalue(オブジェクトのプロパティへの参照) を返すネイティブ関数を許可します:

- - - -

jsidjsval の一種です。ごく少数の API が、jsval の代わりに jsid をプロパティ名に使用します: JS_CheckAccess および JS_Enumerate, JS_GetMethodById, JS_NextProperty

- - - -

jsid 定数:

- - - -

jsid の型を調べる関数とマクロ:

- - - -

- -

クラス

- -

これらの API 機能は、C/C++ に実装された JavaScript からアクセス可能なカスタムクラス—オブジェクト型の定義に使用されます。

- - - -

ネイティブプロパティとメソッドをクラスに追加:

- - - -

JSFastNative メソッドはこれらのマクロを使用します: SpiderMonkey 1.8 の新機能

- - - -

JSClass の振る舞いとそのインスタンスは、コールバック関数を使用して多くの方法でカスタマイズすることができます。

- -

JSClass メソッド型:

- - - -

JSExtendedClass メソッド型:

- - - -

JSObjectOps メソッド型:

- - - -

JSXMLObjectOps メソッド型:

- - - -

これらの stub 関数はカスタム JSClass の作成時に使用されます:

- - - -

JSClass の振る舞いは、これらのフラグを使用してカスタマイズできます:

- - - -

- -

配列

- - - - - - - -

- -

関数

- -

関数またはオブジェクトのメソッドの呼び出し:

- - - -

関数アクセサリ:

- - - -

関数の生成:

- - - -

- -

正規表現

- - - -

- -

セキュリティ

- -

SpiderMonkey 1.8.1 の新機能 セキュリティのコールバックは、ランタイムごと、またはコンテキストごとに設定できます。

- - - -

- -

スレッド

- -

次の関数は SpiderMonkey のスレッドモデルをサポートしています。

- -

JSAPI 1.7 まで これらは JS_THREADSAFE ビルドでのみ利用可能です。

- -

SpiderMonkey 1.8 の新機能 これらの関数はいつでも利用可能です。ただし、JS_THREADSAFE 無しのビルドでは何もしません

- - - -

次の関数はすべてのビルドに存在します。ただし、JS_THREADSAFE 無しのビルドでは何もしません:

- - - -

- -

時間

- - - -

- -

コールバック型

- -

ネイティブ関数型:

- - - -

その他のコールバック型:

- - - -

上記のクラスも参照してください。

- -

- -

マクロ

- - - -

- -

C++ の機能

- - diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_compilefile/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_compilefile/index.html deleted file mode 100644 index a6d409dc85..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_compilefile/index.html +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: JS CompileFile -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_CompileFile -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_CompileUTF8File ---- -

- -

- -

- -

外部ファイルに含まれるスクリプトをコンパイルします。 Compile a script stored in an external file.

- -

構文

- -
JSScript * JS_CompileFile(JSContext *cx, JSObject *obj,
-    const char *filename);
-
- - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
cxJSContext *スクリプトをコンパイルするときのコンテキスト {{ Jsapi-requires-request() }}
objJSObject *スクリプトと関連付けるオブジェクトObject with which the script is associated.
filenameconst char *スクリプトを含むファイルの名前Name of file containing the script to compile.
- -

解説

- -

JS_CompileFileは、JavaScriptエンジンで実行するために外部ファイルのスクリプトをコンパイルする関数です。 <code>JS_CompileFile</code> compiles the text of script in an external file location for execution by the JS engine.

- -

filenameは、コンパイル対象のスクリプトを含んでいるファイルの名前を引数に取ります。 <code>filename</code> is the name of the file containing the script to compile.

- -

コンパイルが成功したとき、JS_CompileFileはコンパイル済みのスクリプトへのポインタを返値とします。失敗時にはNULLを返します。 On success, <code>JS_CompileFile</code> returns a pointer to the compiled script. Otherwise it returns <code>NULL</code>.

- -

ファイル名でスクリプトを指定するのではなく、文字列の引数として関数に渡す場合には、JS_CompileScriptを使ってください。 To pass a script as an argument to a function rather than having to specify a file location, use <code>JS_CompileScript</code> instead.

- -

関連項目

- -

{{ LXRSearch("ident", "i", "JS_CompileFile") }}

- -

JS_CompileScript, JS_DecompileScript, JS_DestroyScript, JS_EvaluateScript, JS_ExecuteScript

- -

{{ languages( { "en": "en/JS_CompileFile" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_constructobject/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_constructobject/index.html deleted file mode 100644 index ae7b116ff2..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_constructobject/index.html +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: JS ConstructObject -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ConstructObject -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ConstructObject ---- -

-

- -

新たにJavaScriptオブジェクトを生成し、コンストラクタを呼び出します。 Create a new JavaScript object and invoke its constructor.

- -

構文

- -
JSObject * JS_ConstructObject(JSContext *cx, JSClass *clasp,
-    JSObject *proto, JSObject *parent);
-
- - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
cxJSContext *新たなオブジェクトを配置するコンテキストThe context in which to create the new object. {{ jsapi-requires-request }}</td> </tr> <tr> <td><code>clasp</code></td> <td><code>JSClass *</code></td> <td>オブジェクト生成時に利用するクラスへのポインタ。<code>NULL</code>を指定したときは、一般的なJavaScript <code>Object</code>が生成されます。<!--Pointer to the class to use for the new object. If this is <code>NULL</code>, an ordinary JavaScript <code>Object</code> is created.
protoJSObject *クラスとなるプロトタイプオブジェクトへのポインタPointer to the prototype object to use for the new class.
parentJSObject *新たなオブジェクトの __parent__ プロパティに指定するオブジェクトへのポインタPointer to which to set the new object's __parent__ property.
- -

解説

- -

JS_ConstructObjectは、与えられたクラス、プロトタイプ、親オブジェクト、コンストラクタ関数をもとに新たなオブジェクトのインスタンスを生成する関数です。cxには、新たなオブジェクトを配置するランタイムと結び付けられたコンテキストへのポインタを指定します。claspには、ファイナライズ処理などの内部関数が定義された既存クラスへのポインタを指定します。protoは、新たなオブジェクトのプロトタイプとなるオブジェクトへのポインタを指定する引数です。 <code>JS_ConstructObject</code> instantiates a new object based on a specified class, prototype, and parent object, and then invokes its constructor function. <code>cx</code> is a pointer to a context associated with the runtime in which to establish the new object. <code>clasp</code> is a pointer to an existing class to use for internal methods, such as finalize. <code>proto</code> is an optional pointer to the prototype object with which to associate the new object.

- -

自分自身をプロトタイプオブジェクトにするには、protoNULLを指定してください。このとき、claspがプロトタイプを定義している場合には、JS_ConstructObjectは新たなオブジェクトのプロトタイプにそれを用います。定義していない場合は、空オブジェクトスタブをプロトタイプとします。 Set <code>proto</code> to <code>NULL</code> to force JS to assign a prototype object for you. In this case, <code>JS_ConstructObject</code> attempts to assign the new object the prototype object belonging to <code>clasp</code>, if one is defined there. Otherwise, it creates an empty object stub for the prototype.

- -

parentには、新規オブジェクトの親プロパティとなるオブジェクトへのポインタを指定します。この引数はオプションであり、parentNULLを指定することで親プロパティを持たないオブジェクトになります。 <code>parent</code> is an optional pointer to an existing object to which to set the new object's parent object property. You can set <code>parent</code> to <code>NULL</code> if you do not want to set the parent property.

- -

JS_ConstructObjectが成功したとき、新たに生成されたオブジェクトへのポインタをその返値とします。失敗したときはNULLを返します。 On success, <code>JS_ConstructObject</code> returns a pointer to the newly instantiated object. Otherwise it returns <code>NULL</code>.

- -

関連項目

- -

{{ LXRSearch("ident", "i", "JS_ConstructObject") }}

- -

JS_DefineObject, JS_GetFunctionObject, JS_NewArrayObject, JS_NewObject, JS_ValueToObject

- -

{{ languages( { "en": "en/JS_ConstructObject" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_defineobject/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_defineobject/index.html deleted file mode 100644 index 782201ccc5..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_defineobject/index.html +++ /dev/null @@ -1,126 +0,0 @@ ---- -title: JS_DefineObject -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DefineObject -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DefineObject ---- -

-

-

- -

あるオブジェクトのプロパティとなるオブジェクトを生成する関数です。 Create an object that is a property of another object. {{ 英語版章題("Syntax") }}

- -

構文

- -
JSObject * JS_DefineObject(JSContext *cx, JSObject *obj,
-    const char *name, JSClass *clasp, JSObject *proto,
-    uintN flags);
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
cxJSContext *エラー報告に用いるランタイム環境から派生したコンテキストへのポインタPointer to a JS context from which to derive runtime information for error reporting. {{ Jsapi-requires-request() }}
objJSObject *生成したオブジェクトをプロパティとして持つオブジェクトへのポインタObject to which this new object belongs as a property.
nameconst char *objでのプロパティ名Name of the property that encapsulates the new object in <code>obj</code>.
claspJSClass *オブジェクト生成に用いるクラスClass to use for the new object.
protoJSObject *オブジェクト生成に用いるプロトタイプPrototype object to use for the new object.
flagsuintN生成したオブジェクトの属性を指定するフラグProperty flags for the new object.
- -

{{ 英語版章題("Description") }}

- -

説明

- -

JS_DefineObjectは、オブジェクトのインスタンスを生成し、それを引数objで指定した既存オブジェクトのプロパティとして設定する関数です。引数nameで、objでのプロパティ名を指定し、flagsでそのプロパティの属性を指定します。以下の表で設定可能なflagsの値を示します。これらの値は単一、あるいは複数の値の論理和として引数に与えることができます。 <code>JS_DefineObject</code> instantiates and names a new object for an existing object, <code>obj</code>. <code>name</code> is the property name to assign to <code>obj</code> to hold the new object, and <code>flags</code> contains the property flags to set for the newly created property. The following table lists possible values you can pass in <code>flags</code>, either singly, or <code>OR</code>'d together:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FlagPurpose
JSPROP_ENUMERATEforinループを使ったアクセス(Core JavaScript 1.5 Guide:Object Manipulation Statements)を可能にします。Property is visible to <code>for</code> and <code>in</code> loops.
JSPROP_READONLYプロパティの値を読み取り専用にします。Property is read only.
JSPROP_PERMANENTプロパティの削除を不可能にします。Property cannot be deleted.
JSPROP_EXPORTEDProperty can be imported by other objects.
JSPROP_INDEXProperty is actually an index into an array of properties, and is cast to a const char *.
- -

引数claspはオブジェクトの生成時に用いる基底クラスへのポインタ、引数protoはプロトタイプへのポインタをそれぞれとります。protoNULLを指定した場合、JavaScriptは自分自身をプロトタイプとします。引数objはオブジェクトの親オブジェクトになります。 <code>clasp</code> is a pointer to the base class to use when creating the new object, and <code>proto</code> is an pointer to the prototype upon which to base the new object. If you set <code>proto</code> to <code>NULL</code>, JS sets the prototype object for you. The parent object for the new object is set to <code>obj</code>.

- -

JS_DefineObjectが成功したとき、返値は新たに生成したプロパティオブジェクトへのポインタになります。もしすでにプロパティが設定されていた場合、オブジェクトは生成されず、返り値はNULLになります。 <code>JS_DefineObject</code> returns a pointer to the newly created property object if successful. If the property already exists, or cannot be created, <code>JS_DefineObject</code> returns <code>NULL</code>. {{ 英語版章題("See Also") }}

- -

参照

- - - - - - - - - - - - - - - - -
GroupsFunctions
Documents{{ LXRSearch("ident", "i", "JS_DefineObject", "LXR ID Search") }}
Entries -

JSClass, JS_DefineConstDoubles, JS_DefineElement, JS_DefineFunction, JS_DefineFunctions, JS_DefineProperties, JS_DefineProperty, JS_DefinePropertyWithTinyId, JS_NewObject, JS_ValueToObject

-
- -
 
- -

{{ languages( { "en": "en/JS_DefineObject" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_destroycontext/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_destroycontext/index.html deleted file mode 100644 index be77b35a40..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_destroycontext/index.html +++ /dev/null @@ -1,55 +0,0 @@ ---- -title: JS DestroyContext -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DestroyContext -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DestroyContext ---- -

- - -

- - -

- -

JSContextを解放します。

- -

構文

- -
void JS_DestroyContext(JSContext *cx);
-
-void JS_DestroyContextNoGC(JSContext *cx);
-
-void JS_DestroyContextMaybeGC(JSContext *cx);
-
- - - - - - - - - - - - - - -
NameTypeDescription
cxJSContext *解放するコンテキスト
- -

解説

- -

これらの関数はコンテキストcxを解放します。それに加え、JS_DestroyContextは実行し、cxグローバルオブジェクトが利用したメモリを回収するためにガベージコレクションを実行します。JS_DestroyContextNoGCはガベージコレクションを実行しません。JS_DestroyContextMaybeGCでは、JavaScriptエンジンが十分なメモリ領域を解放できる可能性を判断し、ガベージコレクションを実行するか否かを判断します。 These functions destroy a context, <code>cx</code>. <code>JS_DestroyContext</code> additionally performs garbage collection to reclaim any memory that was being used by <code>cx</code>'s global object. <code>JS_DestroyContextNoGC</code> does not perform garbage collection. <code>JS_DestroyContextMaybeGC</code> may or may not perform garbage collection; the engine makes an educated guess as to whether enough memory would be reclaimed to justify the work.

- -

JS_THREADSAFEを有効にしたビルドでは、cxのrequest内でこの関数を呼ばないでください。

- -

JS_SetContextCallbackが以前に実行された場合は、そこで設定したコールバック関数が実行されます。 In a <code>JS_THREADSAFE</code> build, the caller must '''not''' be in a request on <code>cx</code>. If <code>JS_SetContextCallback</code> has been called, this calls the callback.

- -

{{ LXRSearch("ident", "i", "JS_DestroyContext") }}

- -

{{ languages( { "en": "en/JS_DestroyContext" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_destroyruntime/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_destroyruntime/index.html deleted file mode 100644 index d65b41c6d6..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_destroyruntime/index.html +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: JS DestroyRuntime -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DestroyRuntime -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DestroyRuntime ---- -

- -

- -

- -

JavaScriptランタイム環境を解放します。 Frees a JavaScript runtime.

- -

構文

- -
void JS_DestroyRuntime(JSRuntime *rt);
-
- - - - - - - - - - - - - - -
NameTypeDescription
rtJSRuntime *解放するランタイムThe runtime to destroy.
- -

説明

- -

JS_DestroyRuntimeは、JavaScriptランタイム環境rtを解放する関数です。JSAPIの利用を終えた後は必ずJS_DestroyRuntimeを呼び出してください。JS_DestroyRuntimeを呼ぶことで、ガベージコレクションおよびJS_NewRuntimeによって確保されたメモリ領域の解放が行われます。 <code>JS_DestroyRuntime</code> frees the specified the JavaScript runtime environment, <code>rt</code>. Call <code>JS_DestroyRuntime</code> after completing all other JS API calls. <code>JS_DestroyRuntime</code> garbage collects and frees the memory previously allocated by <code>JS_NewRuntime</code>.

- -

{{ LXRSearch("ident", "i", "JS_DestroyRuntime") }}

- -

{{ languages( { "en": "en/JS_DestroyRuntime" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_dumpheap/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_dumpheap/index.html deleted file mode 100644 index 4a9b9b3dba..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_dumpheap/index.html +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: JS_DumpHeap -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DumpHeap -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DumpHeap ---- -
{{SpiderMonkeySidebar("JSAPI")}}
- -

{{ obsolete_header("jsapi38") }}

- -

{{ Jsapi_minversion_header("1.8") }}

- -
DEBUG のみ。ヒープに割り当てられたもののオブジェクトグラフをダンプします。
- -

構文

- -
bool
-JS_DumpHeap(JSRuntime *rt, FILE *fp, void* startThing, JSGCTraceKind kind,
-            void *thingToFind, size_t maxDepth, void *thingToIgnore);
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
cx{{jsapixref("JSRuntime", "JSContext *")}}Pointer to a JS context. Every JSContext is permanently associated with a JSRuntime; each JSRuntime contains a GC heap.
fpFILE *File for the dump output.
startThingvoid *NULL or a pointer to a GC thing (use {{jsapixref("JS::Value", "JS::Value::toGCThing()")}} to obtain a pointer to pass here). When null, dump all things reachable from the runtime roots. When non-null, dump only things reachable from the object indicated.
startKindJSGCTraceKindTrace kind of startThing, if startThing is not null. Must be JSTRACE_OBJECT when startThing is null.
thingToFindvoid *NULL or a pointer to a GC thing. If this is non-null, JS_DumpHeap only dumps paths in the object graph leading to the specified thing.
maxDepthsize_tThe upper bound on the number of edges to descend from the graph roots.
thingToIgnorevoid *NULL or a pointer to a GC thing that will be ignored during graph traversal.
- -
enum JSGCTraceKind
-{
-    // These trace kinds have a publicly exposed, although opaque, C++ type.
-    // Note: The order here is determined by our Value packing. Other users
-    //       should sort alphabetically, for consistency.
-    JSTRACE_OBJECT = 0x00,
-    JSTRACE_STRING = 0x01,
-    JSTRACE_SYMBOL = 0x02,
-    JSTRACE_SCRIPT = 0x03,
-
-    // Shape details are exposed through JS_TraceShapeCycleCollectorChildren.
-    JSTRACE_SHAPE = 0x04,
-
-    // The kind associated with a nullptr.
-    JSTRACE_NULL = 0x06,
-
-    // A kind that indicates the real kind should be looked up in the arena.
-    JSTRACE_OUTOFLINE = 0x07,
-
-    // The following kinds do not have an exposed C++ idiom.
-    JSTRACE_BASE_SHAPE = 0x0F,
-    JSTRACE_JITCODE = 0x1F,
-    JSTRACE_LAZY_SCRIPT = 0x2F,
-    JSTRACE_TYPE_OBJECT = 0x3F,
-
-    JSTRACE_LAST = JSTRACE_TYPE_OBJECT
-};
-
- -

Description

- -

See {{ Bug(378261) }} for detail.

- -

When tracing a thing, the GC needs to know about the layout of the object it is looking at. There are a fixed number of different layouts that the GC knows about. The "trace kind" is a static map which tells which layout a GC thing has.

- -

Although this map is public, the details are completely hidden. Not all of the matching C++ types are exposed, and those that are, are opaque.

- -

See {{jsapixref("JS::Value", "JS::Value::gcKind()")}} and {{jsapixref("JSTraceCallback")}} in <codde>Tracer.h</codde> for more details.

- -

See Also

- - diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_evaluatescript/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_evaluatescript/index.html deleted file mode 100644 index a58d781ab4..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_evaluatescript/index.html +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: JS EvaluateScript -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_EvaluateScript -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_EvaluateScript ---- -

- -

- - -

- -

スクリプトのコンパイルおよび実行を行います。 Compile and execute a script.

- -

構文

- -
JSBool JS_EvaluateScript(JSContext *cx, JSObject *obj,
-    const char *src, uintN length, const char *filename,
-    uintN lineno, jsval *rval);
-
-JSBool JS_EvaluateUCScript(JSContext *cx, JSObject *obj,
-    const jschar *src, uintN length, const char *filename,
-    uintN lineno, jsval *rval);
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
cxJSContext *スクリプトを実行するコンテキストThe context in which to run the script. {{ Jsapi-requires-request() }}
objJSObject *スクリプトと関連付けるオブジェクトObject with which the script is associated.
srcconst char *or const jschar *コンパイル・実行対象となるスクリプト文字列String containing the script to compile and execute.
lengthsize_tsrcの文字列長The length of <code>src</code>, in characters.
filenameconst char *エラーメッセージ出力に利用されるスクリプトのファイル名またはそのURLを示す文字列。Name of file or URL containing the script. Used to report filename or URL in error messages.
linenouintNエラー発生時に出力される行数Line number. Used to report the offending line in the file or URL if an error occurs.
rvaljsval *実行結果の出力先。実行に成功したとき、*rvalにはスクリプトの最終行の実行結果の値が格納されます。Out parameter. On success, <code>*rval</code> receives the value of the last-executed expression statement processed in the script.
- -

説明

- -

JS_EvaluateScriptは、オブジェクトobjに結合する形でスクリプトをコンパイル・実行する関数です。実行が成功したとき、rvalにスクリプトの最終行の実行結果の値へのポインタが格納されています。この関数のUnicode版として、JS_EvaluateUCScriptが用意されています。 <code>JS_EvaluateScript</code> compiles and executes a script associated with a JS object, <code>obj</code>. On successful completion, <code>rval</code> is a pointer to a variable that holds the value from the last executed expression statement processed in the script. <code>JS_EvaluateUCScript</code> is the Unicode version of the function.

- -

srcはスクリプト文字列、lengthはその文字列の長さをそれぞれ引数として取ります。 <code>src</code> is the string containing the text of the script. <code>length</code> indicates the size of the text version of the script in characters.

- -

filenameはスクリプトの位置を示すファイル名またはURLを引数として取ります。ここで指定した情報は、コンパイルエラーが発生したときのエラーメッセージに利用されます。linenoも同様にエラーメッセージとして出力される行番号として利用されます。 <code>filename</code> is the name of the file (or URL) containing the script. This information is used in messages if an error occurs during compilation. Similarly, <code>lineno</code> is used to report the line number of the script or file where an error occurred during compilation.

- -

スクリプトのコンパイルと実行が成功したとき、JS_EvaluateScriptおよびJS_EvaluateUCScriptJS_TRUEを、失敗したときはJS_FALSEをそれぞれ返します。コンパイル・実行に失敗したとき、*rvalの値は未定義とみなす必要があります。 If a script compiles and executes successfully, <code>JS_EvaluateScript</code> or <code>JS_EvaluateUCScript</code> returns <code>JS_TRUE</code>. Otherwise it returns <code>JS_FALSE</code>. On failure, your application should assume that <code>*rval</code> is undefined.

- -

関連項目

- -

{{ LXRSearch("ident", "i", "JS_EvaluateScript") }}
- {{ LXRSearch("ident", "i", "JS_EvaluateUCScript") }}

- -

JS_CompileFile, JS_CompileScript, JS_DecompileScript, JS_DestroyScript, JS_EvaluateScriptForPrincipals, JS_ExecuteScript

- -

{{ languages( { "en": "en/JS_EvaluateScript" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getgcparameter/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getgcparameter/index.html deleted file mode 100644 index 1bfa969e7c..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getgcparameter/index.html +++ /dev/null @@ -1,323 +0,0 @@ ---- -title: JS_GetGCParameter -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetGCParameter -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetGCParameter ---- -
{{SpiderMonkeySidebar("JSAPI")}}
- -
-

ガベージコレクションに関連するパフォーマンスパラメータを調整します。

-
- -

構文

- -
uint32_t
-JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key);
-
-void
-JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32_t value);
-
-uint32_t
-JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key); // Added in SpiderMonkeySidebar 17
-
-void
-JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32_t value); // Added in SpiderMonkeySidebar 17
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
rt{{jsapixref("JSRuntime", "JSRuntime *")}}The runtime to configure.
cx{{jsapixref("JSRuntime", "JSContext *")}}The context to configure. {{ Jsapi-requires-request() }}
keyJSGCParamKeySpecifies which garbage collection parameter to get or set.
valueuint32_t(JS_SetGCParameter only) The value to assign to the parameter.
- -
typedef enum JSGCParamKey {
-    JSGC_MAX_BYTES,
-    JSGC_MAX_MALLOC_BYTES,
-    JSGC_MAX_NURSERY_BYTES,
-    JSGC_BYTES,
-    JSGC_NUMBER,
-    JSGC_MODE,
-    JSGC_UNUSED_CHUNKS,
-    JSGC_TOTAL_CHUNKS,
-    JSGC_SLICE_TIME_BUDGET,
-    JSGC_MARK_STACK_LIMIT,
-    JSGC_HIGH_FREQUENCY_TIME_LIMIT,
-    JSGC_HIGH_FREQUENCY_LOW_LIMIT,
-    JSGC_HIGH_FREQUENCY_HIGH_LIMIT,
-    JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX,
-    JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN,
-    JSGC_LOW_FREQUENCY_HEAP_GROWTH,
-    JSGC_DYNAMIC_HEAP_GROWTH,
-    JSGC_DYNAMIC_MARK_SLICE,
-    JSGC_ALLOCATION_THRESHOLD,
-    JSGC_MIN_EMPTY_CHUNK_COUNT,
-    JSGC_MAX_EMPTY_CHUNK_COUNT,
-    JSGC_COMPACTION_ENABLED,
-    JSGC_ALLOCATION_THRESHOLD_FACTOR,
-    JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT,
-    JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION,
-    JSGC_PRETENURE_THRESHOLD,
-    JSGC_PRETENURE_GROUP_THRESHOLD,
-    JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION_PERCENT,
-    JSGC_MIN_NURSERY_BYTES,
-    JSGC_MIN_LAST_DITCH_GC_PERIOD,
-} JSGCParamKey;
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Value (C++/JS Shell)Description
JSGC_MAX_BYTES / "maxBytes"Maximum nominal heap before last ditch GC.
JSGC_MAX_MALLOC_BYTES / "maxMallocBytes"Number of JS_malloc bytes before last ditch GC.
JSGC_MAX_NURSERY_BYTES / "maxNurseryBytes"Maximum size the nursery may grow to, or 0 to disable generational GC.
JSGC_MIN_NURSERY_BYTES / "minNurseryBytes"Minimum size the nursery may shrink to.
JSGC_BYTES / "gcBytes"Amount of bytes allocated by the GC.
JSGC_NUMBER / "gcNumber"Number of times GC has been invoked. Includes both major and minor GC.
JSGC_MODE / "mode" -

Select GC mode:

- -
-
JSGC_MODE_GLOBAL (0)
-
The GC runs all objects are visited in a singleslice.
-
JSGC_MODE_ZONE (1)
-
The GC runs only the objects that belong to somezones are visited in a singleslice.
-
JSGC_MODE_INCREMENTAL (2)
-
The GC runs all objects are visited in multipleslices.
-
JSGC_MODE_ZONE_INCREMENTAL (3)
-
The GC runs only the objects that belong to somezones are visited in multipleslices.
-
- -

This does not affect generational GC, see JSGC_MAX_NURSERY_BYTES

-
JSGC_UNUSED_CHUNKS / "unusedChunks"Number of cached empty GC chunks.
JSGC_TOTAL_CHUNKS / "totalChunks"Total number of allocated GC chunks.
JSGC_SLICE_TIME_BUDGET / "sliceTimeBudget"Max milliseconds to spend in an incremental GC slice. 0 for infinite.
JSGC_MARK_STACK_LIMIT / "markStackLimit"Maximum size the GC mark stack can grow to (units: entries).
JSGC_HIGH_FREQUENCY_TIME_LIMIT / "highFrequencyTimeLimit"GCs less than this far apart in time will be considered 'high-frequency GCs'.
JSGC_HIGH_FREQUENCY_LOW_LIMIT / "highFrequencyLowLimit" -

Controls for dynamic heap growth. When the GC is in "high frequency" mode (see above) then, the heap will be allowed to grow between collections according to these four parameters. See ZoneHeapThreshold::computeZoneHeapGrowthFactorForHeapSize in GC.cpp for the details.

- -

The first two parameters are in MB and the remaining two are in percentage of heap size.

-
JSGC_HIGH_FREQUENCY_HIGH_LIMIT / "highFrequencyHighLimit"
JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX / "highFrequencyHeapGrowthMax"
JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN / "highFrequencyHeapGrowthMin"
JSGC_LOW_FREQUENCY_HEAP_GROWTH / "lowFrequencyHeapGrowth"Heap growth percentage for low frequency GCs.
JSGC_DYNAMIC_HEAP_GROWTH / "dynamicHeapGrowth"If false, the heap growth percentage is fixed at 300%. If true, it is determined based on whether GCs are high- or low- frequency.
JSGC_DYNAMIC_MARK_SLICE / "dynamicMarkSlice"If true, high-frequency GCs will use a longer mark slice.
JSGC_ALLOCATION_THRESHOLD / "allocationThreshold"Lower limit after which we limit the heap growth. The heap will be collected if it is greater than: MAX(allocThreshold, lastSize) * thresholdFactor, This establishes allocThreshold as a baseline or default heap size.
JSGC_ALLOCATION_THRESHOLD_FACTOR / "allocationThresholdFactor" -

These thresholds (as percentages) are compared with the zone threshold (above) to decide when to begin an incremental collection. JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT is used when a GC is already in progress for other zones and we may wish to avoid interrupting it.

- -

Additionally if a zone expands beyond the threshold without this factor, then it will be collected non-incrementally

-
JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT / "allocationThresholdfactorAvoidInterrupt"
JSGC_MIN_EMPTY_CHUNK_COUNT / "minEmptyChunkCount"We try to keep at least this many unused chunks in the free chunk pool at all times, even after a shrinking GC.
JSGC_MAX_EMPTY_CHUNK_COUNT / "maxEmptyChunkCount"We never keep more than this many unused chunks in the free chunk pool.
JSGC_COMPACTION_ENABLED / "compactingEnabled"non-zero to enable compacting, zero to disable.
JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION / "nurseryFreeThresholdForIdleCollection"Collect the nursery in idle time if it has less than this many bytes of free space.
JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION_PERCENT / "nurseryFreeThresholdForIdleCollectionPercent"Collect the nursery in idle time if it has less than this percentage of capacity free (value from 0 - 99).
JSGC_PRETENURE_THRESHOLD / "pretenureThreshold"If this percentage of the nursery is tenured and the nursery is at least 4MB, then process object groups to look for pretenuring candidates.
JSGC_PRETENURE_GROUP_THRESHOLD / "pretenureGroupThreshold"If more than this number of objects in a given object group are tenured, then pretenruing will be enabled for new objects in this group.
JSGC_MIN_LAST_DITCH_GC_PERIOD / "minLastDitchGCPeriod"The minimum time to allow between triggering last ditch GCs in seconds.
- -

説明

- -

JS_GetGCParameter returns the current parameter of the garbage collection.

- -

If successful, JS_GetGCParameter returns the current parameter.

- -

JS_SetGCParameter ajusts the parameter of the garbage collection.

- -

あわせて参照

- - diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getruntime/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getruntime/index.html deleted file mode 100644 index 36a7593d57..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getruntime/index.html +++ /dev/null @@ -1,47 +0,0 @@ ---- -title: JS GetRuntime -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetRuntime -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetRuntime ---- -

- -

- - - -

- -

JSRuntimeへのポインタを取得します。 Retrieves a pointer to the <code>JSRuntime</code>.

- -

構文

- -
JSRuntime * JS_GetRuntime(JSContext *cx);
-
- - - - - - - - - - - - - - -
NameTypeDescription
cxJSContext *コンテキスト
- -

説明

- -

JS_GetRuntimeは、JSContext cxと関連付けられたJSRuntimeへのポインタを取得する関数です。各コンテキストは、その生成時に指定した (JS_NewContextを参照) JSRuntimeと関連付けられており、JS_GetRuntimeを使うことでその関連付けを取得することができます。 <code>JS_GetRuntime</code> retrieves a pointer to the <code>JSRuntime</code> with which a specified <code>JSContext</code>, <code>cx</code>, is associated. Each context is associated with a particular <code>JSRuntime</code> when it is created (see <code>JS_NewContext</code>); <code>JS_GetRuntime</code> provides a convenient, programmatic way to look up the association.

- -

{{ LXRSearch("ident", "i", "JS_GetRuntime") }}

- -

{{ languages( { "en": "en/JS_GetRuntime" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getruntimeprivate/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getruntimeprivate/index.html deleted file mode 100644 index c4f3f7937b..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getruntimeprivate/index.html +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: JS GetRuntimePrivate -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetRuntimePrivate -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetRuntimePrivate ---- -

- -

- - -

- -

JSRuntimeオブジェクトと関連付けられたアプリケーション固有のフィールドにアクセスします。 Access a <code>JSRuntime</code> field for application-specific data.

- -

構文

- -
void * JS_GetRuntimePrivate(JSRuntime *rt);
-
-void JS_SetRuntimePrivate(JSRuntime *rt, void *data);
-
- - - - - - - - - - - - - - - - - - - -
NameTypeDescription
rtJSRuntime *JavaScriptランタイム環境Any JS runtime.
datavoid *(JS_SetRuntimePrivateのみ)ランタイムrtと関連付けるアプリケーション固有のデータへのポインタ ''(in <code>JS_SetRuntimePrivate</code>)'' Pointer to application-defined data to be associated with the runtime <code>rt</code>.
- -

説明

- -

JSRuntime内には、アプリケーション内で用いる任意のデータを指し示すvoid *型のフィールドが存在します。このフィールドは、コールバック関数が容易にアクセスできる領域であるため、その中でのデータ格納に有用に使えます。JS_GetRuntimePrivateでフィールドの値を取得し、JS_SetRuntimePrivateで値を設定します。フィールドの初期値はNULLに設定されています。 Each <code>JSRuntime</code> has a field of type <code>void *</code> which the application may use for any purpose. It is especially useful for storing data which callbacks may then easily access. <code>JS_GetRuntimePrivate</code> gets the value of this field and <code>JS_SetRuntimePrivate</code> sets it. The field is initially <code>NULL</code>.

- -

このプライベートなデータのメモリ管理はアプリケーション側の責任になります。JavaScriptエンジン自体がこの領域を利用することはありません。 Memory management for this private data is the application's responsibility. The JavaScript engine itself never uses it.

- -

関連項目

- -

{{ LXRSearch("ident", "i", "JS_GetRuntimePrivate") }}

- -

JS_GetContextPrivate, JS_SetContextPrivate, JS_GetPrivate, JS_SetPrivate, JS_GetInstancePrivate

- -

{{ languages( { "en": "en/JS_GetRuntimePrivate" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_init/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_init/index.html deleted file mode 100644 index 1d52ec7034..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_init/index.html +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: JS_Init -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_Init -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_Init ---- -
{{obsolete_header}}
- - -

構文

- - -
JSRuntime * JS_Init(uint32 maxbytes);
-
- - - - - - - - - - - - - - - - - -
名称説明
maxbytesuint32ガベージコレクション実行後に割り当てられたバイト数
- - -

説明

-

JS_Init は廃止されました。替わりに JS_NewRuntime を使用して下さい。

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_lock/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_lock/index.html deleted file mode 100644 index 1ffb9dee10..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_lock/index.html +++ /dev/null @@ -1,37 +0,0 @@ ---- -title: JS_Lock -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_Lock -tags: - - JSAPI_Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_Lock ---- -
- {{obsolete_header("jsapi12")}}
-

JS ランタイム環境をロックします。

-

構文

-
void JS_Lock(JSRuntime *rt);
-
- - - - - - - - - - - - - - - -
名称説明
rtJSRuntime *ロックするランタイムへのポインタ
-

説明

-

JS_Lock は非推奨 API です。使用しないで下さい。

-

関連情報

- diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newcontext/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newcontext/index.html deleted file mode 100644 index ab77638f70..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newcontext/index.html +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: JS NewContext -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_NewContext -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_NewContext ---- -

- -

- -

- -

新たなJavaScriptコンテキストを生成します。 Creates a new JavaScript context.

- -

構文

- -

= Syntax =

- -
JSContext * JS_NewContext(JSRuntime *rt, size_t stackchunksize);
-
- - - - - - - - - - - - - - - - - - - -
NameTypeDescription
rtJSRuntime *コンテキストの親となるランタイムを指定します。JavaScriptのオブジェクト、関数、文字列、数値はJSRuntime内のコンテキスト内で共有されますが、JSRuntimeをまたぐことはありません。 -

Parent runtime for the new context. JavaScript objects, functions, strings, and numbers may be shared among the contexts in a <code>JSRuntime</code>, but they cannot be shared across <code>JSRuntime</code>s.

-
stackchunksizesize_t -

各スタック領域のサイズをバイトで指定します。標準的には8192が適切な値であり、大抵の場合において調節すべきでないパラメータです。 The size, in bytes, of each "stack chunk". This is a memory management tuning parameter which most users should not adjust. <code>8192</code> is a good default value.

-
- -

説明

- -

= Description = スクリプトの実行および値の保持に利用するコンテキストを新規に生成する関数です。各スクリプトは独自のコンテキスト上で実行され、各コンテキストは特定のJSRuntimeオブジェクトrtと関連づけられています。 Creates a new JavaScript context for executing scripts and examining JavaScript values. Each script runs in its own context, and each context must be associated with a specified <code>JSRuntime</code>, <code>rt</code>.

- -

JS_NewContextは、成功したとき新たなコンテキストへのポインタを返します。失敗したときはNULLを返します。 On success, <code>JS_NewContext</code> returns a pointer to the new context. Otherwise it returns <code>NULL</code>.

- -

この関数の呼び元は、コンテキストを使い終わったらJS_DestroyContextを実行しなければなりません。JSRuntimeを解放する前に、そのJSContextをすべて解放する必要があります。 The caller must call <code>JS_DestroyContext</code> when it is done using the context. Before a <code>JSRuntime</code> may be destroyed, all the <code>JSContext</code>s associated with it must be destroyed.

- -

JS_THREADSAFEを有効にしたビルドでは、あるJSContextを同時にアクセスできるスレッドは一つだけです。新規のJSContextは、初期状態で呼び元のスレッドと関連付けられます。コンテキストがあるスレッドと関連付けられている間は、他のスレッドからそれを利用したり解放することはできません。JSContextを別のスレッドに移動する場合は、JS_ClearContextThreadJS_SetContextThreadを利用してください。 In a <code>JS_THREADSAFE</code> build, only one thread may use a <code>JSContext</code> at a time. The new <code>JSContext</code> is initially associated with the calling thread. As long as it stays associated with that thread, no other thread may use it or destroy it. A <code>JSContext</code> may be transferred from one thread to another by calling <code>JS_ClearContextThread</code> and <code>JS_SetContextThread</code>.

- -

新たに生成したJSContextは、初期状態においてグローバルオブジェクトを持ちません。 The new <code>JSContext</code> initially has no global object.

- -

注記

- -

== Notes == 一度生成されたコンテキストは異なるスクリプトやJSAPI呼び出しのために複数回利用される可能性があります。具体的には、Webブラウザが各HTMLに対応する独立したコンテキストを生成したときに、ページ内のすべてのスクリプトは同じコンテキストを用いて実行されるといったシナリオが考えられます。 Once created, a context can be used any number of times for different scripts or JSAPI queries. For example, a browser would create a separate context for each HTML page; every script in the page would use the same context.

- -

新規コンテキストは、ObjectDateArrayといった標準的なグローバルオブジェクトを一切保持していません。それらを利用するには、JS_InitStandardClassesを呼び出す必要があります。JSAPIを利用するアプリケーションで独自の関数やクラスを提供したい場合には、JS_GetGlobalObjectを使ってそのコンテキストのグローバルオブジェクトを取得し、JS_DefineFunctionsおよびJS_InitClassをそれに適用することで独自のグローバル関数やクラスをコンテキストに追加できます。 The new context initially does not contain any globals, even standard globals such as <code>Object</code>, <code>Date</code>, and <code>Array</code>. To create them, call <code>JS_InitStandardClasses</code>. A JSAPI application typically also provides some custom functions and classes. Use <code>JS_GetGlobalObject</code> to get a context's global object. Use <code></code> and <code>JS_InitClass</code> to add custom global functions and classes to the context.

- -

stackchunksizeは、JavaScriptのスタックサイズを調節するものではありません(JSAPIでは、スタック長を調節するインタフェースを提供していません)。stackchunksizeに大きい値を設定するのは誤った方法です。DEBUGビルドにおいて、stackchunksizeを大きくすると性能が著しく劣化します。一般的には8192が推奨されます。 The <code>stackchunksize</code> parameter does not control the JavaScript stack size. (The JSAPI does not provide a way to adjust the stack depth limit.) Passing a large number for <code>stackchunksize</code> is a mistake. In a <code>DEBUG</code> build, large chunk sizes can degrade performance dramatically. The usual value of <code>8192</code> is recommended.

- -

関連項目

- -

= See Also =

- - - - - - - - - - - - - - - - -
GroupsFunctions
Documents{{ LXRSearch("ident", "i", "JS_NewContext", "LXR ID Search") }}
EntriesJS_ContextIterator, -

JS_DestroyContext, JS_SetContextCallback

-
- -

{{ languages( { "en": "en/JS_NewContext" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newobject/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newobject/index.html deleted file mode 100644 index 8efb4676c7..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newobject/index.html +++ /dev/null @@ -1,104 +0,0 @@ ---- -title: JS_NewObject -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_NewObject -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_NewObject ---- -

- -

- -

- -

{{ 英語版章題("Summary") }}

- -

概要

- -

オブジェクトのインスタンスを生成する関数です。Instantiates a new object.

- -

{{ 英語版章題("Syntax") }}

- -

構文

- -
JSObject * JS_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto,
-    JSObject *parent);
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
cxJSContext *ランタイム環境へのアクセスに用いる JSContext ポインタPointer to a JS context from which to derive runtime information.
claspJSClass *オブジェクト生成に用いるクラスへのポインタPointer to the class to use for the new object.
protoJSObject *クラスとして用いる prototype オブジェクトへのポインタPointer to the prototype object to use for the new class.
parentJSObject *新規オブジェクトの__parent__プロパティになる親オブジェクトへのポインタ。Pointer to which to set the new object's <code>__parent__</code> property.
- -

{{ 英語版章題("Description") }}

- -

説明

- -

JS_NewObjectは、引数に指定したクラス、プロトタイプ、親オブジェクトを元にしてオブジェクトのインスタンスを生成する関数です。cxは、新規オブジェクトを生成するランタイム環境の子となるコンテキストへのポインタです。claspは、finalizeのような内部で定義されたメソッドを使う既存クラスへのポインタです。protoは、新規に生成するオブジェクトのプロトタイプとなるオブジェクトへのポインタです。 <code>JS_NewObject</code> instantiates a new object based on a specified class, prototype, and parent object. <code>cx</code> is a pointer to a context associated with the runtime in which to establish the new object. <code>clasp</code> is a pointer to an existing class to use for internal methods, such as <code>finalize</code>. <code>proto</code> is an optional pointer to the prototype object with which to associate the new object.

- -

Set proto to NULL to force JS to assign a prototype object for you. In this case, JS_NewObject attempts to assign the new object the prototype object belonging to clasp, if one is defined there. Otherwise, it creates an empty object stub for the prototype.

- -

引数parentは、新たに生成したオブジェクトをプロパティとして持つ親オブジェクトを指定するものです。__parent__プロパティを設定したくない時は、parentNULLを指定してください。 <code>parent</code> is an optional pointer to an existing object to which to set the new object's parent object property. You can set parent to <code>NULL</code> if you do not want to set the <code>__parent__</code> property.

- -

JS_NewObjectが成功したとき、その返値は生成したオブジェクトのインスタンスへのポインタになり、失敗した時はNULLを返します。 On success, <code>JS_NewObject</code> returns a pointer to the newly instantiated object. Otherwise it returns <code>NULL</code>.

- -

{{ 英語版章題("Notes") }}

- -

注記

- -

既存オブジェクトのプロパティとなるオブジェクトを生成するには、JS_DefineObjectを用いてください。 To create a new object that is a property of an existing object, use <code>JS_DefineObject</code>.

- -

{{ 英語版章題("See Also") }}

- -

参照

- - - - - - - - - - - - - - - - -
GroupsFunctions
Documents{{ LXRSearch("ident", "i", "JS_NewObject", "LXR ID Search") }}
Entries -

JSClass, JS_ConstructObject, JS_DefineObject, JS_GetFunctionObject, JS_NewArrayObject, JS_ValueToObject

-
- -
 
- -

{{ languages( { "en": "en/JS_NewObject" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newruntime/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newruntime/index.html deleted file mode 100644 index 5db8397cb9..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newruntime/index.html +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: JS NewRuntime -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_NewRuntime -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_NewRuntime ---- -

-

- -

JavaScript ランタイムの初期化を行います。 {{ 英語版章題("Syntax") }}

- -

構文

- -
JSRuntime * JS_NewRuntime(uint32 maxbytes);
-
- - - - - - - - - - - - - - -
NameTypeDescription
maxbytesuint32ガベージコレクション動作後の最大メモリ使用量Maximum number of allocated bytes after which garbage collection is run.
- -

{{ 英語版章題("Description") }}

- -

説明

- -

JS_NewRuntimeは、JavaScriptランタイム環境の初期化を行う関数です。他のJSAPI関数を使うには前もって必ずJS_NewRuntimeを呼ぶことになります。JS_NewRuntimeは、JSRuntimeに用いるメモリ領域を確保し、ランタイム内の初期化を行います。引数maxbytesで、ガベージコレクションが動作した後の最大メモリ使用量を指定します。 <code>JS_NewRuntime</code> initializes the JavaScript runtime environment. Call <code>JS_NewRuntime</code> before making any other API calls. <code>JS_NewRuntime</code> allocates memory for the <code>JSRuntime</code> and initializes certain internal runtime structures. <code>maxbytes</code> specifies the number of allocated bytes after which garbage collection is run.

- -

一般的に、ほとんどのアプリケーションで必要とされるJSRuntimeは一つのみです。JS_THREADSAFEを有効にしたビルドでは、JSRuntimeを共有するJSContextを各スレッドごとに一つ用意することで、複数スレッドからランタイムにアクセスすることが可能です。複数のランタイムが必要になるのは、JavaScriptの値やオブジェクト、関数をスレッド間で完全に分離させたいときだけです。 Generally speaking, most applications need only one <code>JSRuntime</code>. In a <code>JS_THREADSAFE</code> build, each runtime is capable of handling multiple execution threads, using one <code>JSContext</code> per thread, sharing the same <code>JSRuntime</code>. You only need multiple runtimes if your application requires completely separate JS engines that cannot share values, objects, and functions.

- -

JS_NewRuntimeが成功したときは、新たに生成されたランタイムへのポインタがその返り値となり、失敗した時はNULLを返します。JS_NewRuntimeの呼び出し元は、後で必ずそのランタイムをJS_DestroyRuntimeを用いて破棄しなければなりません。 On success, <code>JS_NewRuntime</code> returns a pointer to the newly created runtime, which the caller must later destroy using <code>JS_DestroyRuntime</code>. Otherwise it returns <code>NULL</code>. {{ 英語版章題("Notes") }}

- -

注記

- -

一般的には、JS_NewRuntimeはアプリケーション内でまず最初に実行し、JS_DestroyRuntimeJS_ShutDownを終了時に呼ぶことになります。 Ordinarily, <code>JS_NewRuntime</code> should be the first JSAPI call in an application, and <code>JS_DestroyRuntime</code> and <code>JS_ShutDown</code> should be the last ones.

- -

{{ LXRSearch("ident", "i", "JS_NewRuntime") }}

- -

{{ languages( { "en": "en/JS_NewRuntime" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_setgczeal/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_setgczeal/index.html deleted file mode 100644 index 0be58ee8dc..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_setgczeal/index.html +++ /dev/null @@ -1,141 +0,0 @@ ---- -title: JS_SetGCZeal -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_SetGCZeal -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_SetGCZeal ---- -
{{SpiderMonkeySidebar("JSAPI")}}
- -
{{jsapi_minversion_header("1.8")}}
- -
-

GC の活動量、JSAPI アプリケーションの GC 関連のバグを見つけるのに役立つテストおよびデバッグ機能を有効にします。

-
- -

構文

- -
void
-JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency);
-
- - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
cx{{jsapixref("JSRuntime", "JSContext *")}}A context. The GC zeal level of the associated {{jsapixref("JSRuntime")}} is set.
zealuint8_tThe desired level of garbage collection.
frequencyuint32_tWith some zeal levels, a GC is triggered every frequency allocations.
- -

説明

- -

JS_SetGCZeal sets the level of additional garbage collection to perform for a runtime, for the purpose of finding or reproducing bugs.

- -

There are several different levels which have different functions:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Zeal levelDescription
0Normal amount of collection.  The default: no additional collections are performed.
1Collect when roots are added or removed.
2Collect when every frequency allocations.
3Collect on window paints.
4Verify pre write barriers between instructions.
5Verify pre write barriers between window paints.
6Verify stack rooting.
7Collect the nursery every frequency nursery allocations.
8Incremental GC in two slices: 1) mark roots 2) finish collection.
9Incremental GC in two slices: 1) mark all 2) new marking and finish.
10Incremental GC in multiple slices.
11Verify post write barriers between instructions.
12Verify post write barriers between paints.
13Check internal hashtables on minor GC.
14Perform a shrinking collection every frequency allocations.
- -

With GC zeal enabled, GC-related crashes are much easier to reproduce (they happen more reliably) and debug (they happen sooner, closer to the source of the bug). The drawback is that GC zeal can cause JavaScript code to run extremely slowly.

- -

Regularly running your test suite with GC zeal enabled at level 2 is a good practice.

- -

This function is available only in DEBUG builds. To enable this function in an optimized build, define the macro JS_GC_ZEAL building SpiderMonkey.

- -

(In a debug build of Gecko, you can also set the current GC zeal level using the javascript.options.gczeal preference.)

- -

あわせて参照

- - diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_shutdown/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_shutdown/index.html deleted file mode 100644 index 5d4e2faacd..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_shutdown/index.html +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: JS ShutDown -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ShutDown -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ShutDown ---- -

- -

- -

- -

ランタイム間で共有している資源を解放します。

- -

Free all resources shared among runtimes.

- -

構文

- -
void JS_ShutDown(void);
-
- -

説明

- -

ランタイム間で共有している資源を解放する関数です。この関数を呼ぶのはJSRuntimeオブジェクトが存在しないとき(具体的には、JS_DestroyRuntimeを読んだ後のプログラムの最後など)だけにしてください。 Frees all resources shared among runtimes. Call this only when no <code>JSRuntime</code>s exist (for example, at the end of the program, after calling <code>JS_DestroyRuntime</code>).

- -

利用時の注意点: この関数はjsdtoa.cが確保するメモリ領域と、JS_THREADSAFEオプションを有効にしたビルドにおけるjslock.cが確保するmutex領域を解放します。 Implementation note: This cleans up memory allocated by <code>jsdtoa.c</code> and, in <code>JS_THREADSAFE</code> builds, mutexes allocated by <code>jslock.c</code>.

- -

{{ LXRSearch("ident", "i", "JS_ShutDown") }}

- -

{{ languages( { "en": "en/JS_ShutDown" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_threadsafe/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_threadsafe/index.html deleted file mode 100644 index b827d4c832..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_threadsafe/index.html +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: JS_THREADSAFE -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_THREADSAFE -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_THREADSAFE ---- -

{{ note("JS_THREADSAFE は現在恒久的に有効です。") }}

- -

JS_THREADSAFE は、オブジェクトや文字列が共有されていない限り、JavaScript コードの複数のスレッドを同時に実行するためのサポートを可能にするコンパイル時オプションです。

- -

最近この機能に大きな変更を加えました。最近まで、スレッド間でオブジェクトを共有することでうまくいくことが多かったのですが、スクリプトを使うとクラッシュすることがありました。この機能は完全に削除されました。JavaScript エンジンを使用する各スレッドは、本質的にまったく別のメモリ領域で動作する必要があります。

- -

Requests

- -

In a JS_THREADSAFE build, the application must separate code that uses the JSAPI from code that performs blocking I/O or time-consuming calculations.

- -

A request is a region of code that uses the JSAPI. Requests must be bracketed with calls to JS_BeginRequest() and JS_EndRequest().

- -
JS_BeginRequest(cx);
-/* ... do JSAPI stuff ... */
-JS_EndRequest(cx);
-
- -

A request is always associated with a specific JSContext and runs from start to finish on a single thread.

- -

Most JSAPI functions require the caller to be in a request. In this reference, these JSAPI functions are marked with the words "Requires request", like this:

- - - - - - - - - - - - - - -
NameTypeDescription
cxJSContext *The context to use. {{ Jsapi-requires-request() }}
- -

Most JSAPI callback functions are always called from within a request. These callbacks are (unreliably!) documented with the words "Provides request", like this:

- - - - - - - - - - - - - - -
NameTypeDescription
cxJSContext *The context in which the event ocurred. Provides request. In JS_THREADSAFE builds, the JavaScript engine calls this callback only from within an active request on cx. The callback does not need to call JS_BeginRequest()).
- -

In particular, JSNative callbacks provide a request. This means that any potentially long-running operation in a native must be bracketed with calls to JS_SuspendRequest() and JS_ResumeRequest().

- -
JSBool socket_recv(JSContext *cx, unsigned int argc, jsval *vp)
-{
-    ...
-    rc = JS_SuspendRequest(cx);
-    read_size = recv(socket, buf, size, flags);
-    JS_ResumeRequest(cx, rc);
-    ...
-}
-
- -

Garbage collection

- -

Requests help make garbage collection safe when multiple threads are using the JSAPI. For each thread that is in a request:

- - - -

These are actually the same rules that apply to single-threaded JSAPI programs. But in multithreaded programs, if you break the rules, your program is more likely to crash. This is because in single-threaded programs, a random call into the JSAPI is actually pretty unlikely to trigger GC, especially if the calling thread has not been using up a lot of memory. In a multithreaded program, even if the calling thread has been idle, other threads may be active or may call JS_GC().

- -

The above rules mean that at any given moment, there can be either (a) multiple threads in active requests, or (b) one thread doing GC and all requests suspended. When one thread calls JS_GC or otherwise finds that garbage collection is necessary, it must wait for all other threads that are in requests to pause before garbage collection can occur. To keep this wait time to a minimum, applications must avoid long-running requests. The recommended technique in SpiderMonkey 1.8 and later is to periodically call JS_YieldRequest from an operation callback.

- -

Sharing data among threads

- -

"Data can be marshaled across the process boundary through a process known as smuggling." --Mr. Bunny's Guide to ActiveX

- -

Even in JS_THREADSAFE builds, threads cannot safely share objects or strings.

- -

Instead, data must be copied when it is sent from one thread to another. Use JS_WriteStructuredClone to transform data into a flat array of bytes that can be safely written to disk, sent to another process or even another machine, or just passed to another thread. Then use JS_ReadStructuredClone on the other side to turn the serialized data back into JavaScript objects, strings, and so on.

- -

Sharing native functions and private data among threads

- -

In a JS_THREADSAFE build, SpiderMonkey's internal data structures that represent JavaScript values are single-thread-only. In a DEBUG build, this is enforced with assertions.

- -

However, SpiderMonkey does not protect the application's data structures. JSNatives and other callback functions can be called concurrently by multiple threads. Multiple threads can end up accessing private data or C/C++ global variables at the same time. It is up to the application to practice safe threading.

- -

Sharing contexts among threads

- -

Ordinarily, a JSContext is created, used, and destroyed by a single thread. This makes sense, as a context can only be used by one thread at a time. However, there are a few cases where an application might need to share contexts across threads. For example:

- - - - - -

For such cases, use JS_ClearContextThread and JS_SetContextThread to transfer the context safely from one thread to another.

- -

Further info

- -

Note: SpiderMonkey Internals: Thread Safety is mostly obsolete.

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/jsint/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/jsint/index.html deleted file mode 100644 index c5028558cc..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/jsint/index.html +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: jsint -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/jsint -tags: - - JSAPI_Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/jsint ---- -

C 言語 / C++ の整数型のエイリアスです。

- -

構文

- -
typedef ... jsint;
-typedef ... jsuint;
-
-typedef ... jsword;
-typedef ... jsuword;
-
-typedef ... intN;
-typedef ... uintN;
-
-typedef ... int8;
-typedef ... uint8;
-typedef ... int16;
-typedef ... uint16;
-typedef ... int32;
-typedef ... uint32;
-typedef ... int64;
-typedef ... uint64;
-
- - -

説明

- - -

jsint および jsuint は 32 ビットの整数型です。

- - -

jsword および jsuword はポインタサイズの整数型です。

- - -

intN および uintN はプラットフォームのネイティブの int 型と同じサイズの整数型です。

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/jsruntime/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/jsruntime/index.html deleted file mode 100644 index b221ea62ef..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/jsruntime/index.html +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: JSRuntime -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSRuntime -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSRuntime ---- -

- -

- -

- -

JSAPIにおいて、JSRuntimeはメモリ管理やグローバルなデータ構造などを扱う最高位のオブジェクトです。複数のスレッドが動作するプログラムにおいても、プログラム内のJSRuntimeは一般的に一つだけです。JSRuntimeはJavaScriptのオブジェクトを保持する空間であり、オブジェクトは複数のJSRuntimeを跨いで移動することはできません。 JSAPI, <code>JSRuntime</code> is the top-level object that handles, among other things, memory management and "global" data structures. A program typically has only one <code>JSRuntime</code>, even if it has many threads. The <code>JSRuntime</code> is the universe in which JavaScript objects live; they can't travel to other <code>JSRuntime</code>s.

- -

JSContextJSRuntimeの子に位置し、すべてのJavaScriptコードとJSAPIの関数はJSContextを介して実行されます。JSContext内には、global objectや実行時スタックなどが含まれます。 例外処理エラー報告、一部のJavaScriptのオプション などは各JSContextごとに管理されます。JS_THREADSAFEオプションを有効にしたビルドでは、複数のスレッドからJavaScriptのコードを呼び出し並行して実行できますが、呼び出し元のスレッドはそれぞれ独立したJSContextを持つ形になります。詳細はJS_THREADSAFEを参照してください。 All JavaScript code and most JSAPI calls run within a <code>JSContext</code>. The <code>JSContext</code> is a child of the <code>JSRuntime</code>. Among other things, it contains the global object and the execution stack. Exception handling, error reporting, and some language options are per-<code>JSContext</code>. In a <code>JS_THREADSAFE</code> build, multiple threads may run JavaScript code concurrently, but each such thread must have its own <code>JSContext</code>. See <code> JS_THREADSAFE</code> for details.

- -

JavaScriptオブジェクトとそのコンテキストとの関係は固定されたものでなく、オブジェクトはJSRuntimeを介してその子となるJSContext間で共有することができます。 Objects may be shared among <code>JSContext</code>s within a <code>JSRuntime</code>. There's no fixed association between an object and a context.

- -

{{ languages( { "en": "en/JSRuntime" } ) }}

diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/jstype/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/jstype/index.html deleted file mode 100644 index 69037c39ee..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/jstype/index.html +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: JSType -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSType -tags: - - JSAPI_Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSType ---- -

列挙型 JSType の値は、 JavaScript の値の型を表します。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
説明
JSTYPE_VOIDundefined
JSTYPE_OBJECTJavaScript オブジェクト
JSTYPE_FUNCTION関数
JSTYPE_STRING文字列
JSTYPE_NUMBER数値
JSTYPE_BOOLEAN真偽値 (true / false)
JSTYPE_NULLnull
JSTYPE_XMLXML オブジェクト
-

 

-- cgit v1.2.3-54-g00ecf