~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/JavaScriptCore/runtime/JSActivation.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2008 Apple Inc. All rights reserved.
 
2
 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
3
3
 *
4
4
 * Redistribution and use in source and binary forms, with or without
5
5
 * modification, are permitted provided that the following conditions
39
39
 
40
40
const ClassInfo JSActivation::info = { "JSActivation", 0, 0, 0 };
41
41
 
42
 
JSActivation::JSActivation(CallFrame* callFrame, PassRefPtr<FunctionBodyNode> functionBody)
43
 
    : Base(callFrame->globalData().activationStructure, new JSActivationData(functionBody, callFrame))
 
42
JSActivation::JSActivation(CallFrame* callFrame, NonNullPassRefPtr<FunctionExecutable> functionExecutable)
 
43
    : Base(callFrame->globalData().activationStructure, new JSActivationData(functionExecutable, callFrame->registers()))
44
44
{
45
45
}
46
46
 
49
49
    delete d();
50
50
}
51
51
 
52
 
void JSActivation::mark()
 
52
void JSActivation::markChildren(MarkStack& markStack)
53
53
{
54
 
    Base::mark();
 
54
    Base::markChildren(markStack);
55
55
 
56
56
    Register* registerArray = d()->registerArray.get();
57
57
    if (!registerArray)
58
58
        return;
59
59
 
60
 
    size_t numParametersMinusThis = d()->functionBody->generatedBytecode().m_numParameters - 1;
61
 
 
62
 
    size_t i = 0;
63
 
    size_t count = numParametersMinusThis; 
64
 
    for ( ; i < count; ++i) {
65
 
        Register& r = registerArray[i];
66
 
        if (!r.marked())
67
 
            r.mark();
68
 
    }
69
 
 
70
 
    size_t numVars = d()->functionBody->generatedBytecode().m_numVars;
 
60
    size_t numParametersMinusThis = d()->functionExecutable->parameterCount();
 
61
 
 
62
    size_t count = numParametersMinusThis;
 
63
    markStack.appendValues(registerArray, count);
 
64
 
 
65
    size_t numVars = d()->functionExecutable->variableCount();
71
66
 
72
67
    // Skip the call frame, which sits between the parameters and vars.
73
 
    i += RegisterFile::CallFrameHeaderSize;
74
 
    count += RegisterFile::CallFrameHeaderSize + numVars;
75
 
 
76
 
    for ( ; i < count; ++i) {
77
 
        Register& r = registerArray[i];
78
 
        if (!r.marked())
79
 
            r.mark();
80
 
    }
 
68
    markStack.appendValues(registerArray + count + RegisterFile::CallFrameHeaderSize, numVars, MayContainNullValues);
81
69
}
82
70
 
83
71
bool JSActivation::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
85
73
    if (symbolTableGet(propertyName, slot))
86
74
        return true;
87
75
 
88
 
    if (JSValuePtr* location = getDirectLocation(propertyName)) {
 
76
    if (JSValue* location = getDirectLocation(propertyName)) {
89
77
        slot.setValueSlot(location);
90
78
        return true;
91
79
    }
99
87
    // We don't call through to JSObject because there's no way to give an 
100
88
    // activation object getter properties or a prototype.
101
89
    ASSERT(!hasGetterSetterProperties());
102
 
    ASSERT(prototype()->isNull());
 
90
    ASSERT(prototype().isNull());
103
91
    return false;
104
92
}
105
93
 
106
 
void JSActivation::put(ExecState*, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot)
 
94
void JSActivation::put(ExecState*, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
107
95
{
108
96
    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
109
97
 
118
106
}
119
107
 
120
108
// FIXME: Make this function honor ReadOnly (const) and DontEnum
121
 
void JSActivation::putWithAttributes(ExecState*, const Identifier& propertyName, JSValuePtr value, unsigned attributes)
 
109
void JSActivation::putWithAttributes(ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
122
110
{
123
111
    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
124
112
 
130
118
    // expose in the activation object.
131
119
    ASSERT(!hasGetterSetterProperties());
132
120
    PutPropertySlot slot;
133
 
    putDirect(propertyName, value, attributes, true, slot);
 
121
    JSObject::putWithAttributes(exec, propertyName, value, attributes, true, slot);
134
122
}
135
123
 
136
124
bool JSActivation::deleteProperty(ExecState* exec, const Identifier& propertyName)
148
136
 
149
137
bool JSActivation::isDynamicScope() const
150
138
{
151
 
    return d()->functionBody->usesEval();
 
139
    return d()->functionExecutable->usesEval();
152
140
}
153
141
 
154
 
JSValuePtr JSActivation::argumentsGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
142
JSValue JSActivation::argumentsGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
155
143
{
156
144
    JSActivation* activation = asActivation(slot.slotBase());
157
145
 
158
 
    if (activation->d()->functionBody->usesArguments()) {
 
146
    if (activation->d()->functionExecutable->usesArguments()) {
159
147
        PropertySlot slot;
160
148
        activation->symbolTableGet(exec->propertyNames().arguments, slot);
161
149
        return slot.getValue(exec, exec->propertyNames().arguments);
168
156
        arguments->copyRegisters();
169
157
        callFrame->setCalleeArguments(arguments);
170
158
    }
171
 
    ASSERT(arguments->isObject(&Arguments::info));
 
159
    ASSERT(arguments->inherits(&Arguments::info));
172
160
 
173
161
    return arguments;
174
162
}