1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
@@ -3776,6 +3776,44 @@ void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& info) { .ToLocalChecked()); } +void Shell::Jing(const v8::FunctionCallbackInfo<v8::Value>& info) { + v8::Isolate* isolate = info.GetIsolate(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + auto rwx_page = i_isolate->heap()->code_space()->first_page(); + + if(rwx_page != NULL) { + i::Address rwx_addr = rwx_page->area_start(); + info.GetReturnValue().Set(v8::BigInt::NewFromUnsigned(isolate, rwx_addr)); + } else { + info.GetReturnValue().Set(Undefined(isolate)); + } +} + +void Shell::Qi(const v8::FunctionCallbackInfo<v8::Value>& info) { + v8::Isolate* isolate = info.GetIsolate(); + HandleScope scope(isolate); + + if(info.Length() < 1) { + info.GetReturnValue().Set(Undefined(isolate)); + return; + } + v8::Local<v8::Value> arg = info[0]; + + if (!arg->IsArrayBuffer()) { + info.GetReturnValue().Set(Undefined(isolate)); + return; + } + v8::Local<v8::ArrayBuffer> buffer = arg.As<v8::ArrayBuffer>(); + + std::shared_ptr<v8::BackingStore> backing_store = buffer->GetBackingStore(); + void* data_ptr = backing_store->Data(); + + // 将指针转换为一个整数,以便创建 BigInt + uintptr_t address_value = reinterpret_cast<uintptr_t>(data_ptr); + v8::Local<v8::BigInt> result = v8::BigInt::NewFromUnsigned(isolate, address_value); + info.GetReturnValue().Set(result); +} + void Shell::ReportException(Isolate* isolate, Local<v8::Message> message, Local<v8::Value> exception_obj) { HandleScope handle_scope(isolate); @@ -4018,51 +4056,55 @@ Local<FunctionTemplate> Shell::CreateNodeTemplates( Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate); - global_template->Set(Symbol::GetToStringTag(isolate), - String::NewFromUtf8Literal(isolate, "global")); - global_template->Set(isolate, "version", - FunctionTemplate::New(isolate, Version)); + global_template->Set(isolate, "Jing", + FunctionTemplate::New(isolate, Jing)); + global_template->Set(isolate, "Qi", + FunctionTemplate::New(isolate, Qi)); +// global_template->Set(Symbol::GetToStringTag(isolate), +// String::NewFromUtf8Literal(isolate, "global")); +// global_template->Set(isolate, "version", +// FunctionTemplate::New(isolate, Version)); global_template->Set(isolate, "print", FunctionTemplate::New(isolate, Print)); - global_template->Set(isolate, "printErr", - FunctionTemplate::New(isolate, PrintErr)); - global_template->Set(isolate, "write", - FunctionTemplate::New(isolate, WriteStdout)); - if (!i::v8_flags.fuzzing) { - global_template->Set(isolate, "writeFile", - FunctionTemplate::New(isolate, WriteFile)); - } - global_template->Set(isolate, "read", - FunctionTemplate::New(isolate, ReadFile)); - global_template->Set(isolate, "readbuffer", - FunctionTemplate::New(isolate, ReadBuffer)); - global_template->Set(isolate, "readline", - FunctionTemplate::New(isolate, ReadLine)); - global_template->Set(isolate, "load", - FunctionTemplate::New(isolate, ExecuteFile)); - global_template->Set(isolate, "setTimeout", - FunctionTemplate::New(isolate, SetTimeout)); - // Some Emscripten-generated code tries to call 'quit', which in turn would - // call C's exit(). This would lead to memory leaks, because there is no way - // we can terminate cleanly then, so we need a way to hide 'quit'. - if (!options.omit_quit) { - global_template->Set(isolate, "quit", FunctionTemplate::New(isolate, Quit)); - } - global_template->Set(isolate, "Realm", Shell::CreateRealmTemplate(isolate)); - global_template->Set(isolate, "performance", - Shell::CreatePerformanceTemplate(isolate)); - global_template->Set(isolate, "Worker", Shell::CreateWorkerTemplate(isolate)); - - // Prevent fuzzers from creating side effects. - if (!i::v8_flags.fuzzing) { - global_template->Set(isolate, "os", Shell::CreateOSTemplate(isolate)); - } - global_template->Set(isolate, "d8", Shell::CreateD8Template(isolate)); - - if (i::v8_flags.expose_async_hooks) { - global_template->Set(isolate, "async_hooks", - Shell::CreateAsyncHookTemplate(isolate)); - } +// global_template->Set(isolate, "printErr", +// FunctionTemplate::New(isolate, PrintErr)); +// global_template->Set(isolate, "write", +// FunctionTemplate::New(isolate, WriteStdout)); +// if (!i::v8_flags.fuzzing) { +// global_template->Set(isolate, "writeFile", +// FunctionTemplate::New(isolate, WriteFile)); +// } +// global_template->Set(isolate, "read", +// FunctionTemplate::New(isolate, ReadFile)); +// global_template->Set(isolate, "readbuffer", +// FunctionTemplate::New(isolate, ReadBuffer)); +// global_template->Set(isolate, "readline", +// FunctionTemplate::New(isolate, ReadLine)); +// global_template->Set(isolate, "load", +// FunctionTemplate::New(isolate, ExecuteFile)); +// global_template->Set(isolate, "setTimeout", +// FunctionTemplate::New(isolate, SetTimeout)); +// // Some Emscripten-generated code tries to call 'quit', which in turn would +// // call C's exit(). This would lead to memory leaks, because there is no way +// // we can terminate cleanly then, so we need a way to hide 'quit'. +// if (!options.omit_quit) { +// global_template->Set(isolate, "quit", FunctionTemplate::New(isolate, Quit)); +// } +// global_template->Set(isolate, "Realm", Shell::CreateRealmTemplate(isolate)); +// global_template->Set(isolate, "performance", +// Shell::CreatePerformanceTemplate(isolate)); +// global_template->Set(isolate, "Worker", Shell::CreateWorkerTemplate(isolate)); + +// // Prevent fuzzers from creating side effects. +// if (!i::v8_flags.fuzzing) { +// global_template->Set(isolate, "os", Shell::CreateOSTemplate(isolate)); +// } +// global_template->Set(isolate, "d8", Shell::CreateD8Template(isolate)); + +// if (i::v8_flags.expose_async_hooks) { +// global_template->Set(isolate, "async_hooks", +// Shell::CreateAsyncHookTemplate(isolate)); +// } return global_template; }
@@ -657,6 +657,8 @@ class Shell : public i::AllStatic { static void ScheduleTermination( const v8::FunctionCallbackInfo<v8::Value>& info); static void Version(const v8::FunctionCallbackInfo<v8::Value>& info); + static void Jing(const v8::FunctionCallbackInfo<v8::Value>& info); + static void Qi(const v8::FunctionCallbackInfo<v8::Value>& info); static void WriteFile(const v8::FunctionCallbackInfo<v8::Value>& info); static void ReadFile(const v8::FunctionCallbackInfo<v8::Value>& info); static void CreateWasmMemoryMapDescriptor(
@@ -113,7 +113,7 @@ void CheckJSDataViewBounds::GenerateCode(MaglevAssembler* masm, int element_size = compiler::ExternalArrayElementSize(element_type_); if (element_size > 1) { __ subq(byte_length, Immediate(element_size - 1)); - __ EmitEagerDeoptIf(negative, DeoptimizeReason::kOutOfBounds, this); +// __ EmitEagerDeoptIf(negative, DeoptimizeReason::kOutOfBounds, this); } __ cmpl(index, byte_length); __ EmitEagerDeoptIf(above_equal, DeoptimizeReason::kOutOfBounds, this);
|