Skip to content

Commit 01e6632

Browse files
bnoordhuischrisdickinson
authored andcommitted
deps: upgrade v8 to 4.2.77.15
This includes the out-of-tree patch (but fixed in upstream HEAD) from commit 41c00a2 ("deps: enable v8 postmortem debugging again".) PR-URL: #1399 Reviewed-By: Fedor Indutny <[email protected]>
1 parent db4ded5 commit 01e6632

File tree

8 files changed

+57
-36
lines changed

8 files changed

+57
-36
lines changed

deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 4
1212
#define V8_MINOR_VERSION 2
1313
#define V8_BUILD_NUMBER 77
14-
#define V8_PATCH_LEVEL 13
14+
#define V8_PATCH_LEVEL 15
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/api-natives.cc

+21-25
Original file line numberDiff line numberDiff line change
@@ -207,36 +207,33 @@ MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
207207
}
208208

209209

210-
void InstallInCache(Isolate* isolate, int serial_number,
211-
Handle<JSFunction> function) {
210+
void CacheFunction(Isolate* isolate, Handle<Smi> serial_number,
211+
Handle<JSFunction> function) {
212212
auto cache = isolate->function_cache();
213-
if (cache->length() <= serial_number) {
214-
int new_size;
215-
if (isolate->next_serial_number() < 50) {
216-
new_size = 100;
217-
} else {
218-
new_size = 3 * isolate->next_serial_number() / 2;
219-
}
220-
cache = FixedArray::CopySize(cache, new_size);
221-
isolate->native_context()->set_function_cache(*cache);
222-
}
223-
cache->set(serial_number, *function);
213+
auto new_cache = ObjectHashTable::Put(cache, serial_number, function);
214+
isolate->native_context()->set_function_cache(*new_cache);
215+
}
216+
217+
218+
void UncacheFunction(Isolate* isolate, Handle<Smi> serial_number) {
219+
auto cache = isolate->function_cache();
220+
bool was_present = false;
221+
auto new_cache = ObjectHashTable::Remove(cache, serial_number, &was_present);
222+
DCHECK(was_present);
223+
isolate->native_context()->set_function_cache(*new_cache);
224224
}
225225

226226

227227
MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate,
228228
Handle<FunctionTemplateInfo> data,
229229
Handle<Name> name) {
230-
int serial_number = Smi::cast(data->serial_number())->value();
230+
auto serial_number = handle(Smi::cast(data->serial_number()), isolate);
231231
// Probe cache.
232232
if (!data->do_not_cache()) {
233233
auto cache = isolate->function_cache();
234-
// Fast case: see if the function has already been instantiated
235-
if (serial_number < cache->length()) {
236-
Handle<Object> element = FixedArray::get(cache, serial_number);
237-
if (element->IsJSFunction()) {
238-
return Handle<JSFunction>::cast(element);
239-
}
234+
Object* element = cache->Lookup(serial_number);
235+
if (element->IsJSFunction()) {
236+
return handle(JSFunction::cast(element), isolate);
240237
}
241238
}
242239
// Enter a new scope. Recursion could otherwise create a lot of handles.
@@ -279,15 +276,14 @@ MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate,
279276
function->shared()->set_name(*name);
280277
}
281278
if (!data->do_not_cache()) {
282-
// Cache the function to limit recursion.
283-
InstallInCache(isolate, serial_number, function);
279+
// Cache the function.
280+
CacheFunction(isolate, serial_number, function);
284281
}
285282
auto result = ConfigureInstance(isolate, function, data);
286283
if (result.is_null()) {
287-
// uncache on error.
284+
// Uncache on error.
288285
if (!data->do_not_cache()) {
289-
auto cache = isolate->function_cache();
290-
cache->set(serial_number, isolate->heap()->undefined_value());
286+
UncacheFunction(isolate, serial_number);
291287
}
292288
return MaybeHandle<JSFunction>();
293289
}

deps/v8/src/api-natives.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace internal {
1212

1313
class ApiNatives {
1414
public:
15+
static const int kInitialFunctionCacheSize = 256;
16+
1517
MUST_USE_RESULT static MaybeHandle<JSFunction> InstantiateFunction(
1618
Handle<FunctionTemplateInfo> data);
1719

deps/v8/src/bootstrapper.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,9 @@ bool Genesis::InstallNatives() {
20592059

20602060
InstallNativeFunctions();
20612061

2062-
native_context()->set_function_cache(heap()->empty_fixed_array());
2062+
auto function_cache =
2063+
ObjectHashTable::New(isolate(), ApiNatives::kInitialFunctionCacheSize);
2064+
native_context()->set_function_cache(*function_cache);
20632065

20642066
// Store the map for the string prototype after the natives has been compiled
20652067
// and the String function has been set up.

deps/v8/src/contexts.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ enum BindingFlags {
138138
V(MAKE_MESSAGE_FUN_INDEX, JSFunction, make_message_fun) \
139139
V(GET_STACK_TRACE_LINE_INDEX, JSFunction, get_stack_trace_line_fun) \
140140
V(CONFIGURE_GLOBAL_INDEX, JSFunction, configure_global_fun) \
141-
V(FUNCTION_CACHE_INDEX, FixedArray, function_cache) \
141+
V(FUNCTION_CACHE_INDEX, ObjectHashTable, function_cache) \
142142
V(JSFUNCTION_RESULT_CACHES_INDEX, FixedArray, jsfunction_result_caches) \
143143
V(NORMALIZED_MAP_CACHE_INDEX, Object, normalized_map_cache) \
144144
V(RUNTIME_CONTEXT_INDEX, Context, runtime_context) \

deps/v8/src/type-info.cc

+3
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ bool TypeFeedbackOracle::CanRetainOtherContext(Map* map,
437437
}
438438
constructor = map->constructor();
439439
if (constructor->IsNull()) return false;
440+
// If the constructor is not null or a JSFunction, we have to conservatively
441+
// assume that it may retain a native context.
442+
if (!constructor->IsJSFunction()) return true;
440443
JSFunction* function = JSFunction::cast(constructor);
441444
return CanRetainOtherContext(function, native_context);
442445
}

deps/v8/test/cctest/test-api.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -20367,15 +20367,15 @@ THREADED_TEST(FunctionNew) {
2036720367
env->Global()->Set(v8_str("func"), func);
2036820368
Local<Value> result = CompileRun("func();");
2036920369
CHECK(v8::Integer::New(isolate, 17)->Equals(result));
20370-
// Verify function not cached
20371-
int serial_number =
20372-
i::Smi::cast(v8::Utils::OpenHandle(*func)
20373-
->shared()->get_api_func_data()->serial_number())->value();
2037420370
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
20375-
i::Handle<i::FixedArray> cache(i_isolate->native_context()->function_cache());
20376-
if (serial_number < cache->length()) {
20377-
CHECK(cache->get(serial_number)->IsUndefined());
20378-
}
20371+
// Verify function not cached
20372+
auto serial_number = handle(i::Smi::cast(v8::Utils::OpenHandle(*func)
20373+
->shared()
20374+
->get_api_func_data()
20375+
->serial_number()),
20376+
i_isolate);
20377+
auto cache = i_isolate->function_cache();
20378+
CHECK(cache->Lookup(serial_number)->IsTheHole());
2037920379
// Verify that each Function::New creates a new function instance
2038020380
Local<Object> data2 = v8::Object::New(isolate);
2038120381
function_new_expected_env = data2;

deps/v8/tools/testrunner/local/progress.py

+18
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def __init__(self, progress_indicator, json_test_results, arch, mode):
291291
self.arch = arch
292292
self.mode = mode
293293
self.results = []
294+
self.tests = []
294295

295296
def Starting(self):
296297
self.progress_indicator.runner = self.runner
@@ -304,10 +305,24 @@ def Done(self):
304305
# Buildbot might start out with an empty file.
305306
complete_results = json.loads(f.read() or "[]")
306307

308+
# Sort tests by duration.
309+
timed_tests = [t for t in self.tests if t.duration is not None]
310+
timed_tests.sort(lambda a, b: cmp(b.duration, a.duration))
311+
slowest_tests = [
312+
{
313+
"name": test.GetLabel(),
314+
"flags": test.flags,
315+
"command": EscapeCommand(self.runner.GetCommand(test)).replace(
316+
ABS_PATH_PREFIX, ""),
317+
"duration": test.duration,
318+
} for test in timed_tests[:20]
319+
]
320+
307321
complete_results.append({
308322
"arch": self.arch,
309323
"mode": self.mode,
310324
"results": self.results,
325+
"slowest_tests": slowest_tests,
311326
})
312327

313328
with open(self.json_test_results, "w") as f:
@@ -318,6 +333,8 @@ def AboutToRun(self, test):
318333

319334
def HasRun(self, test, has_unexpected_output):
320335
self.progress_indicator.HasRun(test, has_unexpected_output)
336+
# Buffer all tests for sorting the durations in the end.
337+
self.tests.append(test)
321338
if not has_unexpected_output:
322339
# Omit tests that run as expected. Passing tests of reruns after failures
323340
# will have unexpected_output to be reported here has well.
@@ -334,6 +351,7 @@ def HasRun(self, test, has_unexpected_output):
334351
"exit_code": test.output.exit_code,
335352
"result": test.suite.GetOutcome(test),
336353
"expected": list(test.outcomes or ["PASS"]),
354+
"duration": test.duration,
337355
})
338356

339357

0 commit comments

Comments
 (0)