| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index feb78c03ec8155437f14aa60b5724092db486b4a..9d317ca535f9630d97ccf08d920adee1e4284ca4 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -575,39 +575,26 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) {
|
| }
|
|
|
|
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) {
|
| HandleScope scope(isolate);
|
| - ASSERT(args.length() == 3);
|
| - CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
|
| - CONVERT_SMI_ARG_CHECKED(literals_index, 1);
|
| - CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
|
| -
|
| - Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals,
|
| - literals_index, elements);
|
| - RETURN_IF_EMPTY_HANDLE(isolate, site);
|
| -
|
| - JSObject* boilerplate = JSObject::cast(site->transition_info());
|
| - if (boilerplate->elements()->map() ==
|
| - isolate->heap()->fixed_cow_array_map()) {
|
| - isolate->counters()->cow_arrays_created_runtime()->Increment();
|
| - }
|
| -
|
| - if (AllocationSite::GetMode(boilerplate->GetElementsKind()) ==
|
| - TRACK_ALLOCATION_SITE) {
|
| - return isolate->heap()->CopyJSObject(boilerplate, *site);
|
| - }
|
| -
|
| - return isolate->heap()->CopyJSObject(boilerplate);
|
| + ASSERT(args.length() == 1);
|
| + Handle<Object> name(args[0], isolate);
|
| + RUNTIME_ASSERT(name->IsString() || name->IsUndefined());
|
| + Symbol* symbol;
|
| + MaybeObject* maybe = isolate->heap()->AllocateSymbol();
|
| + if (!maybe->To(&symbol)) return maybe;
|
| + if (name->IsString()) symbol->set_name(*name);
|
| + return symbol;
|
| }
|
|
|
|
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) {
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_CreatePrivateSymbol) {
|
| HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| Handle<Object> name(args[0], isolate);
|
| RUNTIME_ASSERT(name->IsString() || name->IsUndefined());
|
| Symbol* symbol;
|
| - MaybeObject* maybe = isolate->heap()->AllocateSymbol();
|
| + MaybeObject* maybe = isolate->heap()->AllocatePrivateSymbol();
|
| if (!maybe->To(&symbol)) return maybe;
|
| if (name->IsString()) symbol->set_name(*name);
|
| return symbol;
|
| @@ -622,6 +609,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolName) {
|
| }
|
|
|
|
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolIsPrivate) {
|
| + SealHandleScope shs(isolate);
|
| + ASSERT(args.length() == 1);
|
| + CONVERT_ARG_CHECKED(Symbol, symbol, 0);
|
| + return isolate->heap()->ToBoolean(symbol->is_private());
|
| +}
|
| +
|
| +
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) {
|
| SealHandleScope shs(isolate);
|
| ASSERT(args.length() == 2);
|
| @@ -1413,7 +1408,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) {
|
| CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
|
| Handle<Object> key(args[1], isolate);
|
| Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table()));
|
| - table = ObjectHashSetAdd(table, key);
|
| + table = ObjectHashSet::Add(table, key);
|
| holder->set_table(*table);
|
| return isolate->heap()->undefined_value();
|
| }
|
| @@ -1435,7 +1430,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) {
|
| CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
|
| Handle<Object> key(args[1], isolate);
|
| Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table()));
|
| - table = ObjectHashSetRemove(table, key);
|
| + table = ObjectHashSet::Remove(table, key);
|
| holder->set_table(*table);
|
| return isolate->heap()->undefined_value();
|
| }
|
| @@ -1490,7 +1485,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MapDelete) {
|
| Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
|
| Handle<Object> lookup(table->Lookup(*key), isolate);
|
| Handle<ObjectHashTable> new_table =
|
| - PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value());
|
| + ObjectHashTable::Put(table, key, isolate->factory()->the_hole_value());
|
| holder->set_table(*new_table);
|
| return isolate->heap()->ToBoolean(!lookup->IsTheHole());
|
| }
|
| @@ -1503,7 +1498,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) {
|
| CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
|
| CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
|
| Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
|
| - Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value);
|
| + Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value);
|
| holder->set_table(*new_table);
|
| return isolate->heap()->undefined_value();
|
| }
|
| @@ -1569,7 +1564,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionDelete) {
|
| weak_collection->table()));
|
| Handle<Object> lookup(table->Lookup(*key), isolate);
|
| Handle<ObjectHashTable> new_table =
|
| - PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value());
|
| + ObjectHashTable::Put(table, key, isolate->factory()->the_hole_value());
|
| weak_collection->set_table(*new_table);
|
| return isolate->heap()->ToBoolean(!lookup->IsTheHole());
|
| }
|
| @@ -1583,7 +1578,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionSet) {
|
| Handle<Object> value(args[2], isolate);
|
| Handle<ObjectHashTable> table(
|
| ObjectHashTable::cast(weak_collection->table()));
|
| - Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value);
|
| + Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value);
|
| weak_collection->set_table(*new_table);
|
| return isolate->heap()->undefined_value();
|
| }
|
| @@ -1646,7 +1641,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetPrototype) {
|
| Handle<Object> new_value(
|
| GetPrototypeSkipHiddenPrototypes(isolate, *obj), isolate);
|
| if (!new_value->SameValue(*old_value)) {
|
| - JSObject::EnqueueChangeRecord(obj, "prototype",
|
| + JSObject::EnqueueChangeRecord(obj, "setPrototype",
|
| isolate->factory()->proto_string(),
|
| old_value);
|
| }
|
| @@ -3000,30 +2995,28 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) {
|
|
|
|
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSGeneratorObject) {
|
| - SealHandleScope shs(isolate);
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 0);
|
|
|
| JavaScriptFrameIterator it(isolate);
|
| JavaScriptFrame* frame = it.frame();
|
| - JSFunction* function = frame->function();
|
| + Handle<JSFunction> function(frame->function());
|
| RUNTIME_ASSERT(function->shared()->is_generator());
|
|
|
| - JSGeneratorObject* generator;
|
| + Handle<JSGeneratorObject> generator;
|
| if (frame->IsConstructor()) {
|
| - generator = JSGeneratorObject::cast(frame->receiver());
|
| + generator = handle(JSGeneratorObject::cast(frame->receiver()));
|
| } else {
|
| - MaybeObject* maybe_generator =
|
| - isolate->heap()->AllocateJSGeneratorObject(function);
|
| - if (!maybe_generator->To(&generator)) return maybe_generator;
|
| + generator = isolate->factory()->NewJSGeneratorObject(function);
|
| }
|
| - generator->set_function(function);
|
| + generator->set_function(*function);
|
| generator->set_context(Context::cast(frame->context()));
|
| generator->set_receiver(frame->receiver());
|
| generator->set_continuation(0);
|
| generator->set_operand_stack(isolate->heap()->empty_fixed_array());
|
| generator->set_stack_handler_index(-1);
|
|
|
| - return generator;
|
| + return *generator;
|
| }
|
|
|
|
|
| @@ -4818,6 +4811,19 @@ MaybeObject* Runtime::GetElementOrCharAt(Isolate* isolate,
|
| }
|
|
|
|
|
| +static Handle<Name> ToName(Isolate* isolate, Handle<Object> key) {
|
| + if (key->IsName()) {
|
| + return Handle<Name>::cast(key);
|
| + } else {
|
| + bool has_pending_exception = false;
|
| + Handle<Object> converted =
|
| + Execution::ToString(isolate, key, &has_pending_exception);
|
| + if (has_pending_exception) return Handle<Name>();
|
| + return Handle<Name>::cast(converted);
|
| + }
|
| +}
|
| +
|
| +
|
| MaybeObject* Runtime::HasObjectProperty(Isolate* isolate,
|
| Handle<JSReceiver> object,
|
| Handle<Object> key) {
|
| @@ -4830,16 +4836,8 @@ MaybeObject* Runtime::HasObjectProperty(Isolate* isolate,
|
| }
|
|
|
| // Convert the key to a name - possibly by calling back into JavaScript.
|
| - Handle<Name> name;
|
| - if (key->IsName()) {
|
| - name = Handle<Name>::cast(key);
|
| - } else {
|
| - bool has_pending_exception = false;
|
| - Handle<Object> converted =
|
| - Execution::ToString(isolate, key, &has_pending_exception);
|
| - if (has_pending_exception) return Failure::Exception();
|
| - name = Handle<Name>::cast(converted);
|
| - }
|
| + Handle<Name> name = ToName(isolate, key);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, name);
|
|
|
| return isolate->heap()->ToBoolean(JSReceiver::HasProperty(object, name));
|
| }
|
| @@ -4872,16 +4870,8 @@ MaybeObject* Runtime::GetObjectProperty(Isolate* isolate,
|
| }
|
|
|
| // Convert the key to a name - possibly by calling back into JavaScript.
|
| - Handle<Name> name;
|
| - if (key->IsName()) {
|
| - name = Handle<Name>::cast(key);
|
| - } else {
|
| - bool has_pending_exception = false;
|
| - Handle<Object> converted =
|
| - Execution::ToString(isolate, key, &has_pending_exception);
|
| - if (has_pending_exception) return Failure::Exception();
|
| - name = Handle<Name>::cast(converted);
|
| - }
|
| + Handle<Name> name = ToName(isolate, key);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, name);
|
|
|
| // Check if the name is trivially convertible to an index and get
|
| // the element if so.
|
| @@ -5059,12 +5049,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
|
| RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
|
| PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
|
|
|
| - LookupResult result(isolate);
|
| - js_object->LocalLookupRealNamedProperty(*name, &result);
|
| + LookupResult lookup(isolate);
|
| + js_object->LocalLookupRealNamedProperty(*name, &lookup);
|
|
|
| // Special case for callback properties.
|
| - if (result.IsPropertyCallbacks()) {
|
| - Object* callback = result.GetCallbackObject();
|
| + if (lookup.IsPropertyCallbacks()) {
|
| + Handle<Object> callback(lookup.GetCallbackObject(), isolate);
|
| // To be compatible with Safari we do not change the value on API objects
|
| // in Object.defineProperty(). Firefox disagrees here, and actually changes
|
| // the value.
|
| @@ -5075,13 +5065,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
|
| // setter to update the value instead.
|
| // TODO(mstarzinger): So far this only works if property attributes don't
|
| // change, this should be fixed once we cleanup the underlying code.
|
| - if (callback->IsForeign() && result.GetAttributes() == attr) {
|
| + if (callback->IsForeign() && lookup.GetAttributes() == attr) {
|
| Handle<Object> result_object =
|
| JSObject::SetPropertyWithCallback(js_object,
|
| - handle(callback, isolate),
|
| + callback,
|
| name,
|
| obj_value,
|
| - handle(result.holder()),
|
| + handle(lookup.holder()),
|
| kStrictMode);
|
| RETURN_IF_EMPTY_HANDLE(isolate, result_object);
|
| return *result_object;
|
| @@ -5094,8 +5084,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
|
| // map. The current version of SetObjectProperty does not handle attributes
|
| // correctly in the case where a property is a field and is reset with
|
| // new attributes.
|
| - if (result.IsFound() &&
|
| - (attr != result.GetAttributes() || result.IsPropertyCallbacks())) {
|
| + if (lookup.IsFound() &&
|
| + (attr != lookup.GetAttributes() || lookup.IsPropertyCallbacks())) {
|
| // New attributes - normalize to avoid writing to instance descriptor
|
| if (js_object->IsJSGlobalProxy()) {
|
| // Since the result is a property, the prototype will exist so
|
| @@ -5111,11 +5101,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
|
| return *result;
|
| }
|
|
|
| - return Runtime::ForceSetObjectProperty(isolate,
|
| - js_object,
|
| - name,
|
| - obj_value,
|
| - attr);
|
| + Handle<Object> result = Runtime::ForceSetObjectProperty(isolate, js_object,
|
| + name,
|
| + obj_value,
|
| + attr);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| + return *result;
|
| }
|
|
|
|
|
| @@ -5149,49 +5140,36 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDataProperty) {
|
| }
|
|
|
|
|
| -MaybeObject* Runtime::SetObjectPropertyOrFail(
|
| - Isolate* isolate,
|
| - Handle<Object> object,
|
| - Handle<Object> key,
|
| - Handle<Object> value,
|
| - PropertyAttributes attr,
|
| - StrictModeFlag strict_mode) {
|
| - CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate,
|
| - SetObjectProperty(isolate, object, key, value, attr, strict_mode));
|
| -}
|
| -
|
| -
|
| -MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
| - Handle<Object> object,
|
| - Handle<Object> key,
|
| - Handle<Object> value,
|
| - PropertyAttributes attr,
|
| - StrictModeFlag strict_mode) {
|
| +Handle<Object> Runtime::SetObjectProperty(Isolate* isolate,
|
| + Handle<Object> object,
|
| + Handle<Object> key,
|
| + Handle<Object> value,
|
| + PropertyAttributes attr,
|
| + StrictModeFlag strict_mode) {
|
| SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY;
|
| - HandleScope scope(isolate);
|
|
|
| if (object->IsUndefined() || object->IsNull()) {
|
| Handle<Object> args[2] = { key, object };
|
| Handle<Object> error =
|
| isolate->factory()->NewTypeError("non_object_property_store",
|
| HandleVector(args, 2));
|
| - return isolate->Throw(*error);
|
| + isolate->Throw(*error);
|
| + return Handle<Object>();
|
| }
|
|
|
| if (object->IsJSProxy()) {
|
| bool has_pending_exception = false;
|
| Handle<Object> name_object = key->IsSymbol()
|
| ? key : Execution::ToString(isolate, key, &has_pending_exception);
|
| - if (has_pending_exception) return Failure::Exception();
|
| + if (has_pending_exception) return Handle<Object>(); // exception
|
| Handle<Name> name = Handle<Name>::cast(name_object);
|
| - Handle<Object> result = JSReceiver::SetProperty(
|
| - Handle<JSProxy>::cast(object), name, value, attr, strict_mode);
|
| - RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| - return *result;
|
| + return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value,
|
| + attr,
|
| + strict_mode);
|
| }
|
|
|
| // If the object isn't a JavaScript object, we ignore the store.
|
| - if (!object->IsJSObject()) return *value;
|
| + if (!object->IsJSObject()) return value;
|
|
|
| Handle<JSObject> js_object = Handle<JSObject>::cast(object);
|
|
|
| @@ -5206,7 +5184,7 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
| // string does nothing with the assignment then we can ignore such
|
| // assignments.
|
| if (js_object->IsStringObjectWithCharacterAt(index)) {
|
| - return *value;
|
| + return value;
|
| }
|
|
|
| js_object->ValidateElements();
|
| @@ -5215,15 +5193,16 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
| bool has_exception;
|
| Handle<Object> number =
|
| Execution::ToNumber(isolate, value, &has_exception);
|
| - if (has_exception) return Failure::Exception();
|
| + if (has_exception) return Handle<Object>(); // exception
|
| value = number;
|
| }
|
| }
|
| - MaybeObject* result = js_object->SetElement(
|
| - index, *value, attr, strict_mode, true, set_mode);
|
| + Handle<Object> result = JSObject::SetElement(js_object, index, value, attr,
|
| + strict_mode,
|
| + true,
|
| + set_mode);
|
| js_object->ValidateElements();
|
| - if (result->IsFailure()) return result;
|
| - return *value;
|
| + return result.is_null() ? result : value;
|
| }
|
|
|
| if (key->IsName()) {
|
| @@ -5234,48 +5213,41 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
| bool has_exception;
|
| Handle<Object> number =
|
| Execution::ToNumber(isolate, value, &has_exception);
|
| - if (has_exception) return Failure::Exception();
|
| + if (has_exception) return Handle<Object>(); // exception
|
| value = number;
|
| }
|
| }
|
| - MaybeObject* result = js_object->SetElement(
|
| - index, *value, attr, strict_mode, true, set_mode);
|
| - if (result->IsFailure()) return result;
|
| + return JSObject::SetElement(js_object, index, value, attr, strict_mode,
|
| + true,
|
| + set_mode);
|
| } else {
|
| if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
|
| - Handle<Object> result =
|
| - JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
|
| - RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| + return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
|
| }
|
| - return *value;
|
| }
|
|
|
| // Call-back into JavaScript to convert the key to a string.
|
| bool has_pending_exception = false;
|
| Handle<Object> converted =
|
| Execution::ToString(isolate, key, &has_pending_exception);
|
| - if (has_pending_exception) return Failure::Exception();
|
| + if (has_pending_exception) return Handle<Object>(); // exception
|
| Handle<String> name = Handle<String>::cast(converted);
|
|
|
| if (name->AsArrayIndex(&index)) {
|
| - return js_object->SetElement(
|
| - index, *value, attr, strict_mode, true, set_mode);
|
| + return JSObject::SetElement(js_object, index, value, attr, strict_mode,
|
| + true,
|
| + set_mode);
|
| } else {
|
| - Handle<Object> result =
|
| - JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
|
| - RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| - return *result;
|
| + return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
|
| }
|
| }
|
|
|
|
|
| -MaybeObject* Runtime::ForceSetObjectProperty(Isolate* isolate,
|
| - Handle<JSObject> js_object,
|
| - Handle<Object> key,
|
| - Handle<Object> value,
|
| - PropertyAttributes attr) {
|
| - HandleScope scope(isolate);
|
| -
|
| +Handle<Object> Runtime::ForceSetObjectProperty(Isolate* isolate,
|
| + Handle<JSObject> js_object,
|
| + Handle<Object> key,
|
| + Handle<Object> value,
|
| + PropertyAttributes attr) {
|
| // Check if the given key is an array index.
|
| uint32_t index;
|
| if (key->ToArrayIndex(&index)) {
|
| @@ -5287,24 +5259,24 @@ MaybeObject* Runtime::ForceSetObjectProperty(Isolate* isolate,
|
| // string does nothing with the assignment then we can ignore such
|
| // assignments.
|
| if (js_object->IsStringObjectWithCharacterAt(index)) {
|
| - return *value;
|
| + return value;
|
| }
|
|
|
| - return js_object->SetElement(
|
| - index, *value, attr, kNonStrictMode, false, DEFINE_PROPERTY);
|
| + return JSObject::SetElement(js_object, index, value, attr, kNonStrictMode,
|
| + false,
|
| + DEFINE_PROPERTY);
|
| }
|
|
|
| if (key->IsName()) {
|
| Handle<Name> name = Handle<Name>::cast(key);
|
| if (name->AsArrayIndex(&index)) {
|
| - return js_object->SetElement(
|
| - index, *value, attr, kNonStrictMode, false, DEFINE_PROPERTY);
|
| + return JSObject::SetElement(js_object, index, value, attr, kNonStrictMode,
|
| + false,
|
| + DEFINE_PROPERTY);
|
| } else {
|
| if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
|
| - Handle<Object> result = JSObject::SetLocalPropertyIgnoreAttributes(
|
| - js_object, name, value, attr);
|
| - RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| - return *result;
|
| + return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name,
|
| + value, attr);
|
| }
|
| }
|
|
|
| @@ -5312,17 +5284,16 @@ MaybeObject* Runtime::ForceSetObjectProperty(Isolate* isolate,
|
| bool has_pending_exception = false;
|
| Handle<Object> converted =
|
| Execution::ToString(isolate, key, &has_pending_exception);
|
| - if (has_pending_exception) return Failure::Exception();
|
| + if (has_pending_exception) return Handle<Object>(); // exception
|
| Handle<String> name = Handle<String>::cast(converted);
|
|
|
| if (name->AsArrayIndex(&index)) {
|
| - return js_object->SetElement(
|
| - index, *value, attr, kNonStrictMode, false, DEFINE_PROPERTY);
|
| + return JSObject::SetElement(js_object, index, value, attr, kNonStrictMode,
|
| + false,
|
| + DEFINE_PROPERTY);
|
| } else {
|
| - Handle<Object> result = JSObject::SetLocalPropertyIgnoreAttributes(
|
| - js_object, name, value, attr);
|
| - RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| - return *result;
|
| + return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, value,
|
| + attr);
|
| }
|
| }
|
|
|
| @@ -5371,12 +5342,12 @@ MaybeObject* Runtime::DeleteObjectProperty(Isolate* isolate,
|
|
|
|
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) {
|
| - SealHandleScope shs(isolate);
|
| + HandleScope scope(isolate);
|
| RUNTIME_ASSERT(args.length() == 4 || args.length() == 5);
|
|
|
| - Handle<Object> object = args.at<Object>(0);
|
| - Handle<Object> key = args.at<Object>(1);
|
| - Handle<Object> value = args.at<Object>(2);
|
| + CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
|
| + CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
|
| + CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
|
| CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
|
| RUNTIME_ASSERT(
|
| (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
|
| @@ -5390,12 +5361,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) {
|
| strict_mode = strict_mode_flag;
|
| }
|
|
|
| - return Runtime::SetObjectProperty(isolate,
|
| - object,
|
| - key,
|
| - value,
|
| - attributes,
|
| - strict_mode);
|
| + Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key,
|
| + value,
|
| + attributes,
|
| + strict_mode);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| + return *result;
|
| }
|
|
|
|
|
| @@ -5416,11 +5387,25 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) {
|
| SealHandleScope shs(isolate);
|
| RUNTIME_ASSERT(args.length() == 1);
|
|
|
| + CONVERT_ARG_CHECKED(Object, object, 0);
|
| +
|
| + if (object->IsJSFunction()) {
|
| + JSFunction* func = JSFunction::cast(object);
|
| + func->shared()->set_native(true);
|
| + }
|
| + return isolate->heap()->undefined_value();
|
| +}
|
| +
|
| +
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInlineBuiltinFlag) {
|
| + SealHandleScope shs(isolate);
|
| + RUNTIME_ASSERT(args.length() == 1);
|
| +
|
| Handle<Object> object = args.at<Object>(0);
|
|
|
| if (object->IsJSFunction()) {
|
| JSFunction* func = JSFunction::cast(*object);
|
| - func->shared()->set_native(true);
|
| + func->shared()->set_inline_builtin(true);
|
| }
|
| return isolate->heap()->undefined_value();
|
| }
|
| @@ -6222,6 +6207,7 @@ template <class Converter>
|
| MUST_USE_RESULT static MaybeObject* ConvertCaseHelper(
|
| Isolate* isolate,
|
| String* s,
|
| + String::Encoding result_encoding,
|
| int length,
|
| int input_string_length,
|
| unibrow::Mapping<Converter, 128>* mapping) {
|
| @@ -6237,7 +6223,7 @@ MUST_USE_RESULT static MaybeObject* ConvertCaseHelper(
|
| // might break in the future if we implement more context and locale
|
| // dependent upper/lower conversions.
|
| Object* o;
|
| - { MaybeObject* maybe_o = s->IsOneByteRepresentation()
|
| + { MaybeObject* maybe_o = result_encoding == String::ONE_BYTE_ENCODING
|
| ? isolate->heap()->AllocateRawOneByteString(length)
|
| : isolate->heap()->AllocateRawTwoByteString(length);
|
| if (!maybe_o->ToObject(&o)) return maybe_o;
|
| @@ -6245,6 +6231,8 @@ MUST_USE_RESULT static MaybeObject* ConvertCaseHelper(
|
| String* result = String::cast(o);
|
| bool has_changed_character = false;
|
|
|
| + DisallowHeapAllocation no_gc;
|
| +
|
| // Convert all characters to upper case, assuming that they will fit
|
| // in the buffer
|
| Access<ConsStringIteratorOp> op(
|
| @@ -6253,6 +6241,10 @@ MUST_USE_RESULT static MaybeObject* ConvertCaseHelper(
|
| unibrow::uchar chars[Converter::kMaxWidth];
|
| // We can assume that the string is not empty
|
| uc32 current = stream.GetNext();
|
| + // y with umlauts is the only character that stops fitting into one-byte
|
| + // when converting to uppercase.
|
| + static const uc32 yuml_code = 0xff;
|
| + bool ignore_yuml = result->IsSeqTwoByteString() || Converter::kIsToLower;
|
| for (int i = 0; i < length;) {
|
| bool has_next = stream.HasMore();
|
| uc32 next = has_next ? stream.GetNext() : 0;
|
| @@ -6261,13 +6253,14 @@ MUST_USE_RESULT static MaybeObject* ConvertCaseHelper(
|
| // The case conversion of this character is the character itself.
|
| result->Set(i, current);
|
| i++;
|
| - } else if (char_length == 1) {
|
| + } else if (char_length == 1 && (ignore_yuml || current != yuml_code)) {
|
| // Common case: converting the letter resulted in one character.
|
| ASSERT(static_cast<uc32>(chars[0]) != current);
|
| result->Set(i, chars[0]);
|
| has_changed_character = true;
|
| i++;
|
| } else if (length == input_string_length) {
|
| + bool found_yuml = (current == yuml_code);
|
| // We've assumed that the result would be as long as the
|
| // input but here is a character that converts to several
|
| // characters. No matter, we calculate the exact length
|
| @@ -6287,6 +6280,7 @@ MUST_USE_RESULT static MaybeObject* ConvertCaseHelper(
|
| int current_length = i + char_length + next_length;
|
| while (stream.HasMore()) {
|
| current = stream.GetNext();
|
| + found_yuml |= (current == yuml_code);
|
| // NOTE: we use 0 as the next character here because, while
|
| // the next character may affect what a character converts to,
|
| // it does not in any case affect the length of what it convert
|
| @@ -6299,8 +6293,10 @@ MUST_USE_RESULT static MaybeObject* ConvertCaseHelper(
|
| return Failure::OutOfMemoryException(0x13);
|
| }
|
| }
|
| - // Try again with the real length.
|
| - return Smi::FromInt(current_length);
|
| + // Try again with the real length. Return signed if we need
|
| + // to allocate a two-byte string for y-umlaut to uppercase.
|
| + return (found_yuml && !ignore_yuml) ? Smi::FromInt(-current_length)
|
| + : Smi::FromInt(current_length);
|
| } else {
|
| for (int j = 0; j < char_length; j++) {
|
| result->Set(i, chars[j]);
|
| @@ -6346,121 +6342,108 @@ static inline uintptr_t AsciiRangeMask(uintptr_t w, char m, char n) {
|
| }
|
|
|
|
|
| -enum AsciiCaseConversion {
|
| - ASCII_TO_LOWER,
|
| - ASCII_TO_UPPER
|
| -};
|
| +#ifdef DEBUG
|
| +static bool CheckFastAsciiConvert(char* dst,
|
| + char* src,
|
| + int length,
|
| + bool changed,
|
| + bool is_to_lower) {
|
| + bool expected_changed = false;
|
| + for (int i = 0; i < length; i++) {
|
| + if (dst[i] == src[i]) continue;
|
| + expected_changed = true;
|
| + if (is_to_lower) {
|
| + ASSERT('A' <= src[i] && src[i] <= 'Z');
|
| + ASSERT(dst[i] == src[i] + ('a' - 'A'));
|
| + } else {
|
| + ASSERT('a' <= src[i] && src[i] <= 'z');
|
| + ASSERT(dst[i] == src[i] - ('a' - 'A'));
|
| + }
|
| + }
|
| + return (expected_changed == changed);
|
| +}
|
| +#endif
|
|
|
|
|
| -template <AsciiCaseConversion dir>
|
| -struct FastAsciiConverter {
|
| - static bool Convert(char* dst, char* src, int length, bool* changed_out) {
|
| +template<class Converter>
|
| +static bool FastAsciiConvert(char* dst,
|
| + char* src,
|
| + int length,
|
| + bool* changed_out) {
|
| #ifdef DEBUG
|
| char* saved_dst = dst;
|
| char* saved_src = src;
|
| #endif
|
| - // We rely on the distance between upper and lower case letters
|
| - // being a known power of 2.
|
| - ASSERT('a' - 'A' == (1 << 5));
|
| - // Boundaries for the range of input characters than require conversion.
|
| - const char lo = (dir == ASCII_TO_LOWER) ? 'A' - 1 : 'a' - 1;
|
| - const char hi = (dir == ASCII_TO_LOWER) ? 'Z' + 1 : 'z' + 1;
|
| - bool changed = false;
|
| - uintptr_t or_acc = 0;
|
| - char* const limit = src + length;
|
| + DisallowHeapAllocation no_gc;
|
| + // We rely on the distance between upper and lower case letters
|
| + // being a known power of 2.
|
| + ASSERT('a' - 'A' == (1 << 5));
|
| + // Boundaries for the range of input characters than require conversion.
|
| + static const char lo = Converter::kIsToLower ? 'A' - 1 : 'a' - 1;
|
| + static const char hi = Converter::kIsToLower ? 'Z' + 1 : 'z' + 1;
|
| + bool changed = false;
|
| + uintptr_t or_acc = 0;
|
| + char* const limit = src + length;
|
| #ifdef V8_HOST_CAN_READ_UNALIGNED
|
| - // Process the prefix of the input that requires no conversion one
|
| - // (machine) word at a time.
|
| - while (src <= limit - sizeof(uintptr_t)) {
|
| - uintptr_t w = *reinterpret_cast<uintptr_t*>(src);
|
| - or_acc |= w;
|
| - if (AsciiRangeMask(w, lo, hi) != 0) {
|
| - changed = true;
|
| - break;
|
| - }
|
| - *reinterpret_cast<uintptr_t*>(dst) = w;
|
| - src += sizeof(uintptr_t);
|
| - dst += sizeof(uintptr_t);
|
| - }
|
| - // Process the remainder of the input performing conversion when
|
| - // required one word at a time.
|
| - while (src <= limit - sizeof(uintptr_t)) {
|
| - uintptr_t w = *reinterpret_cast<uintptr_t*>(src);
|
| - or_acc |= w;
|
| - uintptr_t m = AsciiRangeMask(w, lo, hi);
|
| - // The mask has high (7th) bit set in every byte that needs
|
| - // conversion and we know that the distance between cases is
|
| - // 1 << 5.
|
| - *reinterpret_cast<uintptr_t*>(dst) = w ^ (m >> 2);
|
| - src += sizeof(uintptr_t);
|
| - dst += sizeof(uintptr_t);
|
| - }
|
| -#endif
|
| - // Process the last few bytes of the input (or the whole input if
|
| - // unaligned access is not supported).
|
| - while (src < limit) {
|
| - char c = *src;
|
| - or_acc |= c;
|
| - if (lo < c && c < hi) {
|
| - c ^= (1 << 5);
|
| - changed = true;
|
| - }
|
| - *dst = c;
|
| - ++src;
|
| - ++dst;
|
| - }
|
| - if ((or_acc & kAsciiMask) != 0) {
|
| - return false;
|
| - }
|
| -#ifdef DEBUG
|
| - CheckConvert(saved_dst, saved_src, length, changed);
|
| -#endif
|
| - *changed_out = changed;
|
| - return true;
|
| - }
|
| -
|
| -#ifdef DEBUG
|
| - static void CheckConvert(char* dst, char* src, int length, bool changed) {
|
| - bool expected_changed = false;
|
| - for (int i = 0; i < length; i++) {
|
| - if (dst[i] == src[i]) continue;
|
| - expected_changed = true;
|
| - if (dir == ASCII_TO_LOWER) {
|
| - ASSERT('A' <= src[i] && src[i] <= 'Z');
|
| - ASSERT(dst[i] == src[i] + ('a' - 'A'));
|
| - } else {
|
| - ASSERT(dir == ASCII_TO_UPPER);
|
| - ASSERT('a' <= src[i] && src[i] <= 'z');
|
| - ASSERT(dst[i] == src[i] - ('a' - 'A'));
|
| - }
|
| + // Process the prefix of the input that requires no conversion one
|
| + // (machine) word at a time.
|
| + while (src <= limit - sizeof(uintptr_t)) {
|
| + uintptr_t w = *reinterpret_cast<uintptr_t*>(src);
|
| + or_acc |= w;
|
| + if (AsciiRangeMask(w, lo, hi) != 0) {
|
| + changed = true;
|
| + break;
|
| }
|
| - ASSERT(expected_changed == changed);
|
| + *reinterpret_cast<uintptr_t*>(dst) = w;
|
| + src += sizeof(uintptr_t);
|
| + dst += sizeof(uintptr_t);
|
| + }
|
| + // Process the remainder of the input performing conversion when
|
| + // required one word at a time.
|
| + while (src <= limit - sizeof(uintptr_t)) {
|
| + uintptr_t w = *reinterpret_cast<uintptr_t*>(src);
|
| + or_acc |= w;
|
| + uintptr_t m = AsciiRangeMask(w, lo, hi);
|
| + // The mask has high (7th) bit set in every byte that needs
|
| + // conversion and we know that the distance between cases is
|
| + // 1 << 5.
|
| + *reinterpret_cast<uintptr_t*>(dst) = w ^ (m >> 2);
|
| + src += sizeof(uintptr_t);
|
| + dst += sizeof(uintptr_t);
|
| }
|
| #endif
|
| -};
|
| -
|
| -
|
| -struct ToLowerTraits {
|
| - typedef unibrow::ToLowercase UnibrowConverter;
|
| -
|
| - typedef FastAsciiConverter<ASCII_TO_LOWER> AsciiConverter;
|
| -};
|
| -
|
| + // Process the last few bytes of the input (or the whole input if
|
| + // unaligned access is not supported).
|
| + while (src < limit) {
|
| + char c = *src;
|
| + or_acc |= c;
|
| + if (lo < c && c < hi) {
|
| + c ^= (1 << 5);
|
| + changed = true;
|
| + }
|
| + *dst = c;
|
| + ++src;
|
| + ++dst;
|
| + }
|
| + if ((or_acc & kAsciiMask) != 0) {
|
| + return false;
|
| + }
|
|
|
| -struct ToUpperTraits {
|
| - typedef unibrow::ToUppercase UnibrowConverter;
|
| + ASSERT(CheckFastAsciiConvert(
|
| + saved_dst, saved_src, length, changed, Converter::kIsToLower));
|
|
|
| - typedef FastAsciiConverter<ASCII_TO_UPPER> AsciiConverter;
|
| -};
|
| + *changed_out = changed;
|
| + return true;
|
| +}
|
|
|
| } // namespace
|
|
|
|
|
| -template <typename ConvertTraits>
|
| +template <class Converter>
|
| MUST_USE_RESULT static MaybeObject* ConvertCase(
|
| Arguments args,
|
| Isolate* isolate,
|
| - unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) {
|
| + unibrow::Mapping<Converter, 128>* mapping) {
|
| SealHandleScope shs(isolate);
|
| CONVERT_ARG_CHECKED(String, s, 0);
|
| s = s->TryFlattenGetString();
|
| @@ -6482,7 +6465,7 @@ MUST_USE_RESULT static MaybeObject* ConvertCase(
|
| }
|
| SeqOneByteString* result = SeqOneByteString::cast(o);
|
| bool has_changed_character;
|
| - bool is_ascii = ConvertTraits::AsciiConverter::Convert(
|
| + bool is_ascii = FastAsciiConvert<Converter>(
|
| reinterpret_cast<char*>(result->GetChars()),
|
| reinterpret_cast<char*>(SeqOneByteString::cast(s)->GetChars()),
|
| length,
|
| @@ -6493,31 +6476,35 @@ MUST_USE_RESULT static MaybeObject* ConvertCase(
|
| }
|
| }
|
|
|
| + String::Encoding result_encoding = s->IsOneByteRepresentation()
|
| + ? String::ONE_BYTE_ENCODING : String::TWO_BYTE_ENCODING;
|
| Object* answer;
|
| - { MaybeObject* maybe_answer =
|
| - ConvertCaseHelper(isolate, s, length, length, mapping);
|
| + { MaybeObject* maybe_answer = ConvertCaseHelper(
|
| + isolate, s, result_encoding, length, length, mapping);
|
| if (!maybe_answer->ToObject(&answer)) return maybe_answer;
|
| }
|
| if (answer->IsSmi()) {
|
| - // Retry with correct length.
|
| - { MaybeObject* maybe_answer =
|
| - ConvertCaseHelper(isolate,
|
| - s, Smi::cast(answer)->value(), length, mapping);
|
| - if (!maybe_answer->ToObject(&answer)) return maybe_answer;
|
| + int new_length = Smi::cast(answer)->value();
|
| + if (new_length < 0) {
|
| + result_encoding = String::TWO_BYTE_ENCODING;
|
| + new_length = -new_length;
|
| }
|
| + MaybeObject* maybe_answer = ConvertCaseHelper(
|
| + isolate, s, result_encoding, new_length, length, mapping);
|
| + if (!maybe_answer->ToObject(&answer)) return maybe_answer;
|
| }
|
| return answer;
|
| }
|
|
|
|
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToLowerCase) {
|
| - return ConvertCase<ToLowerTraits>(
|
| + return ConvertCase(
|
| args, isolate, isolate->runtime_state()->to_lower_mapping());
|
| }
|
|
|
|
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToUpperCase) {
|
| - return ConvertCase<ToUpperTraits>(
|
| + return ConvertCase(
|
| args, isolate, isolate->runtime_state()->to_upper_mapping());
|
| }
|
|
|
| @@ -7847,6 +7834,35 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) {
|
| }
|
|
|
|
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_PopulateTrigonometricTable) {
|
| + HandleScope scope(isolate);
|
| + ASSERT(args.length() == 3);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sin_table, 0);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, cos_table, 1);
|
| + CONVERT_SMI_ARG_CHECKED(samples, 2);
|
| + RUNTIME_ASSERT(sin_table->type() == kExternalDoubleArray);
|
| + RUNTIME_ASSERT(cos_table->type() == kExternalDoubleArray);
|
| + double* sin_buffer = reinterpret_cast<double*>(
|
| + JSArrayBuffer::cast(sin_table->buffer())->backing_store());
|
| + double* cos_buffer = reinterpret_cast<double*>(
|
| + JSArrayBuffer::cast(cos_table->buffer())->backing_store());
|
| +
|
| + static const double pi_half = 3.1415926535897932 / 2;
|
| + double interval = pi_half / samples;
|
| + for (int i = 0; i < samples + 1; i++) {
|
| + double sample = sin(i * interval);
|
| + sin_buffer[i] = sample;
|
| + cos_buffer[samples - i] = sample * interval;
|
| + }
|
| +
|
| + // Fill this to catch out of bound accesses when calculating Math.sin(pi/2).
|
| + sin_buffer[samples + 1] = sin(pi_half + interval);
|
| + cos_buffer[samples + 1] = cos(pi_half + interval) * interval;
|
| +
|
| + return isolate->heap()->undefined_value();
|
| +}
|
| +
|
| +
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) {
|
| SealHandleScope shs(isolate);
|
| ASSERT(args.length() == 2);
|
| @@ -9755,30 +9771,25 @@ RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) {
|
| }
|
|
|
|
|
| +// Allocate a block of memory in the given space (filled with a filler).
|
| +// Used as a fall-back for generated code when the space is full.
|
| static MaybeObject* Allocate(Isolate* isolate,
|
| int size,
|
| AllocationSpace space) {
|
| - // Allocate a block of memory in the given space (filled with a filler).
|
| - // Use as fallback for allocation in generated code when the space
|
| - // is full.
|
| - SealHandleScope shs(isolate);
|
| + Heap* heap = isolate->heap();
|
| RUNTIME_ASSERT(IsAligned(size, kPointerSize));
|
| RUNTIME_ASSERT(size > 0);
|
| - Heap* heap = isolate->heap();
|
| RUNTIME_ASSERT(size <= heap->MaxRegularSpaceAllocationSize());
|
| - Object* allocation;
|
| - { MaybeObject* maybe_allocation;
|
| - if (space == NEW_SPACE) {
|
| - maybe_allocation = heap->new_space()->AllocateRaw(size);
|
| - } else {
|
| - ASSERT(space == OLD_POINTER_SPACE || space == OLD_DATA_SPACE);
|
| - maybe_allocation = heap->paged_space(space)->AllocateRaw(size);
|
| - }
|
| - if (maybe_allocation->ToObject(&allocation)) {
|
| - heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
|
| - }
|
| - return maybe_allocation;
|
| + HeapObject* allocation;
|
| + { MaybeObject* maybe_allocation = heap->AllocateRaw(size, space, space);
|
| + if (!maybe_allocation->To(&allocation)) return maybe_allocation;
|
| }
|
| +#ifdef DEBUG
|
| + MemoryChunk* chunk = MemoryChunk::FromAddress(allocation->address());
|
| + ASSERT(chunk->owner()->identity() == space);
|
| +#endif
|
| + heap->CreateFillerObjectAt(allocation->address(), size);
|
| + return allocation;
|
| }
|
|
|
|
|
| @@ -10548,11 +10559,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) {
|
| // property.
|
| // Returns the number of non-undefined elements collected.
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) {
|
| - SealHandleScope shs(isolate);
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
| - CONVERT_ARG_CHECKED(JSObject, object, 0);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
|
| CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
|
| - return object->PrepareElementsForSort(limit);
|
| + return *JSObject::PrepareElementsForSort(object, limit);
|
| }
|
|
|
|
|
| @@ -11377,12 +11388,12 @@ static Handle<JSObject> MaterializeStackLocalsWithFrameInspector(
|
|
|
| RETURN_IF_EMPTY_HANDLE_VALUE(
|
| isolate,
|
| - SetProperty(isolate,
|
| - target,
|
| - Handle<String>(scope_info->ParameterName(i)),
|
| - value,
|
| - NONE,
|
| - kNonStrictMode),
|
| + Runtime::SetObjectProperty(isolate,
|
| + target,
|
| + Handle<String>(scope_info->ParameterName(i)),
|
| + value,
|
| + NONE,
|
| + kNonStrictMode),
|
| Handle<JSObject>());
|
| }
|
|
|
| @@ -11393,12 +11404,13 @@ static Handle<JSObject> MaterializeStackLocalsWithFrameInspector(
|
|
|
| RETURN_IF_EMPTY_HANDLE_VALUE(
|
| isolate,
|
| - SetProperty(isolate,
|
| - target,
|
| - Handle<String>(scope_info->StackLocalName(i)),
|
| - value,
|
| - NONE,
|
| - kNonStrictMode),
|
| + Runtime::SetObjectProperty(
|
| + isolate,
|
| + target,
|
| + Handle<String>(scope_info->StackLocalName(i)),
|
| + value,
|
| + NONE,
|
| + kNonStrictMode),
|
| Handle<JSObject>());
|
| }
|
|
|
| @@ -11476,12 +11488,12 @@ static Handle<JSObject> MaterializeLocalContext(Isolate* isolate,
|
| Handle<String> key(String::cast(keys->get(i)));
|
| RETURN_IF_EMPTY_HANDLE_VALUE(
|
| isolate,
|
| - SetProperty(isolate,
|
| - target,
|
| - key,
|
| - GetProperty(isolate, ext, key),
|
| - NONE,
|
| - kNonStrictMode),
|
| + Runtime::SetObjectProperty(isolate,
|
| + target,
|
| + key,
|
| + GetProperty(isolate, ext, key),
|
| + NONE,
|
| + kNonStrictMode),
|
| Handle<JSObject>());
|
| }
|
| }
|
| @@ -11581,12 +11593,9 @@ static bool SetLocalVariableValue(Isolate* isolate,
|
| if (JSReceiver::HasProperty(ext, variable_name)) {
|
| // We don't expect this to do anything except replacing
|
| // property value.
|
| - SetProperty(isolate,
|
| - ext,
|
| - variable_name,
|
| - new_value,
|
| - NONE,
|
| - kNonStrictMode);
|
| + Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
|
| + NONE,
|
| + kNonStrictMode);
|
| return true;
|
| }
|
| }
|
| @@ -11632,12 +11641,10 @@ static Handle<JSObject> MaterializeClosure(Isolate* isolate,
|
| Handle<String> key(String::cast(keys->get(i)));
|
| RETURN_IF_EMPTY_HANDLE_VALUE(
|
| isolate,
|
| - SetProperty(isolate,
|
| - closure_scope,
|
| - key,
|
| - GetProperty(isolate, ext, key),
|
| - NONE,
|
| - kNonStrictMode),
|
| + Runtime::SetObjectProperty(isolate, closure_scope, key,
|
| + GetProperty(isolate, ext, key),
|
| + NONE,
|
| + kNonStrictMode),
|
| Handle<JSObject>());
|
| }
|
| }
|
| @@ -11668,12 +11675,9 @@ static bool SetClosureVariableValue(Isolate* isolate,
|
| Handle<JSObject> ext(JSObject::cast(context->extension()));
|
| if (JSReceiver::HasProperty(ext, variable_name)) {
|
| // We don't expect this to do anything except replacing property value.
|
| - SetProperty(isolate,
|
| - ext,
|
| - variable_name,
|
| - new_value,
|
| - NONE,
|
| - kNonStrictMode);
|
| + Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
|
| + NONE,
|
| + kNonStrictMode);
|
| return true;
|
| }
|
| }
|
| @@ -11694,12 +11698,9 @@ static Handle<JSObject> MaterializeCatchScope(Isolate* isolate,
|
| isolate->factory()->NewJSObject(isolate->object_function());
|
| RETURN_IF_EMPTY_HANDLE_VALUE(
|
| isolate,
|
| - SetProperty(isolate,
|
| - catch_scope,
|
| - name,
|
| - thrown_object,
|
| - NONE,
|
| - kNonStrictMode),
|
| + Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object,
|
| + NONE,
|
| + kNonStrictMode),
|
| Handle<JSObject>());
|
| return catch_scope;
|
| }
|
| @@ -12717,12 +12718,11 @@ static Handle<JSObject> MaterializeArgumentsObject(
|
| // FunctionGetArguments can't throw an exception.
|
| Handle<JSObject> arguments = Handle<JSObject>::cast(
|
| Accessors::FunctionGetArguments(function));
|
| - SetProperty(isolate,
|
| - target,
|
| - isolate->factory()->arguments_string(),
|
| - arguments,
|
| - ::NONE,
|
| - kNonStrictMode);
|
| + Runtime::SetObjectProperty(isolate, target,
|
| + isolate->factory()->arguments_string(),
|
| + arguments,
|
| + ::NONE,
|
| + kNonStrictMode);
|
| return target;
|
| }
|
|
|
| @@ -14752,18 +14752,25 @@ static MaybeObject* ArrayConstructorCommon(Isolate* isolate,
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConstructor) {
|
| HandleScope scope(isolate);
|
| // If we get 2 arguments then they are the stub parameters (constructor, type
|
| - // info). If we get 3, then the first one is a pointer to the arguments
|
| - // passed by the caller.
|
| + // info). If we get 4, then the first one is a pointer to the arguments
|
| + // passed by the caller, and the last one is the length of the arguments
|
| + // passed to the caller (redundant, but useful to check on the deoptimizer
|
| + // with an assert).
|
| Arguments empty_args(0, NULL);
|
| bool no_caller_args = args.length() == 2;
|
| - ASSERT(no_caller_args || args.length() == 3);
|
| + ASSERT(no_caller_args || args.length() == 4);
|
| int parameters_start = no_caller_args ? 0 : 1;
|
| Arguments* caller_args = no_caller_args
|
| ? &empty_args
|
| : reinterpret_cast<Arguments*>(args[0]);
|
| CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start);
|
| CONVERT_ARG_HANDLE_CHECKED(Object, type_info, parameters_start + 1);
|
| -
|
| +#ifdef DEBUG
|
| + if (!no_caller_args) {
|
| + CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 2);
|
| + ASSERT(arg_count == caller_args->length());
|
| + }
|
| +#endif
|
| return ArrayConstructorCommon(isolate,
|
| constructor,
|
| type_info,
|
| @@ -14775,13 +14782,18 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalArrayConstructor) {
|
| HandleScope scope(isolate);
|
| Arguments empty_args(0, NULL);
|
| bool no_caller_args = args.length() == 1;
|
| - ASSERT(no_caller_args || args.length() == 2);
|
| + ASSERT(no_caller_args || args.length() == 3);
|
| int parameters_start = no_caller_args ? 0 : 1;
|
| Arguments* caller_args = no_caller_args
|
| ? &empty_args
|
| : reinterpret_cast<Arguments*>(args[0]);
|
| CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start);
|
| -
|
| +#ifdef DEBUG
|
| + if (!no_caller_args) {
|
| + CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1);
|
| + ASSERT(arg_count == caller_args->length());
|
| + }
|
| +#endif
|
| return ArrayConstructorCommon(isolate,
|
| constructor,
|
| Handle<Object>::null(),
|
|
|