source: webkit/trunk/JavaScriptCore/kjs/JSVariableObject.cpp@ 35203

Last change on this file since 35203 was 35203, checked in by [email protected], 17 years ago

JavaScriptCore:

2008-07-16 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.


First step toward putting doubles in registers: Turned Register into a
proper abstraction layer. It is no longer possible to cast a Register
to a JSValue*, or a Register& to a JSValue*&, or to access the union
inside a Register directly.


SunSpider reports no change.


In support of this change, I had to make the following mechanical changes
in a lot of places:


  1. Clients now use explicit accessors to read data out of Registers, and implicit copy constructors to write data into registers.


So, assignment that used to look like


x.u.jsValue = y;


now looks like


x = y;


And access that used to look like


x = y.u.jsValue;


now looks like


x = y.jsValue();

  1. I made generic flow control specific in opcodes that made their flow control generic by treating a Register& as a JSValue*&. This had the added benefit of removing some exception checking branches from immediate number code.
  1. I beefed up PropertySlot to support storing a Register* in a property slot. For now, only JSVariableObject's symbolTableGet and symbolTablePut use this functionality, but I expect more clients to use it in the future.


  1. I changed ArgList to be a buffer of Registers, not JSValue*'s, and I changed ArgList iterator clients to iterate Registers, not JSValue*'s.

WebCore:

2008-07-16 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.

Support for JavaScriptCore's first step toward putting doubles in
registers: Treat ArgList iterators as Register*'s, not JSValue*'s.

  • bindings/js/ScheduledAction.cpp: (WebCore::ScheduledAction::ScheduledAction):
  • Property svn:eol-style set to native
File size: 3.6 KB
Line 
1/*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include "config.h"
30#include "JSVariableObject.h"
31
32#include "PropertyNameArray.h"
33#include "PropertyMap.h"
34
35namespace KJS {
36
37bool JSVariableObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
38{
39 if (symbolTable().contains(propertyName.ustring().rep()))
40 return false;
41
42 return JSObject::deleteProperty(exec, propertyName);
43}
44
45void JSVariableObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
46{
47 SymbolTable::const_iterator end = symbolTable().end();
48 for (SymbolTable::const_iterator it = symbolTable().begin(); it != end; ++it) {
49 if (!(it->second.getAttributes() & DontEnum))
50 propertyNames.add(Identifier(exec, it->first.get()));
51 }
52
53 JSObject::getPropertyNames(exec, propertyNames);
54}
55
56bool JSVariableObject::getPropertyAttributes(ExecState* exec, const Identifier& propertyName, unsigned& attributes) const
57{
58 SymbolTableEntry entry = symbolTable().get(propertyName.ustring().rep());
59 if (!entry.isNull()) {
60 attributes = entry.getAttributes() | DontDelete;
61 return true;
62 }
63 return JSObject::getPropertyAttributes(exec, propertyName, attributes);
64}
65
66void JSVariableObject::mark()
67{
68 JSObject::mark();
69
70 if (!d->registerArray)
71 return;
72
73 Register* end = d->registerArray.get() + d->registerArraySize;
74 for (Register* it = d->registerArray.get(); it != end; ++it)
75 if (!(*it).marked())
76 (*it).mark();
77}
78
79bool JSVariableObject::isVariableObject() const
80{
81 return true;
82}
83
84void JSVariableObject::copyRegisterArray(Register* src, size_t count)
85{
86 ASSERT(!d->registerArray);
87
88 Register* registerArray = new Register[count];
89 memcpy(registerArray, src, count * sizeof(Register));
90
91 setRegisterArray(registerArray, count);
92}
93
94void JSVariableObject::setRegisterArray(Register* registerArray, size_t count)
95{
96 if (registerArray != d->registerArray.get())
97 d->registerArray.set(registerArray);
98 d->registerArraySize = count;
99 d->registers = registerArray + count;
100}
101
102} // namespace KJS
Note: See TracBrowser for help on using the repository browser.