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