Lines Matching refs:Code
2 // Use of this source code is governed by a BSD-style license that can be
10 #include "src/code-stubs.h"
22 #include "src/wasm/wasm-code-specialization.h"
79 static void RecordStats(Isolate* isolate, Code* code) {
80 isolate->counters()->wasm_generated_code_size()->Increment(code->body_size());
82 code->relocation_info()->length());
88 RecordStats(isolate, Code::cast(functions->get(i)));
96 // systems. It may be safer to fail instead, given that other code might do
131 Handle<Code> code = code_table->GetValueChecked<Code>(isolate, i);
132 Assembler::FlushICache(isolate, code->instruction_start(),
133 code->instruction_size());
170 Handle<Code> CloneOrCompileJSToWasmWrapper(Isolate* isolate,
172 Handle<Code> wasm_code,
177 Handle<Code> code = isolate->factory()->CopyCode(code_cache_[cached_idx]);
178 // Now patch the call to wasm code.
179 for (RelocIterator it(*code, RelocInfo::kCodeTargetMask);; it.next()) {
181 Code* target =
182 Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
183 if (target->kind() == Code::WASM_FUNCTION ||
184 target->kind() == Code::WASM_TO_JS_FUNCTION ||
190 return code;
193 Handle<Code> code =
198 code_cache_.push_back(code);
199 return code;
205 std::vector<Handle<Code>> code_cache_;
300 void FinishCompilationUnits(std::vector<Handle<Code>>& results) {
318 std::vector<Handle<Code>>& results,
374 std::vector<Handle<Code>>& results,
385 Handle<Code> code = Handle<Code>::null();
387 code = compiler::WasmCompilationUnit::CompileWasmFunction(
389 if (code.is_null()) {
395 results[i] = code;
440 // Initialize the code table with the illegal builtin. All call sites will
443 Handle<Code> illegal_builtin = isolate_->builtins()->Illegal();
454 std::vector<Handle<Code>> results(temp_instance.function_code);
463 // At this point, compilation has completed. Update the code table.
466 Code* code = *temp_instance.function_code[i];
467 code_table->set(static_cast<int>(i), code);
468 RecordStats(isolate_, code);
532 Handle<Code> wasm_code(Code::cast(code_table->get(exp.index)), isolate_);
533 Handle<Code> wrapper_code =
557 // Patch code to update memory references, global references, and function
594 Code* code = Code::cast(functions->get(i));
595 if (code->kind() != Code::WASM_FUNCTION) {
598 DCHECK_EQ(Code::JS_TO_WASM_FUNCTION,
599 Code::cast(functions->get(i))->kind());
604 code_specialization.ApplyToWasmCode(code, SKIP_ICACHE_FLUSH);
608 Assembler::FlushICache(isolate, code->instruction_start(),
609 code->instruction_size());
806 os << " code bytes: "
824 Code* code) {
826 DCHECK(code->kind() == Code::WASM_FUNCTION ||
827 code->kind() == Code::WASM_INTERPRETER_ENTRY);
828 FixedArray* deopt_data = code->deoptimization_data();
830 DCHECK_EQ(code->kind() == Code::WASM_INTERPRETER_ENTRY ? 1 : 2,
851 if (func->code()->kind() == Code::JS_TO_WASM_FUNCTION) {
861 static Handle<Code> UnwrapImportWrapper(Handle<Object> target) {
863 Handle<Code> export_wrapper_code = handle(func->code());
866 Handle<Code> code;
870 Code* target = Code::GetCodeFromTargetAddress(target_address);
871 if (target->kind() == Code::WASM_FUNCTION ||
872 target->kind() == Code::WASM_TO_JS_FUNCTION) {
874 code = handle(target);
878 return code;
881 static Handle<Code> CompileImportWrapper(Isolate* isolate, int index,
891 // WASM function code.
894 return Handle<Code>::null();
906 Handle<Code> code) {
923 function_table->set(index, *code);
925 Code* code = nullptr;
927 function_table->set(index, code);
937 Handle<Code>::null());
990 // after we lose the original template handle, the code
1019 // Clone the code for WASM functions and exports.
1021 Handle<Code> orig_code =
1022 code_table->GetValueChecked<Code>(isolate_, i);
1024 case Code::WASM_TO_JS_FUNCTION:
1027 case Code::JS_TO_WASM_FUNCTION:
1028 case Code::WASM_FUNCTION: {
1029 Handle<Code> code = factory->CopyCode(orig_code);
1030 code_table->set(i, *code);
1190 Handle<Code> code = code_table->GetValueChecked<Code>(isolate_, i);
1191 if (code->kind() == Code::WASM_FUNCTION) {
1196 code->set_deoptimization_data(*deopt_data);
1218 // Patch all code with the relocations registered in code_specialization.
1231 Handle<Code> code = code_table->GetValueChecked<Code>(isolate_, i);
1233 if (code->kind() != Code::WASM_FUNCTION) {
1237 const intptr_t base = reinterpret_cast<intptr_t>(code->entry());
1243 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
1304 Handle<Code> startup_code =
1305 code_table->GetValueChecked<Code>(isolate_, start_index);
1307 Handle<Code> wrapper_code =
1341 Handle<FixedArray> function_table; // internal code array
1510 Handle<Code> import_wrapper = CompileImportWrapper(
1802 // Wrap and export the code as a JSFunction.
1808 // Wrap the exported code as a JSFunction.
1809 Handle<Code> export_code =
1810 code_table->GetValueChecked<Code>(isolate_, func_index);
2015 Handle<Code> wasm_code(Code::cast(code_table->get(func_index)),
2023 Handle<Code> wrapper_code =
2323 // Patch the code of the respective instance.
2613 thrower->CompileError("Wasm code generation disallowed in this context");