zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #22331
[Merge] lp:~zorba-coders/zorba/markos-scratch into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch into lp:zorba.
Commit message:
fixed xray performance regression + cleanup
Requested reviews:
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/165747
fixed xray performance regression + cleanup.
--
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/165747
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2013-05-24 16:34:11 +0000
+++ src/compiler/translator/translator.cpp 2013-05-25 14:38:29 +0000
@@ -11969,8 +11969,10 @@
}
case FunctionConsts::FN_HEAD_1:
{
- arguments.push_back(CREATE(const)(theRootSctx, theUDF, loc, numeric_consts<xs_integer>::one()));
- arguments.push_back(CREATE(const)(theRootSctx, theUDF, loc, numeric_consts<xs_integer>::one()));
+ arguments.push_back(CREATE(const)(theRootSctx, theUDF, loc,
+ numeric_consts<xs_integer>::one()));
+ arguments.push_back(CREATE(const)(theRootSctx, theUDF, loc,
+ numeric_consts<xs_integer>::one()));
function* f = BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_3);
@@ -12653,6 +12655,19 @@
break;
}
+ case FunctionConsts::FN_MAP_2:
+ case FunctionConsts::FN_FILTER_2:
+ {
+ flwor_expr* flworBody = CREATE(flwor)(theRootSctx, theUDF, loc, false);
+
+ let_clause* lc = wrap_in_letclause(foArgs[0]);
+ flworBody->add_clause(lc);
+ foArgs[0] = CREATE(wrapper)(theRootSctx, theUDF, loc, lc->get_var());
+
+ flworBody->set_return_expr(generate_fn_body(f, foArgs, loc));
+ body = flworBody;
+ break;
+ }
case FunctionConsts::FN_FUNCTION_LOOKUP_2:
{
bool varAdded = false;
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2013-05-16 22:26:07 +0000
+++ src/diagnostics/diagnostic_en.xml 2013-05-25 14:38:29 +0000
@@ -1641,7 +1641,7 @@
An argument to \c fn:data() contains a node that does not have a typed
value.
</comment>
- <value>"$1": argument to fn:data() is function item</value>
+ <value>"$1": function item passed as argument to fn:data()</value>
</diagnostic>
<diagnostic code="FOTY0014">
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2013-05-16 22:26:07 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2013-05-25 14:38:29 +0000
@@ -71,7 +71,7 @@
{ "FORX0003", "\"$1\": regular expression matches zero-length string" },
{ "FORX0004", "\"$1\": invalid replacement string${: 2}" },
{ "FOTY0012", "\"$1\": element node of type $2 does not have a typed value" },
- { "FOTY0013", "\"$1\": argument to fn:data() is function item" },
+ { "FOTY0013", "\"$1\": function item passed as argument to fn:data()" },
{ "FOTY0014", "\"$1\": argument to fn:string() is a function item" },
{ "FOTY0015", "\"$1\": argument to fn:deep-equal() contains a function item" },
{ "FOUP0001", "first operand of fn:put() is not a node of a supported kind" },
=== modified file 'src/runtime/accessors/accessors_impl.cpp'
--- src/runtime/accessors/accessors_impl.cpp 2013-05-04 20:20:05 +0000
+++ src/runtime/accessors/accessors_impl.cpp 2013-05-25 14:38:29 +0000
@@ -183,6 +183,7 @@
{
PlanIter_t iter;
store::Item_t itemNode;
+ store::Item::ItemKind resKind;
FnDataIteratorState* state;
DEFAULT_STACK_INIT(FnDataIteratorState, state, planState);
@@ -192,7 +193,9 @@
if (!consumeNext(result, theChildren[0], planState))
break;
- if (result->isNode())
+ resKind = result->getKind();
+
+ if (resKind == store::Item::NODE)
{
itemNode.transfer(result);
@@ -227,22 +230,26 @@
}
}
}
- else if (result->isAtomic())
+ else if (resKind == store::Item::ATOMIC)
{
STACK_PUSH(true, state);
}
- else if (result->isJSONItem())
+ else if (resKind == store::Item::JSONIQ)
{
RAISE_ERROR(jerr::JNTY0004, loc,
ERROR_PARAMS(result->isJSONObject() ? "object" : "array"));
}
- else //(result->isFunction())
+ else if (resKind == store::Item::FUNCTION)
{
store::Item_t fnName = result->getFunctionName();
RAISE_ERROR(err::FOTY0013, loc,
ERROR_PARAMS(fnName.getp() ?
result->getFunctionName()->getStringValue() :
- result->show()));
+ zstring("???")));
+ }
+ else
+ {
+ ZORBA_ASSERT(false);
}
}
=== modified file 'src/runtime/api/plan_iterator_wrapper.cpp'
--- src/runtime/api/plan_iterator_wrapper.cpp 2013-03-17 13:55:28 +0000
+++ src/runtime/api/plan_iterator_wrapper.cpp 2013-05-25 14:38:29 +0000
@@ -44,12 +44,6 @@
}
-void PlanIteratorWrapper::reset()
-{
- theIterator->reset(*theStateBlock);
-}
-
-
#ifndef NDEBUG
std::string PlanIteratorWrapper::toString() const
{
@@ -65,25 +59,16 @@
********************************************************************************/
SERIALIZE_INTERNAL_METHOD(PlanStateIteratorWrapper);
+
void PlanStateIteratorWrapper::serialize(::zorba::serialization::Archiver& ar)
{
PlanIterator::serialize(ar);
}
-PlanStateIteratorWrapper::PlanStateIteratorWrapper(PlanIterator* iter, PlanState& state, uint32_t offset)
- :
- PlanIterator(NULL, QueryLoc()),
- theIterator(iter),
- theStoreIterator(NULL),
- theStateBlock(&state),
- theOffset(offset)
-{
-}
PlanStateIteratorWrapper::PlanStateIteratorWrapper(const store::Iterator_t& iter)
:
PlanIterator(NULL, QueryLoc()),
- theIterator(NULL),
theStoreIterator(iter),
theStateBlock(NULL)
{
@@ -96,55 +81,35 @@
}
-void PlanStateIteratorWrapper::open()
-{
- if (theIterator)
- theIterator->open(*theStateBlock, theOffset);
- else
- theStoreIterator->open();
-}
-
-
-// both arguments will be ignored
void PlanStateIteratorWrapper::open(PlanState& planState, uint32_t& offset)
{
- open();
+ theStoreIterator->open();
}
-bool PlanStateIteratorWrapper::produceNext(store::Item_t& result, PlanState& planState) const
+bool PlanStateIteratorWrapper::produceNext(
+ store::Item_t& result,
+ PlanState& planState) const
{
- if (theIterator)
- return theIterator->produceNext(result, *theStateBlock);
- else
- return theStoreIterator->next(result);
+ return theStoreIterator->next(result);
}
bool PlanStateIteratorWrapper::next(store::Item_t& result)
{
- if (theIterator)
- return PlanIterator::consumeNext(result, theIterator, *theStateBlock);
- else
- return theStoreIterator->next(result);
+ return theStoreIterator->next(result);
}
void PlanStateIteratorWrapper::reset() const
{
- if (theIterator)
- theIterator->reset(*theStateBlock);
- else
- theStoreIterator->reset();
+ theStoreIterator->reset();
}
void PlanStateIteratorWrapper::reset(PlanState& planState) const
{
- if (theIterator)
- theIterator->reset(*theStateBlock);
- else
- theStoreIterator->reset();
+ theStoreIterator->reset();
}
@@ -157,10 +122,7 @@
std::string PlanStateIteratorWrapper::toString() const
{
std::stringstream ss;
- if (theIterator)
- ss << getId() << " = PlanStateIteratorWrapper iterator: " << theIterator->toString();
- else
- ss << getId() << " = PlanStateIteratorWrapper iterator: " << theStoreIterator->toString();
+ ss << getId() << " = PlanStateIteratorWrapper iterator: " << theStoreIterator->toString();
return ss.str();
}
#endif
=== modified file 'src/runtime/api/plan_iterator_wrapper.h'
--- src/runtime/api/plan_iterator_wrapper.h 2013-03-05 02:20:27 +0000
+++ src/runtime/api/plan_iterator_wrapper.h 2013-05-25 14:38:29 +0000
@@ -16,8 +16,10 @@
#ifndef XQP_PLAN_ITERATOR_WRAPPER_H
#define XQP_PLAN_ITERATOR_WRAPPER_H
+#include "common/shared_types.h"
+
#include "store/api/iterator.h"
-#include "common/shared_types.h"
+
#include "runtime/base/plan_iterator.h"
namespace zorba {
@@ -47,7 +49,7 @@
bool next(store::Item_t&);
- void reset();
+ void reset() {}
void close() {}
@@ -56,13 +58,13 @@
#endif
};
+
/*******************************************************************************
********************************************************************************/
class PlanStateIteratorWrapper : public PlanIterator
{
protected:
- PlanIterator * theIterator; // only one of these is used
const store::Iterator_t theStoreIterator;
PlanState * theStateBlock;
@@ -76,17 +78,12 @@
void serialize(::zorba::serialization::Archiver& ar);
public:
- PlanStateIteratorWrapper(PlanIterator* iterator, PlanState& planState, uint32_t offset);
-
PlanStateIteratorWrapper(const store::Iterator_t& iterator);
virtual ~PlanStateIteratorWrapper();
virtual void accept(PlanIterVisitor& v) const;
- virtual void open();
-
- // both arguments will be ignored, and the class members equivalents will be used instead
virtual void open(PlanState& planState, uint32_t& offset);
virtual bool produceNext(store::Item_t& result, PlanState& planState) const;
=== modified file 'src/runtime/base/plan_iterator.cpp'
--- src/runtime/base/plan_iterator.cpp 2013-05-08 20:14:47 +0000
+++ src/runtime/base/plan_iterator.cpp 2013-05-25 14:38:29 +0000
@@ -16,14 +16,20 @@
#include "stdafx.h"
#include "compiler/api/compilercb.h"
+
#include "context/static_context.h"
+
#include "runtime/base/plan_iterator.h"
#include "runtime/util/flowctl_exception.h"
+
#include "store/api/item_factory.h"
#include "store/api/store.h"
+
#include "system/globalenv.h"
+
#include "zorbatypes/integer.h"
+#include "diagnostics/util_macros.h"
namespace zorba
{
@@ -69,11 +75,7 @@
void PlanState::checkDepth(const QueryLoc& loc)
{
if (theStackDepth > 256)
- throw XQUERY_EXCEPTION(
- zerr::ZXQP0003_INTERNAL_ERROR,
- ERROR_PARAMS( ZED( StackOverflow ) ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(zerr::ZXQP0003_INTERNAL_ERROR, loc, ERROR_PARAMS(ZED(StackOverflow)));
}
@@ -95,11 +97,12 @@
{
}
-PlanIterator::PlanIterator(static_context* aContext, const QueryLoc& aLoc)
+
+PlanIterator::PlanIterator(static_context* sctx, const QueryLoc& aLoc)
:
theStateOffset(0),
loc(aLoc),
- theSctx(aContext)
+ theSctx(sctx)
{
// Used for debugging purposes
#ifndef NDEBUG
@@ -107,6 +110,20 @@
#endif
}
+
+PlanIterator::PlanIterator(const PlanIterator& it)
+ :
+ SimpleRCObject(it),
+ theStateOffset(0),
+ loc(it.loc),
+ theSctx(it.theSctx)
+#ifndef NDEBUG
+ , theId(it.theId)
+#endif
+{
+}
+
+
SERIALIZE_INTERNAL_METHOD(PlanIterator)
@@ -130,6 +147,16 @@
}
+#ifndef NDEBUG
+std::string PlanIterator::toString() const
+{
+ std::stringstream ss;
+ ss << getId() << " = " << getClassName();
+ return ss.str();
+}
+#endif
+
+
TypeManager* PlanIterator::getTypeManager() const
{
return theSctx->get_typemanager();
=== modified file 'src/runtime/base/plan_iterator.h'
--- src/runtime/base/plan_iterator.h 2013-03-24 20:40:03 +0000
+++ src/runtime/base/plan_iterator.h 2013-05-25 14:38:29 +0000
@@ -301,11 +301,14 @@
// Stable IDs for debugging purposes. An individual ID is assigned to each iterator
// and this can be used to identify it in the debug information.
#ifndef NDEBUG
-public:
int theId;
+
+public:
int getId() const { return theId;}
+
void setId(int id) { theId = id;}
- virtual std::string toString() const { std::stringstream ss; ss << getId() << " = " << getClassName(); return ss.str(); }
+
+ virtual std::string toString() const;
#endif
public:
@@ -316,19 +319,9 @@
void serialize(::zorba::serialization::Archiver& ar);
public:
- PlanIterator(static_context* aContext, const QueryLoc& aLoc);
+ PlanIterator(static_context* sctx, const QueryLoc& loc);
- PlanIterator(const PlanIterator& it)
- :
- SimpleRCObject(it),
- theStateOffset(0),
- loc(it.loc),
- theSctx(it.theSctx)
-#ifndef NDEBUG
- , theId(it.theId)
-#endif
- {
- }
+ PlanIterator(const PlanIterator& it);
virtual ~PlanIterator() {}
=== modified file 'src/runtime/core/constructors.cpp'
--- src/runtime/core/constructors.cpp 2013-05-08 01:05:04 +0000
+++ src/runtime/core/constructors.cpp 2013-05-25 14:38:29 +0000
@@ -336,7 +336,7 @@
if (pre == "xmlns" ||
ns == "http://www.w3.org/2000/xmlns/" ||
(pre == "xml" && ns != "http://www.w3.org/XML/1998/namespace") ||
- (pre != "xml" && ns == "http://www.w3.org/XML/1998/namespace"))
+ (ns == "http://www.w3.org/XML/1998/namespace" && pre != "xml"))
{
RAISE_ERROR(err::XQDY0096, loc, ERROR_PARAMS(nodeName->getStringValue()));
}
@@ -832,7 +832,7 @@
/*******************************************************************************
********************************************************************************/
-PiIterator::PiIterator (
+PiIterator::PiIterator(
static_context* sctx,
const QueryLoc& loc,
PlanIter_t& aTarget,
@@ -1163,6 +1163,7 @@
std::stack<store::Item*>& path = planState.theNodeConstuctionPath;
bool haveContent = false;
store::Item* parent;
+ store::Item::ItemKind resKind;
EnclosedIteratorState* state;
DEFAULT_STACK_INIT(EnclosedIteratorState, state, planState);
@@ -1173,7 +1174,9 @@
{
haveContent = true;
- if (result->isNode())
+ resKind = result->getKind();
+
+ if (resKind == store::Item::NODE)
{
store::Item_t typedValue;
store::Iterator_t typedIter;
@@ -1197,25 +1200,26 @@
}
}
}
-#ifdef ZORBA_WITH_JSON
- else if (result->isJSONItem())
+ else if (resKind == store::Item::JSONIQ)
{
RAISE_ERROR_NO_PARAMS(jerr::JNTY0011, loc);
}
-#endif
- else
+ else if (resKind == store::Item::ATOMIC)
{
- if (result->isFunction())
- {
- store::Item_t fnName = result->getFunctionName();
- RAISE_ERROR(err::FOTY0013, loc,
- ERROR_PARAMS(fnName.getp() ? result->getFunctionName()->getStringValue() : result->show()));
- }
-
- assert(result->isAtomic());
-
result->getStringValue2(strval);
}
+ else if (result->isFunction())
+ {
+ store::Item_t fnName = result->getFunctionName();
+ RAISE_ERROR(err::FOTY0013, loc,
+ ERROR_PARAMS(fnName.getp() ?
+ result->getFunctionName()->getStringValue() :
+ zstring("???")));
+ }
+ else
+ {
+ ZORBA_ASSERT(false);
+ }
while (consumeNext(result, theChild, planState))
{
@@ -1245,12 +1249,10 @@
}
}
}
-#ifdef ZORBA_WITH_JSON
else if (result->isJSONItem())
{
RAISE_ERROR_NO_PARAMS(jerr::JNTY0011, loc);
}
-#endif
else
{
assert(result->isAtomic());
@@ -1291,7 +1293,9 @@
if (!consumeNext(result, theChild, planState))
break;
- if (result->isNode())
+ resKind = result->getKind();
+
+ if (resKind == store::Item::NODE)
{
if (result->getNodeKind() == store::StoreConsts::documentNode)
{
@@ -1303,21 +1307,12 @@
STACK_PUSH(true, state);
}
}
-#ifdef ZORBA_WITH_JSON
- else if (result->isJSONItem())
+ else if (resKind == store::Item::JSONIQ)
{
RAISE_ERROR_NO_PARAMS(jerr::JNTY0011, loc);
}
-#endif
- else
+ else if (resKind == store::Item::ATOMIC)
{
- if (result->isFunction())
- {
- RAISE_ERROR_NO_PARAMS(err::XQTY0105, loc);
- }
-
- assert(result->isAtomic());
-
result->getStringValue2(strval);
{
@@ -1360,6 +1355,14 @@
STACK_PUSH(result != NULL, state);
}
}
+ else if (resKind == store::Item::FUNCTION)
+ {
+ RAISE_ERROR_NO_PARAMS(err::XQTY0105, loc);
+ }
+ else
+ {
+ ZORBA_ASSERT(false);
+ }
}
}
}
=== modified file 'src/runtime/core/fncall_iterator.h'
--- src/runtime/core/fncall_iterator.h 2013-04-24 01:35:58 +0000
+++ src/runtime/core/fncall_iterator.h 2013-05-25 14:38:29 +0000
@@ -24,8 +24,6 @@
#include "runtime/hof/function_item.h"
-// TODO remove the next three includes
-#include "api/unmarshaller.h"
#include "context/static_context.h"
#include "runtime/base/narybase.h"
=== modified file 'src/store/api/item.h'
--- src/store/api/item.h 2013-05-21 21:44:25 +0000
+++ src/store/api/item.h 2013-05-25 14:38:29 +0000
@@ -67,9 +67,7 @@
PUL = 0x3,
FUNCTION = 0x5,
LIST = 0x7,
-#ifdef ZORBA_WITH_JSON
JSONIQ = 0x9,
-#endif
ERROR_ = 0xB
};
@@ -86,15 +84,6 @@
mutable long theRefCount;
mutable ItemUnion theUnion;
-#ifndef NDEBUG
- // This class member is set by some atomic type items to the
- // item's value in order to aid debugging. The debug_str might
- // not always be updated to the current value.
-protected:
- const char* debug_str_; // similar to zorba_string.h
- zstring debug_holder;
-#endif
-
protected:
Item() : theRefCount(0)
@@ -147,7 +136,6 @@
theUnion.treeRCPtr != 0);
}
-#ifdef ZORBA_WITH_JSON
/**
* @return "true" if the item is a JSON item
*/
@@ -155,7 +143,6 @@
{
return ((theUnion.itemKind & 0xF) == JSONIQ);
}
-#endif
/**
* @return "true" if the item is an atomic value
@@ -212,7 +199,6 @@
*/
zstring printKind() const;
-#ifdef ZORBA_WITH_JSON
/**
* @return "true" if the item is a JSON object item
*/
@@ -224,7 +210,6 @@
*/
virtual bool
isJSONArray() const;
-#endif
/**
* @return the qname identifying the XQuery type of the item
@@ -905,7 +890,6 @@
leastCommonAncestor(const store::Item_t&) const;
-#ifdef ZORBA_WITH_JSON
/* -------------------- Methods for JSON items --------------------- */
/**
@@ -962,7 +946,6 @@
virtual xs_integer
getNumObjectPairs() const;
-#endif // ZORBA_WITH_JSON
/* -------------------- Methods for ErrorItem --------------------- */
=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp 2013-05-16 22:16:00 +0000
+++ src/store/naive/atomic_items.cpp 2013-05-25 14:38:29 +0000
@@ -695,13 +695,6 @@
initializeAsUnnormalizedQName(lNormalized, aPrefix);
theIsInPool = false;
-
-#ifndef NDEBUG
- debug_holder = theLocal.c_str();
- if (!thePrefix.empty())
- debug_holder = thePrefix + ":" + debug_holder;
- debug_str_ = debug_holder.c_str();
-#endif
}
=== modified file 'src/store/naive/atomic_items.h'
--- src/store/naive/atomic_items.h 2013-05-16 22:16:00 +0000
+++ src/store/naive/atomic_items.h 2013-05-25 14:38:29 +0000
@@ -492,13 +492,6 @@
assert(isNormalized());
assert(isValid());
-
-#ifndef NDEBUG
- debug_holder = theLocal.c_str();
- if (!thePrefix.empty())
- debug_holder = thePrefix + ":" + debug_holder;
- debug_str_ = debug_holder.c_str();
-#endif
}
void initializeAsUnnormalizedQName(
@@ -515,13 +508,6 @@
assert(!isNormalized());
assert(isValid());
-
-#ifndef NDEBUG
- debug_holder = theLocal.c_str();
- if (!thePrefix.empty())
- debug_holder = thePrefix + ":" + debug_holder;
- debug_str_ = debug_holder.c_str();
-#endif
}
void initializeAsQNameNotInPool(
=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt 2013-05-23 20:33:33 +0000
+++ test/fots/CMakeLists.txt 2013-05-25 14:38:29 +0000
@@ -108,7 +108,6 @@
EXPECTED_FOTS_FAILURE (SLOW fn-subsequence cbcl-subsequence-014 1069794)
EXPECTED_FOTS_FAILURE (SLOW fn-matches.re re00987 1131313)
EXPECTED_FOTS_FAILURE (SLOW app-Demos itunes 0)
-EXPECTED_FOTS_FAILURE (SLOW app-Demos raytracer 0)
#"crashing/hanging" tests. These are not run but marked as 'tooBig' by FOTS driver.
EXPECTED_FOTS_FAILURE (CRASH fn-matches.re re00975 1070533)
Follow ups