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

Side by Side Diff: src/runtime.cc

Issue 546032: Enabled es5conform tests for new array methods and corrected errors that was ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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/runtime.h ('k') | src/v8natives.js » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 552
553 553
554 static Object* Runtime_IsConstructCall(Arguments args) { 554 static Object* Runtime_IsConstructCall(Arguments args) {
555 NoHandleAllocation ha; 555 NoHandleAllocation ha;
556 ASSERT(args.length() == 0); 556 ASSERT(args.length() == 0);
557 JavaScriptFrameIterator it; 557 JavaScriptFrameIterator it;
558 return Heap::ToBoolean(it.frame()->IsConstructor()); 558 return Heap::ToBoolean(it.frame()->IsConstructor());
559 } 559 }
560 560
561 561
562 // Recursively traverses hidden prototypes if property is not found
563 static void GetOwnPropertyImplementation(JSObject* obj,
564 String* name,
565 LookupResult* result) {
566 obj->LocalLookupRealNamedProperty(name, result);
567
568 if (!result->IsProperty()) {
569 Object* proto = obj->GetPrototype();
570 if (proto->IsJSObject() &&
571 JSObject::cast(proto)->map()->is_hidden_prototype())
572 GetOwnPropertyImplementation(JSObject::cast(proto),
573 name, result);
574 }
575 }
576
577
578 // Returns an array with the property description:
579 // if args[1] is not a property on args[0]
580 // returns undefined
581 // if args[1] is a data property on args[0]
582 // [false, value, Writeable, Enumerable, Configurable]
583 // if args[1] is an accessor on args[0]
584 // [true, GetFunction, SetFunction, Enumerable, Configurable]
585 static Object* Runtime_GetOwnProperty(Arguments args) {
586 HandleScope scope;
587 Handle<FixedArray> elms = Factory::NewFixedArray(5);
588 Handle<JSArray> desc = Factory::NewJSArrayWithElements(elms);
589 LookupResult result;
590 CONVERT_CHECKED(JSObject, obj, args[0]);
591 CONVERT_CHECKED(String, name, args[1]);
592
593 // Use recursive implementation to also traverse hidden prototypes
594 GetOwnPropertyImplementation(obj, name, &result);
595
596 if (!result.IsProperty())
597 return Heap::undefined_value();
598
599 if (result.type() == CALLBACKS) {
600 elms->set(0, Heap::true_value());
601 Object* structure = result.GetCallbackObject();
602 if (structure->IsProxy()) {
603 Object* value = obj->GetPropertyWithCallback(
604 obj, structure, name, result.holder());
605 elms->set(1, value);
606 elms->set(2, Heap::ToBoolean(!result.IsReadOnly()));
607 } else {
608 elms->set(1, FixedArray::cast(structure)->get(0));
609 elms->set(2, FixedArray::cast(structure)->get(1));
610 }
611 } else {
612 elms->set(0, Heap::false_value());
613 elms->set(1, result.GetLazyValue());
614 elms->set(2, Heap::ToBoolean(!result.IsReadOnly()));
615 }
616
617 elms->set(3, Heap::ToBoolean(!result.IsDontEnum()));
618 elms->set(4, Heap::ToBoolean(!result.IsReadOnly()));
619 return *desc;
620 }
621
622
562 static Object* Runtime_RegExpCompile(Arguments args) { 623 static Object* Runtime_RegExpCompile(Arguments args) {
563 HandleScope scope; 624 HandleScope scope;
564 ASSERT(args.length() == 3); 625 ASSERT(args.length() == 3);
565 CONVERT_ARG_CHECKED(JSRegExp, re, 0); 626 CONVERT_ARG_CHECKED(JSRegExp, re, 0);
566 CONVERT_ARG_CHECKED(String, pattern, 1); 627 CONVERT_ARG_CHECKED(String, pattern, 1);
567 CONVERT_ARG_CHECKED(String, flags, 2); 628 CONVERT_ARG_CHECKED(String, flags, 2);
568 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); 629 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags);
569 if (result.is_null()) return Failure::Exception(); 630 if (result.is_null()) return Failure::Exception();
570 return *result; 631 return *result;
571 } 632 }
(...skipping 7511 matching lines...) Expand 10 before | Expand all | Expand 10 after
8083 } else { 8144 } else {
8084 // Handle last resort GC and make sure to allow future allocations 8145 // Handle last resort GC and make sure to allow future allocations
8085 // to grow the heap without causing GCs (if possible). 8146 // to grow the heap without causing GCs (if possible).
8086 Counters::gc_last_resort_from_js.Increment(); 8147 Counters::gc_last_resort_from_js.Increment();
8087 Heap::CollectAllGarbage(false); 8148 Heap::CollectAllGarbage(false);
8088 } 8149 }
8089 } 8150 }
8090 8151
8091 8152
8092 } } // namespace v8::internal 8153 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698