Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 165 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 166 HandleScope scope(isolate); | 166 HandleScope scope(isolate); |
| 167 Handle<JSObject> object = Utils::OpenHandle(*info.This()); | 167 Handle<JSObject> object = Utils::OpenHandle(*info.This()); |
| 168 Handle<Object> value = Utils::OpenHandle(*val); | 168 Handle<Object> value = Utils::OpenHandle(*val); |
| 169 | 169 |
| 170 if (SetPropertyOnInstanceIfInherited(isolate, info, name, value)) return; | 170 if (SetPropertyOnInstanceIfInherited(isolate, info, name, value)) return; |
| 171 | 171 |
| 172 LookupIterator it(object, Utils::OpenHandle(*name)); | 172 LookupIterator it(object, Utils::OpenHandle(*name)); |
| 173 CHECK_EQ(LookupIterator::ACCESSOR, it.state()); | 173 CHECK_EQ(LookupIterator::ACCESSOR, it.state()); |
| 174 DCHECK(it.HolderIsReceiverOrHiddenPrototype()); | 174 DCHECK(it.HolderIsReceiverOrHiddenPrototype()); |
| 175 Object::SetDataProperty(&it, value); | 175 |
| 176 if (Object::SetDataProperty(&it, value).is_null()) { | |
| 177 isolate->OptionalRescheduleException(false); | |
| 178 } | |
| 176 } | 179 } |
| 177 | 180 |
| 178 | 181 |
| 179 Handle<AccessorInfo> Accessors::ArgumentsIteratorInfo( | 182 Handle<AccessorInfo> Accessors::ArgumentsIteratorInfo( |
| 180 Isolate* isolate, PropertyAttributes attributes) { | 183 Isolate* isolate, PropertyAttributes attributes) { |
| 181 Handle<Name> name(isolate->native_context()->iterator_symbol(), isolate); | 184 Handle<Name> name(isolate->native_context()->iterator_symbol(), isolate); |
| 182 return MakeAccessor(isolate, name, &ArgumentsIteratorGetter, | 185 return MakeAccessor(isolate, name, &ArgumentsIteratorGetter, |
| 183 &ArgumentsIteratorSetter, attributes); | 186 &ArgumentsIteratorSetter, attributes); |
| 184 } | 187 } |
| 185 | 188 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 } | 243 } |
| 241 Handle<Object> number_v; | 244 Handle<Object> number_v; |
| 242 maybe = Execution::ToNumber(isolate, value); | 245 maybe = Execution::ToNumber(isolate, value); |
| 243 if (!maybe.ToHandle(&number_v)) { | 246 if (!maybe.ToHandle(&number_v)) { |
| 244 isolate->OptionalRescheduleException(false); | 247 isolate->OptionalRescheduleException(false); |
| 245 return; | 248 return; |
| 246 } | 249 } |
| 247 | 250 |
| 248 if (uint32_v->Number() == number_v->Number()) { | 251 if (uint32_v->Number() == number_v->Number()) { |
| 249 maybe = JSArray::SetElementsLength(array_handle, uint32_v); | 252 maybe = JSArray::SetElementsLength(array_handle, uint32_v); |
| 250 maybe.Check(); | 253 if (maybe.is_null()) isolate->OptionalRescheduleException(false); |
| 251 return; | 254 return; |
| 252 } | 255 } |
| 253 | 256 |
| 254 Handle<Object> exception; | 257 Handle<Object> exception; |
| 255 maybe = isolate->factory()->NewRangeError("invalid_array_length", | 258 maybe = isolate->factory()->NewRangeError("invalid_array_length", |
| 256 HandleVector<Object>(NULL, 0)); | 259 HandleVector<Object>(NULL, 0)); |
| 257 if (!maybe.ToHandle(&exception)) { | 260 if (!maybe.ToHandle(&exception)) { |
| 258 isolate->OptionalRescheduleException(false); | 261 isolate->OptionalRescheduleException(false); |
| 259 return; | 262 return; |
| 260 } | 263 } |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 874 static Handle<Object> GetFunctionPrototype(Isolate* isolate, | 877 static Handle<Object> GetFunctionPrototype(Isolate* isolate, |
| 875 Handle<JSFunction> function) { | 878 Handle<JSFunction> function) { |
| 876 if (!function->has_prototype()) { | 879 if (!function->has_prototype()) { |
| 877 Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function); | 880 Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function); |
| 878 JSFunction::SetPrototype(function, proto); | 881 JSFunction::SetPrototype(function, proto); |
| 879 } | 882 } |
| 880 return Handle<Object>(function->prototype(), isolate); | 883 return Handle<Object>(function->prototype(), isolate); |
| 881 } | 884 } |
| 882 | 885 |
| 883 | 886 |
| 884 static Handle<Object> SetFunctionPrototype(Isolate* isolate, | 887 static MaybeHandle<Object> SetFunctionPrototype(Isolate* isolate, |
|
Igor Sheludko
2014/10/13 10:47:24
MUST_USE_RESULT?
| |
| 885 Handle<JSFunction> function, | 888 Handle<JSFunction> function, |
| 886 Handle<Object> value) { | 889 Handle<Object> value) { |
| 887 Handle<Object> old_value; | 890 Handle<Object> old_value; |
| 888 bool is_observed = function->map()->is_observed(); | 891 bool is_observed = function->map()->is_observed(); |
| 889 if (is_observed) { | 892 if (is_observed) { |
| 890 if (function->has_prototype()) | 893 if (function->has_prototype()) |
| 891 old_value = handle(function->prototype(), isolate); | 894 old_value = handle(function->prototype(), isolate); |
| 892 else | 895 else |
| 893 old_value = isolate->factory()->NewFunctionPrototype(function); | 896 old_value = isolate->factory()->NewFunctionPrototype(function); |
| 894 } | 897 } |
| 895 | 898 |
| 896 JSFunction::SetPrototype(function, value); | 899 JSFunction::SetPrototype(function, value); |
| 897 DCHECK(function->prototype() == *value); | 900 DCHECK(function->prototype() == *value); |
| 898 | 901 |
| 899 if (is_observed && !old_value->SameValue(*value)) { | 902 if (is_observed && !old_value->SameValue(*value)) { |
| 900 JSObject::EnqueueChangeRecord( | 903 MaybeHandle<Object> result = JSObject::EnqueueChangeRecord( |
| 901 function, "update", isolate->factory()->prototype_string(), old_value); | 904 function, "update", isolate->factory()->prototype_string(), old_value); |
| 905 if (result.is_null()) { | |
| 906 isolate->OptionalRescheduleException(false); | |
| 907 return MaybeHandle<Object>(); | |
| 908 } | |
| 902 } | 909 } |
| 903 | 910 |
| 904 return function; | 911 return function; |
| 905 } | 912 } |
| 906 | 913 |
| 907 | 914 |
| 908 Handle<Object> Accessors::FunctionSetPrototype(Handle<JSFunction> function, | 915 MaybeHandle<Object> Accessors::FunctionSetPrototype(Handle<JSFunction> function, |
| 909 Handle<Object> prototype) { | 916 Handle<Object> prototype) { |
| 910 DCHECK(function->should_have_prototype()); | 917 DCHECK(function->should_have_prototype()); |
| 911 Isolate* isolate = function->GetIsolate(); | 918 Isolate* isolate = function->GetIsolate(); |
| 912 return SetFunctionPrototype(isolate, function, prototype); | 919 return SetFunctionPrototype(isolate, function, prototype); |
| 913 } | 920 } |
| 914 | 921 |
| 915 | 922 |
| 916 void Accessors::FunctionPrototypeGetter( | 923 void Accessors::FunctionPrototypeGetter( |
| 917 v8::Local<v8::Name> name, | 924 v8::Local<v8::Name> name, |
| 918 const v8::PropertyCallbackInfo<v8::Value>& info) { | 925 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 919 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 926 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1397 info->set_data(Smi::FromInt(index)); | 1404 info->set_data(Smi::FromInt(index)); |
| 1398 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 1405 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
| 1399 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 1406 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
| 1400 info->set_getter(*getter); | 1407 info->set_getter(*getter); |
| 1401 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 1408 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
| 1402 return info; | 1409 return info; |
| 1403 } | 1410 } |
| 1404 | 1411 |
| 1405 | 1412 |
| 1406 } } // namespace v8::internal | 1413 } } // namespace v8::internal |
| OLD | NEW |