Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: src/accessors.cc

Issue 225283005: Return MaybeHandle from SetProperty. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 Object* value_raw, 183 Object* value_raw,
184 void*) { 184 void*) {
185 HandleScope scope(isolate); 185 HandleScope scope(isolate);
186 Handle<JSObject> object(object_raw, isolate); 186 Handle<JSObject> object(object_raw, isolate);
187 Handle<Object> value(value_raw, isolate); 187 Handle<Object> value(value_raw, isolate);
188 188
189 // This means one of the object's prototypes is a JSArray and the 189 // This means one of the object's prototypes is a JSArray and the
190 // object does not have a 'length' property. Calling SetProperty 190 // object does not have a 'length' property. Calling SetProperty
191 // causes an infinite loop. 191 // causes an infinite loop.
192 if (!object->IsJSArray()) { 192 if (!object->IsJSArray()) {
193 Handle<Object> result = JSObject::SetLocalPropertyIgnoreAttributes(object, 193 Handle<Object> result;
194 isolate->factory()->length_string(), value, NONE); 194 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
195 RETURN_IF_EMPTY_HANDLE(isolate, result); 195 isolate, result,
196 JSObject::SetLocalPropertyIgnoreAttributes(
197 object, isolate->factory()->length_string(), value, NONE));
196 return *result; 198 return *result;
197 } 199 }
198 200
199 value = FlattenNumber(isolate, value); 201 value = FlattenNumber(isolate, value);
200 202
201 Handle<JSArray> array_handle = Handle<JSArray>::cast(object); 203 Handle<JSArray> array_handle = Handle<JSArray>::cast(object);
202 204
203 bool has_exception; 205 bool has_exception;
204 Handle<Object> uint32_v = 206 Handle<Object> uint32_v =
205 Execution::ToUint32(isolate, value, &has_exception); 207 Execution::ToUint32(isolate, value, &has_exception);
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 void*) { 586 void*) {
585 JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object_raw); 587 JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object_raw);
586 if (function_raw == NULL) return isolate->heap()->undefined_value(); 588 if (function_raw == NULL) return isolate->heap()->undefined_value();
587 589
588 HandleScope scope(isolate); 590 HandleScope scope(isolate);
589 Handle<JSFunction> function(function_raw, isolate); 591 Handle<JSFunction> function(function_raw, isolate);
590 Handle<JSObject> object(object_raw, isolate); 592 Handle<JSObject> object(object_raw, isolate);
591 Handle<Object> value(value_raw, isolate); 593 Handle<Object> value(value_raw, isolate);
592 if (!function->should_have_prototype()) { 594 if (!function->should_have_prototype()) {
593 // Since we hit this accessor, object will have no prototype property. 595 // Since we hit this accessor, object will have no prototype property.
594 Handle<Object> result = JSObject::SetLocalPropertyIgnoreAttributes(object, 596 Handle<Object> result;
595 isolate->factory()->prototype_string(), value, NONE); 597 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
596 RETURN_IF_EMPTY_HANDLE(isolate, result); 598 isolate, result,
599 JSObject::SetLocalPropertyIgnoreAttributes(
600 object, isolate->factory()->prototype_string(), value, NONE));
597 return *result; 601 return *result;
598 } 602 }
599 603
600 Handle<Object> old_value; 604 Handle<Object> old_value;
601 bool is_observed = *function == *object && function->map()->is_observed(); 605 bool is_observed = *function == *object && function->map()->is_observed();
602 if (is_observed) { 606 if (is_observed) {
603 if (function->has_prototype()) 607 if (function->has_prototype())
604 old_value = handle(function->prototype(), isolate); 608 old_value = handle(function->prototype(), isolate);
605 else 609 else
606 old_value = isolate->factory()->NewFunctionPrototype(function); 610 old_value = isolate->factory()->NewFunctionPrototype(function);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 info->set_data(Smi::FromInt(index)); 967 info->set_data(Smi::FromInt(index));
964 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); 968 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport);
965 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); 969 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport);
966 info->set_getter(*getter); 970 info->set_getter(*getter);
967 if (!(attributes & ReadOnly)) info->set_setter(*setter); 971 if (!(attributes & ReadOnly)) info->set_setter(*setter);
968 return info; 972 return info;
969 } 973 }
970 974
971 975
972 } } // namespace v8::internal 976 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698