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

Side by Side Diff: src/runtime.cc

Issue 8417035: Introduce extended mode. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased version. Created 9 years, 1 month 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
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // Assert that the given argument has a valid value for a StrictModeFlag 109 // Assert that the given argument has a valid value for a StrictModeFlag
110 // and store it in a StrictModeFlag variable with the given name. 110 // and store it in a StrictModeFlag variable with the given name.
111 #define CONVERT_STRICT_MODE_ARG(name, index) \ 111 #define CONVERT_STRICT_MODE_ARG(name, index) \
112 ASSERT(args[index]->IsSmi()); \ 112 ASSERT(args[index]->IsSmi()); \
113 ASSERT(args.smi_at(index) == kStrictMode || \ 113 ASSERT(args.smi_at(index) == kStrictMode || \
114 args.smi_at(index) == kNonStrictMode); \ 114 args.smi_at(index) == kNonStrictMode); \
115 StrictModeFlag name = \ 115 StrictModeFlag name = \
116 static_cast<StrictModeFlag>(args.smi_at(index)); 116 static_cast<StrictModeFlag>(args.smi_at(index));
117 117
118 118
119 // Assert that the given argument has a valid value for a LanguageMode
120 // and store it in a LanguageMode variable with the given name.
121 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \
122 ASSERT(args[index]->IsSmi()); \
123 ASSERT(args.smi_at(index) == CLASSIC_MODE || \
124 args.smi_at(index) == STRICT_MODE || \
125 args.smi_at(index) == EXTENDED_MODE); \
126 LanguageMode name = \
127 static_cast<LanguageMode>(args.smi_at(index));
128
129
119 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate, 130 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
120 JSObject* boilerplate) { 131 JSObject* boilerplate) {
121 StackLimitCheck check(isolate); 132 StackLimitCheck check(isolate);
122 if (check.HasOverflowed()) return isolate->StackOverflow(); 133 if (check.HasOverflowed()) return isolate->StackOverflow();
123 134
124 Heap* heap = isolate->heap(); 135 Heap* heap = isolate->heap();
125 Object* result; 136 Object* result;
126 { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate); 137 { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate);
127 if (!maybe_result->ToObject(&result)) return maybe_result; 138 if (!maybe_result->ToObject(&result)) return maybe_result;
128 } 139 }
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 attr |= lookup.GetAttributes() & DONT_DELETE; 1406 attr |= lookup.GetAttributes() & DONT_DELETE;
1396 } 1407 }
1397 PropertyAttributes attributes = static_cast<PropertyAttributes>(attr); 1408 PropertyAttributes attributes = static_cast<PropertyAttributes>(attr);
1398 1409
1399 RETURN_IF_EMPTY_HANDLE(isolate, 1410 RETURN_IF_EMPTY_HANDLE(isolate,
1400 SetLocalPropertyIgnoreAttributes(global, 1411 SetLocalPropertyIgnoreAttributes(global,
1401 name, 1412 name,
1402 value, 1413 value,
1403 attributes)); 1414 attributes));
1404 } else { 1415 } else {
1405 StrictModeFlag strict_mode = DeclareGlobalsStrictModeFlag::decode(flags); 1416 LanguageMode language_mode = DeclareGlobalsLanguageMode::decode(flags);
1417 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE)
1418 ? kNonStrictMode : kStrictMode;
1406 RETURN_IF_EMPTY_HANDLE(isolate, 1419 RETURN_IF_EMPTY_HANDLE(isolate,
1407 SetProperty(global, 1420 SetProperty(global,
1408 name, 1421 name,
1409 value, 1422 value,
1410 static_cast<PropertyAttributes>(attr), 1423 static_cast<PropertyAttributes>(attr),
1411 strict_mode)); 1424 strict_mode_flag));
1412 } 1425 }
1413 } 1426 }
1414 1427
1415 ASSERT(!isolate->has_pending_exception()); 1428 ASSERT(!isolate->has_pending_exception());
1416 return isolate->heap()->undefined_value(); 1429 return isolate->heap()->undefined_value();
1417 } 1430 }
1418 1431
1419 1432
1420 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { 1433 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) {
1421 HandleScope scope(isolate); 1434 HandleScope scope(isolate);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 kNonStrictMode)); 1520 kNonStrictMode));
1508 } 1521 }
1509 1522
1510 return isolate->heap()->undefined_value(); 1523 return isolate->heap()->undefined_value();
1511 } 1524 }
1512 1525
1513 1526
1514 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { 1527 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) {
1515 NoHandleAllocation nha; 1528 NoHandleAllocation nha;
1516 // args[0] == name 1529 // args[0] == name
1517 // args[1] == strict_mode 1530 // args[1] == language_mode
1518 // args[2] == value (optional) 1531 // args[2] == value (optional)
1519 1532
1520 // Determine if we need to assign to the variable if it already 1533 // Determine if we need to assign to the variable if it already
1521 // exists (based on the number of arguments). 1534 // exists (based on the number of arguments).
1522 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); 1535 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3);
1523 bool assign = args.length() == 3; 1536 bool assign = args.length() == 3;
1524 1537
1525 CONVERT_ARG_CHECKED(String, name, 0); 1538 CONVERT_ARG_CHECKED(String, name, 0);
1526 GlobalObject* global = isolate->context()->global(); 1539 GlobalObject* global = isolate->context()->global();
1527 RUNTIME_ASSERT(args[1]->IsSmi()); 1540 RUNTIME_ASSERT(args[1]->IsSmi());
1528 CONVERT_STRICT_MODE_ARG(strict_mode, 1); 1541 CONVERT_LANGUAGE_MODE_ARG(language_mode, 1);
1542 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE)
1543 ? kNonStrictMode : kStrictMode;
1529 1544
1530 // According to ECMA-262, section 12.2, page 62, the property must 1545 // According to ECMA-262, section 12.2, page 62, the property must
1531 // not be deletable. 1546 // not be deletable.
1532 PropertyAttributes attributes = DONT_DELETE; 1547 PropertyAttributes attributes = DONT_DELETE;
1533 1548
1534 // Lookup the property locally in the global object. If it isn't 1549 // Lookup the property locally in the global object. If it isn't
1535 // there, there is a property with this name in the prototype chain. 1550 // there, there is a property with this name in the prototype chain.
1536 // We follow Safari and Firefox behavior and only set the property 1551 // We follow Safari and Firefox behavior and only set the property
1537 // locally if there is an explicit initialization value that we have 1552 // locally if there is an explicit initialization value that we have
1538 // to assign to the property. 1553 // to assign to the property.
1539 // Note that objects can have hidden prototypes, so we need to traverse 1554 // Note that objects can have hidden prototypes, so we need to traverse
1540 // the whole chain of hidden prototypes to do a 'local' lookup. 1555 // the whole chain of hidden prototypes to do a 'local' lookup.
1541 Object* object = global; 1556 Object* object = global;
1542 LookupResult lookup(isolate); 1557 LookupResult lookup(isolate);
1543 while (object->IsJSObject() && 1558 while (object->IsJSObject() &&
1544 JSObject::cast(object)->map()->is_hidden_prototype()) { 1559 JSObject::cast(object)->map()->is_hidden_prototype()) {
1545 JSObject* raw_holder = JSObject::cast(object); 1560 JSObject* raw_holder = JSObject::cast(object);
1546 raw_holder->LocalLookup(*name, &lookup); 1561 raw_holder->LocalLookup(*name, &lookup);
1547 if (lookup.IsProperty() && lookup.type() == INTERCEPTOR) { 1562 if (lookup.IsProperty() && lookup.type() == INTERCEPTOR) {
1548 HandleScope handle_scope(isolate); 1563 HandleScope handle_scope(isolate);
1549 Handle<JSObject> holder(raw_holder); 1564 Handle<JSObject> holder(raw_holder);
1550 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name); 1565 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name);
1551 // Update the raw pointer in case it's changed due to GC. 1566 // Update the raw pointer in case it's changed due to GC.
1552 raw_holder = *holder; 1567 raw_holder = *holder;
1553 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) { 1568 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) {
1554 // Found an interceptor that's not read only. 1569 // Found an interceptor that's not read only.
1555 if (assign) { 1570 if (assign) {
1556 return raw_holder->SetProperty( 1571 return raw_holder->SetProperty(
1557 &lookup, *name, args[2], attributes, strict_mode); 1572 &lookup, *name, args[2], attributes, strict_mode_flag);
1558 } else { 1573 } else {
1559 return isolate->heap()->undefined_value(); 1574 return isolate->heap()->undefined_value();
1560 } 1575 }
1561 } 1576 }
1562 } 1577 }
1563 object = raw_holder->GetPrototype(); 1578 object = raw_holder->GetPrototype();
1564 } 1579 }
1565 1580
1566 // Reload global in case the loop above performed a GC. 1581 // Reload global in case the loop above performed a GC.
1567 global = isolate->context()->global(); 1582 global = isolate->context()->global();
1568 if (assign) { 1583 if (assign) {
1569 return global->SetProperty(*name, args[2], attributes, strict_mode); 1584 return global->SetProperty(*name, args[2], attributes, strict_mode_flag);
1570 } 1585 }
1571 return isolate->heap()->undefined_value(); 1586 return isolate->heap()->undefined_value();
1572 } 1587 }
1573 1588
1574 1589
1575 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) { 1590 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) {
1576 // All constants are declared with an initial value. The name 1591 // All constants are declared with an initial value. The name
1577 // of the constant is the first argument and the initial value 1592 // of the constant is the first argument and the initial value
1578 // is the second. 1593 // is the second.
1579 RUNTIME_ASSERT(args.length() == 2); 1594 RUNTIME_ASSERT(args.length() == 2);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 1941
1927 return *holder; 1942 return *holder;
1928 } 1943 }
1929 1944
1930 1945
1931 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { 1946 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) {
1932 NoHandleAllocation handle_free; 1947 NoHandleAllocation handle_free;
1933 ASSERT(args.length() == 1); 1948 ASSERT(args.length() == 1);
1934 CONVERT_CHECKED(JSFunction, function, args[0]); 1949 CONVERT_CHECKED(JSFunction, function, args[0]);
1935 SharedFunctionInfo* shared = function->shared(); 1950 SharedFunctionInfo* shared = function->shared();
1936 if (shared->native() || shared->strict_mode()) { 1951 if (shared->native() || shared->is_strict_or_extended_mode()) {
1937 return isolate->heap()->undefined_value(); 1952 return isolate->heap()->undefined_value();
1938 } 1953 }
1939 // Returns undefined for strict or native functions, or 1954 // Returns undefined for strict or native functions, or
1940 // the associated global receiver for "normal" functions. 1955 // the associated global receiver for "normal" functions.
1941 1956
1942 Context* global_context = 1957 Context* global_context =
1943 function->context()->global()->global_context(); 1958 function->context()->global()->global_context();
1944 return global_context->global()->global_receiver(); 1959 return global_context->global()->global_receiver();
1945 } 1960 }
1946 1961
(...skipping 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after
4749 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); 4764 SetLocalPropertyIgnoreAttributes(name, args[2], attributes);
4750 } 4765 }
4751 4766
4752 4767
4753 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { 4768 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) {
4754 NoHandleAllocation ha; 4769 NoHandleAllocation ha;
4755 ASSERT(args.length() == 3); 4770 ASSERT(args.length() == 3);
4756 4771
4757 CONVERT_CHECKED(JSReceiver, object, args[0]); 4772 CONVERT_CHECKED(JSReceiver, object, args[0]);
4758 CONVERT_CHECKED(String, key, args[1]); 4773 CONVERT_CHECKED(String, key, args[1]);
4759 CONVERT_SMI_ARG_CHECKED(strict, 2); 4774 CONVERT_STRICT_MODE_ARG(strict_mode, 2);
4760 return object->DeleteProperty(key, (strict == kStrictMode) 4775 return object->DeleteProperty(key, (strict_mode == kStrictMode)
4761 ? JSReceiver::STRICT_DELETION 4776 ? JSReceiver::STRICT_DELETION
4762 : JSReceiver::NORMAL_DELETION); 4777 : JSReceiver::NORMAL_DELETION);
4763 } 4778 }
4764 4779
4765 4780
4766 static Object* HasLocalPropertyImplementation(Isolate* isolate, 4781 static Object* HasLocalPropertyImplementation(Isolate* isolate,
4767 Handle<JSObject> object, 4782 Handle<JSObject> object,
4768 Handle<String> key) { 4783 Handle<String> key) {
4769 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); 4784 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value();
4770 // Handle hidden prototypes. If there's a hidden prototype above this thing 4785 // Handle hidden prototypes. If there's a hidden prototype above this thing
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
5176 } else { 5191 } else {
5177 return isolate->initial_object_prototype()->GetElement(index); 5192 return isolate->initial_object_prototype()->GetElement(index);
5178 } 5193 }
5179 } 5194 }
5180 5195
5181 // Handle special arguments properties. 5196 // Handle special arguments properties.
5182 if (key->Equals(isolate->heap()->length_symbol())) return Smi::FromInt(n); 5197 if (key->Equals(isolate->heap()->length_symbol())) return Smi::FromInt(n);
5183 if (key->Equals(isolate->heap()->callee_symbol())) { 5198 if (key->Equals(isolate->heap()->callee_symbol())) {
5184 Object* function = frame->function(); 5199 Object* function = frame->function();
5185 if (function->IsJSFunction() && 5200 if (function->IsJSFunction() &&
5186 JSFunction::cast(function)->shared()->strict_mode()) { 5201 JSFunction::cast(function)->shared()->is_strict_or_extended_mode()) {
5187 return isolate->Throw(*isolate->factory()->NewTypeError( 5202 return isolate->Throw(*isolate->factory()->NewTypeError(
5188 "strict_arguments_callee", HandleVector<Object>(NULL, 0))); 5203 "strict_arguments_callee", HandleVector<Object>(NULL, 0)));
5189 } 5204 }
5190 return function; 5205 return function;
5191 } 5206 }
5192 5207
5193 // Lookup in the initial Object.prototype object. 5208 // Lookup in the initial Object.prototype object.
5194 return isolate->initial_object_prototype()->GetProperty(*key); 5209 return isolate->initial_object_prototype()->GetProperty(*key);
5195 } 5210 }
5196 5211
(...skipping 3865 matching lines...) Expand 10 before | Expand all | Expand 10 after
9062 } 9077 }
9063 9078
9064 9079
9065 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) { 9080 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) {
9066 HandleScope scope(isolate); 9081 HandleScope scope(isolate);
9067 ASSERT(args.length() == 4); 9082 ASSERT(args.length() == 4);
9068 9083
9069 Handle<Object> value(args[0], isolate); 9084 Handle<Object> value(args[0], isolate);
9070 CONVERT_ARG_CHECKED(Context, context, 1); 9085 CONVERT_ARG_CHECKED(Context, context, 1);
9071 CONVERT_ARG_CHECKED(String, name, 2); 9086 CONVERT_ARG_CHECKED(String, name, 2);
9072 CONVERT_STRICT_MODE_ARG(strict_mode, 3); 9087 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3);
9088 StrictModeFlag strict_mode = (language_mode == CLASSIC_MODE)
9089 ? kNonStrictMode : kStrictMode;
9073 9090
9074 int index; 9091 int index;
9075 PropertyAttributes attributes; 9092 PropertyAttributes attributes;
9076 ContextLookupFlags flags = FOLLOW_CHAINS; 9093 ContextLookupFlags flags = FOLLOW_CHAINS;
9077 BindingFlags binding_flags; 9094 BindingFlags binding_flags;
9078 Handle<Object> holder = context->Lookup(name, 9095 Handle<Object> holder = context->Lookup(name,
9079 flags, 9096 flags,
9080 &index, 9097 &index,
9081 &attributes, 9098 &attributes,
9082 &binding_flags); 9099 &binding_flags);
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
9432 // strings. Throw an exception if it doesn't. 9449 // strings. Throw an exception if it doesn't.
9433 if (!CodeGenerationFromStringsAllowed(isolate, context)) { 9450 if (!CodeGenerationFromStringsAllowed(isolate, context)) {
9434 return isolate->Throw(*isolate->factory()->NewError( 9451 return isolate->Throw(*isolate->factory()->NewError(
9435 "code_gen_from_strings", HandleVector<Object>(NULL, 0))); 9452 "code_gen_from_strings", HandleVector<Object>(NULL, 0)));
9436 } 9453 }
9437 9454
9438 // Compile source string in the global context. 9455 // Compile source string in the global context.
9439 Handle<SharedFunctionInfo> shared = Compiler::CompileEval(source, 9456 Handle<SharedFunctionInfo> shared = Compiler::CompileEval(source,
9440 context, 9457 context,
9441 true, 9458 true,
9442 kNonStrictMode); 9459 CLASSIC_MODE);
9443 if (shared.is_null()) return Failure::Exception(); 9460 if (shared.is_null()) return Failure::Exception();
9444 Handle<JSFunction> fun = 9461 Handle<JSFunction> fun =
9445 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, 9462 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
9446 context, 9463 context,
9447 NOT_TENURED); 9464 NOT_TENURED);
9448 return *fun; 9465 return *fun;
9449 } 9466 }
9450 9467
9451 9468
9452 static ObjectPair CompileGlobalEval(Isolate* isolate, 9469 static ObjectPair CompileGlobalEval(Isolate* isolate,
9453 Handle<String> source, 9470 Handle<String> source,
9454 Handle<Object> receiver, 9471 Handle<Object> receiver,
9455 StrictModeFlag strict_mode) { 9472 LanguageMode language_mode) {
9456 Handle<Context> context = Handle<Context>(isolate->context()); 9473 Handle<Context> context = Handle<Context>(isolate->context());
9457 Handle<Context> global_context = Handle<Context>(context->global_context()); 9474 Handle<Context> global_context = Handle<Context>(context->global_context());
9458 9475
9459 // Check if global context allows code generation from 9476 // Check if global context allows code generation from
9460 // strings. Throw an exception if it doesn't. 9477 // strings. Throw an exception if it doesn't.
9461 if (!CodeGenerationFromStringsAllowed(isolate, global_context)) { 9478 if (!CodeGenerationFromStringsAllowed(isolate, global_context)) {
9462 isolate->Throw(*isolate->factory()->NewError( 9479 isolate->Throw(*isolate->factory()->NewError(
9463 "code_gen_from_strings", HandleVector<Object>(NULL, 0))); 9480 "code_gen_from_strings", HandleVector<Object>(NULL, 0)));
9464 return MakePair(Failure::Exception(), NULL); 9481 return MakePair(Failure::Exception(), NULL);
9465 } 9482 }
9466 9483
9467 // Deal with a normal eval call with a string argument. Compile it 9484 // Deal with a normal eval call with a string argument. Compile it
9468 // and return the compiled function bound in the local context. 9485 // and return the compiled function bound in the local context.
9469 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( 9486 Handle<SharedFunctionInfo> shared = Compiler::CompileEval(
9470 source, 9487 source,
9471 Handle<Context>(isolate->context()), 9488 Handle<Context>(isolate->context()),
9472 context->IsGlobalContext(), 9489 context->IsGlobalContext(),
9473 strict_mode); 9490 language_mode);
9474 if (shared.is_null()) return MakePair(Failure::Exception(), NULL); 9491 if (shared.is_null()) return MakePair(Failure::Exception(), NULL);
9475 Handle<JSFunction> compiled = 9492 Handle<JSFunction> compiled =
9476 isolate->factory()->NewFunctionFromSharedFunctionInfo( 9493 isolate->factory()->NewFunctionFromSharedFunctionInfo(
9477 shared, context, NOT_TENURED); 9494 shared, context, NOT_TENURED);
9478 return MakePair(*compiled, *receiver); 9495 return MakePair(*compiled, *receiver);
9479 } 9496 }
9480 9497
9481 9498
9482 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) { 9499 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) {
9483 ASSERT(args.length() == 4); 9500 ASSERT(args.length() == 4);
9484 9501
9485 HandleScope scope(isolate); 9502 HandleScope scope(isolate);
9486 Handle<Object> callee = args.at<Object>(0); 9503 Handle<Object> callee = args.at<Object>(0);
9487 9504
9488 // If "eval" didn't refer to the original GlobalEval, it's not a 9505 // If "eval" didn't refer to the original GlobalEval, it's not a
9489 // direct call to eval. 9506 // direct call to eval.
9490 // (And even if it is, but the first argument isn't a string, just let 9507 // (And even if it is, but the first argument isn't a string, just let
9491 // execution default to an indirect call to eval, which will also return 9508 // execution default to an indirect call to eval, which will also return
9492 // the first argument without doing anything). 9509 // the first argument without doing anything).
9493 if (*callee != isolate->global_context()->global_eval_fun() || 9510 if (*callee != isolate->global_context()->global_eval_fun() ||
9494 !args[1]->IsString()) { 9511 !args[1]->IsString()) {
9495 return MakePair(*callee, isolate->heap()->the_hole_value()); 9512 return MakePair(*callee, isolate->heap()->the_hole_value());
9496 } 9513 }
9497 9514
9498 CONVERT_STRICT_MODE_ARG(strict_mode, 3); 9515 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3);
9499 return CompileGlobalEval(isolate, 9516 return CompileGlobalEval(isolate,
9500 args.at<String>(1), 9517 args.at<String>(1),
9501 args.at<Object>(2), 9518 args.at<Object>(2),
9502 strict_mode); 9519 language_mode);
9503 } 9520 }
9504 9521
9505 9522
9506 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) { 9523 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) {
9507 // This utility adjusts the property attributes for newly created Function 9524 // This utility adjusts the property attributes for newly created Function
9508 // object ("new Function(...)") by changing the map. 9525 // object ("new Function(...)") by changing the map.
9509 // All it does is changing the prototype property to enumerable 9526 // All it does is changing the prototype property to enumerable
9510 // as specified in ECMA262, 15.3.5.2. 9527 // as specified in ECMA262, 15.3.5.2.
9511 HandleScope scope(isolate); 9528 HandleScope scope(isolate);
9512 ASSERT(args.length() == 1); 9529 ASSERT(args.length() == 1);
9513 CONVERT_ARG_CHECKED(JSFunction, func, 0); 9530 CONVERT_ARG_CHECKED(JSFunction, func, 0);
9514 9531
9515 Handle<Map> map = func->shared()->strict_mode() 9532 Handle<Map> map = func->shared()->is_classic_mode()
9516 ? isolate->strict_mode_function_instance_map() 9533 ? isolate->function_instance_map()
9517 : isolate->function_instance_map(); 9534 : isolate->strict_mode_function_instance_map();
9518 9535
9519 ASSERT(func->map()->instance_type() == map->instance_type()); 9536 ASSERT(func->map()->instance_type() == map->instance_type());
9520 ASSERT(func->map()->instance_size() == map->instance_size()); 9537 ASSERT(func->map()->instance_size() == map->instance_size());
9521 func->set_map(*map); 9538 func->set_map(*map);
9522 return *func; 9539 return *func;
9523 } 9540 }
9524 9541
9525 9542
9526 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { 9543 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) {
9527 // Allocate a block of memory in NewSpace (filled with a filler). 9544 // Allocate a block of memory in NewSpace (filled with a filler).
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
10935 10952
10936 // Add the value being returned. 10953 // Add the value being returned.
10937 if (at_return) { 10954 if (at_return) {
10938 details->set(details_index++, *return_value); 10955 details->set(details_index++, *return_value);
10939 } 10956 }
10940 10957
10941 // Add the receiver (same as in function frame). 10958 // Add the receiver (same as in function frame).
10942 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE 10959 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE
10943 // THE FRAME ITERATOR TO WRAP THE RECEIVER. 10960 // THE FRAME ITERATOR TO WRAP THE RECEIVER.
10944 Handle<Object> receiver(it.frame()->receiver(), isolate); 10961 Handle<Object> receiver(it.frame()->receiver(), isolate);
10945 if (!receiver->IsJSObject() && !shared->strict_mode() && !shared->native()) { 10962 if (!receiver->IsJSObject() &&
10963 shared->is_classic_mode() &&
10964 !shared->native()) {
10946 // If the receiver is not a JSObject and the function is not a 10965 // If the receiver is not a JSObject and the function is not a
10947 // builtin or strict-mode we have hit an optimization where a 10966 // builtin or strict-mode we have hit an optimization where a
10948 // value object is not converted into a wrapped JS objects. To 10967 // value object is not converted into a wrapped JS objects. To
10949 // hide this optimization from the debugger, we wrap the receiver 10968 // hide this optimization from the debugger, we wrap the receiver
10950 // by creating correct wrapper object based on the calling frame's 10969 // by creating correct wrapper object based on the calling frame's
10951 // global context. 10970 // global context.
10952 it.Advance(); 10971 it.Advance();
10953 Handle<Context> calling_frames_global_context( 10972 Handle<Context> calling_frames_global_context(
10954 Context::cast(Context::cast(it.frame()->context())->global_context())); 10973 Context::cast(Context::cast(it.frame()->context())->global_context()));
10955 receiver = 10974 receiver =
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
12074 Handle<String> function_source = 12093 Handle<String> function_source =
12075 isolate->factory()->NewStringFromAscii( 12094 isolate->factory()->NewStringFromAscii(
12076 Vector<const char>(kSourceStr, sizeof(kSourceStr) - 1)); 12095 Vector<const char>(kSourceStr, sizeof(kSourceStr) - 1));
12077 12096
12078 // Currently, the eval code will be executed in non-strict mode, 12097 // Currently, the eval code will be executed in non-strict mode,
12079 // even in the strict code context. 12098 // even in the strict code context.
12080 Handle<SharedFunctionInfo> shared = 12099 Handle<SharedFunctionInfo> shared =
12081 Compiler::CompileEval(function_source, 12100 Compiler::CompileEval(function_source,
12082 context, 12101 context,
12083 context->IsGlobalContext(), 12102 context->IsGlobalContext(),
12084 kNonStrictMode); 12103 CLASSIC_MODE);
12085 if (shared.is_null()) return Failure::Exception(); 12104 if (shared.is_null()) return Failure::Exception();
12086 Handle<JSFunction> compiled_function = 12105 Handle<JSFunction> compiled_function =
12087 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context); 12106 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context);
12088 12107
12089 // Invoke the result of the compilation to get the evaluation function. 12108 // Invoke the result of the compilation to get the evaluation function.
12090 bool has_pending_exception; 12109 bool has_pending_exception;
12091 Handle<Object> receiver(frame->receiver(), isolate); 12110 Handle<Object> receiver(frame->receiver(), isolate);
12092 Handle<Object> evaluation_function = 12111 Handle<Object> evaluation_function =
12093 Execution::Call(compiled_function, receiver, 0, NULL, 12112 Execution::Call(compiled_function, receiver, 0, NULL,
12094 &has_pending_exception); 12113 &has_pending_exception);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
12167 isolate->factory()->NewFunctionContext( 12186 isolate->factory()->NewFunctionContext(
12168 Context::MIN_CONTEXT_SLOTS, go_between); 12187 Context::MIN_CONTEXT_SLOTS, go_between);
12169 context->set_extension(JSObject::cast(*additional_context)); 12188 context->set_extension(JSObject::cast(*additional_context));
12170 is_global = false; 12189 is_global = false;
12171 } 12190 }
12172 12191
12173 // Compile the source to be evaluated. 12192 // Compile the source to be evaluated.
12174 // Currently, the eval code will be executed in non-strict mode, 12193 // Currently, the eval code will be executed in non-strict mode,
12175 // even in the strict code context. 12194 // even in the strict code context.
12176 Handle<SharedFunctionInfo> shared = 12195 Handle<SharedFunctionInfo> shared =
12177 Compiler::CompileEval(source, context, is_global, kNonStrictMode); 12196 Compiler::CompileEval(source, context, is_global, CLASSIC_MODE);
12178 if (shared.is_null()) return Failure::Exception(); 12197 if (shared.is_null()) return Failure::Exception();
12179 Handle<JSFunction> compiled_function = 12198 Handle<JSFunction> compiled_function =
12180 Handle<JSFunction>( 12199 Handle<JSFunction>(
12181 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, 12200 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
12182 context)); 12201 context));
12183 12202
12184 // Invoke the result of the compilation to get the evaluation function. 12203 // Invoke the result of the compilation to get the evaluation function.
12185 bool has_pending_exception; 12204 bool has_pending_exception;
12186 Handle<Object> receiver = isolate->global(); 12205 Handle<Object> receiver = isolate->global();
12187 Handle<Object> result = 12206 Handle<Object> result =
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
13503 } else { 13522 } else {
13504 // Handle last resort GC and make sure to allow future allocations 13523 // Handle last resort GC and make sure to allow future allocations
13505 // to grow the heap without causing GCs (if possible). 13524 // to grow the heap without causing GCs (if possible).
13506 isolate->counters()->gc_last_resort_from_js()->Increment(); 13525 isolate->counters()->gc_last_resort_from_js()->Increment();
13507 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13526 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13508 } 13527 }
13509 } 13528 }
13510 13529
13511 13530
13512 } } // namespace v8::internal 13531 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698