Skip to content
Permalink
Browse files

Add ecma_6 into spidermonkey vendortest

* Copy more files from es1 to run spidermonkey tests
* Add tools to run ECMA5-incompatible tests
  - [babel](https://babeljs.io/)
  - [es6-shim](https://github.com/paulmillr/es6-shim)
  - [es6-symbol](https://www.npmjs.com/package/es6-symbol)
* Add src/shell/GlobalObjectBuiltinTestFunctions.cpp to add test-only functions
* 'of' should be able to be used as identifier
* Set rpath of x86 binary relative to binary path
* Remove config.h.in~ file from repository
* Fix broken build by removing third_party/libunwind
  • Loading branch information...
ejjeong committed Jan 24, 2017
1 parent cb62dd4 commit 3cac1b803b8148ebde2a554cfbddb5f549b43f36
@@ -0,0 +1,36 @@
/*
* vim: syntax=javascript
*/

{
/*
"presets":
[
["latest",
{ "es2015": { loose: true, modules: false} },
],
],
*/

"plugins":
[
["transform-es2015-block-scoping"], /* let */
["transform-es2015-constants"], /* const */
["transform-es2015-arrow-functions"], /* arrow */

["transform-es2015-destructuring"],
["transform-es2015-template-literals"], /* `foo${bar}` => "foo" + bar */

// ["transform-es2015-for-of"], /* Cannot support array[Symbol.iterator]() */
["transform-es2015-classes"],
["transform-es2015-shorthand-properties"],
],

"ignore":
[
"/JavaScriptCore/stress/resources/", /* Convert manually */
"/JavaScriptCore/stress/regress-159779", /* Too long */
],

"sourceType": "script",
}
@@ -58,3 +58,4 @@ android/libs
*.gen.txt
*.log.txt
bdwgcUsage.dat
node_modules
@@ -5,7 +5,7 @@ build_x64_release:
- escargot_main_build
before_script:
- unset TIZEN_SDK_HOME
- ./build_third_party.sh
- ARCH=x64 MODE=release ./build_third_party.sh
- make clean
script:
- make x64.interpreter.release -j && for file in `ldd ./escargot | grep icu | awk '{print $3}'`; do cp "$file" .; done
@@ -63,7 +63,7 @@ build_x86_release:
- escargot_main_build
before_script:
- unset TIZEN_SDK_HOME
- ./build_third_party.sh
- ARCH=x86 MODE=release ./build_third_party.sh
- make clean
script:
- make x86.interpreter.release -j
@@ -118,7 +118,7 @@ build_x64_debug:
- escargot_main_build
before_script:
- unset TIZEN_SDK_HOME
- ./build_third_party.sh
- ARCH=x64 MODE=debug ./build_third_party.sh
- make clean
script:
- make x64.interpreter.debug -j && for file in `ldd ./escargot | grep icu | awk '{print $3}'`; do cp "$file" .; done
@@ -177,7 +177,7 @@ build_x86_debug:
- escargot_main_build
before_script:
- unset TIZEN_SDK_HOME
- ./build_third_party.sh
- ARCH=x86 MODE=debug ./build_third_party.sh
- make clean
script:
- make x86.interpreter.debug -j
@@ -88,7 +88,7 @@ ifeq ($(HOST), linux)
ESCARGOT_LDFLAGS_THIRD_PARTY += $(shell pkg-config --libs icu-i18n)
else ifeq ($(ARCH), x86)
ESCARGOT_CXXFLAGS_THIRD_PARTY += -I$(ESCARGOT_ROOT)/deps/x86-linux/include
ESCARGOT_LDFLAGS_THIRD_PARTY += -Ldeps/x86-linux/lib -Wl,-rpath=./deps/x86-linux/lib
ESCARGOT_LDFLAGS_THIRD_PARTY += -Ldeps/x86-linux/lib -Wl,-rpath,'$$ORIGIN/deps/x86-linux/lib/'
ESCARGOT_LDFLAGS_THIRD_PARTY += -licuio -licui18n -licuuc -licudata
endif
else ifeq ($(HOST), tizen_obs)
@@ -0,0 +1,13 @@
{
"name": "vendortest",
"dependencies": {
"babel-cli": "latest",
"babel-plugin-transform-es2015-block-scoping": "latest",
"babel-plugin-transform-es2015-constants": "latest",
"babel-plugin-transform-es2015-arrow-functions": "latest",
"babel-plugin-transform-es2015-destructuring": "latest",
"babel-plugin-transform-es2015-template-literals": "latest",
"babel-plugin-transform-es2015-classes": "latest",
"babel-plugin-transform-es2015-shorthand-properties": "latest"
}
}
@@ -94,7 +94,6 @@ enum KeywordKind {
If,
In,
Do,
Of,
Var,
For,
New,
@@ -882,8 +881,6 @@ class Scanner : public gc {

} else if (first == 'd' && id == "do") {
return Do;
} else if (first == 'o' && id == "of") {
return Of;
}
break;
case 3:
@@ -4923,7 +4920,8 @@ class Parser : public gc {
left = init;
right = this->parseExpression();
init = nullptr;
} else if (declarations.size() == 1 && declarations[0]->init() == nullptr && this->matchContextualKeyword(Of)) {
} else if (declarations.size() == 1 && declarations[0]->init() == nullptr
&& this->lookahead->type == Token::IdentifierToken && this->lookahead->valueString == "of") {
init = this->finalize(metaInit, new VariableDeclarationNode(std::move(declarations) /*, 'var'*/));
this->nextToken();
left = init;
@@ -4989,7 +4987,7 @@ class Parser : public gc {
left = init;
right = this->parseExpression();
init = nullptr;
} else if (this->matchContextualKeyword(Of)) {
} else if (this->lookahead->type == Token::IdentifierToken && this->lookahead->valueString == "of") {
// TODO
RELEASE_ASSERT_NOT_REACHED();
/*
@@ -0,0 +1,17 @@
#ifdef ESCARGOT_ENABLE_PROMISE

#include "Escargot.h"
#include "DefaultJobQueue.h"
#include "runtime/Job.h"
#include "runtime/Context.h"
#include "runtime/SandBox.h"

namespace Escargot {

JobQueue* JobQueue::create()
{
return DefaultJobQueue::create();
}
}

#endif
@@ -64,11 +64,6 @@ class DefaultJobQueue : public JobQueue {
private:
std::list<Job*, gc_allocator<Job*> > m_jobs;
};

JobQueue* JobQueue::create()
{
return DefaultJobQueue::create();
}
}
#endif // ESCARGOT_ENABLE_PROMISE
#endif // __EscargotDefaultJobQueue__
@@ -0,0 +1,41 @@
#include "Escargot.h"
#include "shell/DefaultJobQueue.h"

namespace Escargot {

static Value builtinDrainJobQueue(ExecutionState& state, Value thisValue, size_t argc, Value* argv, bool isNewExpression)
{
DefaultJobQueue* jobQueue = DefaultJobQueue::get(state.context()->jobQueue());
while (jobQueue->hasNextJob()) {
auto jobResult = jobQueue->nextJob()->run(state);
if (!jobResult.error.isEmpty())
return Value(false);
}
return Value(true);
}

static Value builtinAddPromiseReactions(ExecutionState& state, Value thisValue, size_t argc, Value* argv, bool isNewExpression)
{
PromiseObject* promise = argv[0].toObject(state)->asPromiseObject();
PromiseReaction::Capability capability = PromiseObject::newPromiseCapability(state, promise->get(state, state.context()->staticStrings().constructor).value(state, promise).toObject(state));
promise->appendReaction(argv[1].toObject(state)->asFunctionObject(), argv[2].toObject(state)->asFunctionObject(), capability);
return Value();
}


void installTestFunctions(ExecutionState& state)
{
GlobalObject* globalObject = state.context()->globalObject();

AtomicString drainJobQueue(state, "drainJobQueue");
globalObject->defineOwnProperty(state, ObjectPropertyName(drainJobQueue),
ObjectPropertyDescriptor(new FunctionObject(state,
NativeFunctionInfo(drainJobQueue, builtinDrainJobQueue, 0, nullptr, NativeFunctionInfo::Strict), false),
(ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::AllPresent)));
AtomicString addPromiseReactions(state, "addPromiseReactions");
globalObject->defineOwnProperty(state, ObjectPropertyName(addPromiseReactions),
ObjectPropertyDescriptor(new FunctionObject(state,
NativeFunctionInfo(addPromiseReactions, builtinAddPromiseReactions, 3, nullptr, NativeFunctionInfo::Strict), false),
(ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::AllPresent)));
}
}
@@ -34,6 +34,11 @@ void __attribute__((optimize("O0"))) fillStack(size_t siz)
}
#endif

namespace Escargot {

void installTestFunctions(Escargot::ExecutionState& state);
}

NEVER_INLINE bool eval(Escargot::Context* context, Escargot::String* str, Escargot::String* fileName, bool shouldPrintScriptResult)
{
auto result = context->scriptParser().parse(str, fileName);
@@ -100,6 +105,9 @@ int main(int argc, char* argv[])
Escargot::VMInstance* instance = new Escargot::VMInstance();
Escargot::Context* context = new Escargot::Context(instance);

Escargot::ExecutionState stateForInit(context);
installTestFunctions(stateForInit);

bool runShell = true;

for (int i = 1; i < argc; i++) {

0 comments on commit 3cac1b8

Please sign in to comment.
You can’t perform that action at this time.