浏览代码

Merge branch 'master' into windows-llvm-13.0.0

gingerBill 2 年之前
父节点
当前提交
95762aff9c
共有 4 个文件被更改,包括 12 次插入4 次删除
  1. 1 1
      core/runtime/dynamic_map_internal.odin
  2. 1 1
      core/runtime/os_specific_js.odin
  3. 2 2
      core/runtime/procs_wasm32.odin
  4. 8 0
      src/checker.cpp

+ 1 - 1
core/runtime/dynamic_map_internal.odin

@@ -771,7 +771,7 @@ map_get :: proc "contextless" (m: $T/map[$K]$V, key: K) -> (stored_key: K, store
 	info := intrinsics.type_map_info(T)
 	key := key
 
-	h := info.key_hasher(&key, map_seed(m))
+	h := info.key_hasher(&key, map_seed(rm))
 	pos := map_desired_position(rm, h)
 	distance := uintptr(0)
 	mask := (uintptr(1) << map_log2_cap(rm)) - 1

+ 1 - 1
core/runtime/os_specific_js.odin

@@ -5,7 +5,7 @@ foreign import "odin_env"
 
 _os_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
 	foreign odin_env {
-		write :: proc "c" (fd: u32, p: []byte) ---
+		write :: proc "contextless" (fd: u32, p: []byte) ---
 	}
 	write(1, data)
 	return len(data), 0

+ 2 - 2
core/runtime/procs_wasm32.odin

@@ -8,7 +8,7 @@ ti_int :: struct #raw_union {
 }
 
 @(link_name="__ashlti3", linkage="strong")
-__ashlti3 :: proc "c" (a: i128, b_: u32) -> i128 {
+__ashlti3 :: proc "contextless" (a: i128, b_: u32) -> i128 {
 	bits_in_dword :: size_of(u32)*8
 	b := u32(b_)
 	
@@ -29,7 +29,7 @@ __ashlti3 :: proc "c" (a: i128, b_: u32) -> i128 {
 
 
 @(link_name="__multi3", linkage="strong")
-__multi3 :: proc "c" (a, b: i128) -> i128 {
+__multi3 :: proc "contextless" (a, b: i128) -> i128 {
 	x, y, r: ti_int
 	
 	x.all = a

+ 8 - 0
src/checker.cpp

@@ -3889,6 +3889,14 @@ gb_internal void check_collect_value_decl(CheckerContext *c, Ast *decl) {
 					GB_ASSERT(pl->type->kind == Ast_ProcType);
 					auto cc = pl->type->ProcType.calling_convention;
 					if (cc == ProcCC_ForeignBlockDefault) {
+						if (is_arch_wasm()) {
+							begin_error_block();
+							error(init, "For wasm related targets, it is required that you either define the"
+							            " @(default_calling_convention=<string>) on the foreign block or"
+							            " explicitly assign it on the procedure signature");
+							error_line("\tSuggestion: when dealing with normal Odin code (e.g. js_wasm32), use \"contextless\"; when dealing with Emscripten like code, use \"c\"\n");
+							end_error_block();
+						}
 						cc = ProcCC_CDecl;
 						if (c->foreign_context.default_cc > 0) {
 							cc = c->foreign_context.default_cc;