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

Side by Side Diff: src/accessors.cc

Issue 19594002: Handlify JSFunction::SetPrototype method. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Toon Verwaest. 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
« no previous file with comments | « src/accessors.h ('k') | src/bootstrapper.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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 443
444 Handle<Object> Accessors::FunctionGetPrototype(Handle<Object> object) { 444 Handle<Object> Accessors::FunctionGetPrototype(Handle<Object> object) {
445 Isolate* isolate = Isolate::Current(); 445 Isolate* isolate = Isolate::Current();
446 CALL_HEAP_FUNCTION( 446 CALL_HEAP_FUNCTION(
447 isolate, Accessors::FunctionGetPrototype(*object, 0), Object); 447 isolate, Accessors::FunctionGetPrototype(*object, 0), Object);
448 } 448 }
449 449
450 450
451 MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) { 451 MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) {
452 Isolate* isolate = Isolate::Current(); 452 Isolate* isolate = Isolate::Current();
453 JSFunction* function = FindInstanceOf<JSFunction>(isolate, object); 453 JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object);
454 if (function == NULL) return isolate->heap()->undefined_value(); 454 if (function_raw == NULL) return isolate->heap()->undefined_value();
455 while (!function->should_have_prototype()) { 455 while (!function_raw->should_have_prototype()) {
456 function = FindInstanceOf<JSFunction>(isolate, function->GetPrototype()); 456 function_raw = FindInstanceOf<JSFunction>(isolate,
457 function_raw->GetPrototype());
457 // There has to be one because we hit the getter. 458 // There has to be one because we hit the getter.
458 ASSERT(function != NULL); 459 ASSERT(function_raw != NULL);
459 } 460 }
460 461
461 if (!function->has_prototype()) { 462 if (!function_raw->has_prototype()) {
462 Object* prototype; 463 HandleScope scope(isolate);
463 { MaybeObject* maybe_prototype 464 Handle<JSFunction> function(function_raw);
464 = isolate->heap()->AllocateFunctionPrototype(function); 465 Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function);
465 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; 466 JSFunction::SetPrototype(function, proto);
466 } 467 function_raw = *function;
467 Object* result;
468 { MaybeObject* maybe_result = function->SetPrototype(prototype);
469 if (!maybe_result->ToObject(&result)) return maybe_result;
470 }
471 } 468 }
472 return function->prototype(); 469 return function_raw->prototype();
473 } 470 }
474 471
475 472
476 MaybeObject* Accessors::FunctionSetPrototype(JSObject* object, 473 MaybeObject* Accessors::FunctionSetPrototype(JSObject* object,
477 Object* value_raw, 474 Object* value_raw,
478 void*) { 475 void*) {
479 Isolate* isolate = object->GetIsolate(); 476 Isolate* isolate = object->GetIsolate();
480 Heap* heap = isolate->heap(); 477 Heap* heap = isolate->heap();
481 JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object); 478 JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object);
482 if (function_raw == NULL) return heap->undefined_value(); 479 if (function_raw == NULL) return heap->undefined_value();
(...skipping 13 matching lines...) Expand all
496 FLAG_harmony_observation && 493 FLAG_harmony_observation &&
497 *function == object && 494 *function == object &&
498 function->map()->is_observed(); 495 function->map()->is_observed();
499 if (is_observed) { 496 if (is_observed) {
500 if (function->has_prototype()) 497 if (function->has_prototype())
501 old_value = handle(function->prototype(), isolate); 498 old_value = handle(function->prototype(), isolate);
502 else 499 else
503 old_value = isolate->factory()->NewFunctionPrototype(function); 500 old_value = isolate->factory()->NewFunctionPrototype(function);
504 } 501 }
505 502
506 Handle<Object> result; 503 JSFunction::SetPrototype(function, value);
507 MaybeObject* maybe_result = function->SetPrototype(*value);
508 if (!maybe_result->ToHandle(&result, isolate)) return maybe_result;
509 ASSERT(function->prototype() == *value); 504 ASSERT(function->prototype() == *value);
510 505
511 if (is_observed && !old_value->SameValue(*value)) { 506 if (is_observed && !old_value->SameValue(*value)) {
512 JSObject::EnqueueChangeRecord( 507 JSObject::EnqueueChangeRecord(
513 function, "updated", isolate->factory()->prototype_string(), old_value); 508 function, "updated", isolate->factory()->prototype_string(), old_value);
514 } 509 }
515 510
516 return *function; 511 return *function;
517 } 512 }
518 513
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 info->set_data(Smi::FromInt(index)); 842 info->set_data(Smi::FromInt(index));
848 Handle<Object> getter = v8::FromCData(&ModuleGetExport); 843 Handle<Object> getter = v8::FromCData(&ModuleGetExport);
849 Handle<Object> setter = v8::FromCData(&ModuleSetExport); 844 Handle<Object> setter = v8::FromCData(&ModuleSetExport);
850 info->set_getter(*getter); 845 info->set_getter(*getter);
851 if (!(attributes & ReadOnly)) info->set_setter(*setter); 846 if (!(attributes & ReadOnly)) info->set_setter(*setter);
852 return info; 847 return info;
853 } 848 }
854 849
855 850
856 } } // namespace v8::internal 851 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698