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

Side by Side Diff: src/runtime.cc

Issue 7060010: Merge bleeding edge into the GC branch up to 7948. The asserts (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 7 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/runtime.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /branches/bleeding_edge/src/runtime.cc:r7794-7948
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 literals->set(literals_index, *boilerplate); 581 literals->set(literals_index, *boilerplate);
582 } 582 }
583 if (JSObject::cast(*boilerplate)->elements()->map() == 583 if (JSObject::cast(*boilerplate)->elements()->map() ==
584 isolate->heap()->fixed_cow_array_map()) { 584 isolate->heap()->fixed_cow_array_map()) {
585 isolate->counters()->cow_arrays_created_runtime()->Increment(); 585 isolate->counters()->cow_arrays_created_runtime()->Increment();
586 } 586 }
587 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); 587 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate));
588 } 588 }
589 589
590 590
591 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) {
592 ASSERT(args.length() == 2);
593 Object* handler = args[0];
594 Object* prototype = args[1];
595 Object* used_prototype =
596 (prototype->IsJSObject() || prototype->IsJSProxy()) ? prototype
597 : isolate->heap()->null_value();
598 return isolate->heap()->AllocateJSProxy(handler, used_prototype);
599 }
600
601
591 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCatchExtensionObject) { 602 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCatchExtensionObject) {
592 ASSERT(args.length() == 2); 603 ASSERT(args.length() == 2);
593 CONVERT_CHECKED(String, key, args[0]); 604 CONVERT_CHECKED(String, key, args[0]);
594 Object* value = args[1]; 605 Object* value = args[1];
606 ASSERT(!value->IsFailure());
595 // Create a catch context extension object. 607 // Create a catch context extension object.
596 JSFunction* constructor = 608 JSFunction* constructor =
597 isolate->context()->global_context()-> 609 isolate->context()->global_context()->
598 context_extension_function(); 610 context_extension_function();
599 Object* object; 611 Object* object;
600 { MaybeObject* maybe_object = isolate->heap()->AllocateJSObject(constructor); 612 { MaybeObject* maybe_object = isolate->heap()->AllocateJSObject(constructor);
601 if (!maybe_object->ToObject(&object)) return maybe_object; 613 if (!maybe_object->ToObject(&object)) return maybe_object;
602 } 614 }
603 // Assign the exception value to the catch variable and make sure 615 // Assign the exception value to the catch variable and make sure
604 // that the catch variable is DontDelete. 616 // that the catch variable is DontDelete.
(...skipping 3495 matching lines...) Expand 10 before | Expand all | Expand 10 after
4100 4112
4101 return Runtime::SetObjectProperty(isolate, 4113 return Runtime::SetObjectProperty(isolate,
4102 object, 4114 object,
4103 key, 4115 key,
4104 value, 4116 value,
4105 attributes, 4117 attributes,
4106 strict_mode); 4118 strict_mode);
4107 } 4119 }
4108 4120
4109 4121
4122 // Set the ES5 native flag on the function.
4123 // This is used to decide if we should transform null and undefined
4124 // into the global object when doing call and apply.
4125 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetES5Flag) {
4126 NoHandleAllocation ha;
4127 RUNTIME_ASSERT(args.length() == 1);
4128
4129 Handle<Object> object = args.at<Object>(0);
4130
4131 if (object->IsJSFunction()) {
4132 JSFunction* func = JSFunction::cast(*object);
4133 func->shared()->set_es5_native(true);
4134 }
4135 return isolate->heap()->undefined_value();
4136 }
4137
4138
4110 // Set a local property, even if it is READ_ONLY. If the property does not 4139 // Set a local property, even if it is READ_ONLY. If the property does not
4111 // exist, it will be added with attributes NONE. 4140 // exist, it will be added with attributes NONE.
4112 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { 4141 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) {
4113 NoHandleAllocation ha; 4142 NoHandleAllocation ha;
4114 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); 4143 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4);
4115 CONVERT_CHECKED(JSObject, object, args[0]); 4144 CONVERT_CHECKED(JSObject, object, args[0]);
4116 CONVERT_CHECKED(String, name, args[1]); 4145 CONVERT_CHECKED(String, name, args[1]);
4117 // Compute attributes. 4146 // Compute attributes.
4118 PropertyAttributes attributes = NONE; 4147 PropertyAttributes attributes = NONE;
4119 if (args.length() == 4) { 4148 if (args.length() == 4) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4159 } 4188 }
4160 return isolate->heap()->false_value(); 4189 return isolate->heap()->false_value();
4161 } 4190 }
4162 4191
4163 4192
4164 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { 4193 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) {
4165 NoHandleAllocation ha; 4194 NoHandleAllocation ha;
4166 ASSERT(args.length() == 2); 4195 ASSERT(args.length() == 2);
4167 CONVERT_CHECKED(String, key, args[1]); 4196 CONVERT_CHECKED(String, key, args[1]);
4168 4197
4198 uint32_t index;
4199 const bool key_is_array_index = key->AsArrayIndex(&index);
4200
4169 Object* obj = args[0]; 4201 Object* obj = args[0];
4170 // Only JS objects can have properties. 4202 // Only JS objects can have properties.
4171 if (obj->IsJSObject()) { 4203 if (obj->IsJSObject()) {
4172 JSObject* object = JSObject::cast(obj); 4204 JSObject* object = JSObject::cast(obj);
4173 // Fast case - no interceptors. 4205 // Fast case: either the key is a real named property or it is not
4206 // an array index and there are no interceptors or hidden
4207 // prototypes.
4174 if (object->HasRealNamedProperty(key)) return isolate->heap()->true_value(); 4208 if (object->HasRealNamedProperty(key)) return isolate->heap()->true_value();
4175 // Slow case. Either it's not there or we have an interceptor. We should 4209 Map* map = object->map();
4176 // have handles for this kind of deal. 4210 if (!key_is_array_index &&
4211 !map->has_named_interceptor() &&
4212 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) {
4213 return isolate->heap()->false_value();
4214 }
4215 // Slow case.
4177 HandleScope scope(isolate); 4216 HandleScope scope(isolate);
4178 return HasLocalPropertyImplementation(isolate, 4217 return HasLocalPropertyImplementation(isolate,
4179 Handle<JSObject>(object), 4218 Handle<JSObject>(object),
4180 Handle<String>(key)); 4219 Handle<String>(key));
4181 } else if (obj->IsString()) { 4220 } else if (obj->IsString() && key_is_array_index) {
4182 // Well, there is one exception: Handle [] on strings. 4221 // Well, there is one exception: Handle [] on strings.
4183 uint32_t index; 4222 String* string = String::cast(obj);
4184 if (key->AsArrayIndex(&index)) { 4223 if (index < static_cast<uint32_t>(string->length())) {
4185 String* string = String::cast(obj); 4224 return isolate->heap()->true_value();
4186 if (index < static_cast<uint32_t>(string->length()))
4187 return isolate->heap()->true_value();
4188 } 4225 }
4189 } 4226 }
4190 return isolate->heap()->false_value(); 4227 return isolate->heap()->false_value();
4191 } 4228 }
4192 4229
4193 4230
4194 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { 4231 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) {
4195 NoHandleAllocation na; 4232 NoHandleAllocation na;
4196 ASSERT(args.length() == 2); 4233 ASSERT(args.length() == 2);
4197 4234
(...skipping 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after
7547 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { 7584 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) {
7548 HandleScope scope(isolate); 7585 HandleScope scope(isolate);
7549 ASSERT(args.length() == 1); 7586 ASSERT(args.length() == 1);
7550 CONVERT_ARG_CHECKED(JSFunction, function, 0); 7587 CONVERT_ARG_CHECKED(JSFunction, function, 0);
7551 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); 7588 if (!function->IsOptimizable()) return isolate->heap()->undefined_value();
7552 function->MarkForLazyRecompilation(); 7589 function->MarkForLazyRecompilation();
7553 return isolate->heap()->undefined_value(); 7590 return isolate->heap()->undefined_value();
7554 } 7591 }
7555 7592
7556 7593
7594 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) {
7595 HandleScope scope(isolate);
7596 ASSERT(args.length() == 1);
7597 if (!V8::UseCrankshaft()) {
7598 return Smi::FromInt(4); // 4 == "never".
7599 }
7600 if (FLAG_always_opt) {
7601 return Smi::FromInt(3); // 3 == "always".
7602 }
7603 CONVERT_ARG_CHECKED(JSFunction, function, 0);
7604 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes".
7605 : Smi::FromInt(2); // 2 == "no".
7606 }
7607
7608
7609 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) {
7610 HandleScope scope(isolate);
7611 ASSERT(args.length() == 1);
7612 CONVERT_ARG_CHECKED(JSFunction, function, 0);
7613 return Smi::FromInt(function->shared()->opt_count());
7614 }
7615
7616
7557 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { 7617 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
7558 HandleScope scope(isolate); 7618 HandleScope scope(isolate);
7559 ASSERT(args.length() == 1); 7619 ASSERT(args.length() == 1);
7560 CONVERT_ARG_CHECKED(JSFunction, function, 0); 7620 CONVERT_ARG_CHECKED(JSFunction, function, 0);
7561 7621
7562 // We're not prepared to handle a function with arguments object. 7622 // We're not prepared to handle a function with arguments object.
7563 ASSERT(!function->shared()->scope_info()->HasArgumentsShadow()); 7623 ASSERT(!function->shared()->scope_info()->HasArgumentsShadow());
7564 7624
7565 // We have hit a back edge in an unoptimized frame for a function that was 7625 // We have hit a back edge in an unoptimized frame for a function that was
7566 // selected for on-stack replacement. Find the unoptimized code object. 7626 // selected for on-stack replacement. Find the unoptimized code object.
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
7862 ContextLookupFlags flags = FOLLOW_CHAINS; 7922 ContextLookupFlags flags = FOLLOW_CHAINS;
7863 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes); 7923 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes);
7864 7924
7865 // If the index is non-negative, the slot has been found in a local 7925 // If the index is non-negative, the slot has been found in a local
7866 // variable or a parameter. Read it from the context object or the 7926 // variable or a parameter. Read it from the context object or the
7867 // arguments object. 7927 // arguments object.
7868 if (index >= 0) { 7928 if (index >= 0) {
7869 // If the "property" we were looking for is a local variable or an 7929 // If the "property" we were looking for is a local variable or an
7870 // argument in a context, the receiver is the global object; see 7930 // argument in a context, the receiver is the global object; see
7871 // ECMA-262, 3rd., 10.1.6 and 10.2.3. 7931 // ECMA-262, 3rd., 10.1.6 and 10.2.3.
7872 JSObject* receiver = 7932 // GetElement below can cause GC.
7873 isolate->context()->global()->global_receiver(); 7933 Handle<JSObject> receiver(
7934 isolate->context()->global()->global_receiver());
7874 MaybeObject* value = (holder->IsContext()) 7935 MaybeObject* value = (holder->IsContext())
7875 ? Context::cast(*holder)->get(index) 7936 ? Context::cast(*holder)->get(index)
7876 : JSObject::cast(*holder)->GetElement(index); 7937 : JSObject::cast(*holder)->GetElement(index);
7877 return MakePair(Unhole(isolate->heap(), value, attributes), receiver); 7938 return MakePair(Unhole(isolate->heap(), value, attributes), *receiver);
7878 } 7939 }
7879 7940
7880 // If the holder is found, we read the property from it. 7941 // If the holder is found, we read the property from it.
7881 if (!holder.is_null() && holder->IsJSObject()) { 7942 if (!holder.is_null() && holder->IsJSObject()) {
7882 ASSERT(Handle<JSObject>::cast(holder)->HasProperty(*name)); 7943 ASSERT(Handle<JSObject>::cast(holder)->HasProperty(*name));
7883 JSObject* object = JSObject::cast(*holder); 7944 JSObject* object = JSObject::cast(*holder);
7884 JSObject* receiver; 7945 JSObject* receiver;
7885 if (object->IsGlobalObject()) { 7946 if (object->IsGlobalObject()) {
7886 receiver = GlobalObject::cast(object)->global_receiver(); 7947 receiver = GlobalObject::cast(object)->global_receiver();
7887 } else if (context->is_exception_holder(*holder)) { 7948 } else if (context->is_exception_holder(*holder)) {
7888 receiver = isolate->context()->global()->global_receiver(); 7949 receiver = isolate->context()->global()->global_receiver();
7889 } else { 7950 } else {
7890 receiver = ComputeReceiverForNonGlobal(isolate, object); 7951 receiver = ComputeReceiverForNonGlobal(isolate, object);
7891 } 7952 }
7953
7954 // GetProperty below can cause GC.
7955 Handle<JSObject> receiver_handle(receiver);
7956
7892 // No need to unhole the value here. This is taken care of by the 7957 // No need to unhole the value here. This is taken care of by the
7893 // GetProperty function. 7958 // GetProperty function.
7894 MaybeObject* value = object->GetProperty(*name); 7959 MaybeObject* value = object->GetProperty(*name);
7895 return MakePair(value, receiver); 7960 return MakePair(value, *receiver_handle);
7896 } 7961 }
7897 7962
7898 if (throw_error) { 7963 if (throw_error) {
7899 // The property doesn't exist - throw exception. 7964 // The property doesn't exist - throw exception.
7900 Handle<Object> reference_error = 7965 Handle<Object> reference_error =
7901 isolate->factory()->NewReferenceError("not_defined", 7966 isolate->factory()->NewReferenceError("not_defined",
7902 HandleVector(&name, 1)); 7967 HandleVector(&name, 1));
7903 return MakePair(isolate->Throw(*reference_error), NULL); 7968 return MakePair(isolate->Throw(*reference_error), NULL);
7904 } else { 7969 } else {
7905 // The property doesn't exist - return undefined 7970 // The property doesn't exist - return undefined
(...skipping 4285 matching lines...) Expand 10 before | Expand all | Expand 10 after
12191 } else { 12256 } else {
12192 // Handle last resort GC and make sure to allow future allocations 12257 // Handle last resort GC and make sure to allow future allocations
12193 // to grow the heap without causing GCs (if possible). 12258 // to grow the heap without causing GCs (if possible).
12194 isolate->counters()->gc_last_resort_from_js()->Increment(); 12259 isolate->counters()->gc_last_resort_from_js()->Increment();
12195 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 12260 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
12196 } 12261 }
12197 } 12262 }
12198 12263
12199 12264
12200 } } // namespace v8::internal 12265 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698