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

Side by Side Diff: src/runtime.cc

Issue 131663003: Make the strict-mode calling convention for contextual calls the default one. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix arm port Created 6 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/ia32/stub-cache-ia32.cc ('k') | src/stub-cache.h » ('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 9152 matching lines...) Expand 10 before | Expand all | Expand 10 after
9163 JSFunction* context_extension_function = 9163 JSFunction* context_extension_function =
9164 top->native_context()->context_extension_function(); 9164 top->native_context()->context_extension_function();
9165 // If the holder isn't a context extension object, we just return it 9165 // If the holder isn't a context extension object, we just return it
9166 // as the receiver. This allows arguments objects to be used as 9166 // as the receiver. This allows arguments objects to be used as
9167 // receivers, but only if they are put in the context scope chain 9167 // receivers, but only if they are put in the context scope chain
9168 // explicitly via a with-statement. 9168 // explicitly via a with-statement.
9169 Object* constructor = holder->map()->constructor(); 9169 Object* constructor = holder->map()->constructor();
9170 if (constructor != context_extension_function) return holder; 9170 if (constructor != context_extension_function) return holder;
9171 // Fall back to using the global object as the implicit receiver if 9171 // Fall back to using the global object as the implicit receiver if
9172 // the property turns out to be a local variable allocated in a 9172 // the property turns out to be a local variable allocated in a
9173 // context extension object - introduced via eval. Implicit global 9173 // context extension object - introduced via eval.
9174 // receivers are indicated with the hole value. 9174 return isolate->heap()->undefined_value();
9175 return isolate->heap()->the_hole_value();
9176 } 9175 }
9177 9176
9178 9177
9179 static ObjectPair LoadContextSlotHelper(Arguments args, 9178 static ObjectPair LoadContextSlotHelper(Arguments args,
9180 Isolate* isolate, 9179 Isolate* isolate,
9181 bool throw_error) { 9180 bool throw_error) {
9182 HandleScope scope(isolate); 9181 HandleScope scope(isolate);
9183 ASSERT_EQ(2, args.length()); 9182 ASSERT_EQ(2, args.length());
9184 9183
9185 if (!args[0]->IsContext() || !args[1]->IsString()) { 9184 if (!args[0]->IsContext() || !args[1]->IsString()) {
(...skipping 13 matching lines...) Expand all
9199 &binding_flags); 9198 &binding_flags);
9200 if (isolate->has_pending_exception()) { 9199 if (isolate->has_pending_exception()) {
9201 return MakePair(Failure::Exception(), NULL); 9200 return MakePair(Failure::Exception(), NULL);
9202 } 9201 }
9203 9202
9204 // If the index is non-negative, the slot has been found in a context. 9203 // If the index is non-negative, the slot has been found in a context.
9205 if (index >= 0) { 9204 if (index >= 0) {
9206 ASSERT(holder->IsContext()); 9205 ASSERT(holder->IsContext());
9207 // If the "property" we were looking for is a local variable, the 9206 // If the "property" we were looking for is a local variable, the
9208 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3. 9207 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3.
9209 // 9208 Handle<Object> receiver = isolate->factory()->undefined_value();
9210 // Use the hole as the receiver to signal that the receiver is implicit
9211 // and that the global receiver should be used (as distinguished from an
9212 // explicit receiver that happens to be a global object).
9213 Handle<Object> receiver = isolate->factory()->the_hole_value();
9214 Object* value = Context::cast(*holder)->get(index); 9209 Object* value = Context::cast(*holder)->get(index);
9215 // Check for uninitialized bindings. 9210 // Check for uninitialized bindings.
9216 switch (binding_flags) { 9211 switch (binding_flags) {
9217 case MUTABLE_CHECK_INITIALIZED: 9212 case MUTABLE_CHECK_INITIALIZED:
9218 case IMMUTABLE_CHECK_INITIALIZED_HARMONY: 9213 case IMMUTABLE_CHECK_INITIALIZED_HARMONY:
9219 if (value->IsTheHole()) { 9214 if (value->IsTheHole()) {
9220 Handle<Object> reference_error = 9215 Handle<Object> reference_error =
9221 isolate->factory()->NewReferenceError("not_defined", 9216 isolate->factory()->NewReferenceError("not_defined",
9222 HandleVector(&name, 1)); 9217 HandleVector(&name, 1));
9223 return MakePair(isolate->Throw(*reference_error), NULL); 9218 return MakePair(isolate->Throw(*reference_error), NULL);
(...skipping 14 matching lines...) Expand all
9238 9233
9239 // Otherwise, if the slot was found the holder is a context extension 9234 // Otherwise, if the slot was found the holder is a context extension
9240 // object, subject of a with, or a global object. We read the named 9235 // object, subject of a with, or a global object. We read the named
9241 // property from it. 9236 // property from it.
9242 if (!holder.is_null()) { 9237 if (!holder.is_null()) {
9243 Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder); 9238 Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder);
9244 ASSERT(object->IsJSProxy() || JSReceiver::HasProperty(object, name)); 9239 ASSERT(object->IsJSProxy() || JSReceiver::HasProperty(object, name));
9245 // GetProperty below can cause GC. 9240 // GetProperty below can cause GC.
9246 Handle<Object> receiver_handle( 9241 Handle<Object> receiver_handle(
9247 object->IsGlobalObject() 9242 object->IsGlobalObject()
9248 ? Object::cast(isolate->heap()->the_hole_value()) 9243 ? Object::cast(isolate->heap()->undefined_value())
9249 : object->IsJSProxy() ? static_cast<Object*>(*object) 9244 : object->IsJSProxy() ? static_cast<Object*>(*object)
9250 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), 9245 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)),
9251 isolate); 9246 isolate);
9252 9247
9253 // No need to unhole the value here. This is taken care of by the 9248 // No need to unhole the value here. This is taken care of by the
9254 // GetProperty function. 9249 // GetProperty function.
9255 MaybeObject* value = object->GetProperty(*name); 9250 MaybeObject* value = object->GetProperty(*name);
9256 return MakePair(value, *receiver_handle); 9251 return MakePair(value, *receiver_handle);
9257 } 9252 }
9258 9253
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
9737 9732
9738 Handle<Object> callee = args.at<Object>(0); 9733 Handle<Object> callee = args.at<Object>(0);
9739 9734
9740 // If "eval" didn't refer to the original GlobalEval, it's not a 9735 // If "eval" didn't refer to the original GlobalEval, it's not a
9741 // direct call to eval. 9736 // direct call to eval.
9742 // (And even if it is, but the first argument isn't a string, just let 9737 // (And even if it is, but the first argument isn't a string, just let
9743 // execution default to an indirect call to eval, which will also return 9738 // execution default to an indirect call to eval, which will also return
9744 // the first argument without doing anything). 9739 // the first argument without doing anything).
9745 if (*callee != isolate->native_context()->global_eval_fun() || 9740 if (*callee != isolate->native_context()->global_eval_fun() ||
9746 !args[1]->IsString()) { 9741 !args[1]->IsString()) {
9747 return MakePair(*callee, isolate->heap()->the_hole_value()); 9742 return MakePair(*callee, isolate->heap()->undefined_value());
9748 } 9743 }
9749 9744
9750 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3); 9745 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3);
9751 ASSERT(args[4]->IsSmi()); 9746 ASSERT(args[4]->IsSmi());
9752 return CompileGlobalEval(isolate, 9747 return CompileGlobalEval(isolate,
9753 args.at<String>(1), 9748 args.at<String>(1),
9754 args.at<Object>(2), 9749 args.at<Object>(2),
9755 language_mode, 9750 language_mode,
9756 args.smi_at(4)); 9751 args.smi_at(4));
9757 } 9752 }
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after
11329 if (!receiver->IsJSObject() && 11324 if (!receiver->IsJSObject() &&
11330 shared->is_classic_mode() && 11325 shared->is_classic_mode() &&
11331 !function->IsBuiltin()) { 11326 !function->IsBuiltin()) {
11332 // If the receiver is not a JSObject and the function is not a 11327 // If the receiver is not a JSObject and the function is not a
11333 // builtin or strict-mode we have hit an optimization where a 11328 // builtin or strict-mode we have hit an optimization where a
11334 // value object is not converted into a wrapped JS objects. To 11329 // value object is not converted into a wrapped JS objects. To
11335 // hide this optimization from the debugger, we wrap the receiver 11330 // hide this optimization from the debugger, we wrap the receiver
11336 // by creating correct wrapper object based on the calling frame's 11331 // by creating correct wrapper object based on the calling frame's
11337 // native context. 11332 // native context.
11338 it.Advance(); 11333 it.Advance();
11339 Handle<Context> calling_frames_native_context( 11334 if (receiver->IsUndefined()) {
11340 Context::cast(Context::cast(it.frame()->context())->native_context())); 11335 Context* context = function->context();
11341 ASSERT(!receiver->IsUndefined() && !receiver->IsNull()); 11336 receiver = handle(context->global_object()->global_receiver());
11342 receiver = 11337 } else {
11343 isolate->factory()->ToObject(receiver, calling_frames_native_context); 11338 ASSERT(!receiver->IsNull());
11339 Context* context = Context::cast(it.frame()->context());
11340 Handle<Context> native_context(Context::cast(context->native_context()));
11341 receiver = isolate->factory()->ToObject(receiver, native_context);
11342 }
11344 } 11343 }
11345 details->set(kFrameDetailsReceiverIndex, *receiver); 11344 details->set(kFrameDetailsReceiverIndex, *receiver);
11346 11345
11347 ASSERT_EQ(details_size, details_index); 11346 ASSERT_EQ(details_size, details_index);
11348 return *isolate->factory()->NewJSArrayWithElements(details); 11347 return *isolate->factory()->NewJSArrayWithElements(details);
11349 } 11348 }
11350 11349
11351 11350
11352 // Create a plain JSObject which materializes the local scope for the specified 11351 // Create a plain JSObject which materializes the local scope for the specified
11353 // frame. 11352 // frame.
(...skipping 3530 matching lines...) Expand 10 before | Expand all | Expand 10 after
14884 // Handle last resort GC and make sure to allow future allocations 14883 // Handle last resort GC and make sure to allow future allocations
14885 // to grow the heap without causing GCs (if possible). 14884 // to grow the heap without causing GCs (if possible).
14886 isolate->counters()->gc_last_resort_from_js()->Increment(); 14885 isolate->counters()->gc_last_resort_from_js()->Increment();
14887 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14886 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14888 "Runtime::PerformGC"); 14887 "Runtime::PerformGC");
14889 } 14888 }
14890 } 14889 }
14891 14890
14892 14891
14893 } } // namespace v8::internal 14892 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698