Reviewers: Yang, dcarney,
Message:
PTAL
Description:
Store the next serial number in the function cache rather than in the
isolate.
BUG=
Please review this at https://codereview.chromium.org/988693003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+18, -7 lines):
M src/api-natives.cc
M src/isolate.h
M src/isolate.cc
Index: src/api-natives.cc
diff --git a/src/api-natives.cc b/src/api-natives.cc
index
44b09dffba387bc60d355a763b484554a949ccd1..852c85d430efc72538731b3029767fc699f5559c
100644
--- a/src/api-natives.cc
+++ b/src/api-natives.cc
@@ -211,12 +211,8 @@ void InstallInCache(Isolate* isolate, int
serial_number,
Handle<JSFunction> function) {
auto cache = isolate->function_cache();
if (cache->length() <= serial_number) {
- int new_size;
- if (isolate->next_serial_number() < 50) {
- new_size = 100;
- } else {
- new_size = 3 * isolate->next_serial_number() / 2;
- }
+ DCHECK(isolate->next_serial_number > 50);
+ int new_size = 3 * isolate->next_serial_number() / 2;
cache = FixedArray::CopySize(cache, new_size);
isolate->native_context()->set_function_cache(*cache);
}
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index
7cd8b002c4b096e15c83a085eba72eaaf4b8739c..0745d58354154f695511a1ad64c8cdbfa85eb303
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -420,6 +420,16 @@ Handle<Object>
Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object,
}
+void Isolate::set_next_serial_number(int serial) {
+ Handle<FixedArray> cache = function_cache();
+ if (function_cache()->length() == 0) {
+ cache = factory()->NewFixedArray(100);
+ native_context()->set_function_cache(*cache);
+ }
+ cache->set(0, Smi::FromInt(serial));
+}
+
+
void Isolate::CaptureAndSetDetailedStackTrace(Handle<JSObject>
error_object) {
if (capture_stack_trace_for_uncaught_exceptions_) {
// Capture stack trace for a detailed exception message.
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index
3ddc82278c9a4e23c070be70b3b7ee8f75582b7c..1dcfa5e30691fb8a85b99da1eec75fd9af07d900
100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -376,7 +376,6 @@ typedef List<HeapObject*> DebugObjectCache;
V(AllowCodeGenerationFromStringsCallback, allow_code_gen_callback,
NULL) \
/* To distinguish the function templates, so that we can find them in
the */ \
/* function cache of the native context.
*/ \
- V(int, next_serial_number,
0) \
V(ExternalReferenceRedirectorPointer*, external_reference_redirector,
NULL) \
/* Part of the state of liveedit.
*/ \
V(FunctionInfoListener*, active_function_info_listener,
NULL) \
@@ -702,6 +701,12 @@ class Isolate {
}
static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); }
+ int next_serial_number() {
+ return function_cache()->length() == 0
+ ? 1
+ : Smi::cast(function_cache()->get(0))->value();
+ }
+ void set_next_serial_number(int serial);
void FreeThreadResources() { thread_local_top_.Free(); }
// This method is called by the api after operations that may throw
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.