Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
ce333b0a
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ce333b0a
编写于
12月 22, 2016
作者:
D
Denis Zharkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor. Remove exception handling part from CoroutineMethodTransformer
There is no handleException operator anymore
上级
8475869f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
1 addition
and
49 deletion
+1
-49
compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformationClassBuilder.kt
...codegen/coroutines/CoroutineTransformationClassBuilder.kt
+1
-47
compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutineCodegenUtil.kt
...tbrains/kotlin/codegen/coroutines/coroutineCodegenUtil.kt
+0
-2
未找到文件。
compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformationClassBuilder.kt
浏览文件 @
ce333b0a
...
@@ -78,9 +78,6 @@ class CoroutineTransformerMethodVisitor(
...
@@ -78,9 +78,6 @@ class CoroutineTransformerMethodVisitor(
splitTryCatchBlocksContainingSuspensionPoint
(
methodNode
,
suspensionPoint
)
splitTryCatchBlocksContainingSuspensionPoint
(
methodNode
,
suspensionPoint
)
}
}
// Add global exception handler
val
isThereGlobalExceptionHandler
=
processHandleExceptionCall
(
methodNode
,
customCoroutineStart
?:
methodNode
.
instructions
.
first
)
// Spill stack to variables before suspension points, try/catch blocks
// Spill stack to variables before suspension points, try/catch blocks
FixStackWithLabelNormalizationMethodTransformer
().
transform
(
classBuilder
.
thisName
,
methodNode
)
FixStackWithLabelNormalizationMethodTransformer
().
transform
(
classBuilder
.
thisName
,
methodNode
)
...
@@ -104,17 +101,7 @@ class CoroutineTransformerMethodVisitor(
...
@@ -104,17 +101,7 @@ class CoroutineTransformerMethodVisitor(
methodNode
.
instructions
.
apply
{
methodNode
.
instructions
.
apply
{
val
startLabel
=
LabelNode
()
val
startLabel
=
LabelNode
()
val
defaultLabel
=
LabelNode
()
val
defaultLabel
=
LabelNode
()
val
firstToInsertBefore
=
val
firstToInsertBefore
=
customCoroutineStart
?:
first
if
(
isThereGlobalExceptionHandler
)
{
// Insert after relevant NOP insn (i.e. before next instruction of this NOP)
val
globalExceptionHandler
=
methodNode
.
tryCatchBlocks
.
last
()
assert
(
globalExceptionHandler
.
start
is
LabelNode
&&
globalExceptionHandler
.
start
.
next
.
opcode
==
Opcodes
.
NOP
)
{
"In a case of global exception handler first insn should be a label"
}
globalExceptionHandler
.
start
.
next
.
next
}
else
customCoroutineStart
?:
first
// tableswitch(this.label)
// tableswitch(this.label)
insertBefore
(
firstToInsertBefore
,
insertBefore
(
firstToInsertBefore
,
insnListOf
(
insnListOf
(
...
@@ -398,39 +385,6 @@ class CoroutineTransformerMethodVisitor(
...
@@ -398,39 +385,6 @@ class CoroutineTransformerMethodVisitor(
return
return
}
}
private
fun
processHandleExceptionCall
(
methodNode
:
MethodNode
,
coroutineStart
:
AbstractInsnNode
):
Boolean
{
val
instructions
=
methodNode
.
instructions
val
marker
=
instructions
.
toArray
().
firstOrNull
{
it
.
isHandleExceptionMarker
()
}
?:
return
false
assert
(
instructions
.
toArray
().
count
{
it
.
isHandleExceptionMarker
()
}
==
1
)
{
"Found more than one handleException markers"
}
val
startLabel
=
LabelNode
()
val
endLabel
=
LabelNode
()
instructions
.
insertBefore
(
coroutineStart
,
startLabel
)
instructions
.
set
(
marker
,
endLabel
)
// NOP is necessary to preserve common invariant: first insn of TCB is always NOP
instructions
.
insert
(
startLabel
,
InsnNode
(
Opcodes
.
NOP
))
// ASTORE is needed by the same reason
val
maxVar
=
methodNode
.
maxLocals
++
instructions
.
insert
(
endLabel
,
VarInsnNode
(
Opcodes
.
ASTORE
,
maxVar
))
val
exceptionArgument
=
instructions
.
toArray
().
single
{
it
.
isHandleExceptionMarkerArgument
()
}
instructions
.
set
(
exceptionArgument
,
VarInsnNode
(
Opcodes
.
ALOAD
,
maxVar
))
methodNode
.
tryCatchBlocks
.
add
(
TryCatchBlockNode
(
startLabel
,
endLabel
,
endLabel
,
AsmTypes
.
JAVA_THROWABLE_TYPE
.
internalName
))
return
true
}
private
fun
AbstractInsnNode
.
isHandleExceptionMarker
()
=
this
is
MethodInsnNode
&&
this
.
owner
==
COROUTINE_MARKER_OWNER
&&
this
.
name
==
HANDLE_EXCEPTION_MARKER_NAME
private
fun
AbstractInsnNode
.
isHandleExceptionMarkerArgument
()
=
this
is
MethodInsnNode
&&
this
.
owner
==
COROUTINE_MARKER_OWNER
&&
this
.
name
==
HANDLE_EXCEPTION_ARGUMENT_MARKER_NAME
}
}
private
fun
InstructionAdapter
.
generateResumeWithExceptionCheck
()
{
private
fun
InstructionAdapter
.
generateResumeWithExceptionCheck
()
{
...
...
compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutineCodegenUtil.kt
浏览文件 @
ce333b0a
...
@@ -54,8 +54,6 @@ val CONTINUATION_METHOD_ANNOTATION_DESC = "Lkotlin/ContinuationMethod;"
...
@@ -54,8 +54,6 @@ val CONTINUATION_METHOD_ANNOTATION_DESC = "Lkotlin/ContinuationMethod;"
const
val
COROUTINE_MARKER_OWNER
=
"kotlin/coroutines/Markers"
const
val
COROUTINE_MARKER_OWNER
=
"kotlin/coroutines/Markers"
const
val
BEFORE_SUSPENSION_POINT_MARKER_NAME
=
"beforeSuspensionPoint"
const
val
BEFORE_SUSPENSION_POINT_MARKER_NAME
=
"beforeSuspensionPoint"
const
val
AFTER_SUSPENSION_POINT_MARKER_NAME
=
"afterSuspensionPoint"
const
val
AFTER_SUSPENSION_POINT_MARKER_NAME
=
"afterSuspensionPoint"
const
val
HANDLE_EXCEPTION_MARKER_NAME
=
"handleException"
const
val
HANDLE_EXCEPTION_ARGUMENT_MARKER_NAME
=
"handleExceptionArgument"
const
val
ACTUAL_COROUTINE_START_MARKER_NAME
=
"actualCoroutineStart"
const
val
ACTUAL_COROUTINE_START_MARKER_NAME
=
"actualCoroutineStart"
const
val
COROUTINE_LABEL_FIELD_NAME
=
"label"
const
val
COROUTINE_LABEL_FIELD_NAME
=
"label"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录