View | Details | Raw Unified | Return to bug 5210
Collapse All | Expand All

(-)JavaScriptCore/kxmlcore/FastMalloc.cpp (-20 / +15 lines)
Lines 95-101 void *fastRealloc(void* p, size_t n) Link Here
95
    return realloc(p, n);
95
    return realloc(p, n);
96
}
96
}
97
97
98
#ifndef WIN32
98
#if !WIN32
99
void fastMallocRegisterThread(pthread_t thread) 
99
void fastMallocRegisterThread(pthread_t thread) 
100
{
100
{
101
}
101
}
Lines 105-136 void fastMallocRegisterThread(pthread_t Link Here
105
105
106
#else
106
#else
107
107
108
#include <new>
108
#if HAVE_STDINT_H
109
#include <stdio.h>
110
#include <stddef.h>
111
#if defined HAVE_STDINT_H
112
#include <stdint.h>
109
#include <stdint.h>
113
#elif defined HAVE_INTTYPES_H
110
#elif HAVE_INTTYPES_H
114
#include <inttypes.h>
111
#include <inttypes.h>
115
#else
112
#else
116
#include <sys/types.h>
113
#include <sys/types.h>
117
#endif
114
#endif
118
#include <string.h>
119
#include <pthread.h>
120
#include <unistd.h>
121
#include <errno.h>
122
#include <stdarg.h>
123
#include "TCSpinLock.h"
124
#include "TCPageMap.h"
125
#include "TCSystemAlloc.h"
126
115
116
#include "AlwaysInline.h"
127
#include "Assertions.h"
117
#include "Assertions.h"
128
118
#include "TCPageMap.h"
129
#ifdef __GNUC__
119
#include "TCSpinLock.h"
130
#define ALWAYS_INLINE inline __attribute__((always_inline))
120
#include "TCSystemAlloc.h"
131
#else
121
#include <errno.h>
132
#define ALWAYS_INLINE inline
122
#include <new>
133
#endif
123
#include <pthread.h>
124
#include <stdarg.h>
125
#include <stddef.h>
126
#include <stdio.h>
127
#include <string.h>
128
#include <unistd.h>
134
129
135
#if KXC_CHANGES
130
#if KXC_CHANGES
136
namespace KXMLCore {
131
namespace KXMLCore {
(-)JavaScriptCore/ChangeLog (+19 lines)
Lines 1-3 Link Here
1
2006-02-04  Darin Adler  <darin@apple.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5210
6
          REGRESSION: for/in loop with var changes global variable instead of making local
7
8
        * kjs/nodes.cpp:
9
        (valueForReadModifyAssignment): Use ALWAYS_INLINE macro.
10
        (ForInNode::execute): Break out of the scope chain loop once we find and set the
11
        loop variable. We don't want to set multiple loop variables.
12
        (ForInNode::processVarDecls): Process the declaration of the loop variable.
13
14
        - other cleanup
15
16
        * kjs/object.cpp: (KJS::tryGetAndCallProperty): Use ALWAYS_INLINE macro.
17
        * kxmlcore/FastMalloc.cpp: Change to use ALWAYS_INLINE macro from AlwaysInline.h
18
        instead of defining it here a second time.
19
1
2006-02-03  Timothy Hatcher  <timothy@apple.com>
20
2006-02-03  Timothy Hatcher  <timothy@apple.com>
2
21
3
        Reviewed by Justin.
22
        Reviewed by Justin.
(-)JavaScriptCore/kjs/object.cpp (-5 / +1 lines)
Lines 327-337 bool JSObject::deleteProperty(ExecState Link Here
327
  return deleteProperty(exec, Identifier::from(propertyName));
327
  return deleteProperty(exec, Identifier::from(propertyName));
328
}
328
}
329
329
330
static inline
330
static ALWAYS_INLINE JSValue *tryGetAndCallProperty(ExecState *exec, const JSObject *object, const Identifier &propertyName) {
331
#ifdef __GNUC__
332
__attribute__((always_inline))
333
#endif
334
JSValue *tryGetAndCallProperty(ExecState *exec, const JSObject *object, const Identifier &propertyName) {
335
  JSValue *v = object->get(exec, propertyName);
331
  JSValue *v = object->get(exec, propertyName);
336
  if (v->isObject()) {
332
  if (v->isObject()) {
337
    JSObject *o = static_cast<JSObject*>(v);
333
    JSObject *o = static_cast<JSObject*>(v);
(-)JavaScriptCore/kjs/nodes.cpp (-8 / +6 lines)
Lines 1237-1248 JSValue *ConditionalNode::evaluate(ExecS Link Here
1237
1237
1238
// ECMA 11.13
1238
// ECMA 11.13
1239
1239
1240
#if __GNUC__
1240
static ALWAYS_INLINE JSValue *valueForReadModifyAssignment(ExecState * exec, JSValue *v1, JSValue *v2, Operator oper)
1241
// gcc refuses to inline this without the always_inline, but inlining it does help
1242
static inline JSValue *valueForReadModifyAssignment(ExecState * exec, JSValue *v1, JSValue *v2, Operator oper) __attribute__((always_inline));
1243
#endif
1244
1245
static inline JSValue *valueForReadModifyAssignment(ExecState * exec, JSValue *v1, JSValue *v2, Operator oper)
1246
{
1241
{
1247
  JSValue *v;
1242
  JSValue *v;
1248
  int i1;
1243
  int i1;
Lines 1859-1867 Completion ForInNode::execute(ExecState Link Here
1859
        JSObject *o;
1854
        JSObject *o;
1860
        do { 
1855
        do { 
1861
            o = *iter;
1856
            o = *iter;
1862
            if (o->getPropertySlot(exec, ident, slot))
1857
            if (o->getPropertySlot(exec, ident, slot)) {
1863
                o->put(exec, ident, str);
1858
                o->put(exec, ident, str);
1864
            
1859
                break;
1860
            }
1865
            ++iter;
1861
            ++iter;
1866
        } while (iter != end);
1862
        } while (iter != end);
1867
        
1863
        
Lines 1915-1920 Completion ForInNode::execute(ExecState Link Here
1915
1911
1916
void ForInNode::processVarDecls(ExecState *exec)
1912
void ForInNode::processVarDecls(ExecState *exec)
1917
{
1913
{
1914
  if (varDecl)
1915
    varDecl->processVarDecls(exec);
1918
  statement->processVarDecls(exec);
1916
  statement->processVarDecls(exec);
1919
}
1917
}
1920
1918
(-)LayoutTests/ChangeLog (+9 lines)
Lines 1-3 Link Here
1
2006-02-03  Darin Adler  <darin@apple.com>
2
3
        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5210
4
          REGRESSION: for/in loop with var changes global variable instead of making local
5
6
        * fast/js/for-in-var-scope.html: Added.
7
        * fast/js/resources/for-in-var-scope.js: Added.
8
        * fast/js/for-in-var-scope-expected.txt: Added.
9
1
2006-02-03  Andrew Wellington  <proton@wiretapped.net>
10
2006-02-03  Andrew Wellington  <proton@wiretapped.net>
2
11
3
        Reviewed by Darin.
12
        Reviewed by Darin.
(-)LayoutTests/fast/js/for-in-var-scope-expected.txt (+11 lines)
Line 0 Link Here
1
This tests that for/in statements properly scope a variable that's declared in one. In previous versions of JavaScriptCore there were two bugs that caused problems. First, the loop variable declaration would not be processed. Second, the code to set the loop variable would incorrectly walk the scope chain even after setting the loop variable.
2
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
6
PASS i is 'start i'
7
PASS j is 'propName'
8
PASS successfullyParsed is true
9
10
TEST COMPLETE
11
0
  + native
12
  + native
(-)LayoutTests/fast/js/for-in-var-scope.html (+13 lines)
Line 0 Link Here
1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2
<html>
3
<head>
4
<link rel="stylesheet" href="resources/js-test-style.css">
5
<script src="resources/js-test-pre.js"></script>
6
</head>
7
<body>
8
<p id="description"></p>
9
<div id="console"></div>
10
<script src="resources/for-in-var-scope.js"></script>
11
<script src="resources/js-test-post.js"></script>
12
</body>
13
</html>
0
  + text/html
14
  + text/html
1
  + native
15
  + native
(-)LayoutTests/fast/js/resources/for-in-var-scope.js (+21 lines)
Line 0 Link Here
1
description(
2
"This tests that for/in statements properly scope a variable that's declared in one. "
3
+ "In previous versions of JavaScriptCore there were two bugs that caused problems. "
4
+ "First, the loop variable declaration would not be processed. "
5
+ "Second, the code to set the loop variable would incorrectly walk the scope chain even after setting the loop variable."
6
);
7
8
var i = "start i";
9
var j = "start j";
10
11
function func() {
12
    var object = new Object;
13
    object.propName = "propValue";
14
    for (var i in object) { j = i; }
15
}
16
func();
17
18
shouldBe("i", "'start i'");
19
shouldBe("j", "'propName'");
20
21
var successfullyParsed = true;

Return to bug 5210