- Revision
- 164812
- Author
- fpi...@apple.com
- Date
- 2014-02-27 10:34:27 -0800 (Thu, 27 Feb 2014)
Log Message
Octane/closure thrashes between flattening dictionaries during global object initialization in a global eval
https://bugs.webkit.org/show_bug.cgi?id=129435
Reviewed by Oliver Hunt.
This is a 5-10% speed-up on Octane/closure.
* interpreter/Interpreter.cpp:
(JSC::Interpreter::execute):
* jsc.cpp:
(GlobalObject::finishCreation):
(functionClearCodeCache):
* runtime/BatchedTransitionOptimizer.h:
(JSC::BatchedTransitionOptimizer::BatchedTransitionOptimizer):
(JSC::BatchedTransitionOptimizer::~BatchedTransitionOptimizer):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (164811 => 164812)
--- trunk/Source/_javascript_Core/ChangeLog 2014-02-27 18:27:08 UTC (rev 164811)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-02-27 18:34:27 UTC (rev 164812)
@@ -1,3 +1,21 @@
+2014-02-27 Filip Pizlo <fpi...@apple.com>
+
+ Octane/closure thrashes between flattening dictionaries during global object initialization in a global eval
+ https://bugs.webkit.org/show_bug.cgi?id=129435
+
+ Reviewed by Oliver Hunt.
+
+ This is a 5-10% speed-up on Octane/closure.
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::execute):
+ * jsc.cpp:
+ (GlobalObject::finishCreation):
+ (functionClearCodeCache):
+ * runtime/BatchedTransitionOptimizer.h:
+ (JSC::BatchedTransitionOptimizer::BatchedTransitionOptimizer):
+ (JSC::BatchedTransitionOptimizer::~BatchedTransitionOptimizer):
+
2014-02-27 Alexey Proskuryakov <a...@apple.com>
Added svn:ignore to two directories, so that .pyc files don't show up as unversioned.
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (164811 => 164812)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2014-02-27 18:27:08 UTC (rev 164811)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2014-02-27 18:34:27 UTC (rev 164812)
@@ -1147,18 +1147,26 @@
if (variableObject->next())
variableObject->globalObject()->varInjectionWatchpoint()->fireAll();
- for (unsigned i = 0; i < numVariables; ++i) {
- const Identifier& ident = codeBlock->variable(i);
- if (!variableObject->hasProperty(callFrame, ident)) {
- PutPropertySlot slot(variableObject);
- variableObject->methodTable()->put(variableObject, callFrame, ident, jsUndefined(), slot);
+ {
+ SamplingRegion samplingRegion("variable puts");
+
+ for (unsigned i = 0; i < numVariables; ++i) {
+ const Identifier& ident = codeBlock->variable(i);
+ if (!variableObject->hasProperty(callFrame, ident)) {
+ PutPropertySlot slot(variableObject);
+ variableObject->methodTable()->put(variableObject, callFrame, ident, jsUndefined(), slot);
+ }
}
}
- for (int i = 0; i < numFunctions; ++i) {
- FunctionExecutable* function = codeBlock->functionDecl(i);
- PutPropertySlot slot(variableObject);
- variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot);
+ {
+ SamplingRegion samplingRegion("function puts");
+
+ for (int i = 0; i < numFunctions; ++i) {
+ FunctionExecutable* function = codeBlock->functionDecl(i);
+ PutPropertySlot slot(variableObject);
+ variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot);
+ }
}
}
Modified: trunk/Source/_javascript_Core/jsc.cpp (164811 => 164812)
--- trunk/Source/_javascript_Core/jsc.cpp 2014-02-27 18:27:08 UTC (rev 164811)
+++ trunk/Source/_javascript_Core/jsc.cpp 2014-02-27 18:34:27 UTC (rev 164812)
@@ -25,6 +25,7 @@
#include "APIShims.h"
#include "ButterflyInlines.h"
#include "BytecodeGenerator.h"
+#include "CodeCache.h"
#include "Completion.h"
#include "CopiedSpaceInlines.h"
#include "ExceptionHelpers.h"
@@ -239,6 +240,7 @@
static NO_RETURN_WITH_VALUE EncodedJSValue JSC_HOST_CALL functionQuit(ExecState*);
static EncodedJSValue JSC_HOST_CALL functionFalse(ExecState*);
static EncodedJSValue JSC_HOST_CALL functionEffectful42(ExecState*);
+static EncodedJSValue JSC_HOST_CALL functionClearCodeCache(ExecState*);
#if ENABLE(SAMPLING_FLAGS)
static EncodedJSValue JSC_HOST_CALL functionSetSamplingFlags(ExecState*);
@@ -375,6 +377,7 @@
putDirectNativeFunction(vm, this, Identifier(&vm, "DFGTrue"), 0, functionFalse, DFGTrue, DontEnum | JSC::Function);
addFunction(vm, "effectful42", functionEffectful42, 0);
+ addFunction(vm, "clearCodeCache", functionClearCodeCache, 0);
JSArray* array = constructEmptyArray(globalExec(), 0);
for (size_t i = 0; i < arguments.size(); ++i)
@@ -735,6 +738,13 @@
return JSValue::encode(jsNumber(42));
}
+EncodedJSValue JSC_HOST_CALL functionClearCodeCache(ExecState* exec)
+{
+ if (CodeCache* cache = exec->vm().codeCache())
+ cache->clear();
+ return JSValue::encode(jsUndefined());
+}
+
// Use SEH for Release builds only to get rid of the crash report dialog
// (luckily the same tests fail in Release and Debug builds so far). Need to
// be in a separate main function because the jscmain function requires object
Modified: trunk/Source/_javascript_Core/runtime/BatchedTransitionOptimizer.h (164811 => 164812)
--- trunk/Source/_javascript_Core/runtime/BatchedTransitionOptimizer.h 2014-02-27 18:27:08 UTC (rev 164811)
+++ trunk/Source/_javascript_Core/runtime/BatchedTransitionOptimizer.h 2014-02-27 18:34:27 UTC (rev 164812)
@@ -1,6 +1,5 @@
-// -*- mode: c++; c-basic-offset: 4 -*-
/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -36,13 +35,13 @@
public:
BatchedTransitionOptimizer(VM& vm, JSObject* object)
: m_vm(&vm)
- , m_object(object)
+ , m_object(object->structure()->isDictionary() ? nullptr : object)
{
}
~BatchedTransitionOptimizer()
{
- if (m_object->structure()->isDictionary())
+ if (m_object && m_object->structure()->isDictionary())
m_object->flattenDictionaryObject(*m_vm);
}