Move quadratic behavior of Context's optimized function list verification behind...
authorjkummerow@chromium.org <jkummerow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 3 Jul 2012 13:01:31 +0000 (13:01 +0000)
committerjkummerow@chromium.org <jkummerow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 3 Jul 2012 13:01:31 +0000 (13:01 +0000)
BUG=webkit:90003
TEST=the following takes only about 1 second in debug mode: var a=[1,2,3,4,5]; eval("for (var i=0;i<50000;i++) a.sort(function(){return 1;});");

Review URL: https://chromiumcodereview.appspot.com/10704078

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11982 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/contexts.cc

index 76784bd..7e67125 100644 (file)
@@ -243,10 +243,12 @@ Handle<Object> Context::Lookup(Handle<String> name,
 void Context::AddOptimizedFunction(JSFunction* function) {
   ASSERT(IsGlobalContext());
 #ifdef DEBUG
-  Object* element = get(OPTIMIZED_FUNCTIONS_LIST);
-  while (!element->IsUndefined()) {
-    CHECK(element != function);
-    element = JSFunction::cast(element)->next_function_link();
+  if (FLAG_enable_slow_asserts) {
+    Object* element = get(OPTIMIZED_FUNCTIONS_LIST);
+    while (!element->IsUndefined()) {
+      CHECK(element != function);
+      element = JSFunction::cast(element)->next_function_link();
+    }
   }
 
   CHECK(function->next_function_link()->IsUndefined());