v8/src/natives.h
vogelheim@chromium.org 7b7bb25a24 Support external startup data in V8.
[Re-retry of r21696 and r21739]

If the embedder chooses, the 'natives' (library sources) and the
precompiled startup blob can be written to files during the build
process and handed over to V8 at startup. The main purpose would be
to reduce the size of the compiled binary for space constrained
platforms.

The build-time option is off by default. Nothing should change if
it's not enabled.

BUG=
R=jochen@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21941 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-06-23 13:52:17 +00:00

54 lines
1.6 KiB
C++

// Copyright 2011 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_NATIVES_H_
#define V8_NATIVES_H_
#include "src/vector.h"
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
};
template <NativeType type>
class NativesCollection {
public:
// 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 int GetRawScriptsSize();
static Vector<const char> GetRawScriptSource(int index);
static Vector<const char> GetScriptName(int index);
static Vector<const byte> GetScriptsSource();
static void SetRawScriptsSource(Vector<const char> raw_source);
};
typedef NativesCollection<CORE> Natives;
typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives;
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
// Used for reading the natives at runtime. Implementation in natives-empty.cc
void SetNativesFromFile(StartupData* natives_blob);
#endif
} } // namespace v8::internal
#endif // V8_NATIVES_H_