*/
class V8EXPORT Script {
public:
+ enum CompileFlags {
+ Default = 0x00,
+ QmlMode = 0x01
+ };
+
/**
* Compiles the specified script (context-independent).
*
static Local<Script> New(Handle<String> source,
ScriptOrigin* origin = NULL,
ScriptData* pre_data = NULL,
- Handle<String> script_data = Handle<String>());
+ Handle<String> script_data = Handle<String>(),
+ CompileFlags = Default);
/**
* Compiles the specified script using the specified file name
* will use the currently entered context).
*/
static Local<Script> New(Handle<String> source,
- Handle<Value> file_name);
+ Handle<Value> file_name,
+ CompileFlags = Default);
/**
* Compiles the specified script (bound to current context).
static Local<Script> Compile(Handle<String> source,
ScriptOrigin* origin = NULL,
ScriptData* pre_data = NULL,
- Handle<String> script_data = Handle<String>());
+ Handle<String> script_data = Handle<String>(),
+ CompileFlags = Default);
/**
* Compiles the specified script using the specified file name
*/
static Local<Script> Compile(Handle<String> source,
Handle<Value> file_name,
- Handle<String> script_data = Handle<String>());
+ Handle<String> script_data = Handle<String>(),
+ CompileFlags = Default);
/**
* Runs the script returning the resulting value. If the script is
* compiled.
*/
Local<Value> Run();
+ Local<Value> Run(Handle<Object> qml);
/**
* Returns the script id value.
* JavaScript frames an empty handle is returned.
*/
static Local<Context> GetCalling();
+ static Local<Object> GetCallingQmlGlobal();
/**
* Sets the security token for the context. To access an object in
Local<Script> Script::New(v8::Handle<String> source,
v8::ScriptOrigin* origin,
v8::ScriptData* pre_data,
- v8::Handle<String> script_data) {
+ v8::Handle<String> script_data,
+ v8::Script::CompileFlags compile_flags) {
i::Isolate* isolate = i::Isolate::Current();
ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>());
LOG_API(isolate, "Script::New");
NULL,
pre_data_impl,
Utils::OpenHandle(*script_data),
- i::NOT_NATIVES_CODE);
+ i::NOT_NATIVES_CODE,
+ compile_flags);
has_pending_exception = result.is_null();
EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>());
return Local<Script>(ToApi<Script>(result));
Local<Script> Script::New(v8::Handle<String> source,
- v8::Handle<Value> file_name) {
+ v8::Handle<Value> file_name,
+ v8::Script::CompileFlags compile_flags) {
ScriptOrigin origin(file_name);
- return New(source, &origin);
+ return New(source, &origin, 0, Handle<String>(), compile_flags);
}
Local<Script> Script::Compile(v8::Handle<String> source,
v8::ScriptOrigin* origin,
v8::ScriptData* pre_data,
- v8::Handle<String> script_data) {
+ v8::Handle<String> script_data,
+ v8::Script::CompileFlags compile_flags) {
i::Isolate* isolate = i::Isolate::Current();
ON_BAILOUT(isolate, "v8::Script::Compile()", return Local<Script>());
LOG_API(isolate, "Script::Compile");
ENTER_V8(isolate);
- Local<Script> generic = New(source, origin, pre_data, script_data);
+ Local<Script> generic = New(source, origin, pre_data, script_data, compile_flags);
if (generic.IsEmpty())
return generic;
i::Handle<i::Object> obj = Utils::OpenHandle(*generic);
Local<Script> Script::Compile(v8::Handle<String> source,
v8::Handle<Value> file_name,
- v8::Handle<String> script_data) {
+ v8::Handle<String> script_data,
+ v8::Script::CompileFlags compile_flags) {
ScriptOrigin origin(file_name);
- return Compile(source, &origin, 0, script_data);
+ return Compile(source, &origin, 0, script_data, compile_flags);
}
Local<Value> Script::Run() {
+ return Run(Handle<Object>());
+}
+
+Local<Value> Script::Run(Handle<Object> qml) {
i::Isolate* isolate = i::Isolate::Current();
ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>());
LOG_API(isolate, "Script::Run");
fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate);
}
EXCEPTION_PREAMBLE(isolate);
+ i::Handle<i::Object> qmlglobal = Utils::OpenHandle(*qml);
i::Handle<i::Object> receiver(
isolate->context()->global_proxy(), isolate);
i::Handle<i::Object> result =
- i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception);
+ i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception, false, qmlglobal);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
raw_result = *result;
}
}
+v8::Local<v8::Object> Context::GetCallingQmlGlobal() {
+ i::Isolate* isolate = i::Isolate::Current();
+ if (IsDeadCheck(isolate, "v8::Context::GetCallingQmlGlobal()")) {
+ return Local<Object>();
+ }
+
+ i::Context *context = isolate->context();
+ i::JavaScriptFrameIterator it;
+ if (it.done()) return Local<Object>();
+ context = i::Context::cast(it.frame()->context());
+ if (!context->qml_global()->IsUndefined()) {
+ i::Handle<i::Object> qmlglobal(context->qml_global());
+ return Utils::ToLocal(i::Handle<i::JSObject>::cast(qmlglobal));
+ } else {
+ return Local<Object>();
+ }
+}
+
+
v8::Local<v8::Object> Context::Global() {
if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) {
return Local<v8::Object>();
__ ldr(r1, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
__ str(r1, MemOperand(r0, Context::SlotOffset(Context::GLOBAL_INDEX)));
+ // Copy the qml global object from the surrounding context.
+ __ ldr(r1, MemOperand(cp, Context::SlotOffset(Context::QML_GLOBAL_INDEX)));
+ __ str(r1, MemOperand(r0, Context::SlotOffset(Context::QML_GLOBAL_INDEX)));
+
// Initialize the rest of the slots to undefined.
__ LoadRoot(r1, Heap::kUndefinedValueRootIndex);
for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) {
__ ldr(r1, ContextOperand(cp, Context::GLOBAL_INDEX));
__ str(r1, ContextOperand(r0, Context::GLOBAL_INDEX));
+ // Copy the qml global object from the surrounding context.
+ __ ldr(r1, ContextOperand(cp, Context::QML_GLOBAL_INDEX));
+ __ str(r1, ContextOperand(r0, Context::QML_GLOBAL_INDEX));
+
// Initialize the rest of the slots to the hole value.
__ LoadRoot(r1, Heap::kTheHoleValueRootIndex);
for (int i = 0; i < slots_; i++) {
// Possibly allocate a local context.
int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
- if (heap_slots > 0) {
+ if (heap_slots > 0 ||
+ (scope()->is_qml_mode() && scope()->is_global_scope())) {
Comment cmnt(masm_, "[ Allocate local context");
// Argument to NewContext is the function, which is in r1.
__ push(r1);
if (heap_slots <= FastNewContextStub::kMaximumSlots) {
- FastNewContextStub stub(heap_slots);
+ FastNewContextStub stub((heap_slots < 0)?0:heap_slots);
__ CallStub(&stub);
} else {
__ CallRuntime(Runtime::kNewFunctionContext, 1);
__ bind(&fast);
}
- __ ldr(r0, GlobalObjectOperand());
+ __ ldr(r0, var->is_qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
__ mov(r2, Operand(var->name()));
- RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF)
+ RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF || var->is_qml_global())
? RelocInfo::CODE_TARGET
: RelocInfo::CODE_TARGET_CONTEXT;
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
Comment cmnt(masm_, "Global variable");
// Use inline caching. Variable name is passed in r2 and the global
// object (receiver) in r0.
- __ ldr(r0, GlobalObjectOperand());
+ __ ldr(r0, var->is_qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
__ mov(r2, Operand(var->name()));
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
- __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT);
+ __ Call(ic, var->is_qml_global()?RelocInfo::CODE_TARGET:RelocInfo::CODE_TARGET_CONTEXT);
context()->Plug(r0);
break;
}
if (var->IsUnallocated()) {
// Global var, const, or let.
__ mov(r2, Operand(var->name()));
- __ ldr(r1, GlobalObjectOperand());
+ __ ldr(r1, var->is_qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
Handle<Code> ic = is_strict_mode()
? isolate()->builtins()->StoreIC_Initialize_Strict()
: isolate()->builtins()->StoreIC_Initialize();
FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
__ mov(r1, Operand(Smi::FromInt(strict_mode)));
__ push(r1);
+ // Push the qml mode flag.
+ __ mov(r1, Operand(Smi::FromInt(is_qml_mode())));
+ __ push(r1);
- __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 4);
+ __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5);
}
context()->DropAndPlug(1, r0);
} else if (proxy != NULL && proxy->var()->IsUnallocated()) {
// Push global object as receiver for the call IC.
- __ ldr(r0, GlobalObjectOperand());
+ __ ldr(r0, proxy->var()->is_qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
__ push(r0);
- EmitCallWithIC(expr, proxy->name(), RelocInfo::CODE_TARGET_CONTEXT);
+ EmitCallWithIC(expr, proxy->name(), proxy->var()->is_qml_global()?RelocInfo::CODE_TARGET:RelocInfo::CODE_TARGET_CONTEXT);
} else if (proxy != NULL && proxy->var()->IsLookupSlot()) {
// Call to a lookup slot (dynamically introduced variable).
Label slow, done;
// but "delete this" is allowed.
ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
if (var->IsUnallocated()) {
- __ ldr(r2, GlobalObjectOperand());
+ __ ldr(r2, var->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
__ mov(r1, Operand(var->name()));
__ mov(r0, Operand(Smi::FromInt(kNonStrictMode)));
__ Push(r2, r1, r0);
VariableProxy* proxy = expr->AsVariableProxy();
if (proxy != NULL && proxy->var()->IsUnallocated()) {
Comment cmnt(masm_, "Global variable");
- __ ldr(r0, GlobalObjectOperand());
+ __ ldr(r0, proxy->var()->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
__ mov(r2, Operand(proxy->name()));
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
// Use a regular load, not a contextual load, to avoid a reference
LInstruction* LChunkBuilder::DoGlobalObject(HGlobalObject* instr) {
LOperand* context = UseRegisterAtStart(instr->value());
- return DefineAsRegister(new LGlobalObject(context));
+ return DefineAsRegister(new LGlobalObject(context, instr->qml_global()));
}
LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) {
argument_count_ -= instr->argument_count();
- return MarkAsCall(DefineFixed(new LCallGlobal, r0), instr);
+ return MarkAsCall(DefineFixed(new LCallGlobal(instr->qml_global()), r0), instr);
}
class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
public:
- explicit LGlobalObject(LOperand* context) {
+ explicit LGlobalObject(LOperand* context, bool qml_global) {
inputs_[0] = context;
+ qml_global_ = qml_global;
}
DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
LOperand* context() { return InputAt(0); }
+ bool qml_global() { return qml_global_; }
+ private:
+ bool qml_global_;
};
DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
+ explicit LCallGlobal(bool qml_global) : qml_global_(qml_global) {}
+
virtual void PrintDataTo(StringStream* stream);
Handle<String> name() const {return hydrogen()->name(); }
int arity() const { return hydrogen()->argument_count() - 1; }
+
+ bool qml_global() { return qml_global_; }
+ private:
+ bool qml_global_;
};
// Possibly allocate a local context.
int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
- if (heap_slots > 0) {
+ if (heap_slots > 0 ||
+ (scope()->is_qml_mode() && scope()->is_global_scope())) {
Comment(";;; Allocate local context");
// Argument to NewContext is the function, which is in r1.
__ push(r1);
if (heap_slots <= FastNewContextStub::kMaximumSlots) {
- FastNewContextStub stub(heap_slots);
+ FastNewContextStub stub((heap_slots < 0)?0:heap_slots);
__ CallStub(&stub);
} else {
__ CallRuntime(Runtime::kNewFunctionContext, 1);
void LCodeGen::DoGlobalObject(LGlobalObject* instr) {
Register result = ToRegister(instr->result());
- __ ldr(result, ContextOperand(cp, Context::GLOBAL_INDEX));
+ __ ldr(result, ContextOperand(cp, instr->qml_global()?Context::QML_GLOBAL_INDEX:Context::GLOBAL_INDEX));
}
ASSERT(ToRegister(instr->result()).is(r0));
int arity = instr->arity();
- RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT;
+ RelocInfo::Mode mode = instr->qml_global()?RelocInfo::CODE_TARGET:RelocInfo::CODE_TARGET_CONTEXT;
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arity, mode);
__ mov(r2, Operand(instr->name()));
}
+static inline MemOperand QmlGlobalObjectOperand() {
+ return ContextOperand(cp, Context::QML_GLOBAL_INDEX);
+}
+
+
#ifdef GENERATED_CODE_COVERAGE
#define CODE_COVERAGE_STRINGIFY(x) #x
#define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x)
}
+bool FunctionLiteral::qml_mode() const {
+ return scope()->is_qml_mode();
+}
+
+
} } // namespace v8::internal
#endif // V8_AST_INL_H_
is_monomorphic_ = oracle->CallIsMonomorphic(this);
Property* property = expression()->AsProperty();
if (property == NULL) {
+ if (VariableProxy *proxy = expression()->AsVariableProxy()) {
+ if (proxy->var()->is_qml_global())
+ return;
+ }
+
// Function call. Specialize for monomorphic calls.
if (is_monomorphic_) target_ = oracle->GetCallTarget(this);
} else {
bool is_anonymous() const { return is_anonymous_; }
bool strict_mode() const { return strict_mode_flag() == kStrictMode; }
StrictModeFlag strict_mode_flag() const;
+ bool qml_mode() const;
int materialized_literal_count() { return materialized_literal_count_; }
int expected_property_count() { return expected_property_count_; }
Handle<JSBuiltinsObject> builtins_global(global_context_->builtins());
global_context_->set_extension(*inner_global);
global_context_->set_global(*inner_global);
+ global_context_->set_qml_global(*inner_global);
global_context_->set_security_token(*inner_global);
static const PropertyAttributes attributes =
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
// Set extension and global object.
global_context()->set_extension(*inner_global);
global_context()->set_global(*inner_global);
+ global_context()->set_qml_global(*inner_global);
// Security setup: Set the security token of the global object to
// its the inner global. This makes the security check between two
// different contexts fail by default even in case of global
static const int kMaximumSlots = 64;
explicit FastNewContextStub(int slots) : slots_(slots) {
- ASSERT(slots_ > 0 && slots_ <= kMaximumSlots);
+ ASSERT(slots_ >= 0 && slots_ <= kMaximumSlots);
}
void Generate(MacroAssembler* masm);
static const int kMaximumSlots = 64;
explicit FastNewBlockContextStub(int slots) : slots_(slots) {
- ASSERT(slots_ > 0 && slots_ <= kMaximumSlots);
+ ASSERT(slots_ >= 0 && slots_ <= kMaximumSlots);
}
void Generate(MacroAssembler* masm);
v8::Extension* extension,
ScriptDataImpl* input_pre_data,
Handle<Object> script_data,
- NativesFlag natives) {
+ NativesFlag natives,
+ v8::Script::CompileFlags compile_flags) {
Isolate* isolate = source->GetIsolate();
int source_length = source->length();
isolate->counters()->total_load_size()->Increment(source_length);
info.MarkAsGlobal();
info.SetExtension(extension);
info.SetPreParseData(pre_data);
+ if (compile_flags & v8::Script::QmlMode) info.MarkAsQmlMode();
result = MakeFunctionInfo(&info);
if (extension == NULL && !result.is_null()) {
compilation_cache->PutScript(source, result);
Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source,
Handle<Context> context,
bool is_global,
- StrictModeFlag strict_mode) {
+ StrictModeFlag strict_mode,
+ bool qml_mode) {
Isolate* isolate = source->GetIsolate();
int source_length = source->length();
isolate->counters()->total_eval_size()->Increment(source_length);
info.MarkAsEval();
if (is_global) info.MarkAsGlobal();
info.SetStrictModeFlag(strict_mode);
+ if (qml_mode) info.MarkAsQmlMode();
info.SetCallingContext(context);
result = MakeFunctionInfo(&info);
if (!result.is_null()) {
info->SetStrictModeFlag(strict_mode);
shared->set_strict_mode_flag(strict_mode);
+ // After parsing we know function's qml mode. Remember it.
+ if (info->function()->qml_mode()) {
+ shared->set_qml_mode(true);
+ info->MarkAsQmlMode();
+ }
+
// Compile the code.
if (!MakeCode(info)) {
if (!isolate->has_pending_exception()) {
*lit->this_property_assignments());
function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation());
function_info->set_strict_mode_flag(lit->strict_mode_flag());
+ function_info->set_qml_mode(lit->qml_mode());
function_info->set_uses_arguments(lit->scope()->arguments() != NULL);
function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters());
}
return StrictModeFlagField::decode(flags_);
}
bool is_in_loop() const { return IsInLoop::decode(flags_); }
+ bool is_qml_mode() const { return IsQmlMode::decode(flags_); }
FunctionLiteral* function() const { return function_; }
Scope* scope() const { return scope_; }
Handle<Code> code() const { return code_; }
ASSERT(is_lazy());
flags_ |= IsInLoop::encode(true);
}
+ void MarkAsQmlMode() {
+ flags_ |= IsQmlMode::encode(true);
+ }
void MarkAsNative() {
flags_ |= IsNative::encode(true);
}
ASSERT(strict_mode_flag() == kNonStrictMode);
SetStrictModeFlag(shared_info_->strict_mode_flag());
}
+ if (!shared_info_.is_null() && shared_info_->qml_mode()) {
+ MarkAsQmlMode();
+ }
}
void SetMode(Mode mode) {
// If compiling for debugging produce just full code matching the
// initial mode setting.
class IsCompilingForDebugging: public BitField<bool, 8, 1> {};
-
+ // Qml mode
+ class IsQmlMode: public BitField<bool, 9, 1> {};
unsigned flags_;
v8::Extension* extension,
ScriptDataImpl* pre_data,
Handle<Object> script_data,
- NativesFlag is_natives_code);
+ NativesFlag is_natives_code,
+ v8::Script::CompileFlags = v8::Script::Default);
// Compile a String source within a context for Eval.
static Handle<SharedFunctionInfo> CompileEval(Handle<String> source,
Handle<Context> context,
bool is_global,
- StrictModeFlag strict_mode);
+ StrictModeFlag strict_mode,
+ bool qml_mode);
// Compile from function info (used for lazy compilation). Returns true on
// success and false if the compilation resulted in a stack overflow.
PrintF(")\n");
}
+ Handle<JSObject> qml_global;
+ Handle<JSObject> qml_global_global;
+
do {
if (FLAG_trace_contexts) {
PrintF(" - looking in context %p", reinterpret_cast<void*>(*context));
PrintF("\n");
}
+ if (qml_global.is_null() && !context->qml_global()->IsUndefined()) {
+ qml_global = Handle<JSObject>(context->qml_global(), isolate);
+ qml_global_global = Handle<JSObject>(context->global(), isolate);
+ }
+
// 1. Check global objects, subjects of with, and extension objects.
if (context->IsGlobalContext() ||
context->IsWithContext() ||
}
} while (follow_context_chain);
+ if (!qml_global.is_null()) {
+ if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0) {
+ *attributes = qml_global_global->GetLocalPropertyAttribute(*name);
+ } else {
+ *attributes = qml_global_global->GetPropertyAttribute(*name);
+ }
+
+ if (*attributes != ABSENT) {
+ *attributes = ABSENT;
+ } else {
+ if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0) {
+ *attributes = qml_global->GetLocalPropertyAttribute(*name);
+ } else {
+ *attributes = qml_global->GetPropertyAttribute(*name);
+ }
+
+ if (*attributes != ABSENT) {
+ // property found
+ if (FLAG_trace_contexts) {
+ PrintF("=> found property in qml global object %p\n",
+ reinterpret_cast<void*>(*qml_global));
+ }
+ return qml_global;
+ }
+ }
+ }
+
if (FLAG_trace_contexts) {
PrintF("=> no property/slot found\n");
}
// (with contexts), or the variable name (catch contexts), the serialized
// scope info (block contexts).
EXTENSION_INDEX,
+ QML_GLOBAL_INDEX,
GLOBAL_INDEX,
MIN_CONTEXT_SLOTS,
}
void set_global(GlobalObject* global) { set(GLOBAL_INDEX, global); }
+ JSObject *qml_global() { return reinterpret_cast<JSObject *>(get(QML_GLOBAL_INDEX)); }
+ void set_qml_global(JSObject *qml_global) { set(QML_GLOBAL_INDEX, qml_global); }
+
// Returns a JSGlobalProxy object or null.
JSObject* global_proxy();
void set_global_proxy(JSObject* global);
Handle<Object> receiver,
int argc,
Handle<Object> args[],
- bool* has_pending_exception) {
+ bool* has_pending_exception,
+ Handle<Object> qml) {
Isolate* isolate = function->GetIsolate();
// Entering JavaScript.
// make the current one is indeed a global object.
ASSERT(function->context()->global()->IsGlobalObject());
+ Handle<JSObject> oldqml;
+ if (!qml.is_null()) {
+ oldqml = Handle<JSObject>(function->context()->qml_global());
+ function->context()->set_qml_global(JSObject::cast(*qml));
+ }
+
{
// Save and restore context around invocation and block the
// allocation of handles without explicit handle scopes.
CALL_GENERATED_CODE(stub_entry, function_entry, func, recv, argc, argv);
}
+ if (!qml.is_null())
+ function->context()->set_qml_global(*oldqml);
+
#ifdef DEBUG
value->Verify();
#endif
int argc,
Handle<Object> argv[],
bool* pending_exception,
- bool convert_receiver) {
+ bool convert_receiver)
+{
+ return Call(callable, receiver, argc, argv, pending_exception, convert_receiver, Handle<Object>());
+}
+
+Handle<Object> Execution::Call(Handle<Object> callable,
+ Handle<Object> receiver,
+ int argc,
+ Handle<Object> argv[],
+ bool* pending_exception,
+ bool convert_receiver,
+ Handle<Object> qml) {
*pending_exception = false;
if (!callable->IsJSFunction()) {
if (*pending_exception) return callable;
}
- return Invoke(false, func, receiver, argc, argv, pending_exception);
+ return Invoke(false, func, receiver, argc, argv, pending_exception, qml);
}
Handle<Object> argv[],
bool* pending_exception) {
return Invoke(true, func, Isolate::Current()->global(), argc, argv,
- pending_exception);
+ pending_exception, Handle<Object>());
}
*caught_exception = false;
Handle<Object> result = Invoke(false, func, receiver, argc, args,
- caught_exception);
+ caught_exception, Handle<Object>());
if (*caught_exception) {
ASSERT(catcher.HasCaught());
bool* pending_exception,
bool convert_receiver = false);
+ static Handle<Object> Call(Handle<Object> callable,
+ Handle<Object> receiver,
+ int argc,
+ Handle<Object> argv[],
+ bool* pending_exception,
+ bool convert_receiver,
+ Handle<Object> qml);
+
// Construct object from function, the caller supplies an array of
// arguments. Arguments are Object* type. After function returns,
// pointers in 'args' might be invalid.
// Batch declare global functions and variables.
if (global_count > 0) {
Handle<FixedArray> array =
- isolate()->factory()->NewFixedArray(2 * global_count, TENURED);
+ isolate()->factory()->NewFixedArray(3 * global_count, TENURED);
for (int j = 0, i = 0; i < length; i++) {
Declaration* decl = declarations->at(i);
Variable* var = decl->proxy()->var();
}
array->set(j++, *function);
}
+ array->set(j++, Smi::FromInt(var->is_qml_global()));
}
}
// Invoke the platform-dependent code generator to do the actual
StrictModeFlag strict_mode_flag() {
return function()->strict_mode_flag();
}
+ bool is_qml_mode() { return function()->qml_mode(); }
FunctionLiteral* function() { return info_->function(); }
Scope* scope() { return scope_; }
context->set_previous(function->context());
context->set_extension(NULL);
context->set_global(function->context()->global());
+ context->set_qml_global(function->context()->qml_global());
return context;
}
context->set_previous(previous);
context->set_extension(name);
context->set_global(previous->global());
+ context->set_qml_global(previous->qml_global());
context->set(Context::THROWN_OBJECT_INDEX, thrown_object);
return context;
}
context->set_previous(previous);
context->set_extension(extension);
context->set_global(previous->global());
+ context->set_qml_global(previous->qml_global());
return context;
}
context->set_previous(previous);
context->set_extension(scope_info);
context->set_global(previous->global());
+ context->set_qml_global(previous->qml_global());
return context;
}
}
+void HGlobalObject::PrintDataTo(StringStream* stream) {
+ stream->Add("qml_global: %s ", qml_global()?"true":"false");
+ HUnaryOperation::PrintDataTo(stream);
+}
+
void HCallGlobal::PrintDataTo(StringStream* stream) {
stream->Add("%o ", *name());
HUnaryCall::PrintDataTo(stream);
class HGlobalObject: public HUnaryOperation {
public:
- explicit HGlobalObject(HValue* context) : HUnaryOperation(context) {
+ explicit HGlobalObject(HValue* context) : HUnaryOperation(context), qml_global_(false) {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
}
+ virtual void PrintDataTo(StringStream* stream);
+
DECLARE_CONCRETE_INSTRUCTION(GlobalObject)
virtual Representation RequiredInputRepresentation(int index) {
return Representation::Tagged();
}
+ bool qml_global() { return qml_global_; }
+ void set_qml_global(bool v) { qml_global_ = v; }
+
protected:
- virtual bool DataEquals(HValue* other) { return true; }
+ virtual bool DataEquals(HValue* other) {
+ HGlobalObject* o = HGlobalObject::cast(other);
+ return o->qml_global_ == qml_global_;
+ }
+
+ private:
+ bool qml_global_;
};
class HCallGlobal: public HUnaryCall {
public:
HCallGlobal(HValue* context, Handle<String> name, int argument_count)
- : HUnaryCall(context, argument_count), name_(name) {
+ : HUnaryCall(context, argument_count), name_(name), qml_global_(false) {
}
virtual void PrintDataTo(StringStream* stream);
return Representation::Tagged();
}
+ bool qml_global() { return qml_global_; }
+ void set_qml_global(bool v) { qml_global_ = v; }
+
DECLARE_CONCRETE_INSTRUCTION(CallGlobal)
private:
Handle<String> name_;
+ bool qml_global_;
};
} else {
HValue* context = environment()->LookupContext();
HGlobalObject* global_object = new(zone()) HGlobalObject(context);
+ if (variable->is_qml_global()) global_object->set_qml_global(true);
AddInstruction(global_object);
HLoadGlobalGeneric* instr =
new(zone()) HLoadGlobalGeneric(context,
} else {
HValue* context = environment()->LookupContext();
HGlobalObject* global_object = new(zone()) HGlobalObject(context);
+ if (var->is_qml_global()) global_object->set_qml_global(true);
AddInstruction(global_object);
HStoreGlobalGeneric* instr =
new(zone()) HStoreGlobalGeneric(context,
} else {
HValue* context = environment()->LookupContext();
HGlobalObject* receiver = new(zone()) HGlobalObject(context);
+ if (var->is_qml_global()) receiver->set_qml_global(true);
AddInstruction(receiver);
PushAndAdd(new(zone()) HPushArgument(receiver));
CHECK_ALIVE(VisitArgumentList(expr->arguments()));
call = new(zone()) HCallGlobal(context, var->name(), argument_count);
+ if (var->is_qml_global()) static_cast<HCallGlobal*>(call)->set_qml_global(true);
Drop(argument_count);
}
__ mov(ebx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
__ mov(Operand(eax, Context::SlotOffset(Context::GLOBAL_INDEX)), ebx);
+ // Copy the qml global object from the previous context.
+ __ mov(ebx, Operand(esi, Context::SlotOffset(Context::QML_GLOBAL_INDEX)));
+ __ mov(Operand(eax, Context::SlotOffset(Context::QML_GLOBAL_INDEX)), ebx);
+
+
// Initialize the rest of the slots to undefined.
__ mov(ebx, factory->undefined_value());
for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) {
__ mov(ebx, ContextOperand(esi, Context::GLOBAL_INDEX));
__ mov(ContextOperand(eax, Context::GLOBAL_INDEX), ebx);
+ // Copy the qml global object from the previous context.
+ __ mov(ebx, ContextOperand(esi, Context::QML_GLOBAL_INDEX));
+ __ mov(ContextOperand(eax, Context::QML_GLOBAL_INDEX), ebx);
+
// Initialize the rest of the slots to the hole value.
if (slots_ == 1) {
__ mov(ContextOperand(eax, Context::MIN_CONTEXT_SLOTS),
// Possibly allocate a local context.
int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
- if (heap_slots > 0) {
+ if (heap_slots > 0 ||
+ (scope()->is_qml_mode() && scope()->is_global_scope())) {
Comment cmnt(masm_, "[ Allocate local context");
// Argument to NewContext is the function, which is still in edi.
__ push(edi);
if (heap_slots <= FastNewContextStub::kMaximumSlots) {
- FastNewContextStub stub(heap_slots);
+ FastNewContextStub stub((heap_slots < 0)?0:heap_slots);
__ CallStub(&stub);
} else {
__ CallRuntime(Runtime::kNewFunctionContext, 1);
// All extension objects were empty and it is safe to use a global
// load IC call.
- __ mov(eax, GlobalObjectOperand());
+ __ mov(eax, var->is_qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
__ mov(ecx, var->name());
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
- RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF)
+ RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF || var->is_qml_global())
? RelocInfo::CODE_TARGET
: RelocInfo::CODE_TARGET_CONTEXT;
__ call(ic, mode);
Comment cmnt(masm_, "Global variable");
// Use inline caching. Variable name is passed in ecx and the global
// object in eax.
- __ mov(eax, GlobalObjectOperand());
+ __ mov(eax, var->is_qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
__ mov(ecx, var->name());
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
- __ call(ic, RelocInfo::CODE_TARGET_CONTEXT);
+ __ call(ic, var->is_qml_global()?RelocInfo::CODE_TARGET:RelocInfo::CODE_TARGET_CONTEXT);
context()->Plug(eax);
break;
}
if (var->IsUnallocated()) {
// Global var, const, or let.
__ mov(ecx, var->name());
- __ mov(edx, GlobalObjectOperand());
+ __ mov(edx, var->is_qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
Handle<Code> ic = is_strict_mode()
? isolate()->builtins()->StoreIC_Initialize_Strict()
: isolate()->builtins()->StoreIC_Initialize();
FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
__ push(Immediate(Smi::FromInt(strict_mode)));
- __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 4);
+ // Push the qml mode flag
+ __ push(Immediate(Smi::FromInt(is_qml_mode())));
+
+ __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5);
}
} else if (proxy != NULL && proxy->var()->IsUnallocated()) {
// Push global object as receiver for the call IC.
- __ push(GlobalObjectOperand());
- EmitCallWithIC(expr, proxy->name(), RelocInfo::CODE_TARGET_CONTEXT);
+ __ push(proxy->var()->is_qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
+ EmitCallWithIC(expr, proxy->name(), proxy->var()->is_qml_global()?RelocInfo::CODE_TARGET:RelocInfo::CODE_TARGET_CONTEXT);
} else if (proxy != NULL && proxy->var()->IsLookupSlot()) {
// Call to a lookup slot (dynamically introduced variable).
// but "delete this" is allowed.
ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
if (var->IsUnallocated()) {
- __ push(GlobalObjectOperand());
+ __ push(var->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
__ push(Immediate(var->name()));
__ push(Immediate(Smi::FromInt(kNonStrictMode)));
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
if (proxy != NULL && proxy->var()->IsUnallocated()) {
Comment cmnt(masm_, "Global variable");
- __ mov(eax, GlobalObjectOperand());
+ __ mov(eax, proxy->var()->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
__ mov(ecx, Immediate(proxy->name()));
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
// Use a regular load, not a contextual load, to avoid a reference
// Possibly allocate a local context.
int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
- if (heap_slots > 0) {
+ if (heap_slots > 0 ||
+ (scope()->is_qml_mode() && scope()->is_global_scope())) {
Comment(";;; Allocate local context");
// Argument to NewContext is the function, which is still in edi.
__ push(edi);
if (heap_slots <= FastNewContextStub::kMaximumSlots) {
- FastNewContextStub stub(heap_slots);
+ FastNewContextStub stub((heap_slots < 0)?0:heap_slots);
__ CallStub(&stub);
} else {
__ CallRuntime(Runtime::kNewFunctionContext, 1);
void LCodeGen::DoGlobalObject(LGlobalObject* instr) {
Register context = ToRegister(instr->context());
Register result = ToRegister(instr->result());
- __ mov(result, Operand(context, Context::SlotOffset(Context::GLOBAL_INDEX)));
+ __ mov(result, Operand(context, Context::SlotOffset(instr->qml_global()?Context::QML_GLOBAL_INDEX:Context::GLOBAL_INDEX)));
}
ASSERT(ToRegister(instr->result()).is(eax));
int arity = instr->arity();
- RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT;
+ RelocInfo::Mode mode = instr->qml_global()?RelocInfo::CODE_TARGET:RelocInfo::CODE_TARGET_CONTEXT;
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arity, mode);
__ mov(ecx, instr->name());
LInstruction* LChunkBuilder::DoGlobalObject(HGlobalObject* instr) {
LOperand* context = UseRegisterAtStart(instr->value());
- return DefineAsRegister(new(zone()) LGlobalObject(context));
+ return DefineAsRegister(new(zone()) LGlobalObject(context, instr->qml_global()));
}
LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) {
LOperand* context = UseFixed(instr->context(), esi);
argument_count_ -= instr->argument_count();
- LCallGlobal* result = new(zone()) LCallGlobal(context);
+ LCallGlobal* result = new(zone()) LCallGlobal(context, instr->qml_global());
return MarkAsCall(DefineFixed(result, eax), instr);
}
class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
public:
- explicit LGlobalObject(LOperand* context) {
+ explicit LGlobalObject(LOperand* context, bool qml_global) {
inputs_[0] = context;
+ qml_global_ = qml_global;
}
DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
LOperand* context() { return InputAt(0); }
+ bool qml_global() { return qml_global_; }
+ private:
+ bool qml_global_;
};
class LCallGlobal: public LTemplateInstruction<1, 1, 0> {
public:
- explicit LCallGlobal(LOperand* context) {
+ explicit LCallGlobal(LOperand* context, bool qml_global) : qml_global_(qml_global) {
inputs_[0] = context;
}
LOperand* context() { return inputs_[0]; }
Handle<String> name() const {return hydrogen()->name(); }
int arity() const { return hydrogen()->argument_count() - 1; }
+
+ bool qml_global() { return qml_global_; }
+ private:
+ bool qml_global_;
};
return ContextOperand(esi, Context::GLOBAL_INDEX);
}
+static inline Operand QmlGlobalObjectOperand() {
+ return ContextOperand(esi, Context::QML_GLOBAL_INDEX);
+}
// Generates an Operand for saving parameters after PrepareCallApiFunction.
Operand ApiParameterOperand(int index);
__ lw(a1, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
__ sw(a1, MemOperand(v0, Context::SlotOffset(Context::GLOBAL_INDEX)));
+ // Copy the qml global object from the surrounding context.
+ __ lw(a1, MemOperand(cp, Context::SlotOffset(Context::QML_GLOBAL_INDEX)));
+ __ sw(a1, MemOperand(v0, Context::SlotOffset(Context::QML_GLOBAL_INDEX)));
+
+
// Initialize the rest of the slots to undefined.
__ LoadRoot(a1, Heap::kUndefinedValueRootIndex);
for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) {
__ lw(a1, ContextOperand(cp, Context::GLOBAL_INDEX));
__ sw(a1, ContextOperand(v0, Context::GLOBAL_INDEX));
+ // Copy the qml global object from the surrounding context.
+ __ lw(a1, ContextOperand(cp, Context::QML_GLOBAL_INDEX));
+ __ sw(a1, ContextOperand(v0, Context::QML_GLOBAL_INDEX));
+
// Initialize the rest of the slots to the hole value.
__ LoadRoot(a1, Heap::kTheHoleValueRootIndex);
for (int i = 0; i < slots_; i++) {
// Possibly allocate a local context.
int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
- if (heap_slots > 0) {
+ if (heap_slots > 0 ||
+ (scope()->is_qml_mode() && scope()->is_global_scope())) {
Comment cmnt(masm_, "[ Allocate local context");
// Argument to NewContext is the function, which is in a1.
__ push(a1);
if (heap_slots <= FastNewContextStub::kMaximumSlots) {
- FastNewContextStub stub(heap_slots);
+ FastNewContextStub stub((heap_slots < 0)?0:heap_slots);
__ CallStub(&stub);
} else {
__ CallRuntime(Runtime::kNewFunctionContext, 1);
__ bind(&fast);
}
- __ lw(a0, GlobalObjectOperand());
+ __ lw(a0, var->is_qml_global() ? QmlGlobalObjectOperand():GlobalObjectOperand());
__ li(a2, Operand(var->name()));
- RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF)
+ RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF || var->is_qml_global())
? RelocInfo::CODE_TARGET
: RelocInfo::CODE_TARGET_CONTEXT;
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
Comment cmnt(masm_, "Global variable");
// Use inline caching. Variable name is passed in a2 and the global
// object (receiver) in a0.
- __ lw(a0, GlobalObjectOperand());
+ __ lw(a0, var->is_qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
__ li(a2, Operand(var->name()));
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
- __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT);
+ __ Call(ic, var->is_qml_global()?RelocInfo::CODE_TARGET:RelocInfo::CODE_TARGET_CONTEXT);
context()->Plug(v0);
break;
}
// Global var, const, or let.
__ mov(a0, result_register());
__ li(a2, Operand(var->name()));
- __ lw(a1, GlobalObjectOperand());
+ __ lw(a1, var->is_qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
Handle<Code> ic = is_strict_mode()
? isolate()->builtins()->StoreIC_Initialize_Strict()
: isolate()->builtins()->StoreIC_Initialize();
__ li(a1, Operand(Smi::FromInt(strict_mode)));
__ push(a1);
- __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 4);
+ // Push the qml mode flag.
+ __ li(a1, Operand(Smi::FromInt(is_qml_mode())));
+ __ push(a1);
+
+ __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5);
}
context()->DropAndPlug(1, v0);
} else if (proxy != NULL && proxy->var()->IsUnallocated()) {
// Push global object as receiver for the call IC.
- __ lw(a0, GlobalObjectOperand());
+ __ lw(a0, proxy->var()->is_qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
__ push(a0);
- EmitCallWithIC(expr, proxy->name(), RelocInfo::CODE_TARGET_CONTEXT);
+ EmitCallWithIC(expr, proxy->name(), proxy->var()->is_qml_global()?RelocInfo::CODE_TARGET:RelocInfo::CODE_TARGET_CONTEXT);
} else if (proxy != NULL && proxy->var()->IsLookupSlot()) {
// Call to a lookup slot (dynamically introduced variable).
Label slow, done;
// but "delete this" is allowed.
ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
if (var->IsUnallocated()) {
- __ lw(a2, GlobalObjectOperand());
+ __ lw(a2, var->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
__ li(a1, Operand(var->name()));
__ li(a0, Operand(Smi::FromInt(kNonStrictMode)));
__ Push(a2, a1, a0);
VariableProxy* proxy = expr->AsVariableProxy();
if (proxy != NULL && proxy->var()->IsUnallocated()) {
Comment cmnt(masm_, "Global variable");
- __ lw(a0, GlobalObjectOperand());
+ __ lw(a0, proxy->var()->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
__ li(a2, Operand(proxy->name()));
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
// Use a regular load, not a contextual load, to avoid a reference
}
+static inline MemOperand QmlGlobalObjectOperand() {
+ return ContextOperand(cp, Context::QML_GLOBAL_INDEX);
+}
+
+
// Generate a MemOperand for loading a field from an object.
static inline MemOperand FieldMemOperand(Register object, int offset) {
return MemOperand(object, offset - kHeapObjectTag);
BOOL_GETTER(SharedFunctionInfo, compiler_hints, strict_mode,
kStrictModeFunction)
+BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, qml_mode,
+ kQmlModeFunction)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
name_should_print_as_anonymous,
// Is this scope a strict mode scope?
bool IsStrictMode();
+ // Is this scope a qml mode scope?
+ bool IsQmlMode();
+
// Return the number of stack slots for code.
int NumberOfStackSlots();
inline StrictModeFlag strict_mode_flag();
inline void set_strict_mode_flag(StrictModeFlag strict_mode_flag);
+ // Indicates whether the function is a qml mode function.
+ DECL_BOOLEAN_ACCESSORS(qml_mode)
+
// False if the function definitely does not allocate an arguments object.
DECL_BOOLEAN_ACCESSORS(uses_arguments)
kCodeAgeShift,
kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize,
kStrictModeFunction,
+ kQmlModeFunction,
kUsesArguments,
kHasDuplicateParameters,
kNative,
FunctionLiteral* Parser::ParseProgram(Handle<String> source,
bool in_global_context,
- StrictModeFlag strict_mode) {
+ StrictModeFlag strict_mode,
+ bool qml_mode) {
ZoneScope zone_scope(isolate(), DONT_DELETE_ON_EXIT);
HistogramTimerScope timer(isolate()->counters()->parse());
ExternalTwoByteStringUC16CharacterStream stream(
Handle<ExternalTwoByteString>::cast(source), 0, source->length());
scanner_.Initialize(&stream);
- return DoParseProgram(source, in_global_context, strict_mode, &zone_scope);
+ return DoParseProgram(source, in_global_context, strict_mode, qml_mode, &zone_scope);
} else {
GenericStringUC16CharacterStream stream(source, 0, source->length());
scanner_.Initialize(&stream);
- return DoParseProgram(source, in_global_context, strict_mode, &zone_scope);
+ return DoParseProgram(source, in_global_context, strict_mode, qml_mode, &zone_scope);
}
}
FunctionLiteral* Parser::DoParseProgram(Handle<String> source,
bool in_global_context,
StrictModeFlag strict_mode,
+ bool qml_mode,
ZoneScope* zone_scope) {
ASSERT(top_scope_ == NULL);
ASSERT(target_stack_ == NULL);
LexicalScope lexical_scope(this, scope, isolate());
ASSERT(top_scope_->strict_mode_flag() == kNonStrictMode);
top_scope_->SetStrictModeFlag(strict_mode);
+ if (qml_mode) {
+ scope->EnableQmlMode();
+ }
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16);
bool ok = true;
int beg_loc = scanner().location().beg_pos;
scope->strict_mode_flag() == info->strict_mode_flag());
ASSERT(info->strict_mode_flag() == shared_info->strict_mode_flag());
scope->SetStrictModeFlag(shared_info->strict_mode_flag());
+ if (shared_info->qml_mode()) {
+ top_scope_->EnableQmlMode();
+ }
+
FunctionLiteral::Type type = shared_info->is_expression()
? (shared_info->is_anonymous()
? FunctionLiteral::ANONYMOUS_EXPRESSION
arguments->Add(value);
value = NULL; // zap the value to avoid the unnecessary assignment
+ int qml_mode = 0;
+ if (top_scope_->is_qml_mode() && !Isolate::Current()->global()->HasProperty(*name))
+ qml_mode = 1;
+ arguments->Add(NewNumberLiteral(qml_mode));
+
// Construct the call to Runtime_InitializeConstGlobal
// and add it to the initialization statement block.
// Note that the function does different things depending on
StrictModeFlag flag = initialization_scope->strict_mode_flag();
arguments->Add(NewNumberLiteral(flag));
+ int qml_mode = 0;
+ if (top_scope_->is_qml_mode() && !Isolate::Current()->global()->HasProperty(*name))
+ qml_mode = 1;
+ arguments->Add(NewNumberLiteral(qml_mode));
+
// Be careful not to assign a value to the global variable if
// we're in a with. The initialization value should not
// necessarily be stored in the global object in that case,
Handle<String> source = Handle<String>(String::cast(script->source()));
result = parser.ParseProgram(source,
info->is_global(),
- info->strict_mode_flag());
+ info->strict_mode_flag(),
+ info->is_qml_mode());
}
}
info->SetFunction(result);
// Returns NULL if parsing failed.
FunctionLiteral* ParseProgram(Handle<String> source,
bool in_global_context,
- StrictModeFlag strict_mode);
+ StrictModeFlag strict_mode,
+ bool qml_mode = false);
FunctionLiteral* ParseLazy(CompilationInfo* info);
FunctionLiteral* DoParseProgram(Handle<String> source,
bool in_global_context,
StrictModeFlag strict_mode,
+ bool qml_mode,
ZoneScope* zone_scope);
// Report syntax error
EmbeddedVector<char, 256> buf;
int pos = OS::SNPrintF(buf, "%s (mode = %s", info,
Variable::Mode2String(var->mode()));
+ if (var->is_qml_global()) {
+ pos += OS::SNPrintF(buf + pos, ":QML");
+ }
OS::SNPrintF(buf + pos, ")");
PrintLiteralIndented(buf.start(), value, true);
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) {
ASSERT(args.length() == 3);
HandleScope scope(isolate);
- Handle<GlobalObject> global = Handle<GlobalObject>(
- isolate->context()->global());
Handle<Context> context = args.at<Context>(0);
CONVERT_ARG_CHECKED(FixedArray, pairs, 1);
CONVERT_SMI_ARG_CHECKED(flags, 2);
+ Handle<JSObject> js_global = Handle<JSObject>(isolate->context()->global());
+ Handle<JSObject> qml_global = Handle<JSObject>(isolate->context()->qml_global());
+
// Traverse the name/value pairs and set the properties.
int length = pairs->length();
- for (int i = 0; i < length; i += 2) {
+ for (int i = 0; i < length; i += 3) {
HandleScope scope(isolate);
Handle<String> name(String::cast(pairs->get(i)));
Handle<Object> value(pairs->get(i + 1), isolate);
+ Handle<Smi> is_qml_global(Smi::cast(pairs->get(i + 2)));
+
+ Handle<JSObject> global = is_qml_global->value()?qml_global:js_global;
// We have to declare a global const property. To capture we only
// assign to it when evaluating the assignment for "const x =
NoHandleAllocation nha;
// args[0] == name
// args[1] == strict_mode
- // args[2] == value (optional)
+ // args[2] == qml_mode
+ // args[3] == value (optional)
// Determine if we need to assign to the variable if it already
// exists (based on the number of arguments).
- RUNTIME_ASSERT(args.length() == 2 || args.length() == 3);
- bool assign = args.length() == 3;
+ RUNTIME_ASSERT(args.length() == 3 || args.length() == 4);
+ bool assign = args.length() == 4;
CONVERT_ARG_CHECKED(String, name, 0);
- GlobalObject* global = isolate->context()->global();
RUNTIME_ASSERT(args[1]->IsSmi());
CONVERT_STRICT_MODE_ARG(strict_mode, 1);
+ RUNTIME_ASSERT(args[2]->IsSmi());
+ int qml_mode = Smi::cast(args[2])->value();
+
+ JSObject* global = qml_mode?isolate->context()->qml_global():isolate->context()->global();
+
// According to ECMA-262, section 12.2, page 62, the property must
// not be deletable.
PropertyAttributes attributes = DONT_DELETE;
// Found an interceptor that's not read only.
if (assign) {
return raw_holder->SetProperty(
- &lookup, *name, args[2], attributes, strict_mode);
+ &lookup, *name, args[3], attributes, strict_mode);
} else {
return isolate->heap()->undefined_value();
}
}
// Reload global in case the loop above performed a GC.
- global = isolate->context()->global();
+ global = qml_mode?isolate->context()->qml_global():isolate->context()->global();
if (assign) {
- return global->SetProperty(*name, args[2], attributes, strict_mode, true);
+ return global->SetProperty(*name, args[3], attributes, strict_mode, true);
}
return isolate->heap()->undefined_value();
}
// All constants are declared with an initial value. The name
// of the constant is the first argument and the initial value
// is the second.
- RUNTIME_ASSERT(args.length() == 2);
+ RUNTIME_ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(String, name, 0);
Handle<Object> value = args.at<Object>(1);
+ RUNTIME_ASSERT(args[2]->IsSmi());
+ int qml_mode = Smi::cast(args[2])->value();
+
// Get the current global object from top.
- GlobalObject* global = isolate->context()->global();
+ JSObject* global = qml_mode?isolate->context()->qml_global():isolate->context()->global();
// According to ECMA-262, section 12.2, page 62, the property must
// not be deletable. Since it's a const, it must be READ_ONLY too.
// Restore global object from context (in case of GC) and continue
// with setting the value.
HandleScope handle_scope(isolate);
- Handle<GlobalObject> global(isolate->context()->global());
+ Handle<JSObject> global(qml_mode?isolate->context()->qml_global():isolate->context()->global());
// BUG 1213575: Handle the case where we have to set a read-only
// property through an interceptor and only do it if it's
Handle<SharedFunctionInfo> shared = Compiler::CompileEval(source,
context,
true,
- kNonStrictMode);
+ kNonStrictMode,
+ false);
if (shared.is_null()) return Failure::Exception();
Handle<JSFunction> fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
static ObjectPair CompileGlobalEval(Isolate* isolate,
Handle<String> source,
Handle<Object> receiver,
- StrictModeFlag strict_mode) {
+ StrictModeFlag strict_mode,
+ bool qml_mode) {
Handle<Context> context = Handle<Context>(isolate->context());
Handle<Context> global_context = Handle<Context>(context->global_context());
source,
Handle<Context>(isolate->context()),
context->IsGlobalContext(),
- strict_mode);
+ strict_mode,
+ qml_mode);
if (shared.is_null()) return MakePair(Failure::Exception(), NULL);
Handle<JSFunction> compiled =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) {
- ASSERT(args.length() == 4);
+ ASSERT(args.length() == 5);
HandleScope scope(isolate);
Handle<Object> callee = args.at<Object>(0);
}
CONVERT_STRICT_MODE_ARG(strict_mode, 3);
+ ASSERT(args[4]->IsSmi());
return CompileGlobalEval(isolate,
args.at<String>(1),
args.at<Object>(2),
- strict_mode);
+ strict_mode,
+ Smi::cast(args[4])->value());
}
ZoneScope zone_scope(isolate, DELETE_ON_EXIT);
Handle<Script> script(Script::cast(shared_info->script()));
Scope* scope;
- if (index >= 0) {
+ if (index >= 0 || shared_info->qml_mode()) {
// Global code
CompilationInfo info(script);
info.MarkAsGlobal();
+ if (shared_info->qml_mode())
+ info.MarkAsQmlMode();
CHECK(ParserApi::Parse(&info));
CHECK(Scope::Analyze(&info));
scope = info.function()->scope();
ScopeType scope_type = Type();
if (scope_type == ScopeTypeGlobal) {
// The global scope is always the last in the chain.
- ASSERT(context_->IsGlobalContext());
context_ = Handle<Context>();
return;
}
!scope_info->HasContext());
return ScopeTypeLocal;
case GLOBAL_SCOPE:
- ASSERT(context_->IsGlobalContext());
+ ASSERT(context_->IsGlobalContext() || scope_info->IsQmlMode());
return ScopeTypeGlobal;
case WITH_SCOPE:
ASSERT(context_->IsWithContext());
switch (Type()) {
case ScopeIterator::ScopeTypeGlobal:
return Handle<JSObject>(CurrentContext()->global());
- case ScopeIterator::ScopeTypeLocal:
+ case ScopeIterator::ScopeTypeLocal: {
+ Handle<SerializedScopeInfo> scope_info = nested_scope_chain_.last();
+ if (scope_info->IsQmlMode())
+ ASSERT(nested_scope_chain_.length() == 2);
+ else
+ ASSERT(nested_scope_chain_.length() == 1);
// Materialize the content of the local scope into a JSObject.
- ASSERT(nested_scope_chain_.length() == 1);
return MaterializeLocalScope(isolate_, frame_, inlined_frame_index_);
+ }
case ScopeIterator::ScopeTypeWith:
// Return the with object.
return Handle<JSObject>(JSObject::cast(CurrentContext()->extension()));
Handle<JSFunction> function(JSFunction::cast(frame->function()));
Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info());
ScopeInfo<> sinfo(*scope_info);
+ bool qml_mode = function->shared()->qml_mode();
// Traverse the saved contexts chain to find the active context for the
// selected frame.
Compiler::CompileEval(function_source,
context,
context->IsGlobalContext(),
- kNonStrictMode);
+ kNonStrictMode,
+ qml_mode);
if (shared.is_null()) return Failure::Exception();
Handle<JSFunction> compiled_function =
isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context);
Handle<Object> receiver(frame->receiver(), isolate);
Handle<Object> evaluation_function =
Execution::Call(compiled_function, receiver, 0, NULL,
- &has_pending_exception);
+ &has_pending_exception, false,
+ Handle<Object>(function->context()->qml_global()));
if (has_pending_exception) return Failure::Exception();
Handle<Object> arguments = GetArgumentsObject(isolate,
// Currently, the eval code will be executed in non-strict mode,
// even in the strict code context.
Handle<SharedFunctionInfo> shared =
- Compiler::CompileEval(source, context, is_global, kNonStrictMode);
+ Compiler::CompileEval(source, context, is_global, kNonStrictMode, false);
if (shared.is_null()) return Failure::Exception();
Handle<JSFunction> compiled_function =
Handle<JSFunction>(
\
/* Eval */ \
F(GlobalReceiver, 1, 1) \
- F(ResolvePossiblyDirectEval, 4, 2) \
+ F(ResolvePossiblyDirectEval, 5, 2) \
\
F(SetProperty, -1 /* 4 or 5 */, 1) \
F(DefineOrRedefineDataProperty, 4, 1) \
/* Declarations and initialization */ \
F(DeclareGlobals, 3, 1) \
F(DeclareContextSlot, 4, 1) \
- F(InitializeVarGlobal, -1 /* 2 or 3 */, 1) \
- F(InitializeConstGlobal, 2, 1) \
+ F(InitializeVarGlobal, -1 /* 3 or 4 */, 1) \
+ F(InitializeConstGlobal, 3, 1) \
F(InitializeConstContextSlot, 3, 1) \
F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
\
: function_name_(FACTORY->empty_symbol()),
calls_eval_(scope->calls_eval()),
is_strict_mode_(scope->is_strict_mode()),
+ is_qml_mode_(scope->is_qml_mode()),
type_(scope->type()),
parameters_(scope->num_parameters()),
stack_slots_(scope->num_stack_slots()),
//
// - is strict mode scope
//
+// - is qml mode scope
+//
// - scope type
//
// - number of variables in the context object (smi) (= function context
p = ReadObject(p, &function_name_);
p = ReadBool(p, &calls_eval_);
p = ReadBool(p, &is_strict_mode_);
+ p = ReadBool(p, &is_qml_mode_);
p = ReadInt(p, &type_);
p = ReadList<Allocator>(p, &context_slots_, &context_modes_);
p = ReadList<Allocator>(p, ¶meters_);
template<class Allocator>
Handle<SerializedScopeInfo> ScopeInfo<Allocator>::Serialize() {
- // function name, calls eval, is_strict_mode, scope type,
+ // function name, calls eval, is_strict_mode, is_qml_mode, scope type,
// length for 3 tables:
- const int extra_slots = 1 + 1 + 1 + 1 + 3;
+ const int extra_slots = 1 + 1 + 1 + 1 + 1 + 3;
int length = extra_slots +
context_slots_.length() * 2 +
parameters_.length() +
p = WriteObject(p, function_name_);
p = WriteBool(p, calls_eval_);
p = WriteBool(p, is_strict_mode_);
+ p = WriteBool(p, is_qml_mode_);
p = WriteInt(p, type_);
p = WriteList(p, &context_slots_, &context_modes_);
p = WriteList(p, ¶meters_);
Object** SerializedScopeInfo::ContextEntriesAddr() {
ASSERT(length() > 0);
- // +4 for function name, calls eval, strict mode, scope type.
- return data_start() + 4;
+ // +5 for function name, calls eval, strict mode, qml mode, scope type.
+ return data_start() + 5;
}
}
+bool SerializedScopeInfo::IsQmlMode() {
+ if (length() > 0) {
+ Object** p = data_start() + 3; // +3 for function name, calls eval, strict mode.
+ bool qml_mode;
+ p = ReadBool(p, &qml_mode);
+ return qml_mode;
+ }
+ return false;
+}
+
+
ScopeType SerializedScopeInfo::Type() {
ASSERT(length() > 0);
- // +3 for function name, calls eval, strict mode.
- Object** p = data_start() + 3;
+ // +4 for function name, calls eval, strict mode, qml mode.
+ Object** p = data_start() + 4;
ScopeType type;
p = ReadInt(p, &type);
return type;
Handle<String> function_name_;
bool calls_eval_;
bool is_strict_mode_;
+ bool is_qml_mode_;
ScopeType type_;
List<Handle<String>, Allocator > parameters_;
List<Handle<String>, Allocator > stack_slots_;
#include "allocation-inl.h"
+#include "debug.h"
+
namespace v8 {
namespace internal {
// Inherit the strict mode from the parent scope.
strict_mode_flag_ = (outer_scope != NULL)
? outer_scope->strict_mode_flag_ : kNonStrictMode;
+ qml_mode_ = (outer_scope != NULL) && outer_scope->qml_mode_;
outer_scope_calls_non_strict_eval_ = false;
inner_scope_calls_eval_ = false;
force_eager_compilation_ = false;
// by 'eval' introduced variable bindings.
if (var->is_global()) {
var = NonLocal(proxy->name(), DYNAMIC_GLOBAL);
+
+ if (qml_mode_) {
+ Handle<GlobalObject> global = isolate_->global();
+
+#ifdef ENABLE_DEBUGGER_SUPPORT
+ if (isolate_->debug()->IsLoaded() && isolate_->debug()->InDebugger()) {
+ //Get the context before the debugger was entered.
+ SaveContext *save = isolate_->save_context();
+ while (save != NULL && *save->context() == *isolate_->debug()->debug_context())
+ save = save->prev();
+
+ global = Handle<GlobalObject>(save->context()->global());
+ }
+#endif
+
+ if (qml_mode_ && !global->HasProperty(*(proxy->name()))) {
+ var->set_is_qml_global(true);
+ }
+ }
+
} else {
Variable* invalidated = var;
var = NonLocal(proxy->name(), DYNAMIC_LOCAL);
// No binding has been found. Declare a variable in global scope.
ASSERT(global_scope != NULL);
var = global_scope->DeclareGlobal(proxy->name());
+
+ if (qml_mode_) {
+ Handle<GlobalObject> global = isolate_->global();
+
+#ifdef ENABLE_DEBUGGER_SUPPORT
+ if (isolate_->debug()->IsLoaded() && isolate_->debug()->InDebugger()) {
+ //Get the context before the debugger was entered.
+ SaveContext *save = isolate_->save_context();
+ while (save != NULL && *save->context() == *isolate_->debug()->debug_context())
+ save = save->prev();
+
+ global = Handle<GlobalObject>(save->context()->global());
+ }
+#endif
+
+ if (!global->HasProperty(*(proxy->name()))) {
+ var->set_is_qml_global(true);
+ }
+ }
+
break;
case UNBOUND_EVAL_SHADOWED:
// No binding has been found. But some scope makes a
// non-strict 'eval' call.
var = NonLocal(proxy->name(), DYNAMIC_GLOBAL);
+
+ if (qml_mode_) {
+ Handle<GlobalObject> global = isolate_->global();
+
+#ifdef ENABLE_DEBUGGER_SUPPORT
+ if (isolate_->debug()->IsLoaded() && isolate_->debug()->InDebugger()) {
+ //Get the context before the debugger was entered.
+ SaveContext *save = isolate_->save_context();
+ while (save != NULL && *save->context() == *isolate_->debug()->debug_context())
+ save = save->prev();
+
+ global = Handle<GlobalObject>(save->context()->global());
+ }
+#endif
+
+ if (qml_mode_ && !global->HasProperty(*(proxy->name()))) {
+ var->set_is_qml_global(true);
+ }
+ }
+
break;
case DYNAMIC_LOOKUP:
end_position_ = statement_pos;
}
+ // Enable qml mode for this scope
+ void EnableQmlMode() {
+ qml_mode_ = true;
+ }
+
// ---------------------------------------------------------------------------
// Predicates.
return is_eval_scope() || is_function_scope() || is_global_scope();
}
bool is_strict_mode() const { return strict_mode_flag() == kStrictMode; }
+ bool is_qml_mode() const { return qml_mode_; }
bool is_strict_mode_eval_scope() const {
return is_eval_scope() && is_strict_mode();
}
// Source positions.
int start_position_;
int end_position_;
+ // This scope is a qml mode scope.
+ bool qml_mode_;
// Computed via PropagateScopeInfo.
bool outer_scope_calls_non_strict_eval_;
local_if_not_shadowed_(NULL),
is_valid_LHS_(is_valid_LHS),
is_accessed_from_inner_scope_(false),
- is_used_(false) {
+ is_used_(false),
+ is_qml_global_(false) {
// names must be canonicalized for fast equality checks
ASSERT(name->IsSymbol());
}
index_ = index;
}
+ bool is_qml_global() const { return is_qml_global_; }
+ void set_is_qml_global(bool is_qml_global) { is_qml_global_ = is_qml_global; }
private:
Scope* scope_;
Handle<String> name_;
// Usage info.
bool is_accessed_from_inner_scope_; // set by variable resolver
bool is_used_;
+
+ // QML info
+ bool is_qml_global_;
};
__ movq(rbx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)));
__ movq(Operand(rax, Context::SlotOffset(Context::GLOBAL_INDEX)), rbx);
+ // Copy the qmlglobal object from the previous context.
+ __ movq(rbx, Operand(rsi, Context::SlotOffset(Context::QML_GLOBAL_INDEX)));
+ __ movq(Operand(rax, Context::SlotOffset(Context::QML_GLOBAL_INDEX)), rbx);
+
// Initialize the rest of the slots to undefined.
__ LoadRoot(rbx, Heap::kUndefinedValueRootIndex);
for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) {
__ movq(rbx, ContextOperand(rsi, Context::GLOBAL_INDEX));
__ movq(ContextOperand(rax, Context::GLOBAL_INDEX), rbx);
+ // Copy the qmlglobal object from the previous context.
+ __ movq(rbx, ContextOperand(rsi, Context::QML_GLOBAL_INDEX));
+ __ movq(ContextOperand(rax, Context::QML_GLOBAL_INDEX), rbx);
+
// Initialize the rest of the slots to the hole value.
__ LoadRoot(rbx, Heap::kTheHoleValueRootIndex);
for (int i = 0; i < slots_; i++) {
// Possibly allocate a local context.
int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
- if (heap_slots > 0) {
+ if (heap_slots > 0 ||
+ (scope()->is_qml_mode() && scope()->is_global_scope())) {
Comment cmnt(masm_, "[ Allocate local context");
// Argument to NewContext is the function, which is still in rdi.
__ push(rdi);
if (heap_slots <= FastNewContextStub::kMaximumSlots) {
- FastNewContextStub stub(heap_slots);
+ FastNewContextStub stub((heap_slots < 0)?0:heap_slots);
__ CallStub(&stub);
} else {
__ CallRuntime(Runtime::kNewFunctionContext, 1);
// All extension objects were empty and it is safe to use a global
// load IC call.
- __ movq(rax, GlobalObjectOperand());
+ __ movq(rax, var->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
__ Move(rcx, var->name());
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
- RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF)
+ RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF || var->is_qml_global())
? RelocInfo::CODE_TARGET
: RelocInfo::CODE_TARGET_CONTEXT;
__ call(ic, mode);
// Use inline caching. Variable name is passed in rcx and the global
// object on the stack.
__ Move(rcx, var->name());
- __ movq(rax, GlobalObjectOperand());
+ __ movq(rax, var->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
- __ call(ic, RelocInfo::CODE_TARGET_CONTEXT);
+ __ call(ic, var->is_qml_global() ? RelocInfo::CODE_TARGET : RelocInfo::CODE_TARGET_CONTEXT);
context()->Plug(rax);
break;
}
if (var->IsUnallocated()) {
// Global var, const, or let.
__ Move(rcx, var->name());
- __ movq(rdx, GlobalObjectOperand());
+ __ movq(rdx, var->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
Handle<Code> ic = is_strict_mode()
? isolate()->builtins()->StoreIC_Initialize_Strict()
: isolate()->builtins()->StoreIC_Initialize();
FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
__ Push(Smi::FromInt(strict_mode));
- __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 4);
+ // Push the qml mode flag
+ __ Push(Smi::FromInt(is_qml_mode()));
+ __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5);
}
} else if (proxy != NULL && proxy->var()->IsUnallocated()) {
// Call to a global variable. Push global object as receiver for the
// call IC lookup.
- __ push(GlobalObjectOperand());
- EmitCallWithIC(expr, proxy->name(), RelocInfo::CODE_TARGET_CONTEXT);
+ __ push(proxy->var()->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
+ EmitCallWithIC(expr, proxy->name(), proxy->var()->is_qml_global() ? RelocInfo::CODE_TARGET : RelocInfo::CODE_TARGET_CONTEXT);
} else if (proxy != NULL && proxy->var()->IsLookupSlot()) {
// Call to a lookup slot (dynamically introduced variable).
Label slow, done;
// but "delete this" is allowed.
ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
if (var->IsUnallocated()) {
- __ push(GlobalObjectOperand());
+ __ push(var->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
__ Push(var->name());
__ Push(Smi::FromInt(kNonStrictMode));
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
if (proxy != NULL && proxy->var()->IsUnallocated()) {
Comment cmnt(masm_, "Global variable");
__ Move(rcx, proxy->name());
- __ movq(rax, GlobalObjectOperand());
+ __ movq(rax, proxy->var()->is_qml_global() ? QmlGlobalObjectOperand() : GlobalObjectOperand());
Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
// Use a regular load, not a contextual load, to avoid a reference
// error.
// Possibly allocate a local context.
int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
- if (heap_slots > 0) {
+ if (heap_slots > 0 ||
+ (scope()->is_qml_mode() && scope()->is_global_scope())) {
Comment(";;; Allocate local context");
// Argument to NewContext is the function, which is still in rdi.
__ push(rdi);
if (heap_slots <= FastNewContextStub::kMaximumSlots) {
- FastNewContextStub stub(heap_slots);
+ FastNewContextStub stub((heap_slots < 0)?0:heap_slots);
__ CallStub(&stub);
} else {
__ CallRuntime(Runtime::kNewFunctionContext, 1);
void LCodeGen::DoGlobalObject(LGlobalObject* instr) {
Register result = ToRegister(instr->result());
- __ movq(result, GlobalObjectOperand());
+ __ movq(result, instr->qml_global()?QmlGlobalObjectOperand():GlobalObjectOperand());
}
void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
ASSERT(ToRegister(instr->result()).is(rax));
int arity = instr->arity();
- RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT;
+ RelocInfo::Mode mode = instr->qml_global()?RelocInfo::CODE_TARGET:RelocInfo::CODE_TARGET_CONTEXT;
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arity, mode);
__ Move(rcx, instr->name());
LInstruction* LChunkBuilder::DoGlobalObject(HGlobalObject* instr) {
- return DefineAsRegister(new LGlobalObject);
+ return DefineAsRegister(new LGlobalObject(instr->qml_global()));
}
LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) {
argument_count_ -= instr->argument_count();
- return MarkAsCall(DefineFixed(new LCallGlobal, rax), instr);
+ return MarkAsCall(DefineFixed(new LCallGlobal(instr->qml_global()), rax), instr);
}
class LGlobalObject: public LTemplateInstruction<1, 0, 0> {
public:
+ explicit LGlobalObject(bool qml_global) : qml_global_(qml_global) {}
+
DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
+
+ bool qml_global() { return qml_global_; }
+ private:
+ bool qml_global_;
};
DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
+ explicit LCallGlobal(bool qml_global) : qml_global_(qml_global) {}
+
virtual void PrintDataTo(StringStream* stream);
Handle<String> name() const {return hydrogen()->name(); }
int arity() const { return hydrogen()->argument_count() - 1; }
+
+ bool qml_global() { return qml_global_; }
+ private:
+ bool qml_global_;
};
}
+static inline Operand QmlGlobalObjectOperand() {
+ return ContextOperand(rsi, Context::QML_GLOBAL_INDEX);
+}
+
+
// Provides access to exit frame stack space (not GCed).
static inline Operand StackSpaceOperand(int index) {
#ifdef _WIN64