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: test/cctest/test-heap.cc

Issue 238773009: Set code on the SharedFunctionInfo before creating the function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 | « test/cctest/test-alloc.cc ('k') | test/cctest/test-mark-compact.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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 Handle<String> name = factory->InternalizeUtf8String("theFunction"); 260 Handle<String> name = factory->InternalizeUtf8String("theFunction");
261 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); 261 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
262 Handle<String> prop_namex = factory->InternalizeUtf8String("theSlotx"); 262 Handle<String> prop_namex = factory->InternalizeUtf8String("theSlotx");
263 Handle<String> obj_name = factory->InternalizeUtf8String("theObject"); 263 Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
264 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); 264 Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
265 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); 265 Handle<Smi> twenty_four(Smi::FromInt(24), isolate);
266 266
267 { 267 {
268 HandleScope inner_scope(isolate); 268 HandleScope inner_scope(isolate);
269 // Allocate a function and keep it in global object's property. 269 // Allocate a function and keep it in global object's property.
270 Handle<JSFunction> function = 270 Handle<JSFunction> function = factory->NewFunctionWithPrototype(
271 factory->NewFunction(name, factory->undefined_value()); 271 name, factory->undefined_value());
272 Handle<Map> initial_map = 272 Handle<Map> initial_map =
273 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 273 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
274 function->set_initial_map(*initial_map); 274 function->set_initial_map(*initial_map);
275 JSReceiver::SetProperty(global, name, function, NONE, SLOPPY).Check(); 275 JSReceiver::SetProperty(global, name, function, NONE, SLOPPY).Check();
276 // Allocate an object. Unrooted after leaving the scope. 276 // Allocate an object. Unrooted after leaving the scope.
277 Handle<JSObject> obj = factory->NewJSObject(function); 277 Handle<JSObject> obj = factory->NewJSObject(function);
278 JSReceiver::SetProperty( 278 JSReceiver::SetProperty(
279 obj, prop_name, twenty_three, NONE, SLOPPY).Check(); 279 obj, prop_name, twenty_three, NONE, SLOPPY).Check();
280 JSReceiver::SetProperty( 280 JSReceiver::SetProperty(
281 obj, prop_namex, twenty_four, NONE, SLOPPY).Check(); 281 obj, prop_namex, twenty_four, NONE, SLOPPY).Check();
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 618 }
619 619
620 620
621 TEST(FunctionAllocation) { 621 TEST(FunctionAllocation) {
622 CcTest::InitializeVM(); 622 CcTest::InitializeVM();
623 Isolate* isolate = CcTest::i_isolate(); 623 Isolate* isolate = CcTest::i_isolate();
624 Factory* factory = isolate->factory(); 624 Factory* factory = isolate->factory();
625 625
626 v8::HandleScope sc(CcTest::isolate()); 626 v8::HandleScope sc(CcTest::isolate());
627 Handle<String> name = factory->InternalizeUtf8String("theFunction"); 627 Handle<String> name = factory->InternalizeUtf8String("theFunction");
628 Handle<JSFunction> function = 628 Handle<JSFunction> function = factory->NewFunctionWithPrototype(
629 factory->NewFunction(name, factory->undefined_value()); 629 name, factory->undefined_value());
630 Handle<Map> initial_map = 630 Handle<Map> initial_map =
631 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 631 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
632 function->set_initial_map(*initial_map); 632 function->set_initial_map(*initial_map);
633 633
634 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); 634 Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
635 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); 635 Handle<Smi> twenty_four(Smi::FromInt(24), isolate);
636 636
637 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); 637 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
638 Handle<JSObject> obj = factory->NewJSObject(function); 638 Handle<JSObject> obj = factory->NewJSObject(function);
639 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check(); 639 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 717 }
718 718
719 719
720 TEST(JSObjectMaps) { 720 TEST(JSObjectMaps) {
721 CcTest::InitializeVM(); 721 CcTest::InitializeVM();
722 Isolate* isolate = CcTest::i_isolate(); 722 Isolate* isolate = CcTest::i_isolate();
723 Factory* factory = isolate->factory(); 723 Factory* factory = isolate->factory();
724 724
725 v8::HandleScope sc(CcTest::isolate()); 725 v8::HandleScope sc(CcTest::isolate());
726 Handle<String> name = factory->InternalizeUtf8String("theFunction"); 726 Handle<String> name = factory->InternalizeUtf8String("theFunction");
727 Handle<JSFunction> function = 727 Handle<JSFunction> function = factory->NewFunctionWithPrototype(
728 factory->NewFunction(name, factory->undefined_value()); 728 name, factory->undefined_value());
729 Handle<Map> initial_map = 729 Handle<Map> initial_map =
730 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 730 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
731 function->set_initial_map(*initial_map); 731 function->set_initial_map(*initial_map);
732 732
733 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); 733 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
734 Handle<JSObject> obj = factory->NewJSObject(function); 734 Handle<JSObject> obj = factory->NewJSObject(function);
735 735
736 // Set a propery 736 // Set a propery
737 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); 737 Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
738 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check(); 738 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check();
(...skipping 3443 matching lines...) Expand 10 before | Expand all | Expand 10 after
4182 v8::Context::Scope cscope(context); 4182 v8::Context::Scope cscope(context);
4183 4183
4184 v8::Local<v8::Value> result = CompileRun( 4184 v8::Local<v8::Value> result = CompileRun(
4185 "var locals = '';" 4185 "var locals = '';"
4186 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" 4186 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';"
4187 "eval('function f() {' + locals + 'return function() { return v0; }; }');" 4187 "eval('function f() {' + locals + 'return function() { return v0; }; }');"
4188 "interrupt();" // This triggers a fake stack overflow in f. 4188 "interrupt();" // This triggers a fake stack overflow in f.
4189 "f()()"); 4189 "f()()");
4190 CHECK_EQ(42.0, result->ToNumber()->Value()); 4190 CHECK_EQ(42.0, result->ToNumber()->Value());
4191 } 4191 }
OLDNEW
« no previous file with comments | « test/cctest/test-alloc.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698