-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
156 additions
and
125 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* ARM64 JIT compilation example. | ||
*/ | ||
|
||
|
||
# -------------- STANDARD IMPLEMENTATION BEGINS ---------------------------- | ||
|
||
def square2(x) { | ||
var y = 0 | ||
for i in 0..1000000 { | ||
y += x | ||
} | ||
return y | ||
} | ||
|
||
var start = microtime() | ||
echo square2(9) | ||
echo 'Default: ${(microtime() - start)} microseconds' | ||
|
||
# -------------- STANDARD IMPLEMENTATION ENDS ------------------------------ | ||
|
||
# ------------------- JIT IMPLEMENTATION BEGINS ---------------------------- | ||
|
||
import process | ||
import clib | ||
import convert | ||
|
||
var code_address = process.PagedValue(true, true) | ||
|
||
# long square(long num) { | ||
# long y = 0; | ||
# for(int i = 0; i < 1000000; i++) { | ||
# y += num; | ||
# } | ||
# return y; | ||
# } | ||
# gcc -g -O3 arm64 | ||
# square: | ||
# mov x1, #0x4240 | ||
# movk x1, #0xf, lsl #16 | ||
# mul x0, x0, x1 | ||
# ret | ||
var data = convert.hex_to_bytes(hex(0xd2884801)) | ||
data.extend(convert.hex_to_bytes(hex(0xf2a001e1))) | ||
data.extend(convert.hex_to_bytes(hex(0x9b017c00))) | ||
data.extend(convert.hex_to_bytes(hex(0xd65f03c0))) | ||
|
||
code_address.set(data) | ||
|
||
var square3 = clib.function_handle(code_address.raw_pointer(), clib.long, clib.long) | ||
|
||
start = microtime() | ||
echo square3(9) | ||
echo 'JITed: ${(microtime() - start)} microseconds' | ||
|
||
# ------------------- JIT IMPLEMENTATION ENDS ------------------------------ | ||
|
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,29 @@ | ||
/** | ||
* This example sends an email with itself as a file attachment. | ||
*/ | ||
|
||
# Change the MY_* to their correct values. | ||
|
||
import mail | ||
|
||
var smtp = mail.smtp({ | ||
host: 'MY_SMTP_HOST', # e.g. smtp.gmail.com | ||
username: 'MY_SMTP_USERNAME', # usually your email address | ||
password: 'MY_SMTP_PASSWORD', | ||
}) | ||
|
||
echo smtp.add_message(mail.message(). | ||
to('MY_MAIL_RECIPIENT'). # change to the correct value | ||
subject('Testing a very new transmission'). | ||
html( | ||
'Hi,'+ | ||
'<br><br>'+ | ||
'If you are receiving this mail, know that it was sent '+ | ||
'with the <strong>mailer</strong> library for '+ | ||
'<a href="https://bladelang.org">Blade programming language</a>.' + | ||
'<br><br>' + | ||
'Sincerely,<br>' + | ||
'The Blade Community' | ||
). | ||
attachment(__file__, 'smtp_mail.b') | ||
).send() |
This file was deleted.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.