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

Side by Side Diff: src/runtime.cc

Issue 9716035: Make setting of accessors even more atomic. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | 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 4332 matching lines...) Expand 10 before | Expand all | Expand 10 after
4343 RUNTIME_ASSERT(!obj->IsNull()); 4343 RUNTIME_ASSERT(!obj->IsNull());
4344 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); 4344 CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
4345 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); 4345 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2);
4346 RUNTIME_ASSERT(IsValidAccessor(getter)); 4346 RUNTIME_ASSERT(IsValidAccessor(getter));
4347 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); 4347 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3);
4348 RUNTIME_ASSERT(IsValidAccessor(setter)); 4348 RUNTIME_ASSERT(IsValidAccessor(setter));
4349 CONVERT_SMI_ARG_CHECKED(unchecked, 4); 4349 CONVERT_SMI_ARG_CHECKED(unchecked, 4);
4350 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4350 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4351 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); 4351 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
4352 4352
4353 // TODO(svenpanne) Define getter/setter/attributes in a single step. 4353 JSObject::DefineAccessor(obj, name, getter, setter, attr);
4354 if (getter->IsNull() && setter->IsNull()) { 4354 JSObject::TransformToFastProperties(obj, 0);
Michael Starzinger 2012/03/21 12:33:08 See first comment.
Sven Panne 2012/03/21 13:14:18 Done.
4355 JSArray* array;
4356 { MaybeObject* maybe_array = GetOwnProperty(isolate, obj, name);
4357 if (!maybe_array->To(&array)) return maybe_array;
4358 }
4359 Object* current = FixedArray::cast(array->elements())->get(GETTER_INDEX);
4360 getter = Handle<Object>(current, isolate);
4361 }
4362 if (!getter->IsNull()) {
4363 MaybeObject* ok =
4364 obj->DefineAccessor(*name, ACCESSOR_GETTER, *getter, attr);
4365 if (ok->IsFailure()) return ok;
4366 }
4367 if (!setter->IsNull()) {
4368 MaybeObject* ok =
4369 obj->DefineAccessor(*name, ACCESSOR_SETTER, *setter, attr);
4370 if (ok->IsFailure()) return ok;
4371 }
4372
4373 return isolate->heap()->undefined_value(); 4355 return isolate->heap()->undefined_value();
4374 } 4356 }
4375 4357
4376 // Implements part of 8.12.9 DefineOwnProperty. 4358 // Implements part of 8.12.9 DefineOwnProperty.
4377 // There are 3 cases that lead here: 4359 // There are 3 cases that lead here:
4378 // Step 4a - define a new data property. 4360 // Step 4a - define a new data property.
4379 // Steps 9b & 12 - replace an existing accessor property with a data property. 4361 // Steps 9b & 12 - replace an existing accessor property with a data property.
4380 // Step 12 - update an existing data property with a data or generic 4362 // Step 12 - update an existing data property with a data or generic
4381 // descriptor. 4363 // descriptor.
4382 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { 4364 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
(...skipping 8979 matching lines...) Expand 10 before | Expand all | Expand 10 after
13362 // Handle last resort GC and make sure to allow future allocations 13344 // Handle last resort GC and make sure to allow future allocations
13363 // to grow the heap without causing GCs (if possible). 13345 // to grow the heap without causing GCs (if possible).
13364 isolate->counters()->gc_last_resort_from_js()->Increment(); 13346 isolate->counters()->gc_last_resort_from_js()->Increment();
13365 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13347 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13366 "Runtime::PerformGC"); 13348 "Runtime::PerformGC");
13367 } 13349 }
13368 } 13350 }
13369 13351
13370 13352
13371 } } // namespace v8::internal 13353 } } // namespace v8::internal
OLDNEW
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698