Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
eb432633
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
eb432633
编写于
11月 05, 2015
作者:
C
Chinmay Garde
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow dynamic resolution of Dart isolate and instructions snapshot
上级
1e98421c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
101 addition
and
74 deletion
+101
-74
sky/engine/bindings/BUILD.gn
sky/engine/bindings/BUILD.gn
+4
-4
sky/engine/bindings/bindings.gni
sky/engine/bindings/bindings.gni
+8
-8
sky/engine/bindings/snapshot.c.tmpl
sky/engine/bindings/snapshot.c.tmpl
+4
-10
sky/engine/core/script/dart_controller.cc
sky/engine/core/script/dart_controller.cc
+3
-2
sky/engine/core/script/dart_init.cc
sky/engine/core/script/dart_init.cc
+77
-48
sky/engine/core/script/dart_init.h
sky/engine/core/script/dart_init.h
+5
-2
未找到文件。
sky/engine/bindings/BUILD.gn
浏览文件 @
eb432633
...
...
@@ -116,11 +116,11 @@ action("generate_snapshot_file") {
]
inputs = [
"//dart/runtime/tools/create_snapshot_file.py",
"snapshot.c
c
.tmpl",
"snapshot.c.tmpl",
"$target_gen_dir/vm_isolate_snapshot.bin",
"$target_gen_dir/isolate_snapshot.bin",
]
output = "$target_gen_dir/snapshot.c
c
"
output = "$target_gen_dir/snapshot.c"
outputs = [
output,
]
...
...
@@ -132,7 +132,7 @@ action("generate_snapshot_file") {
"--input_bin",
rebase_path("$target_gen_dir/isolate_snapshot.bin"),
"--input_cc",
rebase_path("snapshot.c
c
.tmpl"),
rebase_path("snapshot.c.tmpl"),
"--output",
rebase_path(output),
]
...
...
@@ -171,7 +171,7 @@ action("generate_updater_snapshot_file") {
source_set("snapshot_cc") {
sources = [
"$target_gen_dir/snapshot.c
c
",
"$target_gen_dir/snapshot.c",
]
deps = [
...
...
sky/engine/bindings/bindings.gni
浏览文件 @
eb432633
...
...
@@ -137,14 +137,14 @@ template("dart_precompile") {
]
}
snapshot_c
c = "$target_gen_dir/" + target_name + "_precompiled_snapshot.c
c"
snapshot_c
c_gen_target_name = target_name + "_snapshot_c
c"
action(snapshot_c
c
_gen_target_name) {
snapshot_c
= "$target_gen_dir/" + target_name + "_precompiled_snapshot.
c"
snapshot_c
_gen_target_name = target_name + "_snapshot_
c"
action(snapshot_c_gen_target_name) {
deps = [
":$instructions_gen_target_name",
]
template_file = "//sky/engine/bindings/snapshot.c
c
.tmpl"
template_file = "//sky/engine/bindings/snapshot.c.tmpl"
inputs = [
template_file,
...
...
@@ -153,7 +153,7 @@ template("dart_precompile") {
]
outputs = [
snapshot_c
c
,
snapshot_c,
]
script = "//dart/runtime/tools/create_snapshot_file.py"
...
...
@@ -165,19 +165,19 @@ template("dart_precompile") {
"--input_cc",
rebase_path(template_file, root_build_dir),
"--output",
rebase_path(snapshot_c
c
),
rebase_path(snapshot_c),
]
}
source_set(target_name) {
sources = [
assembly_path,
snapshot_c
c
,
snapshot_c,
]
deps = [
":$instructions_gen_target_name",
":$snapshot_c
c
_gen_target_name",
":$snapshot_c_gen_target_name",
]
}
}
sky/engine/bindings/snapshot.c
c
.tmpl
→
sky/engine/bindings/snapshot.c.tmpl
浏览文件 @
eb432633
...
...
@@ -6,22 +6,16 @@
#include <stdint.h>
#include <stddef.h>
namespace blink {
// The string on the next line will be filled in with the contents of the
// generated snapshot binary file for the vm isolate.
// This string forms the content of the dart vm isolate snapshot which
// is loaded into the vm isolate.
static const uint8_t vm_isolate_snapshot_buffer_[]
__attribute__((aligned(8))) = { % s};
const uint8_t* kDartVmIsolateSnapshotBuffer = vm_isolate_snapshot_buffer_;
const uint8_t kDartVmIsolateSnapshotBuffer[]
__attribute__((visibility("default"), aligned(8), used)) = { %s };
// The string on the next line will be filled in with the contents of the
// generated snapshot binary file for a regular dart isolate.
// This string forms the content of a regular dart isolate snapshot which
// is loaded into an isolate when it is created.
static const uint8_t isolate_snapshot_buffer_[]
__attribute__((aligned(8))) = { % s};
const uint8_t* kDartIsolateSnapshotBuffer = isolate_snapshot_buffer_;
} // namespace blink
const uint8_t kDartIsolateSnapshotBuffer[]
__attribute__((visibility("default"), aligned(8), used)) = { %s };
sky/engine/core/script/dart_controller.cc
浏览文件 @
eb432633
...
...
@@ -137,11 +137,12 @@ void DartController::RunFromLibrary(const String& name,
}
void
DartController
::
CreateIsolateFor
(
std
::
unique_ptr
<
DOMDartState
>
state
)
{
CHECK
(
kDartIsolateSnapshotBuffer
);
char
*
error
=
nullptr
;
dom_dart_state_
=
std
::
move
(
state
);
Dart_Isolate
isolate
=
Dart_CreateIsolate
(
dom_dart_state_
->
url
().
utf8
().
data
(),
"main"
,
kDartIsolateSnapshotBuffer
,
dom_dart_state_
->
url
().
utf8
().
data
(),
"main"
,
reinterpret_cast
<
uint8_t
*>
(
DartSymbolLookup
(
kDartIsolateSnapshotBufferName
)),
nullptr
,
static_cast
<
DartState
*>
(
dom_dart_state_
.
get
()),
&
error
);
Dart_SetMessageNotifyCallback
(
MessageNotifyCallback
);
CHECK
(
isolate
)
<<
error
;
...
...
sky/engine/core/script/dart_init.cc
浏览文件 @
eb432633
...
...
@@ -48,17 +48,12 @@ void EnsureHandleWatcherStarted() {
// during shutdown.
Dart_Handle
mojo_core_lib
=
Dart_LookupLibrary
(
ToDart
(
"dart:mojo.internal"
));
CHECK
(
!
LogIfError
((
mojo_core_lib
)));
Dart_Handle
handle_watcher_type
=
Dart_GetType
(
mojo_core_lib
,
Dart_NewStringFromCString
(
"MojoHandleWatcher"
),
0
,
nullptr
);
Dart_Handle
handle_watcher_type
=
Dart_GetType
(
mojo_core_lib
,
Dart_NewStringFromCString
(
"MojoHandleWatcher"
),
0
,
nullptr
);
CHECK
(
!
LogIfError
(
handle_watcher_type
));
CHECK
(
!
LogIfError
(
Dart_Invoke
(
handle_watcher_type
,
Dart_NewStringFromCString
(
"_start"
),
0
,
nullptr
)));
handle_watcher_type
,
Dart_NewStringFromCString
(
"_start"
),
0
,
nullptr
)));
// RunLoop until the handle watcher isolate is spun-up.
CHECK
(
!
LogIfError
(
Dart_RunLoop
()));
...
...
@@ -87,15 +82,15 @@ static const char* kDartArgs[] = {
#endif
};
static
const
char
*
kDartPrecompilationArgs
[]
{
"--precompilation"
,
static
const
char
*
kDartPrecompilationArgs
[]{
"--precompilation"
,
};
static
const
char
*
kDartCheckedModeArgs
[]
=
{
"--enable_asserts"
,
"--enable_type_checks"
,
"--error_on_bad_type"
,
"--error_on_bad_override"
,
"--enable_asserts"
,
"--enable_type_checks"
,
"--error_on_bad_type"
,
"--error_on_bad_override"
,
};
void
UnhandledExceptionCallback
(
Dart_Handle
error
)
{
...
...
@@ -108,17 +103,12 @@ void IsolateShutdownCallback(void* callback_data) {
bool
IsServiceIsolateURL
(
const
char
*
url_name
)
{
return
url_name
!=
nullptr
&&
String
(
url_name
)
==
DART_VM_SERVICE_ISOLATE_NAME
;
String
(
url_name
)
==
DART_VM_SERVICE_ISOLATE_NAME
;
}
static
const
uint8_t
*
PrecompiledInstructionsSymbolIfPresent
()
{
dlerror
();
// clear previous errors on thread
void
*
sym
=
nullptr
;
#ifdef RTLD_SELF
static
const
char
kInstructionsSnapshotSymbolName
[]
=
"kInstructionsSnapshot"
;
sym
=
dlsym
(
RTLD_SELF
,
kInstructionsSnapshotSymbolName
);
#endif
return
(
dlerror
()
!=
nullptr
)
?
nullptr
:
reinterpret_cast
<
uint8_t
*
>
(
sym
);
return
reinterpret_cast
<
uint8_t
*>
(
DartSymbolLookup
(
kInstructionsSnapshotName
));
}
static
bool
IsRunningPrecompiledCode
()
{
...
...
@@ -136,11 +126,11 @@ Dart_Isolate IsolateCreateCallback(const char* script_uri,
void
*
callback_data
,
char
**
error
)
{
if
(
IsServiceIsolateURL
(
script_uri
))
{
CHECK
(
kDartIsolateSnapshotBuffer
);
DartState
*
dart_state
=
new
DartState
();
Dart_Isolate
isolate
=
Dart_CreateIsolate
(
script_uri
,
"main"
,
kDartIsolateSnapshotBuffer
,
nullptr
,
nullptr
,
error
);
Dart_Isolate
isolate
=
Dart_CreateIsolate
(
script_uri
,
"main"
,
reinterpret_cast
<
const
uint8_t
*>
(
DartSymbolLookup
(
kDartIsolateSnapshotBufferName
)),
nullptr
,
nullptr
,
error
);
CHECK
(
isolate
)
<<
error
;
dart_state
->
SetIsolate
(
isolate
);
CHECK
(
Dart_IsServiceIsolate
(
isolate
));
...
...
@@ -157,9 +147,8 @@ Dart_Isolate IsolateCreateCallback(const char* script_uri,
if
(
RuntimeEnabledFeatures
::
observatoryEnabled
())
{
std
::
string
ip
=
"127.0.0.1"
;
const
intptr_t
port
=
8181
;
const
bool
service_isolate_booted
=
DartServiceIsolate
::
Startup
(
ip
,
port
,
DartLibraryTagHandler
,
IsRunningPrecompiledCode
(),
error
);
const
bool
service_isolate_booted
=
DartServiceIsolate
::
Startup
(
ip
,
port
,
DartLibraryTagHandler
,
IsRunningPrecompiledCode
(),
error
);
CHECK
(
service_isolate_booted
)
<<
error
;
}
}
...
...
@@ -168,12 +157,12 @@ Dart_Isolate IsolateCreateCallback(const char* script_uri,
}
// Create & start the handle watcher isolate
CHECK
(
kDartIsolateSnapshotBuffer
);
// TODO(abarth): Who deletes this DartState instance?
DartState
*
dart_state
=
new
DartState
();
Dart_Isolate
isolate
=
Dart_CreateIsolate
(
"sky:handle_watcher"
,
""
,
kDartIsolateSnapshotBuffer
,
nullptr
,
dart_state
,
error
);
Dart_Isolate
isolate
=
Dart_CreateIsolate
(
"sky:handle_watcher"
,
""
,
reinterpret_cast
<
uint8_t
*>
(
DartSymbolLookup
(
kDartIsolateSnapshotBufferName
)),
nullptr
,
dart_state
,
error
);
CHECK
(
isolate
)
<<
error
;
dart_state
->
SetIsolate
(
isolate
);
...
...
@@ -195,7 +184,47 @@ Dart_Isolate IsolateCreateCallback(const char* script_uri,
return
isolate
;
}
}
// namespace
}
// namespace
const
char
*
kDartVmIsolateSnapshotBufferName
=
"kDartVmIsolateSnapshotBuffer"
;
const
char
*
kDartIsolateSnapshotBufferName
=
"kDartIsolateSnapshotBuffer"
;
const
char
*
kInstructionsSnapshotName
=
"kInstructionsSnapshot"
;
const
char
*
kDartApplicationLibraryPath
=
"FlutterApplication.framework/FlutterApplication"
;
static
void
*
DartLookupSymbolInLibrary
(
const
char
*
symbol_name
,
const
char
*
library
)
{
if
(
symbol_name
==
nullptr
)
{
return
nullptr
;
}
dlerror
();
// clear previous errors on thread
void
*
library_handle
=
dlopen
(
library
,
RTLD_NOW
);
if
(
dlerror
()
!=
nullptr
)
{
return
nullptr
;
}
void
*
sym
=
dlsym
(
library_handle
,
symbol_name
);
return
dlerror
()
!=
nullptr
?
nullptr
:
sym
;
}
void
*
DartSymbolLookup
(
const
char
*
symbol_name
)
{
if
(
symbol_name
==
nullptr
)
{
return
nullptr
;
}
// First the application library is checked for the valid symbols. This
// library may not necessarily exist. If it does exist, it is loaded and the
// symbols resolved. Once the application library is loaded, there is
// currently no provision to unload the same.
void
*
symbol
=
DartLookupSymbolInLibrary
(
symbol_name
,
kDartApplicationLibraryPath
);
if
(
symbol
!=
nullptr
)
{
return
symbol
;
}
// Check inside the default library
return
DartLookupSymbolInLibrary
(
symbol_name
,
nullptr
);
}
void
InitDartVM
()
{
dart
::
bin
::
BootstrapDartIo
();
...
...
@@ -217,21 +246,21 @@ void InitDartVM() {
CHECK
(
Dart_SetVMFlags
(
args
.
size
(),
args
.
data
()));
// This should be called before calling Dart_Initialize.
DartDebugger
::
InitDebugger
();
CHECK
(
Dart_Initialize
(
kDartVmIsolateSnapshotBuffer
,
PrecompiledInstructionsSymbolIfPresent
(),
IsolateCreateCallback
,
nullptr
,
// Isolate interrupt callback.
UnhandledExceptionCallback
,
IsolateShutdownCallback
,
// File IO callbacks.
nullptr
,
nullptr
,
nullptr
,
nullptr
,
// Entroy source
nullptr
,
// VM service assets archive
nullptr
)
==
nullptr
);
CHECK
(
Dart_Initialize
(
reinterpret_cast
<
uint8_t
*>
(
DartSymbolLookup
(
kDartVmIsolateSnapshotBufferName
))
,
PrecompiledInstructionsSymbolIfPresent
(),
IsolateCreateCallback
,
nullptr
,
// Isolate interrupt callback.
UnhandledExceptionCallback
,
IsolateShutdownCallback
,
// File IO callbacks.
nullptr
,
nullptr
,
nullptr
,
nullptr
,
// Entroy source
nullptr
,
// VM service assets archive
nullptr
)
==
nullptr
);
// Wait for load port- ensures handle watcher and service isolates are
// running.
Dart_ServiceWaitForLoadPort
();
}
}
// namespace blink
}
// namespace blink
sky/engine/core/script/dart_init.h
浏览文件 @
eb432633
...
...
@@ -9,8 +9,11 @@
namespace
blink
{
extern
const
uint8_t
*
kDartVmIsolateSnapshotBuffer
;
extern
const
uint8_t
*
kDartIsolateSnapshotBuffer
;
extern
const
char
*
kDartVmIsolateSnapshotBufferName
;
extern
const
char
*
kDartIsolateSnapshotBufferName
;
extern
const
char
*
kInstructionsSnapshotName
;
void
*
DartSymbolLookup
(
const
char
*
symbol_name
);
void
InitDartVM
();
Dart_Handle
DartLibraryTagHandler
(
Dart_LibraryTag
tag
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录