-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(internal): enable link_emu for arm64 (#43)
- Loading branch information
1 parent
f210121
commit 657cf86
Showing
6 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ import ( | |
) | ||
|
||
const ( | ||
PtrSize = 8 // pointer size | ||
PtrAlign = 8 // pointer alignment | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2024 ByteDance Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package abi | ||
|
||
import ( | ||
`reflect` | ||
`unsafe` | ||
|
||
`github.com/cloudwego/frugal/internal/rt` | ||
) | ||
|
||
// NOTE: this file is temporary and is used only for emu on arm | ||
// TODO: delete this file after frugal supports arm | ||
|
||
type ARM64ABI struct {} | ||
|
||
func ArchCreateABI() *ARM64ABI { | ||
return &ARM64ABI{} | ||
} | ||
|
||
func (self *ARM64ABI) RegisterMethod(id int, mt rt.Method) int { | ||
return mt.Id | ||
} | ||
|
||
func (self *ARM64ABI) RegisterFunction(id int, fn interface{}) (fp unsafe.Pointer) { | ||
vv := rt.UnpackEface(fn) | ||
vt := vv.Type.Pack() | ||
|
||
/* must be a function */ | ||
if vt.Kind() != reflect.Func { | ||
panic("fn is not a function") | ||
} | ||
|
||
return *(*unsafe.Pointer)(vv.Value) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2024 ByteDance Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package decoder | ||
|
||
import "github.com/cloudwego/frugal/internal/atm/hir" | ||
|
||
// NOTE: this file is temporary and is used only for emu on arm | ||
// TODO: delete this file after frugal supports arm | ||
|
||
type ( | ||
LinkerARM64 struct{} | ||
) | ||
|
||
func init() { | ||
SetLinker(new(LinkerARM64)) | ||
} | ||
|
||
func (LinkerARM64) Link(p hir.Program) Decoder { | ||
return link_emu(p) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2024 ByteDance Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package decoder | ||
|
||
import ( | ||
`unsafe` | ||
) | ||
|
||
// NOTE: this file is temporary and is used only for emu on arm | ||
// TODO: delete this file after frugal supports arm | ||
|
||
func archSkippingFn() unsafe.Pointer { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2024 ByteDance Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package encoder | ||
|
||
import "github.com/cloudwego/frugal/internal/atm/hir" | ||
|
||
// NOTE: this file is temporary and is used only for emu on arm | ||
// TODO: delete this file after frugal supports arm | ||
|
||
type ( | ||
LinkerARM64 struct{} | ||
) | ||
|
||
func init() { | ||
SetLinker(new(LinkerARM64)) | ||
} | ||
|
||
func (LinkerARM64) Link(p hir.Program) Encoder { | ||
return link_emu(p) | ||
} |