Changeset 26914 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Oct 23, 2007, 12:00:37 AM (18 years ago)
Author:
darin
Message:

Reviewed by Eric.

  • streamline exception handling code for a >1% speed-up of SunSpider
  • kjs/nodes.cpp: Changed macros to use functions for everything that's not part of normal execution. We'll take function call overhead when propagating an exception or out of memory. (KJS::createOutOfMemoryCompletion): Added. (KJS::substitute): Use append instead of the relatively inefficient + operator. (KJS::Node::rethrowException): Added.
  • kjs/nodes.h: Added rethrowException.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r26832 r26914  
    11/*
    2  *  This file is part of the KDE libraries
    32 *  Copyright (C) 1999-2002 Harri Porten ([email protected])
    43 *  Copyright (C) 2001 Peter Kelly ([email protected])
     
    2625#include "nodes.h"
    2726
    28 #include <math.h>
    29 #ifdef KJS_DEBUG_MEM
    30 #include <stdio.h>
    31 #include <typeinfo>
    32 #endif
    33 
     27#include "PropertyNameArray.h"
    3428#include "context.h"
    3529#include "debugger.h"
     
    3731#include "lexer.h"
    3832#include "operations.h"
    39 #include "PropertyNameArray.h"
     33#include <math.h>
    4034#include <wtf/Assertions.h>
     35#include <wtf/HashCountedSet.h>
    4136#include <wtf/HashSet.h>
    42 #include <wtf/HashCountedSet.h>
    4337#include <wtf/MathExtras.h>
    4438
    45 using namespace KJS;
     39namespace KJS {
    4640
    4741#define KJS_BREAKPOINT \
     
    4943    return Completion(Normal);
    5044
    51 #define KJS_ABORTPOINT \
    52   if (Debugger::debuggersPresent > 0 && \
    53       exec->dynamicInterpreter()->imp()->debugger() && \
    54       exec->dynamicInterpreter()->imp()->debugger()->imp()->aborted()) \
    55     return Completion(Normal);
    56 
    5745#define KJS_CHECKEXCEPTION \
    58   if (exec->hadException()) { \
    59     JSValue *ex = exec->exception(); \
    60     exec->clearException(); \
    61     handleException(exec, ex); \
    62     return Completion(Throw, ex); \
    63   } \
     46  if (exec->hadException()) \
     47    return rethrowException(exec); \
    6448  if (Collector::isOutOfMemory()) \
    65     return Completion(Throw, Error::create(exec, GeneralError, "Out of memory"));
     49    return createOutOfMemoryCompletion(exec);
    6650
    6751#define KJS_CHECKEXCEPTIONVALUE \
     
    8064  if (Collector::isOutOfMemory()) \
    8165    return List(); // will be picked up by KJS_CHECKEXCEPTION
     66
     67static Completion createOutOfMemoryCompletion(ExecState* exec)
     68{
     69    return Completion(Throw, Error::create(exec, GeneralError, "Out of memory"));
     70}
    8271
    8372// ------------------------------ Node -----------------------------------------
     
    193182    int position = string.find("%s");
    194183    ASSERT(position != -1);
    195     string = string.substr(0, position) + substring + string.substr(position + 2);
     184    UString newString = string.substr(0, position);
     185    newString.append(substring);
     186    newString.append(string.substr(position + 2));
     187    string = newString;
    196188}
    197189
     
    299291            dbg->imp()->abort();
    300292    }
     293}
     294
     295Completion Node::rethrowException(ExecState* exec)
     296{
     297    JSValue* exception = exec->exception();
     298    exec->clearException();
     299    handleException(exec, exception);
     300    return Completion(Throw, exception);
    301301}
    302302
     
    26162616{
    26172617}
     2618
     2619}
Note: See TracChangeset for help on using the changeset viewer.