Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
5f5c5de0
提交
5f5c5de0
authored
7月 12, 2017
作者:
Andrey Volk
提交者:
Mike Jerris
4月 02, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-10496: [mod_v8] Speedup JavaScript. Enabling Code Caching.
上级
c135279e
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
256 行增加
和
27 行删除
+256
-27
v8.conf.xml
conf/curl/autoload_configs/v8.conf.xml
+2
-0
v8.conf.xml
conf/insideout/autoload_configs/v8.conf.xml
+2
-0
v8.conf.xml
conf/vanilla/autoload_configs/v8.conf.xml
+2
-0
v8.conf.xml
src/mod/languages/mod_v8/conf/autoload_configs/v8.conf.xml
+2
-0
mod_v8.cpp
src/mod/languages/mod_v8/mod_v8.cpp
+206
-15
mod_v8.h
src/mod/languages/mod_v8/mod_v8.h
+4
-0
fsglobal.cpp
src/mod/languages/mod_v8/src/fsglobal.cpp
+10
-3
jsmain.cpp
src/mod/languages/mod_v8/src/jsmain.cpp
+28
-9
没有找到文件。
conf/curl/autoload_configs/v8.conf.xml
浏览文件 @
5f5c5de0
<configuration
name=
"v8.conf"
description=
"Google V8 JavaScript Plug-Ins"
>
<settings>
<!-- <param name="script-caching" value="enabled"/> -->
<!-- <param name="cache-expires-sec" value="3600"/> -->
<!-- <param name="startup-script" value="startup1.js"/> -->
<!-- <param name="startup-script" value="startup2.js"/> -->
<!-- <param name="xml-handler-script" value="directory.js"/> -->
...
...
conf/insideout/autoload_configs/v8.conf.xml
浏览文件 @
5f5c5de0
<configuration
name=
"v8.conf"
description=
"Google V8 JavaScript Plug-Ins"
>
<settings>
<!-- <param name="script-caching" value="enabled"/> -->
<!-- <param name="cache-expires-sec" value="3600"/> -->
<!-- <param name="startup-script" value="startup1.js"/> -->
<!-- <param name="startup-script" value="startup2.js"/> -->
<!-- <param name="xml-handler-script" value="directory.js"/> -->
...
...
conf/vanilla/autoload_configs/v8.conf.xml
浏览文件 @
5f5c5de0
<configuration
name=
"v8.conf"
description=
"Google V8 JavaScript Plug-Ins"
>
<settings>
<!-- <param name="script-caching" value="enabled"/> -->
<!-- <param name="cache-expires-sec" value="3600"/> -->
<!-- <param name="startup-script" value="startup1.js"/> -->
<!-- <param name="startup-script" value="startup2.js"/> -->
<!-- <param name="xml-handler-script" value="directory.js"/> -->
...
...
src/mod/languages/mod_v8/conf/autoload_configs/v8.conf.xml
浏览文件 @
5f5c5de0
<configuration
name=
"v8.conf"
description=
"Google V8 JavaScript Plug-Ins"
>
<settings>
<!-- <param name="script-caching" value="enabled"/> -->
<!-- <param name="cache-expires-sec" value="3600"/> -->
<!-- <param name="startup-script" value="startup1.js"/> -->
<!-- <param name="startup-script" value="startup2.js"/> -->
<!-- <param name="xml-handler-script" value="directory.js"/> -->
...
...
src/mod/languages/mod_v8/mod_v8.cpp
浏览文件 @
5f5c5de0
差异被折叠。
点击展开。
src/mod/languages/mod_v8/mod_v8.h
浏览文件 @
5f5c5de0
...
...
@@ -36,6 +36,10 @@
#include "javascript.hpp"
#include <switch.h>
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
void
LoadScript
(
v8
::
MaybeLocal
<
v8
::
Script
>
*
v8_script
,
v8
::
Isolate
*
isolate
,
const
char
*
script_data
,
const
char
*
script_file
);
#endif
SWITCH_BEGIN_EXTERN_C
#define JS_BUFFER_SIZE 1024 * 32
...
...
src/mod/languages/mod_v8/src/fsglobal.cpp
浏览文件 @
5f5c5de0
...
...
@@ -477,13 +477,20 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(Include)
string
js_file
=
JSMain
::
LoadFileToString
(
script_name
);
if
(
js_file
.
length
()
>
0
)
{
Handle
<
String
>
source
=
String
::
NewFromUtf8
(
info
.
GetIsolate
(),
js_file
.
c_str
());
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
Handle
<
Script
>
script
=
Script
::
Compile
(
source
,
info
[
i
]
->
ToString
());
MaybeLocal
<
v8
::
Script
>
script
;
LoadScript
(
&
script
,
info
.
GetIsolate
(),
js_file
.
c_str
(),
script_name
);
if
(
script
.
IsEmpty
())
{
info
.
GetReturnValue
().
Set
(
false
);
}
else
{
info
.
GetReturnValue
().
Set
(
script
.
ToLocalChecked
()
->
Run
());
}
#else
Handle
<
String
>
source
=
String
::
NewFromUtf8
(
info
.
GetIsolate
(),
js_file
.
c_str
());
Handle
<
Script
>
script
=
Script
::
Compile
(
source
,
info
[
i
]);
#endif
info
.
GetReturnValue
().
Set
(
script
->
Run
());
#endif
switch_safe_free
(
path
);
return
;
}
...
...
src/mod/languages/mod_v8/src/jsmain.cpp
浏览文件 @
5f5c5de0
...
...
@@ -29,6 +29,9 @@
*/
#include "javascript.hpp"
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
#include "mod_v8.h"
#endif
#ifdef V8_ENABLE_DEBUGGING
#include <v8-debug.h>
...
...
@@ -228,15 +231,21 @@ void JSMain::Include(const v8::FunctionCallbackInfo<Value>& args)
string
js_file
=
LoadFileToString
(
js_safe_str
(
*
str
));
if
(
js_file
.
length
()
>
0
)
{
Handle
<
String
>
source
=
String
::
NewFromUtf8
(
args
.
GetIsolate
(),
js_file
.
c_str
());
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
Handle
<
Script
>
script
=
Script
::
Compile
(
source
,
args
[
i
]
->
ToString
());
MaybeLocal
<
v8
::
Script
>
script
;
LoadScript
(
&
script
,
args
.
GetIsolate
(),
js_file
.
c_str
(),
js_safe_str
(
*
str
));
if
(
script
.
IsEmpty
())
{
args
.
GetReturnValue
().
Set
(
false
);
}
else
{
args
.
GetReturnValue
().
Set
(
script
.
ToLocalChecked
()
->
Run
());
}
#else
Handle
<
String
>
source
=
String
::
NewFromUtf8
(
args
.
GetIsolate
(),
js_file
.
c_str
());
Handle
<
Script
>
script
=
Script
::
Compile
(
source
,
args
[
i
]);
#endif
args
.
GetReturnValue
().
Set
(
script
->
Run
());
#endif
return
;
}
...
...
@@ -314,15 +323,16 @@ const string JSMain::ExecuteString(const string& scriptData, const string& fileN
inst
->
obj
->
RegisterInstance
(
isolate
,
inst
->
name
,
inst
->
auto_destroy
);
}
// Create a string containing the JavaScript source code.
Handle
<
String
>
source
=
String
::
NewFromUtf8
(
isolate
,
scriptData
.
c_str
());
TryCatch
try_catch
;
// Compile the source code.
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
Handle
<
Script
>
script
=
Script
::
Compile
(
source
,
String
::
NewFromUtf8
(
isolate
,
fileName
.
c_str
()));
// Compile the source code.
MaybeLocal
<
v8
::
Script
>
script
;
LoadScript
(
&
script
,
isolate
,
scriptData
.
c_str
(),
fileName
.
c_str
());
#else
// Create a string containing the JavaScript source code.
Handle
<
String
>
source
=
String
::
NewFromUtf8
(
isolate
,
scriptData
.
c_str
());
Handle
<
Script
>
script
=
Script
::
Compile
(
source
,
Local
<
Value
>::
New
(
isolate
,
String
::
NewFromUtf8
(
isolate
,
fileName
.
c_str
())));
#endif
...
...
@@ -330,8 +340,17 @@ const string JSMain::ExecuteString(const string& scriptData, const string& fileN
res
=
JSMain
::
GetExceptionInfo
(
isolate
,
&
try_catch
);
isError
=
true
;
}
else
{
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
// Run the script
Handle
<
Value
>
result
;
if
(
!
script
.
IsEmpty
())
{
result
=
script
.
ToLocalChecked
()
->
Run
();
}
#else
// Run the script
Handle
<
Value
>
result
=
script
->
Run
();
#endif
if
(
try_catch
.
HasCaught
())
{
res
=
JSMain
::
GetExceptionInfo
(
isolate
,
&
try_catch
);
isError
=
true
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论