| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "src/base/atomic-utils.h" | 7 #include "src/base/atomic-utils.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 | 9 |
| 10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
| (...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 TENURED); | 1138 TENURED); |
| 1139 exportedSig->copy_in(0, | 1139 exportedSig->copy_in(0, |
| 1140 reinterpret_cast<const byte*>(funcSig->raw_data()), | 1140 reinterpret_cast<const byte*>(funcSig->raw_data()), |
| 1141 exportedSig->length()); | 1141 exportedSig->length()); |
| 1142 export_metadata->set(kExportedSignature, *exportedSig); | 1142 export_metadata->set(kExportedSignature, *exportedSig); |
| 1143 WasmName str = GetName(exp.name_offset, exp.name_length); | 1143 WasmName str = GetName(exp.name_offset, exp.name_length); |
| 1144 Handle<String> name = factory->InternalizeUtf8String(str); | 1144 Handle<String> name = factory->InternalizeUtf8String(str); |
| 1145 Handle<Code> code = | 1145 Handle<Code> code = |
| 1146 temp_instance_for_compilation.function_code[exp.func_index]; | 1146 temp_instance_for_compilation.function_code[exp.func_index]; |
| 1147 Handle<Code> export_code = compiler::CompileJSToWasmWrapper( | 1147 Handle<Code> export_code = compiler::CompileJSToWasmWrapper( |
| 1148 isolate, &module_env, code, exp.func_index); | 1148 isolate, temp_instance_for_compilation.context, &module_env, code, |
| 1149 exp.func_index); |
| 1149 if (thrower->error()) return nothing; | 1150 if (thrower->error()) return nothing; |
| 1150 export_metadata->set(kExportCode, *export_code); | 1151 export_metadata->set(kExportCode, *export_code); |
| 1151 export_metadata->set(kExportName, *name); | 1152 export_metadata->set(kExportName, *name); |
| 1152 export_metadata->set( | 1153 export_metadata->set( |
| 1153 kExportArity, Smi::FromInt(static_cast<int>( | 1154 kExportArity, Smi::FromInt(static_cast<int>( |
| 1154 functions[exp.func_index].sig->parameter_count()))); | 1155 functions[exp.func_index].sig->parameter_count()))); |
| 1155 export_metadata->set(kExportedFunctionIndex, | 1156 export_metadata->set(kExportedFunctionIndex, |
| 1156 Smi::FromInt(static_cast<int>(exp.func_index))); | 1157 Smi::FromInt(static_cast<int>(exp.func_index))); |
| 1157 exports->set(i, *export_metadata); | 1158 exports->set(i, *export_metadata); |
| 1158 if (exp.func_index == start_function_index) { | 1159 if (exp.func_index == start_function_index) { |
| 1159 startup_fct = export_code; | 1160 startup_fct = export_code; |
| 1160 } | 1161 } |
| 1161 } | 1162 } |
| 1162 ret->set(kExports, *exports); | 1163 ret->set(kExports, *exports); |
| 1163 } | 1164 } |
| 1164 | 1165 |
| 1165 // Compile startup function, if we haven't already. | 1166 // Compile startup function, if we haven't already. |
| 1166 if (start_function_index >= 0) { | 1167 if (start_function_index >= 0) { |
| 1167 uint32_t index = static_cast<uint32_t>(start_function_index); | 1168 uint32_t index = static_cast<uint32_t>(start_function_index); |
| 1168 HandleScope scope(isolate); | 1169 HandleScope scope(isolate); |
| 1169 if (startup_fct.is_null()) { | 1170 if (startup_fct.is_null()) { |
| 1170 Handle<Code> code = temp_instance_for_compilation.function_code[index]; | 1171 Handle<Code> code = temp_instance_for_compilation.function_code[index]; |
| 1171 DCHECK_EQ(0, functions[index].sig->parameter_count()); | 1172 DCHECK_EQ(0, functions[index].sig->parameter_count()); |
| 1172 startup_fct = | 1173 startup_fct = compiler::CompileJSToWasmWrapper( |
| 1173 compiler::CompileJSToWasmWrapper(isolate, &module_env, code, index); | 1174 isolate, temp_instance_for_compilation.context, &module_env, code, |
| 1175 index); |
| 1174 } | 1176 } |
| 1175 Handle<FixedArray> metadata = | 1177 Handle<FixedArray> metadata = |
| 1176 factory->NewFixedArray(kWasmExportMetadataTableSize, TENURED); | 1178 factory->NewFixedArray(kWasmExportMetadataTableSize, TENURED); |
| 1177 metadata->set(kExportCode, *startup_fct); | 1179 metadata->set(kExportCode, *startup_fct); |
| 1178 metadata->set(kExportArity, Smi::FromInt(0)); | 1180 metadata->set(kExportArity, Smi::FromInt(0)); |
| 1179 metadata->set(kExportedFunctionIndex, Smi::FromInt(start_function_index)); | 1181 metadata->set(kExportedFunctionIndex, Smi::FromInt(start_function_index)); |
| 1180 ret->set(kStartupFunction, *metadata); | 1182 ret->set(kStartupFunction, *metadata); |
| 1181 } | 1183 } |
| 1182 | 1184 |
| 1183 // TODO(wasm): saving the module bytes for debugging is wasteful. We should | 1185 // TODO(wasm): saving the module bytes for debugging is wasteful. We should |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); | 1669 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); |
| 1668 } | 1670 } |
| 1669 thrower->Error("WASM.compileRun() failed: Return value should be number"); | 1671 thrower->Error("WASM.compileRun() failed: Return value should be number"); |
| 1670 return -1; | 1672 return -1; |
| 1671 } | 1673 } |
| 1672 | 1674 |
| 1673 } // namespace testing | 1675 } // namespace testing |
| 1674 } // namespace wasm | 1676 } // namespace wasm |
| 1675 } // namespace internal | 1677 } // namespace internal |
| 1676 } // namespace v8 | 1678 } // namespace v8 |
| OLD | NEW |