Commit 5c8560a7 authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Remove vestiges of debug context.

We no longer implement part of the debugger in JS. Therefore we can
remove the infrastructure to support this in the bootstrapper.

Also includes some drive-by cleanups.

Bug: v8:5530

R=petermarshall@chromium.org

Change-Id: I06628a559c17f99c70029fcc94848b0c78f1d3e9
Reviewed-on: https://chromium-review.googlesource.com/c/1369945
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58140}
parent e23bbceb
......@@ -167,8 +167,7 @@ class Genesis {
Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy,
v8::Local<v8::ObjectTemplate> global_proxy_template,
size_t context_snapshot_index,
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer,
GlobalContextType context_type);
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer);
Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy,
v8::Local<v8::ObjectTemplate> global_proxy_template);
~Genesis() = default;
......@@ -227,11 +226,10 @@ class Genesis {
void InstallGlobalThisBinding();
// New context initialization. Used for creating a context from scratch.
void InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> empty_function,
GlobalContextType context_type);
Handle<JSFunction> empty_function);
void InitializeExperimentalGlobal();
// Depending on the situation, expose and/or get rid of the utils object.
void ConfigureUtilsObject(GlobalContextType context_type);
void ConfigureUtilsObject();
#define DECLARE_FEATURE_INITIALIZATION(id, descr) \
void InitializeGlobal_##id();
......@@ -250,13 +248,12 @@ class Genesis {
Handle<JSFunction> InstallInternalArray(Handle<JSObject> target,
const char* name,
ElementsKind elements_kind);
bool InstallNatives(GlobalContextType context_type);
bool InstallNatives();
Handle<JSFunction> InstallTypedArray(const char* name,
ElementsKind elements_kind);
bool InstallExtraNatives();
bool InstallExperimentalExtraNatives();
bool InstallDebuggerNatives();
void InstallBuiltinFunctionIds();
void InstallExperimentalBuiltinFunctionIds();
void InitializeNormalizedMapCaches();
......@@ -335,14 +332,12 @@ Handle<Context> Bootstrapper::CreateEnvironment(
MaybeHandle<JSGlobalProxy> maybe_global_proxy,
v8::Local<v8::ObjectTemplate> global_proxy_template,
v8::ExtensionConfiguration* extensions, size_t context_snapshot_index,
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer,
GlobalContextType context_type) {
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) {
HandleScope scope(isolate_);
Handle<Context> env;
{
Genesis genesis(isolate_, maybe_global_proxy, global_proxy_template,
context_snapshot_index, embedder_fields_deserializer,
context_type);
context_snapshot_index, embedder_fields_deserializer);
env = genesis.result();
if (env.is_null() || !InstallExtensions(env, extensions)) {
return Handle<Context>();
......@@ -1412,8 +1407,7 @@ void InstallMakeError(Isolate* isolate, int builtin_id, int context_index) {
// This is only called if we are not using snapshots. The equivalent
// work in the snapshot case is done in HookUpGlobalObject.
void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> empty_function,
GlobalContextType context_type) {
Handle<JSFunction> empty_function) {
// --- N a t i v e C o n t e x t ---
// Use the empty scope info.
native_context()->set_scope_info(empty_function->shared()->scope_info());
......@@ -4047,26 +4041,19 @@ static Handle<JSObject> ResolveBuiltinIdHolder(Isolate* isolate,
return Handle<JSObject>::cast(value);
}
void Genesis::ConfigureUtilsObject(GlobalContextType context_type) {
switch (context_type) {
// We still need the utils object to find debug functions.
case DEBUG_CONTEXT:
return;
// Expose the natives in global if a valid name for it is specified.
case FULL_CONTEXT: {
// We still need the utils object after deserialization.
if (isolate()->serializer_enabled()) return;
if (FLAG_expose_natives_as == nullptr) break;
if (strlen(FLAG_expose_natives_as) == 0) break;
HandleScope scope(isolate());
Handle<String> natives_key =
factory()->InternalizeUtf8String(FLAG_expose_natives_as);
uint32_t dummy_index;
if (natives_key->AsArrayIndex(&dummy_index)) break;
void Genesis::ConfigureUtilsObject() {
// We still need the utils object after deserialization.
if (isolate()->serializer_enabled()) return;
if (FLAG_expose_natives_as != nullptr &&
strlen(FLAG_expose_natives_as) != 0) {
HandleScope scope(isolate());
Handle<String> natives_key =
factory()->InternalizeUtf8String(FLAG_expose_natives_as);
uint32_t dummy_index;
if (!natives_key->AsArrayIndex(&dummy_index)) {
Handle<Object> utils = isolate()->natives_utils_object();
Handle<JSObject> global = isolate()->global_object();
JSObject::AddProperty(isolate(), global, natives_key, utils, DONT_ENUM);
break;
}
}
......@@ -4076,7 +4063,6 @@ void Genesis::ConfigureUtilsObject(GlobalContextType context_type) {
native_context()->set_extras_utils_object(undefined);
}
void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<JSObject> container) {
Factory* factory = isolate->factory();
......@@ -4957,7 +4943,7 @@ Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
return array_function;
}
bool Genesis::InstallNatives(GlobalContextType context_type) {
bool Genesis::InstallNatives() {
HandleScope scope(isolate());
// Set up the utils object as shared container between native scripts.
......@@ -5005,7 +4991,7 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
factory()->InternalizeUtf8String("isPromise"),
isolate()->is_promise(), DONT_ENUM);
int builtin_index = Natives::GetDebuggerCount();
int builtin_index = 0;
// Only run prologue.js at this point.
DCHECK_EQ(builtin_index, Natives::GetIndex("prologue"));
if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false;
......@@ -5367,8 +5353,7 @@ bool Genesis::InstallExtraNatives() {
native_context()->set_extras_binding_object(*extras_binding);
for (int i = ExtraNatives::GetDebuggerCount();
i < ExtraNatives::GetBuiltinsCount(); i++) {
for (int i = 0; i < ExtraNatives::GetBuiltinsCount(); i++) {
if (!Bootstrapper::CompileExtraBuiltin(isolate(), i)) return false;
}
......@@ -5377,8 +5362,7 @@ bool Genesis::InstallExtraNatives() {
bool Genesis::InstallExperimentalExtraNatives() {
for (int i = ExperimentalExtraNatives::GetDebuggerCount();
i < ExperimentalExtraNatives::GetBuiltinsCount(); i++) {
for (int i = 0; i < ExperimentalExtraNatives::GetBuiltinsCount(); i++) {
if (!Bootstrapper::CompileExperimentalExtraBuiltin(isolate(), i))
return false;
}
......@@ -5387,13 +5371,6 @@ bool Genesis::InstallExperimentalExtraNatives() {
}
bool Genesis::InstallDebuggerNatives() {
for (int i = 0; i < Natives::GetDebuggerCount(); ++i) {
if (!Bootstrapper::CompileBuiltin(isolate(), i)) return false;
}
return true;
}
static void InstallBuiltinFunctionId(Isolate* isolate, Handle<JSObject> holder,
const char* function_name,
BuiltinFunctionId id) {
......@@ -5791,13 +5768,11 @@ void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) {
JSObject::ForceSetPrototype(to, proto);
}
Genesis::Genesis(
Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy,
v8::Local<v8::ObjectTemplate> global_proxy_template,
size_t context_snapshot_index,
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer,
GlobalContextType context_type)
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer)
: isolate_(isolate), active_(isolate->bootstrapper()) {
RuntimeCallTimerScope rcs_timer(isolate, RuntimeCallCounterId::kGenesis);
result_ = Handle<Context>::null();
......@@ -5876,10 +5851,10 @@ Genesis::Genesis(
CreateAsyncFunctionMaps(empty_function);
Handle<JSGlobalObject> global_object =
CreateNewGlobals(global_proxy_template, global_proxy);
InitializeGlobal(global_object, empty_function, context_type);
InitializeGlobal(global_object, empty_function);
InitializeNormalizedMapCaches();
if (!InstallNatives(context_type)) return;
if (!InstallNatives()) return;
if (!InstallExtraNatives()) return;
if (!ConfigureGlobalObjects(global_proxy_template)) return;
......@@ -5896,7 +5871,6 @@ Genesis::Genesis(
// Install experimental natives. Do not include them into the
// snapshot as we should be able to turn them off at runtime. Re-installing
// them after they have already been deserialized would also fail.
if (context_type == FULL_CONTEXT) {
if (!isolate->serializer_enabled()) {
InitializeExperimentalGlobal();
......@@ -5914,18 +5888,13 @@ Genesis::Genesis(
native_context()->set_string_function_prototype_map(
string_function_prototype->map());
}
} else if (context_type == DEBUG_CONTEXT) {
DCHECK(!isolate->serializer_enabled());
InitializeExperimentalGlobal();
if (!InstallDebuggerNatives()) return;
}
if (FLAG_disallow_code_generation_from_strings) {
native_context()->set_allow_code_gen_from_strings(
ReadOnlyRoots(isolate).false_value());
}
ConfigureUtilsObject(context_type);
ConfigureUtilsObject();
// We created new functions, which may require debug instrumentation.
if (isolate->debug()->is_active()) {
......
......@@ -40,7 +40,6 @@ class SourceCodeCache final {
DISALLOW_COPY_AND_ASSIGN(SourceCodeCache);
};
enum GlobalContextType { FULL_CONTEXT, DEBUG_CONTEXT };
// The Boostrapper is the public interface for creating a JavaScript global
// context.
......@@ -59,8 +58,7 @@ class Bootstrapper final {
MaybeHandle<JSGlobalProxy> maybe_global_proxy,
v8::Local<v8::ObjectTemplate> global_object_template,
v8::ExtensionConfiguration* extensions, size_t context_snapshot_index,
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer,
GlobalContextType context_type = FULL_CONTEXT);
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer);
Handle<JSGlobalProxy> NewRemoteContext(
MaybeHandle<JSGlobalProxy> maybe_global_proxy,
......
......@@ -38,19 +38,6 @@ function ImportNow(name) {
}
function InstallConstants(object, constants) {
%CheckIsBootstrapping();
%OptimizeObjectForAddingMultipleProperties(object, constants.length >> 1);
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
for (var i = 0; i < constants.length; i += 2) {
var name = constants[i];
var k = constants[i + 1];
%AddNamedProperty(object, name, k, attributes);
}
%ToFastProperties(object);
}
// Prevents changes to the prototype of a built-in function.
// The "prototype" property of the function object is made non-configurable,
// and the prototype object is made non-extensible. The latter prevents
......@@ -96,6 +83,7 @@ function PostNatives(utils) {
utils.Export = UNDEFINED;
utils.Import = UNDEFINED;
utils.ImportNow = UNDEFINED;
utils.SetUpLockedPrototype = UNDEFINED;
utils.PostNatives = UNDEFINED;
}
......@@ -106,7 +94,6 @@ function PostNatives(utils) {
utils.Import = Import;
utils.ImportNow = ImportNow;
utils.Export = Export;
utils.InstallConstants = InstallConstants;
utils.SetUpLockedPrototype = SetUpLockedPrototype;
utils.PostNatives = PostNatives;
......
......@@ -33,7 +33,6 @@ class NativesStore {
}
int GetBuiltinsCount() { return static_cast<int>(native_ids_.size()); }
int GetDebuggerCount() { return debugger_count_; }
Vector<const char> GetScriptSource(int index) {
return native_source_[index];
......@@ -60,22 +59,17 @@ class NativesStore {
NativesStore* store = new NativesStore;
// We expect the libraries in the following format:
// int: # of debugger sources.
// int: # of sources.
// 2N blobs: N pairs of source name + actual source.
// then, repeat for non-debugger sources.
int debugger_count = source->GetInt();
for (int i = 0; i < debugger_count; ++i)
store->ReadNameAndContentPair(source);
int library_count = source->GetInt();
for (int i = 0; i < library_count; ++i)
store->ReadNameAndContentPair(source);
store->debugger_count_ = debugger_count;
return store;
}
private:
NativesStore() : debugger_count_(0) {}
NativesStore() = default;
Vector<const char> NameFromId(const byte* id, int id_length) {
const char native[] = "native ";
......@@ -103,7 +97,6 @@ class NativesStore {
std::vector<Vector<const char>> native_ids_;
std::vector<Vector<const char>> native_names_;
std::vector<Vector<const char>> native_source_;
int debugger_count_;
DISALLOW_COPY_AND_ASSIGN(NativesStore);
};
......@@ -187,11 +180,6 @@ int NativesCollection<type>::GetBuiltinsCount() {
return NativesHolder<type>::get()->GetBuiltinsCount();
}
template<NativeType type>
int NativesCollection<type>::GetDebuggerCount() {
return NativesHolder<type>::get()->GetDebuggerCount();
}
template<NativeType type>
int NativesCollection<type>::GetIndex(const char* name) {
return NativesHolder<type>::get()->GetIndex(name);
......@@ -216,7 +204,6 @@ Vector<const char> NativesCollection<type>::GetScriptsSource() {
// Explicit template instantiations.
#define INSTANTIATE_TEMPLATES(T) \
template int NativesCollection<T>::GetBuiltinsCount(); \
template int NativesCollection<T>::GetDebuggerCount(); \
template int NativesCollection<T>::GetIndex(const char* name); \
template Vector<const char> NativesCollection<T>::GetScriptSource(int i); \
template Vector<const char> NativesCollection<T>::GetScriptName(int i); \
......
......@@ -36,13 +36,6 @@ class V8_EXPORT_PRIVATE NativesCollection {
// Number of built-in scripts.
static int GetBuiltinsCount();
// Number of debugger implementation scripts.
static int GetDebuggerCount();
// These are used to access built-in scripts. The debugger implementation
// scripts have an index in the interval [0, GetDebuggerCount()). The
// non-debugger scripts have an index in the interval [GetDebuggerCount(),
// GetNativesCount()).
static int GetIndex(const char* name);
static Vector<const char> GetScriptSource(int index);
static Vector<const char> GetScriptName(int index);
......
......@@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-natives-as natives --allow-natives-syntax
// Flags: --allow-natives-syntax
// Test the SameValue and SameValueZero internal methods.
var obj1 = {x: 10, y: 11, z: "test"};
......
......@@ -272,11 +272,6 @@ namespace internal {
return %(builtin_count)i;
}
template <>
int NativesCollection<%(type)s>::GetDebuggerCount() {
return %(debugger_count)i;
}
template <>
int NativesCollection<%(type)s>::GetIndex(const char* name) {
%(get_index_cases)s\
......@@ -363,11 +358,6 @@ class Sources:
def __init__(self):
self.names = []
self.modules = []
self.is_debugger_id = []
def IsDebuggerFile(filename):
return os.path.basename(os.path.dirname(filename)) == "debug"
def IsMacroFile(filename):
return filename.endswith("macros.py")
......@@ -410,10 +400,6 @@ def PrepareSources(source_files, native_type, emit_js):
else:
filters = BuildFilterChain(macro_file, message_template_file)
# Sort 'debugger' sources first.
source_files = sorted(source_files,
lambda l,r: IsDebuggerFile(r) - IsDebuggerFile(l))
source_files_and_contents = [(f, ReadFile(f)) for f in source_files]
# Have a single not-quite-empty source file if there are none present;
......@@ -433,9 +419,6 @@ def PrepareSources(source_files, native_type, emit_js):
result.modules.append(lines)
is_debugger = IsDebuggerFile(source)
result.is_debugger_id.append(is_debugger)
name = os.path.basename(source)[:-3]
result.names.append(name)
......@@ -483,7 +466,6 @@ def BuildMetadata(sources, source_bytes, native_type):
metadata = {
"builtin_count": len(sources.modules),
"debugger_count": sum(sources.is_debugger_id),
"sources_declaration": SOURCES_DECLARATION % ToCArray(source_bytes),
"total_length": total_length,
"get_index_cases": "".join(get_index_cases),
......@@ -528,14 +510,8 @@ def WriteStartupBlob(sources, startup_blob):
"""
output = open(startup_blob, "wb")
debug_sources = sum(sources.is_debugger_id);
PutInt(output, debug_sources)
for i in xrange(debug_sources):
PutStr(output, sources.names[i]);
PutStr(output, sources.modules[i]);
PutInt(output, len(sources.names) - debug_sources)
for i in xrange(debug_sources, len(sources.names)):
PutInt(output, len(sources.names))
for i in xrange(len(sources.names)):
PutStr(output, sources.names[i]);
PutStr(output, sources.modules[i]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment