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

Side by Side Diff: src/runtime.cc

Issue 18089024: Handlify JSObject::SetPrototype method. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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
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 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 Object* current = receiver->GetPrototype(isolate); 1443 Object* current = receiver->GetPrototype(isolate);
1444 while (current->IsJSObject() && 1444 while (current->IsJSObject() &&
1445 JSObject::cast(current)->map()->is_hidden_prototype()) { 1445 JSObject::cast(current)->map()->is_hidden_prototype()) {
1446 current = current->GetPrototype(isolate); 1446 current = current->GetPrototype(isolate);
1447 } 1447 }
1448 return current; 1448 return current;
1449 } 1449 }
1450 1450
1451 1451
1452 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetPrototype) { 1452 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetPrototype) {
1453 SealHandleScope shs(isolate); 1453 HandleScope scope(isolate);
1454 ASSERT(args.length() == 2); 1454 ASSERT(args.length() == 2);
1455 CONVERT_ARG_CHECKED(JSObject, obj, 0); 1455 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
1456 CONVERT_ARG_CHECKED(Object, prototype, 1); 1456 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
1457 if (FLAG_harmony_observation && obj->map()->is_observed()) { 1457 if (FLAG_harmony_observation && obj->map()->is_observed()) {
1458 HandleScope scope(isolate);
1459 Handle<JSObject> receiver(obj);
1460 Handle<Object> value(prototype, isolate);
1461 Handle<Object> old_value( 1458 Handle<Object> old_value(
1462 GetPrototypeSkipHiddenPrototypes(isolate, *receiver), isolate); 1459 GetPrototypeSkipHiddenPrototypes(isolate, *obj), isolate);
1463 1460
1464 MaybeObject* result = receiver->SetPrototype(*value, true); 1461 Handle<Object> result = JSObject::SetPrototype(obj, prototype, true);
1465 Handle<Object> hresult; 1462 if (result.is_null()) return Failure::Exception();
1466 if (!result->ToHandle(&hresult, isolate)) return result;
1467 1463
1468 Handle<Object> new_value( 1464 Handle<Object> new_value(
1469 GetPrototypeSkipHiddenPrototypes(isolate, *receiver), isolate); 1465 GetPrototypeSkipHiddenPrototypes(isolate, *obj), isolate);
1470 if (!new_value->SameValue(*old_value)) { 1466 if (!new_value->SameValue(*old_value)) {
1471 JSObject::EnqueueChangeRecord(receiver, "prototype", 1467 JSObject::EnqueueChangeRecord(obj, "prototype",
1472 isolate->factory()->proto_string(), 1468 isolate->factory()->proto_string(),
1473 old_value); 1469 old_value);
1474 } 1470 }
1475 return *hresult; 1471 return *result;
1476 } 1472 }
1477 return obj->SetPrototype(prototype, true); 1473 Handle<Object> result = JSObject::SetPrototype(obj, prototype, true);
1474 if (result.is_null()) return Failure::Exception();
1475 return *result;
1478 } 1476 }
1479 1477
1480 1478
1481 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { 1479 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) {
1482 SealHandleScope shs(isolate); 1480 SealHandleScope shs(isolate);
1483 ASSERT(args.length() == 2); 1481 ASSERT(args.length() == 2);
1484 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). 1482 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8).
1485 Object* O = args[0]; 1483 Object* O = args[0];
1486 Object* V = args[1]; 1484 Object* V = args[1];
1487 while (true) { 1485 while (true) {
(...skipping 12459 matching lines...) Expand 10 before | Expand all | Expand 10 after
13947 // Handle last resort GC and make sure to allow future allocations 13945 // Handle last resort GC and make sure to allow future allocations
13948 // to grow the heap without causing GCs (if possible). 13946 // to grow the heap without causing GCs (if possible).
13949 isolate->counters()->gc_last_resort_from_js()->Increment(); 13947 isolate->counters()->gc_last_resort_from_js()->Increment();
13950 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13948 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13951 "Runtime::PerformGC"); 13949 "Runtime::PerformGC");
13952 } 13950 }
13953 } 13951 }
13954 13952
13955 13953
13956 } } // namespace v8::internal 13954 } } // namespace v8::internal
OLDNEW
« src/objects.cc ('K') | « src/objects-inl.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698