This also keeps backwards compatibility (window.gc() still works).
BUG=2641
Review URL: https://codereview.chromium.org/
14075012
Patch from Marja Hölttä <marja@chromium.org>.
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14397
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "gc-extension.h"
+#include "platform.h"
namespace v8 {
namespace internal {
-const char* const GCExtension::kSource = "native function gc();";
-
v8::Handle<v8::FunctionTemplate> GCExtension::GetNativeFunction(
v8::Handle<v8::String> str) {
void GCExtension::Register() {
- static GCExtension gc_extension;
+ static char buffer[50];
+ Vector<char> temp_vector(buffer, sizeof(buffer));
+ if (FLAG_expose_gc_as != NULL && strlen(FLAG_expose_gc_as) != 0) {
+ OS::SNPrintF(temp_vector, "native function %s();", FLAG_expose_gc_as);
+ } else {
+ OS::SNPrintF(temp_vector, "native function gc();");
+ }
+
+ static GCExtension gc_extension(buffer);
static v8::DeclareExtension declaration(&gc_extension);
}
class GCExtension : public v8::Extension {
public:
- GCExtension() : v8::Extension("v8/gc", kSource) {}
+ explicit GCExtension(const char* source) : v8::Extension("v8/gc", source) {}
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
v8::Handle<v8::String> name);
static v8::Handle<v8::Value> GC(const v8::Arguments& args);
static void Register();
- private:
- static const char* const kSource;
};
} } // namespace v8::internal
DEFINE_string(expose_natives_as, NULL, "expose natives in global object")
DEFINE_string(expose_debug_as, NULL, "expose debug in global object")
DEFINE_bool(expose_gc, false, "expose gc extension")
+DEFINE_string(expose_gc_as,
+ NULL,
+ "expose gc extension under the specified name")
+DEFINE_implication(expose_gc_as, expose_gc)
DEFINE_bool(expose_externalize_string, false,
"expose externalize string extension")
DEFINE_int(stack_trace_limit, 10, "number of stack frames to capture")