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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
| new file mode 100644
@@ -0,0 +1 @@ +5a2307d0f2c5b650c6858e2b9b57b335a59946ff \ No newline at end of file
@@ -624,6 +624,45 @@ BUILTIN(ArrayShift) { return GenericArrayShift(isolate, receiver, length); } +BUILTIN(ArrayShrink) { + HandleScope scope(isolate); + Factory *factory = isolate->factory(); + Handle<Object> receiver = args.receiver(); + + if (!IsJSArray(*receiver) || !HasOnlySimpleReceiverElements(isolate, Cast<JSArray>(*receiver))) { + THROW_NEW_ERROR_RETURN_FAILURE( + isolate, NewTypeError(MessageTemplate::kPlaceholderOnly, + factory->NewStringFromAsciiChecked("Oldest trick in the book")) + ); + } + + Handle<JSArray> array = Cast<JSArray>(receiver); + + if (args.length() != 2) { + THROW_NEW_ERROR_RETURN_FAILURE( + isolate, NewTypeError(MessageTemplate::kPlaceholderOnly, + factory->NewStringFromAsciiChecked("specify length to shrink to ")) + ); + } + + + uint32_t old_len = static_cast<uint32_t>(Object::NumberValue(array->length())); + + Handle<Object> new_len_obj; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, new_len_obj, Object::ToNumber(isolate, args.at(1))); + uint32_t new_len = static_cast<uint32_t>(Object::NumberValue(*new_len_obj)); + + if (new_len >= old_len){ + THROW_NEW_ERROR_RETURN_FAILURE( + isolate, NewTypeError(MessageTemplate::kPlaceholderOnly, + factory->NewStringFromAsciiChecked("invalid length")) + ); + } + + array->set_length(Smi::FromInt(new_len)); + + return ReadOnlyRoots(isolate).undefined_value(); +} BUILTIN(ArrayUnshift) { HandleScope scope(isolate);
@@ -424,6 +424,8 @@ namespace internal { TFJ(ArrayPrototypePush, kDontAdaptArgumentsSentinel) \ /* ES6 #sec-array.prototype.shift */ \ CPP(ArrayShift) \ + CPP(ArrayShrink) \ + \ /* ES6 #sec-array.prototype.unshift */ \ CPP(ArrayUnshift) \ /* Support for Array.from and other array-copying idioms */ \
@@ -3370,47 +3370,47 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { 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)); + // 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, "testRunner", - Shell::CreateTestRunnerTemplate(isolate)); - global_template->Set(isolate, "Realm", Shell::CreateRealmTemplate(isolate)); - global_template->Set(isolate, "performance", - Shell::CreatePerformanceTemplate(isolate)); - global_template->Set(isolate, "Worker", Shell::CreateWorkerTemplate(isolate)); + // if (!options.omit_quit) { + // global_template->Set(isolate, "quit", FunctionTemplate::New(isolate, Quit)); + // } + // global_template->Set(isolate, "testRunner", + // Shell::CreateTestRunnerTemplate(isolate)); + // 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.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)); - } + // if (i::v8_flags.expose_async_hooks) { + // global_template->Set(isolate, "async_hooks", + // Shell::CreateAsyncHookTemplate(isolate)); + // } return global_template; } @@ -3719,10 +3719,10 @@ void Shell::Initialize(Isolate* isolate, D8Console* console, v8::Isolate::kMessageLog); } - isolate->SetHostImportModuleDynamicallyCallback( - Shell::HostImportModuleDynamically); - isolate->SetHostInitializeImportMetaObjectCallback( - Shell::HostInitializeImportMetaObject); + // isolate->SetHostImportModuleDynamicallyCallback( + // Shell::HostImportModuleDynamically); + // isolate->SetHostInitializeImportMetaObjectCallback( + // Shell::HostInitializeImportMetaObject); isolate->SetHostCreateShadowRealmContextCallback( Shell::HostCreateShadowRealmContext);
@@ -2535,6 +2535,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, true); SimpleInstallFunction(isolate_, proto, "concat", Builtin::kArrayPrototypeConcat, 1, false); + + SimpleInstallFunction(isolate_, proto, "shrink", + Builtin::kArrayShrink, 1, false); SimpleInstallFunction(isolate_, proto, "copyWithin", Builtin::kArrayPrototypeCopyWithin, 2, false); SimpleInstallFunction(isolate_, proto, "fill", Builtin::kArrayPrototypeFill,
new file mode 100644
@@ -0,0 +1,12 @@ +# Build arguments go here. +# See "gn args <out_dir> --list" for available build arguments. +is_component_build = false +is_debug = false +target_cpu = "x64" +v8_enable_sandbox = false +v8_enable_backtrace = true +v8_enable_disassembler = true +v8_enable_object_print = true +dcheck_always_on = false +use_goma = false +v8_code_pointer_sandboxing = false
new file mode 100755
Binary files /dev/null and b/to_give/d8 differ
new file mode 100644
@@ -0,0 +1,78 @@ +diff --git a/src/builtins/builtins-array.cc b/src/builtins/builtins-array.cc +index ea45a7ada6b..2552c286b60 100644 +--- a/src/builtins/builtins-array.cc
+@@ -624,6 +624,45 @@ BUILTIN(ArrayShift) { + + return GenericArrayShift(isolate, receiver, length); + } ++BUILTIN(ArrayShrink) { ++ HandleScope scope(isolate); ++ Factory *factory = isolate->factory(); ++ Handle<Object> receiver = args.receiver(); ++ ++ if (!IsJSArray(*receiver) || !HasOnlySimpleReceiverElements(isolate, Cast<JSArray>(*receiver))) { ++ THROW_NEW_ERROR_RETURN_FAILURE( ++ isolate, NewTypeError(MessageTemplate::kPlaceholderOnly, ++ factory->NewStringFromAsciiChecked("Oldest trick in the book")) ++ ); ++ } ++ ++ Handle<JSArray> array = Cast<JSArray>(receiver); ++ ++ if (args.length() != 2) { ++ THROW_NEW_ERROR_RETURN_FAILURE( ++ isolate, NewTypeError(MessageTemplate::kPlaceholderOnly, ++ factory->NewStringFromAsciiChecked("specify length to shrink to ")) ++ ); ++ } ++ ++ ++ uint32_t old_len = static_cast<uint32_t>(Object::NumberValue(array->length())); ++ ++ Handle<Object> new_len_obj; ++ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, new_len_obj, Object::ToNumber(isolate, args.at(1))); ++ uint32_t new_len = static_cast<uint32_t>(Object::NumberValue(*new_len_obj)); ++ ++ if (new_len >= old_len){ ++ THROW_NEW_ERROR_RETURN_FAILURE( ++ isolate, NewTypeError(MessageTemplate::kPlaceholderOnly, ++ factory->NewStringFromAsciiChecked("invalid length")) ++ ); ++ } ++ ++ array->set_length(Smi::FromInt(new_len)); ++ ++ return ReadOnlyRoots(isolate).undefined_value(); ++} + + BUILTIN(ArrayUnshift) { + HandleScope scope(isolate); +diff --git a/src/builtins/builtins-definitions.h b/src/builtins/builtins-definitions.h +index 78cbf8874ed..dc60d59e637 100644 +--- a/src/builtins/builtins-definitions.h
+@@ -424,6 +424,8 @@ namespace internal { + TFJ(ArrayPrototypePush, kDontAdaptArgumentsSentinel) \ + /* ES6 #sec-array.prototype.shift */ \ + CPP(ArrayShift) \ ++ CPP(ArrayShrink) \ ++ \ + /* ES6 #sec-array.prototype.unshift */ \ + CPP(ArrayUnshift) \ + /* Support for Array.from and other array-copying idioms */ \ +diff --git a/src/init/bootstrapper.cc b/src/init/bootstrapper.cc +index 48249695b7b..c8c5c2eda25 100644 +--- a/src/init/bootstrapper.cc
+@@ -2535,6 +2535,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, + true); + SimpleInstallFunction(isolate_, proto, "concat", + Builtin::kArrayPrototypeConcat, 1, false); ++ ++ SimpleInstallFunction(isolate_, proto, "shrink", ++ Builtin::kArrayShrink, 1, false); + SimpleInstallFunction(isolate_, proto, "copyWithin", + Builtin::kArrayPrototypeCopyWithin, 2, false); + SimpleInstallFunction(isolate_, proto, "fill", Builtin::kArrayPrototypeFill, +
new file mode 100644
Binary files /dev/null and b/to_give/snapshot_blob.bin differ
@@ -18,7 +18,7 @@ import ast import errno import json import os -import pipes +import shlex as pipes import platform import pprint import re
new file mode 160000
@@ -0,0 +1 @@ +Subproject commit f93e7ca2a64938e9b4759ec3297f02ca7b3f605f
new file mode 160000
@@ -0,0 +1 @@ +Subproject commit 2cbfc8d2e5ef4a6afd9774e9a9eaebd921a9f248
|