source: webkit/trunk/JavaScriptCore/runtime/PropertySlot.cpp@ 48788

Last change on this file since 48788 was 47236, checked in by Darin Adler, 16 years ago

JavaScriptCore: JavaScriptCore tweaks to get ready for the parser arena
https://bugs.webkit.org/show_bug.cgi?id=28243

Patch by Darin Adler <Darin Adler> on 2009-08-13
Reviewed by David Levin.

Eliminate dependencies on Nodes.h outside JavaScriptCore,
and cut down on them inside JavaScriptCore.

Change regular expression parsing to use identifiers as
with other strings we parse.

Fix a couple things that are needed to use const Identifier
more, which will be part of the parser arena work.

CollectorHeapIterator.h to be project-internal.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitPushNewScope): Added const.

  • bytecompiler/BytecodeGenerator.h: Ditto.
  • debugger/Debugger.cpp:

(JSC::Debugger::recompileAllJSFunctions): Moved this function
here from WebCore. Here is better since it uses so many internals.
Removed unimportant optimization for the no listener case.

  • debugger/Debugger.h: Ditto. Also removed unneeded include

and tweaked formatting and comments.

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::functionName): Call asFunction instead
of doing the unchecked static_cast.
(JSC::DebuggerCallFrame::calculatedFunctionName): Ditto.

  • jit/JITStubs.cpp:

(JSC::op_call_JSFunction): Call isHostFunction on the body rather
than on the JSFunction.
(JSC::vm_lazyLinkCall): Ditto.
(JSC::op_construct_JSConstruct): Ditto.

  • parser/Grammar.y: Changed callers to use new scanRegExp with

out arguments instead of relying on state in the Lexer. And
callers that just want to skip a regular expression to use
skipRegExp.

  • parser/Lexer.cpp:

(JSC::Lexer::scanRegExp): Changed to use out arguments, and to
add a prefix argument so we can add in the "=" character as needed.
Also rewrote to streamline the logic a bit inspired by suggestions
by David Levin.
(JSC::Lexer::skipRegExp): Added. Version of the function above that
does not actually put the regular expression into a string.
(JSC::Lexer::clear): Removed code to clear m_pattern and m_flags.

  • parser/Lexer.h: Changed scanRegExp to have out arguments. Added

skipRegExp. Eliminated pattern, flags, m_pattern, and m_flags.

  • parser/NodeConstructors.h:

(JSC::RegExpNode::RegExpNode): Changed to take const Identifier&.

  • parser/Nodes.cpp:

(JSC::RegExpNode::emitBytecode): Changed since m_pattern and
m_flags are now Identifier instead of UString.
(JSC::FunctionBodyNode::make): Moved this function here instead
of putting it in the JSFunction.h header.

  • parser/Nodes.h: Changed RegExpNode to use Identifier.
  • profiler/Profiler.cpp:

(JSC::Profiler::createCallIdentifier): Changed to use isHostFunction
on the body instead of on the JSFunction object.

  • runtime/FunctionPrototype.cpp:

(JSC::functionProtoFuncToString): Ditto.

  • runtime/JSFunction.cpp:

(JSC::JSFunction::isHostFunction): Moved here from header.
(JSC::JSFunction::isHostFunctionNonInline): Added.
(JSC::JSFunction::JSFunction): Removed unneeded initialization of
m_body to 0.
(JSC::JSFunction::setBody): Moved here from header.

  • runtime/JSFunction.h: Removed unneeded includes. Moved private

constructor down to the private section. Made virtual functions
private. Removed unneeded overload of setBody and moved the body
of the function into the .cpp file. Changed assertions to use
the non-inline version of isHostFunction.

  • runtime/PropertySlot.cpp:

(JSC::PropertySlot::functionGetter): Use asFunction instead
of doing the unchecked static_cast.

  • wtf/SegmentedVector.h:

(WTF::SegmentedVector::isEmpty): Added.

WebCore: JavaScriptCore tweaks to get ready for the parser arena
https://bugs.webkit.org/show_bug.cgi?id=28243

Patch by Darin Adler <Darin Adler> on 2009-08-13
Reviewed by David Levin.

  • ForwardingHeaders/runtime/CollectorHeapIterator.h: Removed.
  • WebCore.xcodeproj/project.pbxproj: Exposed a couple header

files as Private that are now needed to compile Mac WebKit.

  • bindings/js/JSAudioConstructor.cpp:
  • bindings/js/JSDOMBinding.cpp:
  • bindings/js/JSDOMBinding.h:
  • bindings/js/JSDOMWindowCustom.cpp:
  • bindings/js/JSHTMLInputElementCustom.cpp:
  • bindings/js/JSHistoryCustom.cpp:
  • bindings/js/JSImageConstructor.cpp:
  • bindings/js/JSLazyEventListener.cpp:
  • bindings/js/JSLocationCustom.cpp:
  • bindings/js/JSMessageChannelConstructor.cpp:
  • bindings/js/JSOptionConstructor.cpp:
  • bindings/js/JSWebSocketConstructor.cpp:
  • bindings/js/JSWebSocketCustom.cpp:
  • bindings/js/JSWorkerConstructor.cpp:
  • bindings/js/JSXMLHttpRequestConstructor.cpp:
  • bridge/jni/jni_jsobject.mm:

Updated includes.

  • inspector/JavaScriptDebugServer.cpp:

(WebCore::JavaScriptDebugServer::sourceParsed):
Change to not assert if this is called with no listeners.
I don't think this was guaranteed before, and we now use
this code path when recompiling. Slightly less efficient,
but this is a one-time cost when turning on the debugger.
(WebCore::JavaScriptDebugServer::recompileAllJSFunctions):
Change to call Debugger::recompileAllJSFunctions.

WebKit/mac: * Plugins/Hosted/NetscapePluginInstanceProxy.mm: Updated includes.

  • WebView/WebScriptDebugger.mm: Ditto.
  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1/*
2 * Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#include "config.h"
22#include "PropertySlot.h"
23
24#include "JSFunction.h"
25#include "JSGlobalObject.h"
26
27namespace JSC {
28
29JSValue PropertySlot::functionGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
30{
31 // Prevent getter functions from observing execution if an exception is pending.
32 if (exec->hadException())
33 return exec->exception();
34
35 CallData callData;
36 CallType callType = slot.m_data.getterFunc->getCallData(callData);
37 if (callType == CallTypeHost)
38 return callData.native.function(exec, slot.m_data.getterFunc, slot.slotBase(), exec->emptyList());
39 ASSERT(callType == CallTypeJS);
40 // FIXME: Can this be done more efficiently using the callData?
41 return asFunction(slot.m_data.getterFunc)->call(exec, slot.slotBase(), exec->emptyList());
42}
43
44} // namespace JSC
Note: See TracBrowser for help on using the repository browser.