[Pkg-mozext-commits] [adblock-plus] 18/464: I think I finally fixed all of the GC problems.

David Prévot taffit at moszumanska.debian.org
Tue Jul 22 20:43:58 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit 48dc8c73d3dbde8f8db18fc32d488c99e6e72911
Author: Joshua Cranmer <Pidgeot18 at gmail.com>
Date:   Wed Mar 4 12:42:53 2009 -0500

    I think I finally fixed all of the GC problems.
    
    Any problems henceforth is probably just a violation of my assumptions about parse node structures. Heck, all of the GC problems beyond the past through fell under such criteria.
---
 jshydra.cpp        | 33 +++++++++++++++++++++++++--------
 jshydra_bridge.cpp |  2 +-
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/jshydra.cpp b/jshydra.cpp
index ff59c3f..7e75d8a 100644
--- a/jshydra.cpp
+++ b/jshydra.cpp
@@ -30,7 +30,7 @@ TokenValue tokens[] = {
     UNARY, /*TOK_SEMI*/
     LIST, /*TOK_COMMA*/
     BINARY, /*TOK_ASSIGN*/
-    BINARY, /*TOK_HOOK*/
+    TERNARY, /*TOK_HOOK*/
 	NAME, /*TOK_COLON*/
     BINARY, /*TOK_OR*/
     BINARY, /*TOK_AND*/
@@ -105,7 +105,7 @@ TokenValue tokens[] = {
     ERROR, /*TOK_YIELD*/
     LIST, /*TOK_ARRAYCOMP*/
     UNARY, /*TOK_ARRAYPUSH*/
-    NAME, /*TOK_LEXICALSCOPE*/
+    LEXICAL, /*TOK_LEXICALSCOPE*/
     LIST, /*TOK_LET*/
     ERROR, /*TOK_SEQ*/
     TERNARY, /*TOK_FORHEAD*/
@@ -114,6 +114,8 @@ TokenValue tokens[] = {
 	ERROR
 };
 
+TokenValue arityFix[] = {FUNCTION, LIST, TERNARY, BINARY, UNARY, NAME, NULLARY};
+
 JSObject *makeNode(JSParseNode *node) {
 	if (!node)
 		return NULL;
@@ -124,7 +126,13 @@ JSObject *makeNode(JSParseNode *node) {
 	setIntProperty(object, "column", node->pn_pos.begin.index);
 	setIntProperty(object, "op", node->pn_op);
 	setIntProperty(object, "type", node->pn_type);
-	switch (tokens[node->pn_type]) {
+
+	// Some of our nodes actually need the arity to work right.
+	TokenValue value = tokens[node->pn_type];
+	if (node->pn_type == TOK_COLON)
+		value = arityFix[node->pn_arity];
+
+	switch (value) {
 	case FUNCTION: {
 		setIntProperty(object, "flags", node->pn_flags);
 		JSFunction *func = (JSFunction *) node->pn_funpob->object;
@@ -175,12 +183,23 @@ JSObject *makeNode(JSParseNode *node) {
 		setObjectProperty(object, "kids", array);
 		break;
 	}
-	//case LEXICAL:
+	case LEXICAL: {
+		JSObject *array = JS_NewArrayObject(cx, 0, NULL);
+		setArrayElement(array, 0, makeNode(node->pn_expr));
+		setObjectProperty(object, "kids", array);
+		break;
+	}
 	//case APAIR:
 	//case OBJLITERAL:
-	case DOUBLELITERAL:
-		jshydra_defineProperty(cx, object, "value", DOUBLE_TO_JSVAL(&node->pn_dval));
+	case DOUBLELITERAL: {
+		jsval dval;
+		if (!JS_NewDoubleValue(cx, node->pn_dval, &dval)) {
+			fprintf(stderr, "I think I ran out of memory...\n");
+			return NULL;
+		}
+		jshydra_defineProperty(cx, object, "value", dval);
 		break;
+	}
 	case NULLARY:
 		break;
 	case ERROR:
@@ -199,11 +218,9 @@ void parseFile(FILE *file, char *filename) {
 	JSParseNode *root = js_ParseScript(cx, globalObj, &pc);
 	JSObject *ast = makeNode(root);
 	jshydra_rootObject(cx, ast);
-	JS_GC(cx);
 	jsval func = jshydra_getToplevelFunction(cx, "process_js");
 	if (JS_TypeOfValue(cx, func) != JSTYPE_FUNCTION) {
 		fprintf(stderr, "No function process_js!\n");
-  		JS_LeaveLocalRootScope(cx);
 		return;
 	}
 	jsval rval, argv[1];
diff --git a/jshydra_bridge.cpp b/jshydra_bridge.cpp
index 8461d03..03e2270 100644
--- a/jshydra_bridge.cpp
+++ b/jshydra_bridge.cpp
@@ -48,7 +48,7 @@ void jshydra_init(const char *file) {
   rt = JS_NewRuntime (0x9000000L);
   cx = JS_NewContext (rt, 8192);
   JS_BeginRequest(cx);
-  //JS_SetGCZeal(cx, 2);
+  JS_SetGCZeal(cx, 2);
 
   //JS_SetContextPrivate (this->cx, this);
   

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list