Commit b27431d5 authored by vogelheim's avatar vogelheim Committed by Commit bot

Cleanup: Remove NativesCollection<.>::*Raw* methods.

These methods for used for compressed libraries, where GetSource* functions
contained the compressed sources and [GS]etRawSource* the uncompressed
sources. This is dead code since the API no longer supports compression.

(If you need/want compressed sources, use the external startup data and
 compress/uncompress on the Embedder's side.)

BUG=

Review URL: https://codereview.chromium.org/772853003

Cr-Commit-Position: refs/heads/master@{#25666}
parent 6230641b
...@@ -48,7 +48,7 @@ Handle<String> Bootstrapper::NativesSourceLookup(int index) { ...@@ -48,7 +48,7 @@ Handle<String> Bootstrapper::NativesSourceLookup(int index) {
Heap* heap = isolate_->heap(); Heap* heap = isolate_->heap();
if (heap->natives_source_cache()->get(index)->IsUndefined()) { if (heap->natives_source_cache()->get(index)->IsUndefined()) {
// We can use external strings for the natives. // We can use external strings for the natives.
Vector<const char> source = Natives::GetRawScriptSource(index); Vector<const char> source = Natives::GetScriptSource(index);
NativesExternalStringResource* resource = NativesExternalStringResource* resource =
new NativesExternalStringResource(this, new NativesExternalStringResource(this,
source.start(), source.start(),
...@@ -1394,8 +1394,8 @@ bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { ...@@ -1394,8 +1394,8 @@ bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Handle<String> source_code; Handle<String> source_code;
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, source_code, factory->NewStringFromAscii( isolate, source_code,
ExperimentalNatives::GetRawScriptSource(index)), factory->NewStringFromAscii(ExperimentalNatives::GetScriptSource(index)),
false); false);
return CompileNative(isolate, name, source_code); return CompileNative(isolate, name, source_code);
} }
......
...@@ -851,7 +851,7 @@ void Shell::InstallUtilityScript(Isolate* isolate) { ...@@ -851,7 +851,7 @@ void Shell::InstallUtilityScript(Isolate* isolate) {
// Run the d8 shell utility script in the utility context // Run the d8 shell utility script in the utility context
int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); int source_index = i::NativesCollection<i::D8>::GetIndex("d8");
i::Vector<const char> shell_source = i::Vector<const char> shell_source =
i::NativesCollection<i::D8>::GetRawScriptSource(source_index); i::NativesCollection<i::D8>::GetScriptSource(source_index);
i::Vector<const char> shell_source_name = i::Vector<const char> shell_source_name =
i::NativesCollection<i::D8>::GetScriptName(source_index); i::NativesCollection<i::D8>::GetScriptName(source_index);
Handle<String> source = Handle<String> source =
......
...@@ -32,12 +32,12 @@ class NativesStore { ...@@ -32,12 +32,12 @@ class NativesStore {
int GetBuiltinsCount() { return native_ids_.length(); } int GetBuiltinsCount() { return native_ids_.length(); }
int GetDebuggerCount() { return debugger_count_; } int GetDebuggerCount() { return debugger_count_; }
Vector<const char> GetScriptName(int index) { return native_names_[index]; } Vector<const char> GetScriptSource(int index) {
Vector<const char> GetRawScriptSource(int index) {
return native_source_[index]; return native_source_[index];
} }
Vector<const char> GetScriptName(int index) { return native_names_[index]; }
int GetIndex(const char* id) { int GetIndex(const char* id) {
for (int i = 0; i < native_ids_.length(); ++i) { for (int i = 0; i < native_ids_.length(); ++i) {
int native_id_length = native_ids_[i].length(); int native_id_length = native_ids_[i].length();
...@@ -50,14 +50,9 @@ class NativesStore { ...@@ -50,14 +50,9 @@ class NativesStore {
return -1; return -1;
} }
int GetRawScriptsSize() { Vector<const char> GetScriptsSource() {
DCHECK(false); // Used for compression. Doesn't really make sense here. DCHECK(false); // Not implemented.
return 0; return Vector<const char>();
}
Vector<const byte> GetScriptsSource() {
DCHECK(false); // Used for compression. Doesn't really make sense here.
return Vector<const byte>();
} }
static NativesStore* MakeFromScriptsSource(SnapshotByteSource* source) { static NativesStore* MakeFromScriptsSource(SnapshotByteSource* source) {
...@@ -177,14 +172,9 @@ int NativesCollection<type>::GetIndex(const char* name) { ...@@ -177,14 +172,9 @@ int NativesCollection<type>::GetIndex(const char* name) {
return NativesHolder<type>::get()->GetIndex(name); return NativesHolder<type>::get()->GetIndex(name);
} }
template<NativeType type> template <NativeType type>
int NativesCollection<type>::GetRawScriptsSize() { Vector<const char> NativesCollection<type>::GetScriptSource(int index) {
return NativesHolder<type>::get()->GetRawScriptsSize(); return NativesHolder<type>::get()->GetScriptSource(index);
}
template<NativeType type>
Vector<const char> NativesCollection<type>::GetRawScriptSource(int index) {
return NativesHolder<type>::get()->GetRawScriptSource(index);
} }
template<NativeType type> template<NativeType type>
...@@ -192,17 +182,11 @@ Vector<const char> NativesCollection<type>::GetScriptName(int index) { ...@@ -192,17 +182,11 @@ Vector<const char> NativesCollection<type>::GetScriptName(int index) {
return NativesHolder<type>::get()->GetScriptName(index); return NativesHolder<type>::get()->GetScriptName(index);
} }
template<NativeType type> template <NativeType type>
Vector<const byte> NativesCollection<type>::GetScriptsSource() { Vector<const char> NativesCollection<type>::GetScriptsSource() {
return NativesHolder<type>::get()->GetScriptsSource(); return NativesHolder<type>::get()->GetScriptsSource();
} }
template<NativeType type>
void NativesCollection<type>::SetRawScriptsSource(
Vector<const char> raw_source) {
CHECK(false); // Use SetNativesFromFile for this implementation.
}
// The compiler can't 'see' all uses of the static methods and hence // The compiler can't 'see' all uses of the static methods and hence
// my chose to elide them. This we'll explicitly instantiate these. // my chose to elide them. This we'll explicitly instantiate these.
......
...@@ -12,10 +12,6 @@ namespace v8 { class StartupData; } // Forward declaration. ...@@ -12,10 +12,6 @@ namespace v8 { class StartupData; } // Forward declaration.
namespace v8 { namespace v8 {
namespace internal { namespace internal {
typedef bool (*NativeSourceCallback)(Vector<const char> name,
Vector<const char> source,
int index);
enum NativeType { enum NativeType {
CORE, EXPERIMENTAL, D8, TEST CORE, EXPERIMENTAL, D8, TEST
}; };
...@@ -33,11 +29,9 @@ class NativesCollection { ...@@ -33,11 +29,9 @@ class NativesCollection {
// non-debugger scripts have an index in the interval [GetDebuggerCount(), // non-debugger scripts have an index in the interval [GetDebuggerCount(),
// GetNativesCount()). // GetNativesCount()).
static int GetIndex(const char* name); static int GetIndex(const char* name);
static int GetRawScriptsSize(); static Vector<const char> GetScriptSource(int index);
static Vector<const char> GetRawScriptSource(int index);
static Vector<const char> GetScriptName(int index); static Vector<const char> GetScriptName(int index);
static Vector<const byte> GetScriptsSource(); static Vector<const char> GetScriptsSource();
static void SetRawScriptsSource(Vector<const char> raw_source);
}; };
typedef NativesCollection<CORE> Natives; typedef NativesCollection<CORE> Natives;
......
...@@ -1248,7 +1248,7 @@ void Deserializer::ReadData(Object** current, Object** limit, int source_space, ...@@ -1248,7 +1248,7 @@ void Deserializer::ReadData(Object** current, Object** limit, int source_space,
case kNativesStringResource: { case kNativesStringResource: {
int index = source_->Get(); int index = source_->Get();
Vector<const char> source_vector = Natives::GetRawScriptSource(index); Vector<const char> source_vector = Natives::GetScriptSource(index);
NativesExternalStringResource* resource = NativesExternalStringResource* resource =
new NativesExternalStringResource(isolate->bootstrapper(), new NativesExternalStringResource(isolate->bootstrapper(),
source_vector.start(), source_vector.start(),
......
...@@ -477,10 +477,9 @@ TEST(EquivalenceOfLoggingAndTraversal) { ...@@ -477,10 +477,9 @@ TEST(EquivalenceOfLoggingAndTraversal) {
isolate, log.start(), v8::String::kNormalString, log.length()); isolate, log.start(), v8::String::kNormalString, log.length());
initialize_logger.env()->Global()->Set(v8_str("_log"), log_str); initialize_logger.env()->Global()->Set(v8_str("_log"), log_str);
i::Vector<const unsigned char> source = TestSources::GetScriptsSource(); i::Vector<const char> source = TestSources::GetScriptsSource();
v8::Handle<v8::String> source_str = v8::String::NewFromUtf8( v8::Handle<v8::String> source_str = v8::String::NewFromUtf8(
isolate, reinterpret_cast<const char*>(source.start()), isolate, source.start(), v8::String::kNormalString, source.length());
v8::String::kNormalString, source.length());
v8::TryCatch try_catch; v8::TryCatch try_catch;
v8::Handle<v8::Script> script = CompileWithOrigin(source_str, ""); v8::Handle<v8::Script> script = CompileWithOrigin(source_str, "");
if (script.IsEmpty()) { if (script.IsEmpty()) {
......
...@@ -255,8 +255,6 @@ namespace internal { ...@@ -255,8 +255,6 @@ namespace internal {
%(sources_declaration)s\ %(sources_declaration)s\
%(raw_sources_declaration)s\
template <> template <>
int NativesCollection<%(type)s>::GetBuiltinsCount() { int NativesCollection<%(type)s>::GetBuiltinsCount() {
return %(builtin_count)i; return %(builtin_count)i;
...@@ -274,13 +272,8 @@ namespace internal { ...@@ -274,13 +272,8 @@ namespace internal {
} }
template <> template <>
int NativesCollection<%(type)s>::GetRawScriptsSize() { Vector<const char> NativesCollection<%(type)s>::GetScriptSource(int index) {
return %(raw_total_length)i; %(get_script_source_cases)s\
}
template <>
Vector<const char> NativesCollection<%(type)s>::GetRawScriptSource(int index) {
%(get_raw_script_source_cases)s\
return Vector<const char>("", 0); return Vector<const char>("", 0);
} }
...@@ -291,32 +284,15 @@ namespace internal { ...@@ -291,32 +284,15 @@ namespace internal {
} }
template <> template <>
Vector<const byte> NativesCollection<%(type)s>::GetScriptsSource() { Vector<const char> NativesCollection<%(type)s>::GetScriptsSource() {
return Vector<const byte>(sources, %(total_length)i); return Vector<const char>(sources, %(total_length)i);
} }
template <>
void NativesCollection<%(type)s>::SetRawScriptsSource(Vector<const char> raw_source) {
DCHECK(%(raw_total_length)i == raw_source.length());
raw_sources = raw_source.start();
}
} // internal } // internal
} // v8 } // v8
""" """
SOURCES_DECLARATION = """\ SOURCES_DECLARATION = """\
static const byte sources[] = { %s }; static const char sources[] = { %s };
"""
RAW_SOURCES_COMPRESSION_DECLARATION = """\
static const char* raw_sources = NULL;
"""
RAW_SOURCES_DECLARATION = """\
static const char* raw_sources = reinterpret_cast<const char*>(sources);
""" """
...@@ -325,8 +301,8 @@ GET_INDEX_CASE = """\ ...@@ -325,8 +301,8 @@ GET_INDEX_CASE = """\
""" """
GET_RAW_SCRIPT_SOURCE_CASE = """\ GET_SCRIPT_SOURCE_CASE = """\
if (index == %(i)i) return Vector<const char>(raw_sources + %(offset)i, %(raw_length)i); if (index == %(i)i) return Vector<const char>(sources + %(offset)i, %(source_length)i);
""" """
...@@ -440,7 +416,7 @@ def BuildMetadata(sources, source_bytes, native_type): ...@@ -440,7 +416,7 @@ def BuildMetadata(sources, source_bytes, native_type):
# Loop over modules and build up indices into the source blob: # Loop over modules and build up indices into the source blob:
get_index_cases = [] get_index_cases = []
get_script_name_cases = [] get_script_name_cases = []
get_raw_script_source_cases = [] get_script_source_cases = []
offset = 0 offset = 0
for i in xrange(len(sources.modules)): for i in xrange(len(sources.modules)):
native_name = "native %s.js" % sources.names[i] native_name = "native %s.js" % sources.names[i]
...@@ -450,28 +426,21 @@ def BuildMetadata(sources, source_bytes, native_type): ...@@ -450,28 +426,21 @@ def BuildMetadata(sources, source_bytes, native_type):
"name": native_name, "name": native_name,
"length": len(native_name), "length": len(native_name),
"offset": offset, "offset": offset,
"raw_length": len(sources.modules[i]), "source_length": len(sources.modules[i]),
} }
get_index_cases.append(GET_INDEX_CASE % d) get_index_cases.append(GET_INDEX_CASE % d)
get_script_name_cases.append(GET_SCRIPT_NAME_CASE % d) get_script_name_cases.append(GET_SCRIPT_NAME_CASE % d)
get_raw_script_source_cases.append(GET_RAW_SCRIPT_SOURCE_CASE % d) get_script_source_cases.append(GET_SCRIPT_SOURCE_CASE % d)
offset += len(sources.modules[i]) offset += len(sources.modules[i])
assert offset == len(raw_sources) assert offset == len(raw_sources)
# If we have the raw sources we can declare them accordingly.
have_raw_sources = source_bytes == raw_sources
raw_sources_declaration = (RAW_SOURCES_DECLARATION
if have_raw_sources else RAW_SOURCES_COMPRESSION_DECLARATION)
metadata = { metadata = {
"builtin_count": len(sources.modules), "builtin_count": len(sources.modules),
"debugger_count": sum(sources.is_debugger_id), "debugger_count": sum(sources.is_debugger_id),
"sources_declaration": SOURCES_DECLARATION % ToCArray(source_bytes), "sources_declaration": SOURCES_DECLARATION % ToCArray(source_bytes),
"raw_sources_declaration": raw_sources_declaration,
"raw_total_length": sum(map(len, sources.modules)),
"total_length": total_length, "total_length": total_length,
"get_index_cases": "".join(get_index_cases), "get_index_cases": "".join(get_index_cases),
"get_raw_script_source_cases": "".join(get_raw_script_source_cases), "get_script_source_cases": "".join(get_script_source_cases),
"get_script_name_cases": "".join(get_script_name_cases), "get_script_name_cases": "".join(get_script_name_cases),
"type": native_type, "type": native_type,
} }
......
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